opencode-quota-gui 1.3.0 → 1.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/README.md +34 -20
- package/dist/bin/opencode-quota-gui.js +0 -0
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-order.d.ts +2 -0
- package/dist/contracts/card-order.js +2 -2
- package/dist/contracts/card-visibility.d.ts +2 -1
- package/dist/contracts/card-visibility.js +2 -1
- package/dist/contracts/dashboard.d.ts +95 -6
- package/dist/contracts/dashboard.js +10 -0
- package/dist/contracts/dto-guards.d.ts +4 -0
- package/dist/contracts/dto-guards.js +31 -7
- package/dist/contracts/guards.js +3 -1
- package/dist/contracts/identity.d.ts +37 -5
- package/dist/contracts/identity.js +43 -0
- package/dist/contracts/openai-quota.d.ts +3 -0
- package/dist/contracts/openai-quota.js +3 -0
- package/dist/contracts/provider-auto-resume.d.ts +9 -0
- package/dist/contracts/provider-auto-resume.js +24 -0
- package/dist/contracts/provider-failure.d.ts +22 -0
- package/dist/contracts/provider-failure.js +25 -1
- package/dist/contracts/row-order.d.ts +13 -0
- package/dist/contracts/row-order.js +34 -0
- package/dist/contracts/row-visibility.d.ts +53 -0
- package/dist/contracts/row-visibility.js +130 -0
- package/dist/data/modelsdev-pricing.min.json +1 -1
- package/dist/data/modelsdev-temporal.min.json +60 -634
- package/dist/gui/aggregation.d.ts +29 -1
- package/dist/gui/aggregation.js +157 -4
- package/dist/gui/analytics-bridge.d.ts +8 -9
- package/dist/gui/analytics-bridge.js +197 -54
- package/dist/gui/analytics-engine.d.ts +7 -15
- package/dist/gui/analytics-engine.js +246 -106
- package/dist/gui/analytics-model.d.ts +7 -0
- package/dist/gui/analytics-model.js +75 -9
- package/dist/gui/analytics-pricing-upkeep.d.ts +21 -0
- package/dist/gui/analytics-pricing-upkeep.js +23 -0
- package/dist/gui/analytics-protocol.d.ts +17 -7
- package/dist/gui/analytics-protocol.js +1 -0
- package/dist/gui/analytics-service.d.ts +10 -0
- package/dist/gui/analytics-service.js +30 -9
- package/dist/gui/analytics-state.d.ts +30 -5
- package/dist/gui/analytics-state.js +46 -7
- package/dist/gui/analytics-worker-runtime.d.ts +5 -0
- package/dist/gui/analytics-worker-runtime.js +9 -1
- package/dist/gui/analytics-worker.js +11 -0
- package/dist/gui/config.d.ts +3 -3
- package/dist/gui/config.js +77 -7
- package/dist/gui/identity.d.ts +6 -20
- package/dist/gui/identity.js +6 -54
- package/dist/gui/lifecycle.d.ts +5 -3
- package/dist/gui/lifecycle.js +3 -3
- package/dist/gui/primary-quota-windows.js +67 -44
- package/dist/gui/provider-cards.d.ts +20 -8
- package/dist/gui/provider-cards.js +42 -55
- package/dist/gui/quota-notification-detector.d.ts +29 -6
- package/dist/gui/quota-notification-detector.js +136 -47
- package/dist/gui/quota-notification-observer.d.ts +3 -4
- package/dist/gui/quota-notification-observer.js +73 -20
- package/dist/gui/quota-observation.d.ts +4 -0
- package/dist/gui/quota-observation.js +18 -0
- package/dist/gui/rpc.d.ts +2 -0
- package/dist/gui/rpc.js +14 -3
- package/dist/gui/server.js +17 -3
- package/dist/gui/snapshot-service.d.ts +3 -15
- package/dist/gui/snapshot-service.js +281 -23
- package/dist/gui/sources.js +179 -64
- package/dist/gui/temporal-status.d.ts +3 -2
- package/dist/gui/temporal-status.js +10 -6
- package/dist/gui-experimental.cjs +230 -225
- package/dist/lib/accounting-format.d.ts +8 -0
- package/dist/lib/accounting-format.js +20 -2
- package/dist/lib/alibaba-coding-plan-cli.d.ts +79 -0
- package/dist/lib/alibaba-coding-plan-cli.js +539 -0
- package/dist/lib/anthropic-api-auth.d.ts +7 -0
- package/dist/lib/anthropic-api-auth.js +27 -0
- package/dist/lib/anthropic-api-rate-limits.d.ts +47 -0
- package/dist/lib/anthropic-api-rate-limits.js +92 -0
- package/dist/lib/anthropic-auth.d.ts +2 -3
- package/dist/lib/anthropic-auth.js +2 -3
- package/dist/lib/anthropic-oauth-throttle.d.ts +76 -0
- package/dist/lib/anthropic-oauth-throttle.js +379 -0
- package/dist/lib/anthropic.d.ts +68 -14
- package/dist/lib/anthropic.js +1016 -363
- package/dist/lib/api-key-retry-after.d.ts +7 -0
- package/dist/lib/api-key-retry-after.js +62 -0
- package/dist/lib/atomic-json.d.ts +2 -0
- package/dist/lib/atomic-json.js +1 -0
- package/dist/lib/cache-observer-ingestion.d.ts +90 -0
- package/dist/lib/cache-observer-ingestion.js +1008 -0
- package/dist/lib/cache-observer.d.ts +141 -0
- package/dist/lib/cache-observer.js +323 -0
- package/dist/lib/canonical-config-lock.d.ts +9 -0
- package/dist/lib/canonical-config-lock.js +36 -0
- package/dist/lib/chutes.js +62 -51
- package/dist/lib/claude-agent-transcript-ttl.d.ts +48 -0
- package/dist/lib/claude-agent-transcript-ttl.js +154 -0
- package/dist/lib/claude-agent-ttl-tracker.d.ts +21 -0
- package/dist/lib/claude-agent-ttl-tracker.js +152 -0
- package/dist/lib/cli-show.d.ts +5 -0
- package/dist/lib/cli-show.js +21 -8
- package/dist/lib/cli-status.js +3 -6
- package/dist/lib/config-write-target.d.ts +1 -1
- package/dist/lib/config-write-target.js +5 -2
- package/dist/lib/config.d.ts +2 -1
- package/dist/lib/config.js +257 -4
- package/dist/lib/copilot.js +171 -86
- package/dist/lib/dashboard-visibility.d.ts +5 -0
- package/dist/lib/dashboard-visibility.js +11 -10
- package/dist/lib/dashboard-web-policy.d.ts +4 -4
- package/dist/lib/dashboard-web-policy.js +2 -2
- package/dist/lib/deepseek.js +25 -13
- package/dist/lib/display-sanitize.js +2 -0
- package/dist/lib/entries.d.ts +33 -1
- package/dist/lib/entries.js +6 -0
- package/dist/lib/glm-coding-plan.js +98 -74
- package/dist/lib/google-agy.js +90 -12
- package/dist/lib/google-gemini-cli.js +84 -11
- package/dist/lib/grouped-entry-normalization.js +1 -1
- package/dist/lib/http.d.ts +4 -0
- package/dist/lib/http.js +16 -2
- package/dist/lib/init-installer.js +5 -3
- package/dist/lib/kilo.js +37 -18
- package/dist/lib/kimi.js +35 -18
- package/dist/lib/maintainer-announcements.js +2 -2
- package/dist/lib/mimo.d.ts +2 -0
- package/dist/lib/mimo.js +36 -0
- package/dist/lib/modelsdev-pricing.d.ts +74 -2
- package/dist/lib/modelsdev-pricing.js +457 -63
- package/dist/lib/modelsdev-temporal.d.ts +6 -0
- package/dist/lib/modelsdev-temporal.js +16 -2
- package/dist/lib/nanogpt.d.ts +1 -0
- package/dist/lib/nanogpt.js +26 -3
- package/dist/lib/ollama-cloud.d.ts +1 -1
- package/dist/lib/ollama-cloud.js +48 -35
- package/dist/lib/openai.js +84 -38
- package/dist/lib/opencode-auth-sqlite.d.ts +2 -2
- package/dist/lib/opencode-auth-sqlite.js +2 -2
- package/dist/lib/opencode-config-editor.d.ts +1 -0
- package/dist/lib/opencode-config-editor.js +6 -1
- package/dist/lib/opencode-config-providers.js +2 -2
- package/dist/lib/opencode-go.js +29 -2
- package/dist/lib/opencode-storage.d.ts +20 -0
- package/dist/lib/opencode-storage.js +89 -2
- package/dist/lib/opencode-version-core.d.ts +30 -0
- package/dist/lib/opencode-version-core.js +59 -0
- package/dist/lib/opencode-version.d.ts +2 -22
- package/dist/lib/opencode-version.js +4 -48
- package/dist/lib/opencode-warming-refresh.d.ts +19 -0
- package/dist/lib/opencode-warming-refresh.js +95 -0
- package/dist/lib/opencode-zen.d.ts +3 -0
- package/dist/lib/opencode-zen.js +71 -5
- package/dist/lib/provider-add.js +5 -2
- package/dist/lib/provider-metadata.d.ts +11 -3
- package/dist/lib/provider-metadata.js +20 -2
- package/dist/lib/provider-registration.d.ts +358 -9
- package/dist/lib/provider-registration.js +423 -30
- package/dist/lib/quota-auto-resume.d.ts +74 -0
- package/dist/lib/quota-auto-resume.js +539 -0
- package/dist/lib/quota-command-format.js +23 -10
- package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
- package/dist/lib/quota-exhaustion-projection.js +25 -0
- package/dist/lib/quota-identity.d.ts +64 -0
- package/dist/lib/quota-identity.js +111 -0
- package/dist/lib/quota-providers-remote.d.ts +2 -1
- package/dist/lib/quota-providers-remote.js +59 -3
- package/dist/lib/quota-providers.d.ts +1 -1
- package/dist/lib/quota-providers.js +14 -37
- package/dist/lib/quota-render-data.d.ts +6 -0
- package/dist/lib/quota-render-data.js +45 -19
- package/dist/lib/quota-reset-notifications.js +11 -155
- package/dist/lib/quota-retry-wait.d.ts +106 -5
- package/dist/lib/quota-retry-wait.js +301 -34
- package/dist/lib/quota-runtime-context.js +1 -0
- package/dist/lib/quota-state-codec.d.ts +2 -0
- package/dist/lib/quota-state-codec.js +31 -2
- package/dist/lib/quota-state.d.ts +8 -2
- package/dist/lib/quota-state.js +253 -47
- package/dist/lib/quota-stats.d.ts +26 -0
- package/dist/lib/quota-stats.js +40 -1
- package/dist/lib/quota-status.js +3 -51
- package/dist/lib/quota-surface-data.js +18 -3
- package/dist/lib/quota-telemetry.js +2 -2
- package/dist/lib/resolved-auth-identity.d.ts +19 -0
- package/dist/lib/resolved-auth-identity.js +44 -0
- package/dist/lib/scoped-update.d.ts +1 -1
- package/dist/lib/state-file-lock.d.ts +26 -0
- package/dist/lib/state-file-lock.js +205 -0
- package/dist/lib/synthetic.js +65 -54
- package/dist/lib/toast-format-grouped.js +7 -4
- package/dist/lib/tui-compact-format.js +29 -16
- package/dist/lib/types.d.ts +51 -1
- package/dist/lib/types.js +17 -1
- package/dist/lib/xai.js +48 -22
- package/dist/plugin.js +328 -14
- package/dist/provider-logos/NOTICE.md +1 -1
- package/dist/provider-logos/OPENCODE-NOTICE.md +4 -3
- package/dist/providers/alibaba-coding-plan.js +125 -104
- package/dist/providers/alibaba-token-plan.js +9 -5
- package/dist/providers/anthropic.d.ts +16 -3
- package/dist/providers/anthropic.js +172 -220
- package/dist/providers/cache-policies.d.ts +11 -4
- package/dist/providers/cache-policies.js +19 -13
- package/dist/providers/chutes.js +2 -0
- package/dist/providers/claude-agent.d.ts +19 -0
- package/dist/providers/claude-agent.js +215 -0
- package/dist/providers/copilot.js +7 -4
- package/dist/providers/glm-coding-plan-provider.d.ts +1 -0
- package/dist/providers/glm-coding-plan-provider.js +30 -23
- package/dist/providers/google-account-format.js +1 -0
- package/dist/providers/google-agy.d.ts +6 -5
- package/dist/providers/google-agy.js +43 -15
- package/dist/providers/google-gemini-cli.js +1 -0
- package/dist/providers/kilo.js +1 -0
- package/dist/providers/kimi-code.js +2 -0
- package/dist/providers/mimo.js +1 -0
- package/dist/providers/nanogpt.js +1 -0
- package/dist/providers/ollama-cloud.js +10 -0
- package/dist/providers/openai.js +24 -23
- package/dist/providers/opencode-go.js +10 -6
- package/dist/providers/opencode-zen.js +3 -1
- package/dist/providers/openrouter.js +1 -0
- package/dist/providers/quota-providers.js +16 -5
- package/dist/providers/registry.js +2 -0
- package/dist/providers/result-helpers.d.ts +6 -2
- package/dist/providers/result-helpers.js +7 -1
- package/dist/providers/synthetic.js +4 -0
- package/dist/providers/xai.js +9 -8
- package/dist/rpc.d.ts +129 -8
- package/dist/rpc.js +219 -14
- package/dist/ui/assets/{index-cDd9jUVY.css → index-6_g1FHs-.css} +1 -1
- package/dist/ui/assets/index-sZnGUuML.js +10 -0
- package/dist/ui/assets/{popover-BGkgv9s0.js → popover-C4ZLYe9E.js} +1 -1
- package/dist/ui/assets/providers/claude-agent.svg +3 -0
- package/dist/ui/index.html +2 -2
- package/package.json +45 -46
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts +0 -47
- package/dist/lib/alibaba-coding-plan-local-quota.js +0 -146
- package/dist/ui/assets/index-DLHeXYff.js +0 -9
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Agent provider: OpenCode's native Claude Agent integration, backed by the installed Claude
|
|
3
|
+
* CLI login. It is independent of OpenCode's Anthropic logins (see `./anthropic.ts`); it is the
|
|
4
|
+
* only provider that launches the Claude CLI.
|
|
5
|
+
*/
|
|
6
|
+
import { CLAUDE_AGENT_RESETS_ROW_KEY } from "../contracts/openai-quota.js";
|
|
7
|
+
import { getAnthropicDiagnostics, hasAnthropicCredentialsConfigured } from "../lib/anthropic.js";
|
|
8
|
+
import { QUOTA_FORCE_REFRESH } from "../lib/entries.js";
|
|
9
|
+
import { isAnyProviderIdAvailable } from "../lib/provider-availability.js";
|
|
10
|
+
import { resolveQuotaProviderSessionModelIdentity } from "../lib/quota-providers.js";
|
|
11
|
+
import { anthropicQuotaEntries } from "./anthropic.js";
|
|
12
|
+
import { attemptedErrorResult, attemptedResult, statusDetailsFromRecord, withStatusDetails, } from "./result-helpers.js";
|
|
13
|
+
/** `claude-agent` is OpenCode's native integration; `claude-code` is its legacy runtime alias. */
|
|
14
|
+
export const CLAUDE_AGENT_RUNTIME_IDS = ["claude-agent", "claude-code"];
|
|
15
|
+
const CLAUDE_AGENT_GROUP = "Claude Agent";
|
|
16
|
+
/** Always the OAuth-reported value: even beside CLI-local windows, resets come from the usage API. */
|
|
17
|
+
function claudeAgentResetsEntry(resets, observedAtMs) {
|
|
18
|
+
return {
|
|
19
|
+
kind: "value",
|
|
20
|
+
accounting: {
|
|
21
|
+
resultType: "status",
|
|
22
|
+
acquisitionMethod: "remote_api",
|
|
23
|
+
ownership: "maintained",
|
|
24
|
+
authority: "provider_reported",
|
|
25
|
+
...(observedAtMs !== undefined
|
|
26
|
+
? { observedAtIso: new Date(observedAtMs).toISOString() }
|
|
27
|
+
: {}),
|
|
28
|
+
},
|
|
29
|
+
name: `${CLAUDE_AGENT_GROUP} Resets`,
|
|
30
|
+
group: CLAUDE_AGENT_GROUP,
|
|
31
|
+
label: "Resets:",
|
|
32
|
+
rowKey: CLAUDE_AGENT_RESETS_ROW_KEY,
|
|
33
|
+
value: `${resets.availableCount} available`,
|
|
34
|
+
bankedResets: {
|
|
35
|
+
availableCount: resets.availableCount,
|
|
36
|
+
credits: resets.credits.map((credit) => ({
|
|
37
|
+
...(credit.expiresAtIso !== undefined ? { expiresAtIso: credit.expiresAtIso } : {}),
|
|
38
|
+
})),
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function getClaudeAgentNoDataMessage() {
|
|
43
|
+
return "Quota unavailable via local Claude CLI";
|
|
44
|
+
}
|
|
45
|
+
function safeDiagnosticMessage(diagnostics) {
|
|
46
|
+
// A probe that timed out says nothing about the login; keep the token and the card, show the error.
|
|
47
|
+
if (diagnostics.probeFailure === true && diagnostics.quotaSource === "none")
|
|
48
|
+
return "Claude CLI did not respond. Retry.";
|
|
49
|
+
if (diagnostics.failureCategory === "provider_api")
|
|
50
|
+
return "Claude quota request failed.";
|
|
51
|
+
if (diagnostics.storedAccessTokenExpired)
|
|
52
|
+
return "Claude's stored access token has expired. Run any `claude` command to refresh it, then Retry.";
|
|
53
|
+
// "credentials" is only assigned after the CLI reported a verified login, so this is the usage
|
|
54
|
+
// endpoint rejecting the stored token, not proof that the login is invalid.
|
|
55
|
+
if (diagnostics.failureCategory === "credentials")
|
|
56
|
+
return "Claude CLI reports you are signed in, but the usage request was rejected. Retry; if it persists, run `claude auth login`.";
|
|
57
|
+
if (!diagnostics.installed)
|
|
58
|
+
return "Claude CLI is unavailable.";
|
|
59
|
+
if (diagnostics.authStatus === "unauthenticated")
|
|
60
|
+
return "Claude is not authenticated. Run `claude auth login` and try again.";
|
|
61
|
+
if (diagnostics.authStatus === "unknown")
|
|
62
|
+
return "Claude authentication could not be verified. Retry; if it persists, run `claude auth login`.";
|
|
63
|
+
return "Claude Agent usage is unavailable.";
|
|
64
|
+
}
|
|
65
|
+
/** The Claude Agent route selected by `onlyCurrentModel`, if any. */
|
|
66
|
+
export function getClaudeAgentRuntimeProviderId(ctx) {
|
|
67
|
+
if (ctx.config?.onlyCurrentModel !== true)
|
|
68
|
+
return undefined;
|
|
69
|
+
const currentProviderId = (ctx.config?.currentProviderID ??
|
|
70
|
+
resolveQuotaProviderSessionModelIdentity({ currentModel: ctx.config?.currentModel ?? "" })
|
|
71
|
+
?.providerId)
|
|
72
|
+
?.trim()
|
|
73
|
+
.toLowerCase();
|
|
74
|
+
return currentProviderId &&
|
|
75
|
+
CLAUDE_AGENT_RUNTIME_IDS.includes(currentProviderId)
|
|
76
|
+
? currentProviderId
|
|
77
|
+
: undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* OpenCode registers Claude Agent independently of the external login; provider presence alone
|
|
81
|
+
* cannot report its auth or quota. The independent CLI probe supplies what it can; it does not
|
|
82
|
+
* establish account equivalence from a matching email or plan.
|
|
83
|
+
*/
|
|
84
|
+
export async function isClaudeAgentRuntimeDetected(ctx) {
|
|
85
|
+
if (ctx.client?.integration) {
|
|
86
|
+
try {
|
|
87
|
+
const { data } = await ctx.client.integration.list();
|
|
88
|
+
if (Array.isArray(data)) {
|
|
89
|
+
const agent = data.find((integration) => integration.id === "claude-agent");
|
|
90
|
+
if (agent && Array.isArray(agent.connections)) {
|
|
91
|
+
if (agent.connections.some((connection) => connection.type === "credential" && connection.method === "external")) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return await isAnyProviderIdAvailable({
|
|
95
|
+
ctx,
|
|
96
|
+
candidateIds: ["claude-code"],
|
|
97
|
+
fallbackOnError: false,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// Older hosts or an unavailable integration service use legacy provider detection.
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return await isAnyProviderIdAvailable({
|
|
107
|
+
ctx,
|
|
108
|
+
candidateIds: CLAUDE_AGENT_RUNTIME_IDS,
|
|
109
|
+
fallbackOnError: false,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
export const claudeAgentProvider = {
|
|
113
|
+
id: "claude-agent",
|
|
114
|
+
async isAvailable(ctx) {
|
|
115
|
+
if (ctx.config?.onlyCurrentModel === true) {
|
|
116
|
+
// A selected Claude Agent route stays visible; its CLI probe runs in fetch, so a missing or
|
|
117
|
+
// signed-out CLI shows as an error instead of disappearing.
|
|
118
|
+
return getClaudeAgentRuntimeProviderId(ctx) !== undefined;
|
|
119
|
+
}
|
|
120
|
+
const runtimeAvailable = await isAnyProviderIdAvailable({
|
|
121
|
+
ctx,
|
|
122
|
+
candidateIds: CLAUDE_AGENT_RUNTIME_IDS,
|
|
123
|
+
fallbackOnError: false,
|
|
124
|
+
});
|
|
125
|
+
if (!runtimeAvailable)
|
|
126
|
+
return false;
|
|
127
|
+
// A probe that cannot report a status must not hide a detected runtime: fetch then shows the
|
|
128
|
+
// error row (and a genuine sign-out still hides it). Only a confirmed sign-out is unavailable.
|
|
129
|
+
return await hasAnthropicCredentialsConfigured({
|
|
130
|
+
binaryPath: ctx.config?.anthropicBinaryPath,
|
|
131
|
+
operationCache: ctx.operationCache,
|
|
132
|
+
}, { treatUnverifiedAsConfigured: true });
|
|
133
|
+
},
|
|
134
|
+
async isDiscovered(ctx) {
|
|
135
|
+
// Dashboard-only: a detected Claude Agent runtime stays visible while its CLI is not ready, and
|
|
136
|
+
// fetch says why.
|
|
137
|
+
if (ctx.config?.onlyCurrentModel === true)
|
|
138
|
+
return false;
|
|
139
|
+
return await isClaudeAgentRuntimeDetected(ctx);
|
|
140
|
+
},
|
|
141
|
+
matchesCurrentModel(model) {
|
|
142
|
+
const normalized = model.toLowerCase();
|
|
143
|
+
return CLAUDE_AGENT_RUNTIME_IDS.some((id) => normalized.startsWith(`${id}/`));
|
|
144
|
+
},
|
|
145
|
+
async fetch(ctx) {
|
|
146
|
+
const forceRefresh = ctx.operationCache?.get(QUOTA_FORCE_REFRESH) === true;
|
|
147
|
+
let diagnostics;
|
|
148
|
+
try {
|
|
149
|
+
diagnostics = await getAnthropicDiagnostics({
|
|
150
|
+
binaryPath: ctx.config?.anthropicBinaryPath,
|
|
151
|
+
...(ctx.operationCache ? { operationCache: ctx.operationCache } : {}),
|
|
152
|
+
requestTimeoutMs: ctx.config?.requestTimeoutMs,
|
|
153
|
+
pollIntervalMs: ctx.config?.claudeAgentPollIntervalMs,
|
|
154
|
+
...(forceRefresh ? { forceRefresh: true } : {}),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return withStatusDetails(attemptedErrorResult(CLAUDE_AGENT_GROUP, "Claude CLI probe failed."), statusDetailsFromRecord({ cli_installed: "false", message: "Failed to probe Claude CLI." }));
|
|
159
|
+
}
|
|
160
|
+
const statusDetails = statusDetailsFromRecord({
|
|
161
|
+
cli_installed: diagnostics.installed ? "true" : "false",
|
|
162
|
+
cli_version: diagnostics.version && /^\d+\.\d+\.\d+$/.test(diagnostics.version)
|
|
163
|
+
? diagnostics.version
|
|
164
|
+
: "(none)",
|
|
165
|
+
binary_path: diagnostics.binaryPath ? "(detected)" : "(none)",
|
|
166
|
+
auth_status: diagnostics.authStatus,
|
|
167
|
+
quota_supported: diagnostics.quotaSupported ? "true" : "false",
|
|
168
|
+
quota_source: diagnostics.quotaSource === "none" ? "(none)" : diagnostics.quotaSource,
|
|
169
|
+
oauth_credential_source: diagnostics.oauthCredentialSource ?? "(none)",
|
|
170
|
+
checked_commands: diagnostics.checkedCommands.length ? "(checked)" : "(none)",
|
|
171
|
+
message: diagnostics.message === undefined ? undefined : safeDiagnosticMessage(diagnostics),
|
|
172
|
+
five_hour_remaining: diagnostics.quota?.five_hour
|
|
173
|
+
? `${diagnostics.quota.five_hour.percentRemaining}% reset_at=${diagnostics.quota.five_hour.resetTimeIso ?? "(none)"}`
|
|
174
|
+
: undefined,
|
|
175
|
+
seven_day_remaining: diagnostics.quota?.seven_day
|
|
176
|
+
? `${diagnostics.quota.seven_day.percentRemaining}% reset_at=${diagnostics.quota.seven_day.resetTimeIso ?? "(none)"}`
|
|
177
|
+
: undefined,
|
|
178
|
+
fable_weekly_remaining: diagnostics.quota?.fable_weekly
|
|
179
|
+
? `${diagnostics.quota.fable_weekly.percentRemaining}% reset_at=${diagnostics.quota.fable_weekly.resetTimeIso ?? "(none)"}`
|
|
180
|
+
: undefined,
|
|
181
|
+
});
|
|
182
|
+
if (diagnostics.quotaSupported && diagnostics.quota) {
|
|
183
|
+
const acquisitionMethod = diagnostics.quotaSource === "claude-auth-status-json" ? "local_cli" : "remote_api";
|
|
184
|
+
const credits = diagnostics.quota.saved_resets?.credits.filter((credit) => credit.expiresAtIso == null || Date.parse(credit.expiresAtIso) > Date.now());
|
|
185
|
+
const savedResets = credits?.length ? { availableCount: credits.length, credits } : undefined;
|
|
186
|
+
const result = attemptedResult([
|
|
187
|
+
...anthropicQuotaEntries(diagnostics.quota, {
|
|
188
|
+
group: CLAUDE_AGENT_GROUP,
|
|
189
|
+
acquisitionMethod,
|
|
190
|
+
...(diagnostics.quotaMeasuredAtMs !== undefined
|
|
191
|
+
? { observedAtMs: diagnostics.quotaMeasuredAtMs }
|
|
192
|
+
: {}),
|
|
193
|
+
}),
|
|
194
|
+
...(savedResets && savedResets.availableCount > 0
|
|
195
|
+
? [claudeAgentResetsEntry(savedResets, diagnostics.quotaMeasuredAtMs)]
|
|
196
|
+
: []),
|
|
197
|
+
]);
|
|
198
|
+
return withStatusDetails(diagnostics.planLabel === undefined
|
|
199
|
+
? result
|
|
200
|
+
: { ...result, planLabel: diagnostics.planLabel }, statusDetails);
|
|
201
|
+
}
|
|
202
|
+
return withStatusDetails(attemptedErrorResult(CLAUDE_AGENT_GROUP, safeDiagnosticMessage(diagnostics), {
|
|
203
|
+
...(diagnostics.failureCategory !== undefined
|
|
204
|
+
? { failureCategory: diagnostics.failureCategory }
|
|
205
|
+
: {}),
|
|
206
|
+
...(diagnostics.attemptOutcome !== undefined
|
|
207
|
+
? { attemptOutcome: diagnostics.attemptOutcome }
|
|
208
|
+
: {}),
|
|
209
|
+
...(diagnostics.retryAtMs !== undefined
|
|
210
|
+
? { retryable: true, retryAtMs: diagnostics.retryAtMs }
|
|
211
|
+
: {}),
|
|
212
|
+
}), statusDetails);
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=claude-agent.js.map
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* into the shared provider/result boundary.
|
|
6
6
|
*/
|
|
7
7
|
import { COPILOT_AUTH_KEYS, getCopilotQuotaAuthDiagnostics, hasCopilotQuotaRuntimeAvailable, queryCopilotQuota, } from "../lib/copilot.js";
|
|
8
|
+
import { windowSemantic } from "../lib/entries.js";
|
|
8
9
|
import { credentialRowAuthEntry, formatCredentialDisplayNames, readAuthFileCached, readCredentialRows, } from "../lib/opencode-auth.js";
|
|
9
10
|
import { isCanonicalProviderAvailable } from "../lib/provider-availability.js";
|
|
10
11
|
import { modelIncludesAny, modelProviderIncludesAny } from "../lib/provider-model-matching.js";
|
|
@@ -118,7 +119,7 @@ function personalEntries(result) {
|
|
|
118
119
|
name,
|
|
119
120
|
group,
|
|
120
121
|
label: "Quota:",
|
|
121
|
-
|
|
122
|
+
semantic: windowSemantic("month"),
|
|
122
123
|
value: "Unlimited",
|
|
123
124
|
resetTimeIso: result.resetTimeIso,
|
|
124
125
|
},
|
|
@@ -131,7 +132,7 @@ function personalEntries(result) {
|
|
|
131
132
|
name,
|
|
132
133
|
group,
|
|
133
134
|
label: result.unit === "ai_credits" ? "Credits:" : "Quota:",
|
|
134
|
-
|
|
135
|
+
semantic: windowSemantic("month"),
|
|
135
136
|
right: `${formatNumber(result.used)}/${formatNumber(result.total)}`,
|
|
136
137
|
percentRemaining: result.percentRemaining,
|
|
137
138
|
resetTimeIso: result.resetTimeIso,
|
|
@@ -144,7 +145,7 @@ function personalEntries(result) {
|
|
|
144
145
|
name,
|
|
145
146
|
group,
|
|
146
147
|
label: result.unit === "ai_credits" ? "Credits:" : "Usage:",
|
|
147
|
-
|
|
148
|
+
semantic: windowSemantic("month", "supplementary"),
|
|
148
149
|
value: result.unit === "ai_credits"
|
|
149
150
|
? formatAiCreditUsageValue(result)
|
|
150
151
|
: `Used ${formatNumber(result.used)}`,
|
|
@@ -207,7 +208,7 @@ function managedEntries(result) {
|
|
|
207
208
|
name: "Copilot AI Credits",
|
|
208
209
|
group,
|
|
209
210
|
label: "Credits:",
|
|
210
|
-
|
|
211
|
+
semantic: windowSemantic("month", "supplementary"),
|
|
211
212
|
value: formatAiCreditUsageValue(result),
|
|
212
213
|
resetTimeIso: result.resetTimeIso,
|
|
213
214
|
},
|
|
@@ -279,6 +280,7 @@ export const copilotProvider = {
|
|
|
279
280
|
message: result.error,
|
|
280
281
|
sourceId: row.id,
|
|
281
282
|
failureCategory: result.failureCategory,
|
|
283
|
+
...(result.retryAtMs !== undefined ? { retryAtMs: result.retryAtMs } : {}),
|
|
282
284
|
});
|
|
283
285
|
continue;
|
|
284
286
|
}
|
|
@@ -309,6 +311,7 @@ export const copilotProvider = {
|
|
|
309
311
|
if (!result.success) {
|
|
310
312
|
return withStatusDetails(attemptedErrorResult("Copilot", result.error, {
|
|
311
313
|
failureCategory: result.failureCategory,
|
|
314
|
+
...(result.retryAtMs !== undefined ? { retryAtMs: result.retryAtMs } : {}),
|
|
312
315
|
}), statusDetails);
|
|
313
316
|
}
|
|
314
317
|
const entries = result.mode === "user_plan"
|
|
@@ -1,39 +1,46 @@
|
|
|
1
|
+
import { windowSemantic } from "../lib/entries.js";
|
|
1
2
|
import { credentialRowAuthEntry, formatCredentialDisplayNames, readCredentialRows, } from "../lib/opencode-auth.js";
|
|
2
3
|
import { isCanonicalProviderAvailable } from "../lib/provider-availability.js";
|
|
3
4
|
import { apiKeyStatusDetails, attemptedResult, groupedPercentWindowEntries, mapNullableProviderResult, statusDetailsFromRecord, withStatusDetails, } from "./result-helpers.js";
|
|
4
|
-
const
|
|
5
|
-
fiveHour: "
|
|
6
|
-
weekly: "
|
|
7
|
-
mcp: "
|
|
5
|
+
const GLM_WINDOW_METRICS = {
|
|
6
|
+
fiveHour: "five_hour",
|
|
7
|
+
weekly: "week",
|
|
8
|
+
mcp: "mcp",
|
|
8
9
|
};
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
* explicit `rowKey`s (metric + window) instead of label-derived ids.
|
|
12
|
-
*/
|
|
13
|
-
function windowEntriesWithRowKeys(params) {
|
|
10
|
+
/** Percent-only window rows carry typed window semantics instead of label-derived ids. */
|
|
11
|
+
function windowEntriesWithSemantics(params) {
|
|
14
12
|
const specs = [];
|
|
15
|
-
const rowKeys = [];
|
|
16
13
|
if (params.windows.fiveHour) {
|
|
17
|
-
specs.push({
|
|
18
|
-
|
|
14
|
+
specs.push({
|
|
15
|
+
window: params.windows.fiveHour,
|
|
16
|
+
suffix: "5h",
|
|
17
|
+
label: "5h:",
|
|
18
|
+
semantic: windowSemantic(GLM_WINDOW_METRICS.fiveHour),
|
|
19
|
+
});
|
|
19
20
|
}
|
|
20
21
|
if (params.windows.weekly) {
|
|
21
|
-
specs.push({
|
|
22
|
-
|
|
22
|
+
specs.push({
|
|
23
|
+
window: params.windows.weekly,
|
|
24
|
+
suffix: "Weekly",
|
|
25
|
+
label: "Weekly:",
|
|
26
|
+
semantic: windowSemantic(GLM_WINDOW_METRICS.weekly),
|
|
27
|
+
});
|
|
23
28
|
}
|
|
24
29
|
if (params.windows.mcp) {
|
|
25
|
-
specs.push({
|
|
26
|
-
|
|
30
|
+
specs.push({
|
|
31
|
+
window: params.windows.mcp,
|
|
32
|
+
suffix: "MCP",
|
|
33
|
+
label: "MCP:",
|
|
34
|
+
semantic: windowSemantic(GLM_WINDOW_METRICS.mcp),
|
|
35
|
+
});
|
|
27
36
|
}
|
|
28
37
|
return groupedPercentWindowEntries({
|
|
29
38
|
group: params.group,
|
|
30
39
|
accounting: params.accounting,
|
|
31
40
|
windows: specs,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
rowKey: rowKeys[index] ?? "aggregate",
|
|
36
|
-
}));
|
|
41
|
+
// No reported window is not a 0% quota.
|
|
42
|
+
fallbackWhenEmpty: false,
|
|
43
|
+
});
|
|
37
44
|
}
|
|
38
45
|
export function createGlmCodingPlanProvider(params) {
|
|
39
46
|
return {
|
|
@@ -92,7 +99,7 @@ export function createGlmCodingPlanProvider(params) {
|
|
|
92
99
|
const group = names[index] ?? params.errorLabel;
|
|
93
100
|
const mapped = mapNullableProviderResult(result, {
|
|
94
101
|
errorLabel: group,
|
|
95
|
-
onSuccess: (quota) => attemptedResult(
|
|
102
|
+
onSuccess: (quota) => attemptedResult(windowEntriesWithSemantics({
|
|
96
103
|
group,
|
|
97
104
|
accounting: {
|
|
98
105
|
resultType: "quota",
|
|
@@ -113,7 +120,7 @@ export function createGlmCodingPlanProvider(params) {
|
|
|
113
120
|
const result = await params.queryQuota({ requestTimeoutMs: ctx.config?.requestTimeoutMs });
|
|
114
121
|
const providerResult = mapNullableProviderResult(result, {
|
|
115
122
|
errorLabel: params.errorLabel,
|
|
116
|
-
onSuccess: (quota) => attemptedResult(
|
|
123
|
+
onSuccess: (quota) => attemptedResult(windowEntriesWithSemantics({
|
|
117
124
|
group: quota.label,
|
|
118
125
|
accounting: {
|
|
119
126
|
resultType: "quota",
|
|
@@ -48,6 +48,7 @@ export function formatGoogleAccountErrors(errors, style, labels) {
|
|
|
48
48
|
label: (error.email && labels?.get(error.email)) ?? formatGoogleAccountLabel(error.email, style),
|
|
49
49
|
message: error.error,
|
|
50
50
|
...(error.failureCategory !== undefined ? { failureCategory: error.failureCategory } : {}),
|
|
51
|
+
...(error.retryAtMs !== undefined ? { retryAtMs: error.retryAtMs } : {}),
|
|
51
52
|
}));
|
|
52
53
|
}
|
|
53
54
|
//# sourceMappingURL=google-account-format.js.map
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { QuotaProvider, QuotaProviderAccount } from "../lib/entries.js";
|
|
2
|
-
import type { GoogleAgyQuotaBucket } from "../lib/types.js";
|
|
2
|
+
import type { GoogleAccountError, GoogleAgyQuotaBucket } from "../lib/types.js";
|
|
3
3
|
/** Stable explicit row key for one AGY bucket row (family + window; never the label). */
|
|
4
4
|
export declare function agyBucketRowKey(bucket: Pick<GoogleAgyQuotaBucket, "family" | "window">): string;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Legacy companion accounts have no `CredentialRow`. `sourceId` keeps the
|
|
7
|
+
* historical `account-N` value for reset/cache compatibility; email-backed
|
|
8
|
+
* descriptors use a server-only digest identity, while missing emails retain
|
|
9
|
+
* the existing source-id identity fallback.
|
|
10
10
|
*/
|
|
11
11
|
export declare function buildAgyLegacyAccounts(params: {
|
|
12
12
|
buckets: readonly GoogleAgyQuotaBucket[];
|
|
13
|
+
errors?: readonly GoogleAccountError[];
|
|
13
14
|
accountLabels: ReadonlyMap<string, string>;
|
|
14
15
|
}): QuotaProviderAccount[];
|
|
15
16
|
export declare function formatAgyCredentialGroup(credentialName: string, familyLabel: string): string;
|
|
@@ -72,25 +72,43 @@ export function agyBucketRowKey(bucket) {
|
|
|
72
72
|
return `named:${bucket.family} ${bucket.window}`;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
75
|
+
* Legacy companion accounts have no `CredentialRow`. `sourceId` keeps the
|
|
76
|
+
* historical `account-N` value for reset/cache compatibility; email-backed
|
|
77
|
+
* descriptors use a server-only digest identity, while missing emails retain
|
|
78
|
+
* the existing source-id identity fallback.
|
|
79
79
|
*/
|
|
80
80
|
export function buildAgyLegacyAccounts(params) {
|
|
81
81
|
const accounts = new Map();
|
|
82
82
|
for (const bucket of [...params.buckets].sort(compareBuckets)) {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
if (!accounts.has(bucket.accountIndex))
|
|
84
|
+
accounts.set(bucket.accountIndex, bucket);
|
|
85
|
+
}
|
|
86
|
+
for (const error of params.errors ?? []) {
|
|
87
|
+
const accountIndex = error.accountIndex;
|
|
88
|
+
if (accountIndex === undefined ||
|
|
89
|
+
!Number.isInteger(accountIndex) ||
|
|
90
|
+
accountIndex < 0 ||
|
|
91
|
+
accounts.has(accountIndex)) {
|
|
85
92
|
continue;
|
|
86
|
-
|
|
87
|
-
accounts.set(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
}
|
|
94
|
+
accounts.set(accountIndex, {
|
|
95
|
+
...(AGY_AUTH_KEYS.some((sourceKey) => sourceKey === error.email)
|
|
96
|
+
? {}
|
|
97
|
+
: { accountEmail: error.email }),
|
|
98
|
+
accountIndex,
|
|
91
99
|
});
|
|
92
100
|
}
|
|
93
|
-
return [...accounts.values()]
|
|
101
|
+
return [...accounts.values()]
|
|
102
|
+
.sort((left, right) => left.accountIndex - right.accountIndex)
|
|
103
|
+
.map((account) => {
|
|
104
|
+
const sourceId = `account-${account.accountIndex + 1}`;
|
|
105
|
+
const email = account.accountEmail;
|
|
106
|
+
return {
|
|
107
|
+
sourceId,
|
|
108
|
+
...(email ? { identityKey: deriveStableAccountIdentityKey(email) } : {}),
|
|
109
|
+
label: formatAgyAccountLabel(account, params.accountLabels),
|
|
110
|
+
};
|
|
111
|
+
});
|
|
94
112
|
}
|
|
95
113
|
export function formatAgyCredentialGroup(credentialName, familyLabel) {
|
|
96
114
|
const trimmed = credentialName.trim();
|
|
@@ -205,6 +223,7 @@ export const googleAgyProvider = {
|
|
|
205
223
|
...(error.failureCategory !== undefined
|
|
206
224
|
? { failureCategory: error.failureCategory }
|
|
207
225
|
: {}),
|
|
226
|
+
...(error.retryAtMs !== undefined ? { retryAtMs: error.retryAtMs } : {}),
|
|
208
227
|
})));
|
|
209
228
|
}
|
|
210
229
|
return withStatusDetails({ ...attemptedResult(entries, errors, { singleWindowShowRight: true }), accounts }, statusDetails);
|
|
@@ -227,7 +246,11 @@ export const googleAgyProvider = {
|
|
|
227
246
|
...sortedBuckets.map((bucket) => bucket.accountEmail),
|
|
228
247
|
...(result.errors ?? []).map((error) => error.email),
|
|
229
248
|
], "domainHint");
|
|
230
|
-
const legacyAccounts = buildAgyLegacyAccounts({
|
|
249
|
+
const legacyAccounts = buildAgyLegacyAccounts({
|
|
250
|
+
buckets: sortedBuckets,
|
|
251
|
+
errors: result.errors,
|
|
252
|
+
accountLabels,
|
|
253
|
+
});
|
|
231
254
|
const sourceIdByEmail = new Map(sortedBuckets.flatMap((bucket) => bucket.accountEmail
|
|
232
255
|
? [[bucket.accountEmail, `account-${bucket.accountIndex + 1}`]]
|
|
233
256
|
: []));
|
|
@@ -253,8 +276,13 @@ export const googleAgyProvider = {
|
|
|
253
276
|
};
|
|
254
277
|
});
|
|
255
278
|
const errors = formatGoogleAccountErrors(result.errors, "domainHint", accountLabels).map((error, index) => {
|
|
256
|
-
const
|
|
257
|
-
|
|
279
|
+
const failed = result.errors?.[index];
|
|
280
|
+
// Same `account-N` ids the entries use, so a failed account keeps its previous rows.
|
|
281
|
+
const sourceId = failed?.accountIndex !== undefined
|
|
282
|
+
? `account-${failed.accountIndex + 1}`
|
|
283
|
+
: failed?.email
|
|
284
|
+
? sourceIdByEmail.get(failed.email)
|
|
285
|
+
: undefined;
|
|
258
286
|
return sourceId ? { ...error, sourceId } : error;
|
|
259
287
|
});
|
|
260
288
|
return withStatusDetails({
|
|
@@ -158,6 +158,7 @@ export const googleGeminiCliProvider = {
|
|
|
158
158
|
...(error.failureCategory !== undefined
|
|
159
159
|
? { failureCategory: error.failureCategory }
|
|
160
160
|
: {}),
|
|
161
|
+
...(error.retryAtMs !== undefined ? { retryAtMs: error.retryAtMs } : {}),
|
|
161
162
|
})));
|
|
162
163
|
}
|
|
163
164
|
return withStatusDetails({
|
package/dist/providers/kilo.js
CHANGED
|
@@ -134,6 +134,7 @@ export const kiloProvider = {
|
|
|
134
134
|
{
|
|
135
135
|
label: "Kilo Gateway",
|
|
136
136
|
message: stateResult.error,
|
|
137
|
+
...(stateResult.retryAtMs !== undefined ? { retryAtMs: stateResult.retryAtMs } : {}),
|
|
137
138
|
...(stateResult.failureCategory !== undefined
|
|
138
139
|
? { failureCategory: stateResult.failureCategory }
|
|
139
140
|
: {}),
|
|
@@ -92,6 +92,7 @@ function createKimiProvider(spec) {
|
|
|
92
92
|
message: result.error,
|
|
93
93
|
sourceId: row.id,
|
|
94
94
|
failureCategory: result.failureCategory,
|
|
95
|
+
...(result.retryAtMs !== undefined ? { retryAtMs: result.retryAtMs } : {}),
|
|
95
96
|
});
|
|
96
97
|
continue;
|
|
97
98
|
}
|
|
@@ -127,6 +128,7 @@ function createKimiProvider(spec) {
|
|
|
127
128
|
if (!result.success) {
|
|
128
129
|
return withStatusDetails(attemptedErrorResult(spec.label, result.error, {
|
|
129
130
|
failureCategory: result.failureCategory,
|
|
131
|
+
...(result.retryAtMs !== undefined ? { retryAtMs: result.retryAtMs } : {}),
|
|
130
132
|
}), [...authDetails, { key: "live_fetch_error", value: result.error }]);
|
|
131
133
|
}
|
|
132
134
|
const entries = result.windows.map((window) => ({
|
package/dist/providers/mimo.js
CHANGED
|
@@ -66,6 +66,7 @@ function mapNanoGptSuccess(result) {
|
|
|
66
66
|
const errors = result.endpointErrors?.map((entry) => ({
|
|
67
67
|
label: entry.endpoint === "usage" ? "NanoGPT Usage" : "NanoGPT Balance",
|
|
68
68
|
message: entry.message,
|
|
69
|
+
...(entry.retryAtMs !== undefined ? { retryAtMs: entry.retryAtMs } : {}),
|
|
69
70
|
...(entry.failureCategory !== undefined ? { failureCategory: entry.failureCategory } : {}),
|
|
70
71
|
})) ?? [];
|
|
71
72
|
const subscription = result.subscription;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Queries the Ollama Cloud balance API and reports included credits or
|
|
5
5
|
* session/weekly limits, plus purchased credits.
|
|
6
6
|
*/
|
|
7
|
+
import { windowSemantic } from "../lib/entries.js";
|
|
7
8
|
import { queryOllamaCloudQuota } from "../lib/ollama-cloud.js";
|
|
8
9
|
import { getOllamaCloudKeyDiagnostics, hasOllamaCloudApiKey } from "../lib/ollama-cloud-config.js";
|
|
9
10
|
import { modelProviderMatchesRuntimeId } from "../lib/provider-model-matching.js";
|
|
@@ -25,6 +26,9 @@ function mapOllamaCloudSuccess(result) {
|
|
|
25
26
|
name: `${OLLAMA_CLOUD_PROVIDER_LABEL} Session`,
|
|
26
27
|
group: OLLAMA_CLOUD_PROVIDER_LABEL,
|
|
27
28
|
label: "Session:",
|
|
29
|
+
// The API calls this a "session" limit without a documented fixed
|
|
30
|
+
// window, so it gets a stable named identity but stays reset-ineligible.
|
|
31
|
+
semantic: { metric: { kind: "named", name: "Session" }, prominence: "primary" },
|
|
28
32
|
percentRemaining: result.session.percentRemaining,
|
|
29
33
|
...(result.session.resetTimeIso ? { resetTimeIso: result.session.resetTimeIso } : {}),
|
|
30
34
|
});
|
|
@@ -38,6 +42,7 @@ function mapOllamaCloudSuccess(result) {
|
|
|
38
42
|
name: `${OLLAMA_CLOUD_PROVIDER_LABEL} Weekly`,
|
|
39
43
|
group: OLLAMA_CLOUD_PROVIDER_LABEL,
|
|
40
44
|
label: "Weekly:",
|
|
45
|
+
semantic: windowSemantic("week"),
|
|
41
46
|
percentRemaining: result.weekly.percentRemaining,
|
|
42
47
|
...(result.weekly.resetTimeIso ? { resetTimeIso: result.weekly.resetTimeIso } : {}),
|
|
43
48
|
});
|
|
@@ -53,6 +58,7 @@ function mapOllamaCloudSuccess(result) {
|
|
|
53
58
|
name: `${OLLAMA_CLOUD_PROVIDER_LABEL} Monthly`,
|
|
54
59
|
group: OLLAMA_CLOUD_PROVIDER_LABEL,
|
|
55
60
|
label: "Monthly:",
|
|
61
|
+
semantic: windowSemantic("month"),
|
|
56
62
|
percentRemaining: included.percentRemaining,
|
|
57
63
|
...(included.resetTimeIso ? { resetTimeIso: included.resetTimeIso } : {}),
|
|
58
64
|
});
|
|
@@ -68,6 +74,10 @@ function mapOllamaCloudSuccess(result) {
|
|
|
68
74
|
name: `${OLLAMA_CLOUD_PROVIDER_LABEL} Purchased`,
|
|
69
75
|
group: OLLAMA_CLOUD_PROVIDER_LABEL,
|
|
70
76
|
label: "Purchased:",
|
|
77
|
+
semantic: {
|
|
78
|
+
metric: { kind: "component", component: "remaining_credits" },
|
|
79
|
+
prominence: "supplementary",
|
|
80
|
+
},
|
|
71
81
|
value: `$${result.purchasedUsd.toFixed(2)} left`,
|
|
72
82
|
});
|
|
73
83
|
}
|