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
|
@@ -1,18 +1,114 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { isAlibabaModelId } from "../lib/alibaba-auth.js";
|
|
2
|
+
import { queryAlibabaCodingPlanQuota, } from "../lib/alibaba-coding-plan-cli.js";
|
|
3
|
+
import { sanitizeSingleLineDisplayText } from "../lib/display-sanitize.js";
|
|
4
|
+
import { windowSemantic } from "../lib/entries.js";
|
|
5
|
+
import { isCanonicalProviderAvailable } from "../lib/provider-availability.js";
|
|
6
|
+
import { attemptedErrorResult, attemptedResult, statusDetailsFromRecord, withStatusDetails, } from "./result-helpers.js";
|
|
7
|
+
const CLI_LABEL = "Bailian CLI";
|
|
8
|
+
const QUOTA_ACCOUNTING = {
|
|
9
|
+
resultType: "quota",
|
|
10
|
+
acquisitionMethod: "local_cli",
|
|
11
|
+
ownership: "maintained",
|
|
12
|
+
authority: "provider_reported",
|
|
13
|
+
};
|
|
14
|
+
const STATUS_ACCOUNTING = {
|
|
15
|
+
...QUOTA_ACCOUNTING,
|
|
16
|
+
resultType: "status",
|
|
17
|
+
};
|
|
18
|
+
function windowEntry(window, params) {
|
|
19
|
+
if (!window)
|
|
20
|
+
return undefined;
|
|
21
|
+
const name = `${params.group} ${params.suffix}`;
|
|
22
|
+
const resetTime = window.resetTimeIso ? { resetTimeIso: window.resetTimeIso } : {};
|
|
23
|
+
if (window.percentage !== undefined) {
|
|
24
|
+
const hasCounts = window.used !== undefined && window.total !== undefined && window.total > 0;
|
|
25
|
+
return {
|
|
26
|
+
accounting: { ...QUOTA_ACCOUNTING },
|
|
27
|
+
name,
|
|
28
|
+
group: params.group,
|
|
29
|
+
label: params.label,
|
|
30
|
+
semantic: windowSemantic(params.semanticWindow),
|
|
31
|
+
...(hasCounts ? { right: `${window.used}/${window.total}` } : {}),
|
|
32
|
+
percentRemaining: Math.max(0, Math.min(100, (1 - window.percentage) * 100)),
|
|
33
|
+
...resetTime,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (window.resetTimeIso) {
|
|
37
|
+
return {
|
|
38
|
+
kind: "value",
|
|
39
|
+
accounting: { ...STATUS_ACCOUNTING },
|
|
40
|
+
name,
|
|
41
|
+
group: params.group,
|
|
42
|
+
label: params.label,
|
|
43
|
+
semantic: windowSemantic(params.semanticWindow),
|
|
44
|
+
value: "Quota details unavailable",
|
|
45
|
+
...resetTime,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
function entriesFromUsage(result) {
|
|
51
|
+
const instanceType = result.usage.instanceType
|
|
52
|
+
? sanitizeSingleLineDisplayText(result.usage.instanceType).trim().slice(0, 40)
|
|
53
|
+
: "";
|
|
54
|
+
const group = `Alibaba Coding Plan${instanceType ? ` (${instanceType})` : ""} (CLI)`;
|
|
55
|
+
return [
|
|
56
|
+
windowEntry(result.usage.fiveHour, {
|
|
57
|
+
group,
|
|
58
|
+
suffix: "5h",
|
|
59
|
+
label: "5h:",
|
|
60
|
+
semanticWindow: "five_hour",
|
|
61
|
+
}),
|
|
62
|
+
windowEntry(result.usage.weekly, {
|
|
63
|
+
group,
|
|
64
|
+
suffix: "Weekly",
|
|
65
|
+
label: "Weekly:",
|
|
66
|
+
semanticWindow: "week",
|
|
67
|
+
}),
|
|
68
|
+
windowEntry(result.usage.monthly, {
|
|
69
|
+
group,
|
|
70
|
+
suffix: "Monthly",
|
|
71
|
+
label: "Monthly:",
|
|
72
|
+
semanticWindow: "month",
|
|
73
|
+
}),
|
|
74
|
+
].filter((entry) => entry !== undefined);
|
|
75
|
+
}
|
|
76
|
+
function failureCategoryFor(kind) {
|
|
77
|
+
if (kind === "not_authenticated")
|
|
78
|
+
return "credentials";
|
|
79
|
+
if (kind === "invalid_json" ||
|
|
80
|
+
kind === "invalid_schema" ||
|
|
81
|
+
kind === "nonzero_exit" ||
|
|
82
|
+
kind === "output_truncated" ||
|
|
83
|
+
kind === "no_quota_data") {
|
|
84
|
+
return "provider_api";
|
|
85
|
+
}
|
|
86
|
+
return "local";
|
|
87
|
+
}
|
|
88
|
+
function resultWithCliStatus(result, statusDetails, status) {
|
|
89
|
+
return withStatusDetails(result, [
|
|
90
|
+
...statusDetails,
|
|
91
|
+
...statusDetailsFromRecord({ alibaba_coding_plan_cli_status: status }),
|
|
92
|
+
]);
|
|
7
93
|
}
|
|
8
94
|
export const alibabaCodingPlanProvider = {
|
|
9
95
|
id: "alibaba-coding-plan",
|
|
10
|
-
async isAvailable(
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
96
|
+
async isAvailable(ctx) {
|
|
97
|
+
const selected = await isCanonicalProviderAvailable({
|
|
98
|
+
ctx,
|
|
99
|
+
providerId: "alibaba-coding-plan",
|
|
100
|
+
fallbackOnError: false,
|
|
14
101
|
});
|
|
15
|
-
|
|
102
|
+
if (selected)
|
|
103
|
+
return true;
|
|
104
|
+
if (ctx.config.currentProviderID === "alibaba-coding-plan" ||
|
|
105
|
+
ctx.config.currentProviderID === "alibaba") {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
const currentModel = ctx.config.currentModel;
|
|
109
|
+
return typeof currentModel === "string" && currentModel.length > 0
|
|
110
|
+
? isAlibabaModelId(currentModel)
|
|
111
|
+
: false;
|
|
16
112
|
},
|
|
17
113
|
matchesCurrentModel(model, context) {
|
|
18
114
|
return context?.currentProviderID
|
|
@@ -21,104 +117,29 @@ export const alibabaCodingPlanProvider = {
|
|
|
21
117
|
: isAlibabaModelId(model);
|
|
22
118
|
},
|
|
23
119
|
async fetch(ctx) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
const plan = await resolveAlibabaCodingPlanAuthCached({
|
|
29
|
-
maxAgeMs: DEFAULT_ALIBABA_AUTH_CACHE_MAX_AGE_MS,
|
|
30
|
-
fallbackTier: "lite",
|
|
120
|
+
const result = await queryAlibabaCodingPlanQuota({
|
|
121
|
+
requestTimeoutMs: ctx.config?.requestTimeoutMs,
|
|
122
|
+
runtime: { cwd: ctx.workspaceRoot },
|
|
31
123
|
});
|
|
32
|
-
const statePath = getAlibabaCodingPlanQuotaPath();
|
|
33
|
-
const state = await inspectGeneratedCounterFile(statePath, ALIBABA_CODING_PLAN_STATE_VERSION);
|
|
34
|
-
const lastUpdate = state.lastUpdatedAt === null ? "(none)" : new Date(state.lastUpdatedAt).toISOString();
|
|
35
|
-
const authError = diagnostics.state === "invalid" ? diagnostics.error : undefined;
|
|
36
124
|
const statusDetails = statusDetailsFromRecord({
|
|
37
|
-
|
|
38
|
-
alibaba_api_key_source: diagnostics.source ?? "(none)",
|
|
39
|
-
alibaba_api_key_checked_paths: diagnostics.checkedPaths.join(" | ") || "(none)",
|
|
40
|
-
alibaba_api_key_credential_database_paths: diagnostics.credentialDatabasePaths.join(" | ") || "(none)",
|
|
41
|
-
alibaba_coding_plan: diagnostics.state === "configured"
|
|
42
|
-
? diagnostics.tier
|
|
43
|
-
: diagnostics.state === "invalid"
|
|
44
|
-
? "invalid"
|
|
45
|
-
: "(none)",
|
|
46
|
-
alibaba_auth_error: authError,
|
|
47
|
-
"alibaba coding plan error": authError,
|
|
48
|
-
"alibaba coding plan local quota": `path=${statePath} exists=${state.exists ? "true" : "false"} health=${state.health} version=${state.version ?? "(none)"} last_update=${lastUpdate}`,
|
|
49
|
-
local_state_path: statePath,
|
|
50
|
-
local_state_exists: state.exists ? "true" : "false",
|
|
51
|
-
local_state_health: state.health,
|
|
52
|
-
local_state_version: String(state.version ?? "(none)"),
|
|
53
|
-
local_state_last_update: lastUpdate,
|
|
125
|
+
alibaba_coding_plan_source: "bl usage coding-plan --output json",
|
|
54
126
|
});
|
|
55
|
-
if (
|
|
56
|
-
return
|
|
127
|
+
if (result.state === "error") {
|
|
128
|
+
return resultWithCliStatus(attemptedErrorResult(`${CLI_LABEL} Coding Plan usage`, result.error.message, {
|
|
129
|
+
retryable: result.error.retryable,
|
|
130
|
+
failureCategory: failureCategoryFor(result.error.kind),
|
|
131
|
+
}), statusDetails, result.error.kind);
|
|
57
132
|
}
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
60
|
-
failureCategory: "credentials",
|
|
61
|
-
}), statusDetails);
|
|
133
|
+
if (result.state === "no-subscription") {
|
|
134
|
+
return resultWithCliStatus(attemptedResult([]), statusDetails, "no-subscription");
|
|
62
135
|
}
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
: undefined;
|
|
71
|
-
const quota = computeAlibabaCodingPlanQuota({
|
|
72
|
-
state: await readAlibabaCodingPlanQuotaState(),
|
|
73
|
-
tier: plan.tier,
|
|
74
|
-
...(limits ? { limits } : {}),
|
|
75
|
-
});
|
|
76
|
-
const label = `Alibaba Coding Plan (${tierLabel(plan.tier)})`;
|
|
77
|
-
const entries = [
|
|
78
|
-
{
|
|
79
|
-
accounting: {
|
|
80
|
-
resultType: "quota",
|
|
81
|
-
acquisitionMethod: "local_estimation",
|
|
82
|
-
ownership: "maintained",
|
|
83
|
-
authority: "locally_derived",
|
|
84
|
-
},
|
|
85
|
-
name: `${label} 5h`,
|
|
86
|
-
group: label,
|
|
87
|
-
label: "5h:",
|
|
88
|
-
right: `${quota.fiveHour.used}/${quota.fiveHour.limit}`,
|
|
89
|
-
percentRemaining: quota.fiveHour.percentRemaining,
|
|
90
|
-
resetTimeIso: quota.fiveHour.resetTimeIso,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
accounting: {
|
|
94
|
-
resultType: "quota",
|
|
95
|
-
acquisitionMethod: "local_estimation",
|
|
96
|
-
ownership: "maintained",
|
|
97
|
-
authority: "locally_derived",
|
|
98
|
-
},
|
|
99
|
-
name: `${label} Weekly`,
|
|
100
|
-
group: label,
|
|
101
|
-
label: "Weekly:",
|
|
102
|
-
right: `${quota.weekly.used}/${quota.weekly.limit}`,
|
|
103
|
-
percentRemaining: quota.weekly.percentRemaining,
|
|
104
|
-
resetTimeIso: quota.weekly.resetTimeIso,
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
accounting: {
|
|
108
|
-
resultType: "quota",
|
|
109
|
-
acquisitionMethod: "local_estimation",
|
|
110
|
-
ownership: "maintained",
|
|
111
|
-
authority: "locally_derived",
|
|
112
|
-
},
|
|
113
|
-
name: `${label} Monthly`,
|
|
114
|
-
group: label,
|
|
115
|
-
label: "Monthly:",
|
|
116
|
-
right: `${quota.monthly.used}/${quota.monthly.limit}`,
|
|
117
|
-
percentRemaining: quota.monthly.percentRemaining,
|
|
118
|
-
resetTimeIso: quota.monthly.resetTimeIso,
|
|
119
|
-
},
|
|
120
|
-
];
|
|
121
|
-
return withStatusDetails(attemptedResult(entries), statusDetails);
|
|
136
|
+
const entries = entriesFromUsage(result);
|
|
137
|
+
if (entries.length === 0) {
|
|
138
|
+
return resultWithCliStatus(attemptedErrorResult(`${CLI_LABEL} Coding Plan usage`, "Bailian CLI returned no usable Coding Plan quota data.", {
|
|
139
|
+
failureCategory: "provider_api",
|
|
140
|
+
}), statusDetails, "no-quota-data");
|
|
141
|
+
}
|
|
142
|
+
return resultWithCliStatus(attemptedResult(entries), statusDetails, "success");
|
|
122
143
|
},
|
|
123
144
|
};
|
|
124
145
|
//# sourceMappingURL=alibaba-coding-plan.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isAlibabaTokenPlanSupportedPlatform, queryAlibabaTokenPlanQuota, } from "../lib/alibaba-token-plan.js";
|
|
2
|
+
import { windowSemantic } from "../lib/entries.js";
|
|
2
3
|
import { isCanonicalProviderAvailable } from "../lib/provider-availability.js";
|
|
3
4
|
import { modelProviderMatchesRuntimeId } from "../lib/provider-model-matching.js";
|
|
4
5
|
import { REQUEST_TIMEOUT_MS } from "../lib/types.js";
|
|
@@ -10,12 +11,13 @@ const ACCOUNTING = {
|
|
|
10
11
|
ownership: "maintained",
|
|
11
12
|
authority: "provider_reported",
|
|
12
13
|
};
|
|
13
|
-
function windowEntry(window, suffix, label) {
|
|
14
|
+
function windowEntry(window, suffix, label, semanticWindow) {
|
|
14
15
|
return {
|
|
15
16
|
accounting: { ...ACCOUNTING },
|
|
16
17
|
name: `${GROUP} ${suffix}`,
|
|
17
18
|
group: GROUP,
|
|
18
19
|
label,
|
|
20
|
+
semantic: windowSemantic(semanticWindow),
|
|
19
21
|
percentRemaining: window.percentRemaining,
|
|
20
22
|
...(window.resetTimeIso ? { resetTimeIso: window.resetTimeIso } : {}),
|
|
21
23
|
};
|
|
@@ -56,10 +58,12 @@ function alibabaFailureCategory(kind) {
|
|
|
56
58
|
function mapClosedResult(result) {
|
|
57
59
|
if (result.ok) {
|
|
58
60
|
const entries = [];
|
|
59
|
-
if (result.fiveHour)
|
|
60
|
-
entries.push(windowEntry(result.fiveHour, "5h", "5h:"));
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
if (result.fiveHour) {
|
|
62
|
+
entries.push(windowEntry(result.fiveHour, "5h", "5h:", "five_hour"));
|
|
63
|
+
}
|
|
64
|
+
if (result.weekly) {
|
|
65
|
+
entries.push(windowEntry(result.weekly, "Weekly", "Weekly:", "week"));
|
|
66
|
+
}
|
|
63
67
|
return attemptedResult(entries);
|
|
64
68
|
}
|
|
65
69
|
if (result.error.kind === "unsupported_platform") {
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anthropic
|
|
2
|
+
* Anthropic provider: the Anthropic API-key connection only.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Subscription quota belongs to Claude Agent. An ordinary API key exposes no spend, balance or
|
|
5
|
+
* quota endpoint, so this card shows only per-minute rate limits passively observed on real
|
|
6
|
+
* OpenCode API-key Messages traffic (see `../lib/anthropic-api-rate-limits.ts`).
|
|
5
7
|
*/
|
|
6
|
-
import type {
|
|
8
|
+
import type { AnthropicQuotaResult } from "../lib/anthropic.js";
|
|
9
|
+
import type { QuotaProvider, QuotaToastEntry } from "../lib/entries.js";
|
|
7
10
|
export declare function getAnthropicNoDataMessage(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Map subscription quota returned for the Claude Agent CLI login.
|
|
13
|
+
*/
|
|
14
|
+
export declare function anthropicQuotaEntries(quota: AnthropicQuotaResult, params: {
|
|
15
|
+
group: string;
|
|
16
|
+
acquisitionMethod: QuotaToastEntry["accounting"]["acquisitionMethod"];
|
|
17
|
+
sourceId?: string;
|
|
18
|
+
/** When this quota was measured; omitted for legacy callers that carry no timestamp. */
|
|
19
|
+
observedAtMs?: number;
|
|
20
|
+
}): QuotaToastEntry[];
|
|
8
21
|
export declare const anthropicProvider: QuotaProvider;
|
|
9
22
|
//# sourceMappingURL=anthropic.d.ts.map
|