opencode-quota-gui 1.3.0 → 1.3.1
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 +27 -17
- package/dist/bin/opencode-quota-gui.js +0 -0
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/dashboard.d.ts +8 -1
- package/dist/contracts/dto-guards.js +2 -0
- package/dist/contracts/openai-quota.d.ts +3 -0
- package/dist/contracts/openai-quota.js +3 -0
- package/dist/data/modelsdev-temporal.min.json +57 -0
- package/dist/gui/config.d.ts +3 -3
- package/dist/gui/config.js +31 -2
- package/dist/gui/lifecycle.d.ts +5 -3
- package/dist/gui/lifecycle.js +3 -3
- package/dist/gui/primary-quota-windows.js +16 -14
- package/dist/gui/provider-cards.d.ts +10 -2
- package/dist/gui/provider-cards.js +51 -23
- package/dist/gui/quota-notification-detector.d.ts +4 -4
- package/dist/gui/quota-notification-detector.js +76 -42
- package/dist/gui/quota-notification-observer.d.ts +2 -3
- package/dist/gui/quota-notification-observer.js +68 -19
- package/dist/gui/rpc.d.ts +2 -0
- package/dist/gui/rpc.js +11 -3
- package/dist/gui/server.js +11 -2
- package/dist/gui/snapshot-service.d.ts +3 -1
- package/dist/gui/snapshot-service.js +126 -18
- package/dist/gui/sources.js +98 -56
- package/dist/gui-experimental.cjs +230 -225
- package/dist/lib/accounting-format.js +8 -0
- 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-auth.d.ts +2 -3
- package/dist/lib/anthropic-auth.js +2 -3
- package/dist/lib/anthropic.d.ts +48 -12
- package/dist/lib/anthropic.js +610 -275
- 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 +981 -0
- package/dist/lib/cache-observer.d.ts +138 -0
- package/dist/lib/cache-observer.js +317 -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.js +5 -3
- 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 +193 -2
- package/dist/lib/copilot.js +171 -86
- 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 +1 -0
- package/dist/lib/entries.d.ts +23 -0
- package/dist/lib/entries.js +2 -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/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/mimo.d.ts +2 -0
- package/dist/lib/mimo.js +36 -0
- 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-go.js +29 -2
- package/dist/lib/opencode-version-core.d.ts +23 -0
- package/dist/lib/opencode-version-core.js +49 -0
- package/dist/lib/opencode-version.d.ts +2 -22
- package/dist/lib/opencode-version.js +4 -48
- 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-registration.d.ts +19 -9
- package/dist/lib/provider-registration.js +17 -6
- package/dist/lib/quota-command-format.js +1 -1
- package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
- package/dist/lib/quota-exhaustion-projection.js +25 -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 +12 -35
- package/dist/lib/quota-render-data.d.ts +6 -0
- package/dist/lib/quota-render-data.js +43 -17
- package/dist/lib/quota-state-codec.js +17 -1
- package/dist/lib/quota-state.d.ts +7 -1
- package/dist/lib/quota-state.js +208 -34
- package/dist/lib/quota-stats.js +21 -0
- package/dist/lib/quota-status.js +3 -51
- package/dist/lib/scoped-update.d.ts +1 -1
- package/dist/lib/synthetic.js +65 -54
- package/dist/lib/types.d.ts +31 -1
- package/dist/lib/types.js +13 -0
- package/dist/lib/xai.js +48 -22
- package/dist/plugin.js +261 -13
- package/dist/provider-logos/NOTICE.md +1 -1
- package/dist/provider-logos/OPENCODE-NOTICE.md +4 -3
- package/dist/providers/alibaba-coding-plan.js +107 -104
- package/dist/providers/anthropic.d.ts +12 -3
- package/dist/providers/anthropic.js +71 -228
- package/dist/providers/cache-policies.d.ts +11 -4
- package/dist/providers/cache-policies.js +19 -13
- package/dist/providers/claude-agent.d.ts +19 -0
- package/dist/providers/claude-agent.js +196 -0
- package/dist/providers/copilot.js +2 -0
- package/dist/providers/glm-coding-plan-provider.d.ts +1 -0
- 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/opencode-go.js +3 -0
- package/dist/providers/opencode-zen.js +2 -0
- 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 +2 -0
- package/dist/providers/result-helpers.js +2 -0
- package/dist/rpc.d.ts +121 -8
- package/dist/rpc.js +204 -12
- package/dist/ui/assets/{index-cDd9jUVY.css → index-BcueIm3Z.css} +1 -1
- package/dist/ui/assets/index-C6qRSoh8.js +10 -0
- package/dist/ui/assets/{popover-BGkgv9s0.js → popover-4bFSvRZ7.js} +1 -1
- package/dist/ui/assets/providers/claude-agent.svg +3 -0
- package/dist/ui/index.html +2 -2
- package/package.json +44 -45
- 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,10 +1,11 @@
|
|
|
1
1
|
import { getAnthropicNoDataMessage } from "../providers/anthropic.js";
|
|
2
|
+
import { getClaudeAgentNoDataMessage } from "../providers/claude-agent.js";
|
|
2
3
|
import { getProviders } from "../providers/registry.js";
|
|
3
4
|
import { cloneQuotaToastEntry } from "./entries.js";
|
|
4
5
|
import { getQuotaProviderDisplayLabel, getQuotaProviderIdsForRuntimeId, getQuotaProviderShape, } from "./provider-metadata.js";
|
|
5
6
|
import { projectQuotaProviderResults } from "./quota-accounting-projection.js";
|
|
6
7
|
import { createQuotaProviderRuntimeContext } from "./quota-runtime-context.js";
|
|
7
|
-
import { fetchQuotaProviderResult } from "./quota-state.js";
|
|
8
|
+
import { fetchQuotaProviderResult, getQuotaProviderResultScope, QUOTA_FORCE_REFRESH, } from "./quota-state.js";
|
|
8
9
|
import { retainQuotaTelemetryProviders } from "./quota-telemetry.js";
|
|
9
10
|
import { createRuntimeProviderIdResolver, } from "./runtime-provider-ids.js";
|
|
10
11
|
import { fetchSessionTokensForDisplay } from "./session-tokens.js";
|
|
@@ -93,22 +94,25 @@ export async function resolveQuotaRenderSelection(params) {
|
|
|
93
94
|
currentModel = request.sessionMeta.modelID;
|
|
94
95
|
currentProviderID = request.sessionMeta.providerID;
|
|
95
96
|
}
|
|
96
|
-
const ctx =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
const ctx = {
|
|
98
|
+
...createQuotaProviderRuntimeContext({
|
|
99
|
+
client,
|
|
100
|
+
config,
|
|
101
|
+
configMeta: params.configMeta,
|
|
102
|
+
resolveRuntimeProviderIds: params.resolveRuntimeProviderIds ?? createRuntimeProviderIdResolver(client),
|
|
103
|
+
workspaceRoot: params.workspaceRoot,
|
|
104
|
+
...(params.openaiResetDetailsVisible
|
|
105
|
+
? { openaiResetDetailsVisible: params.openaiResetDetailsVisible }
|
|
106
|
+
: {}),
|
|
107
|
+
session: {
|
|
108
|
+
sessionMeta: {
|
|
109
|
+
modelID: currentModel,
|
|
110
|
+
providerID: currentProviderID,
|
|
111
|
+
},
|
|
109
112
|
},
|
|
110
|
-
},
|
|
111
|
-
|
|
113
|
+
}),
|
|
114
|
+
operationCache: new Map(),
|
|
115
|
+
};
|
|
112
116
|
if (!config.enabled)
|
|
113
117
|
return null;
|
|
114
118
|
const allProviders = params.providers ?? getProviders();
|
|
@@ -153,6 +157,7 @@ async function fetchProviderWithCache(params) {
|
|
|
153
157
|
ctx,
|
|
154
158
|
ttlMs,
|
|
155
159
|
bypassCache: params.bypassCache,
|
|
160
|
+
forceRefresh: params.forceRefresh,
|
|
156
161
|
});
|
|
157
162
|
}
|
|
158
163
|
function makeProviderFetchFailure(provider) {
|
|
@@ -174,6 +179,7 @@ export async function fetchProviderResults(params) {
|
|
|
174
179
|
ctx: params.ctx,
|
|
175
180
|
ttlMs: params.ttlMs,
|
|
176
181
|
bypassCache: params.bypassCache,
|
|
182
|
+
forceRefresh: params.forceRefresh,
|
|
177
183
|
})));
|
|
178
184
|
return settled.map((result, index) => result.status === "fulfilled"
|
|
179
185
|
? result.value
|
|
@@ -256,6 +262,7 @@ export async function collectQuotaDashboardProviderResults(params) {
|
|
|
256
262
|
config: { ...params.config, onlyCurrentModel: false },
|
|
257
263
|
request: undefined,
|
|
258
264
|
surfaceExplicitProviderIssues: false,
|
|
265
|
+
includeProviderScope: true,
|
|
259
266
|
});
|
|
260
267
|
return result.providerResults;
|
|
261
268
|
}
|
|
@@ -266,6 +273,9 @@ function getExplicitNoDataMessage(provider) {
|
|
|
266
273
|
if (provider.id === "anthropic") {
|
|
267
274
|
return getAnthropicNoDataMessage();
|
|
268
275
|
}
|
|
276
|
+
if (provider.id === "claude-agent") {
|
|
277
|
+
return getClaudeAgentNoDataMessage();
|
|
278
|
+
}
|
|
269
279
|
return "Not configured";
|
|
270
280
|
}
|
|
271
281
|
function shouldSurfaceNoDataMessage(params) {
|
|
@@ -276,7 +286,8 @@ function shouldSurfaceNoDataMessage(params) {
|
|
|
276
286
|
if (!isAutoMode) {
|
|
277
287
|
return true;
|
|
278
288
|
}
|
|
279
|
-
return activeProviderCount === 1 &&
|
|
289
|
+
return (activeProviderCount === 1 &&
|
|
290
|
+
(provider.id === "anthropic" || provider.id === "claude-agent" || provider.id === "cursor"));
|
|
280
291
|
}
|
|
281
292
|
function buildExplicitProviderIssues(params) {
|
|
282
293
|
if (!params.enabled || params.selection.isAutoMode)
|
|
@@ -332,6 +343,8 @@ export async function collectQuotaRenderData(params) {
|
|
|
332
343
|
data: null,
|
|
333
344
|
};
|
|
334
345
|
}
|
|
346
|
+
if (params.forceProviderRefresh)
|
|
347
|
+
selection.ctx.operationCache?.set(QUOTA_FORCE_REFRESH, true);
|
|
335
348
|
if (selection.waitingForCurrentSelection) {
|
|
336
349
|
retainQuotaTelemetryProviders({
|
|
337
350
|
token: selection.ctx.config.telemetryToken,
|
|
@@ -375,12 +388,22 @@ export async function collectQuotaRenderData(params) {
|
|
|
375
388
|
data: packageQuotaRenderData({ entries: [], errors: explicitProviderIssues }),
|
|
376
389
|
};
|
|
377
390
|
}
|
|
391
|
+
const initialScopes = params.includeProviderScope
|
|
392
|
+
? await Promise.all(active.map((provider) => getQuotaProviderResultScope(provider, selection.ctx)))
|
|
393
|
+
: [];
|
|
378
394
|
const results = await fetchProviderResults({
|
|
379
395
|
providers: active,
|
|
380
396
|
ctx: selection.ctx,
|
|
381
397
|
ttlMs: params.config.minIntervalMs,
|
|
382
398
|
bypassCache: params.bypassProviderCache,
|
|
399
|
+
forceRefresh: params.forceProviderRefresh,
|
|
383
400
|
});
|
|
401
|
+
const finalScopes = params.includeProviderScope
|
|
402
|
+
? await Promise.all(active.map((provider) => getQuotaProviderResultScope(provider, provider.cachePolicy?.kind === "resolved-auth" &&
|
|
403
|
+
provider.cachePolicy.revalidateWithCycleCache
|
|
404
|
+
? selection.ctx
|
|
405
|
+
: { ...selection.ctx, operationCache: undefined })))
|
|
406
|
+
: [];
|
|
384
407
|
const style = params.formatStyle ?? params.config.formatStyle;
|
|
385
408
|
const projectionOptions = {
|
|
386
409
|
quotaProjection: params.config.quotaProjection,
|
|
@@ -450,6 +473,9 @@ export async function collectQuotaRenderData(params) {
|
|
|
450
473
|
providerResults: active.map((provider, index) => ({
|
|
451
474
|
providerId: provider.id,
|
|
452
475
|
result: results[index],
|
|
476
|
+
...(initialScopes[index] && initialScopes[index] === finalScopes[index]
|
|
477
|
+
? { cacheScope: initialScopes[index] }
|
|
478
|
+
: {}),
|
|
453
479
|
})),
|
|
454
480
|
attemptedAny,
|
|
455
481
|
hasExplicitProviderIssues,
|
|
@@ -10,6 +10,7 @@ export function cloneQuotaProviderResult(result) {
|
|
|
10
10
|
entries: result.entries.map(cloneQuotaToastEntry),
|
|
11
11
|
errors: result.errors.map((error) => ({ ...error })),
|
|
12
12
|
...(result.accounts ? { accounts: result.accounts.map((account) => ({ ...account })) } : {}),
|
|
13
|
+
...(result.planLabel === undefined ? {} : { planLabel: result.planLabel }),
|
|
13
14
|
...(result.diagnostics
|
|
14
15
|
? {
|
|
15
16
|
diagnostics: result.diagnostics.map((diagnostic) => ({
|
|
@@ -265,9 +266,19 @@ function isQuotaToastEntry(value, safeText) {
|
|
|
265
266
|
function isQuotaToastError(value) {
|
|
266
267
|
if (!isRecord(value))
|
|
267
268
|
return false;
|
|
268
|
-
return (hasOnlyKeys(value, [
|
|
269
|
+
return (hasOnlyKeys(value, [
|
|
270
|
+
"label",
|
|
271
|
+
"message",
|
|
272
|
+
"retryable",
|
|
273
|
+
"failureCategory",
|
|
274
|
+
"kind",
|
|
275
|
+
"sourceId",
|
|
276
|
+
"retryAtMs",
|
|
277
|
+
]) &&
|
|
269
278
|
typeof value.label === "string" &&
|
|
270
279
|
typeof value.message === "string" &&
|
|
280
|
+
(value.retryAtMs === undefined ||
|
|
281
|
+
(Number.isSafeInteger(value.retryAtMs) && value.retryAtMs >= 0)) &&
|
|
271
282
|
(value.retryable === undefined || typeof value.retryable === "boolean") &&
|
|
272
283
|
(value.failureCategory === undefined || isProviderFailureCategory(value.failureCategory)) &&
|
|
273
284
|
(value.kind === undefined || value.kind === "intentional-filter") &&
|
|
@@ -392,6 +403,7 @@ function isQuotaProviderResult(value, safeText) {
|
|
|
392
403
|
"entries",
|
|
393
404
|
"errors",
|
|
394
405
|
"accounts",
|
|
406
|
+
"planLabel",
|
|
395
407
|
"diagnostics",
|
|
396
408
|
"statusDetails",
|
|
397
409
|
"rawDetails",
|
|
@@ -404,6 +416,7 @@ function isQuotaProviderResult(value, safeText) {
|
|
|
404
416
|
value.errors.every(isQuotaToastError) &&
|
|
405
417
|
(value.accounts === undefined ||
|
|
406
418
|
(isDenseArray(value.accounts) && value.accounts.every(isQuotaProviderAccount))) &&
|
|
419
|
+
(value.planLabel === undefined || typeof value.planLabel === "string") &&
|
|
407
420
|
(value.diagnostics === undefined ||
|
|
408
421
|
(isDenseArray(value.diagnostics) && value.diagnostics.every(isQuotaProviderDiagnostic))) &&
|
|
409
422
|
(value.statusDetails === undefined ||
|
|
@@ -440,6 +453,9 @@ export function normalizeQuotaProviderResult(value) {
|
|
|
440
453
|
})),
|
|
441
454
|
}
|
|
442
455
|
: {}),
|
|
456
|
+
...(value.planLabel !== undefined
|
|
457
|
+
? { planLabel: sanitizeSingleLineDisplayText(value.planLabel) }
|
|
458
|
+
: {}),
|
|
443
459
|
};
|
|
444
460
|
return isQuotaProviderResult(preserved, true) ? cloneQuotaProviderResult(preserved) : null;
|
|
445
461
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import type { QuotaProvider, QuotaProviderContext, QuotaProviderResult } from "./entries.js";
|
|
1
|
+
import type { QuotaProvider, QuotaProviderContext, QuotaProviderResult, QuotaToastEntry } from "./entries.js";
|
|
2
|
+
export { QUOTA_FORCE_REFRESH } from "./entries.js";
|
|
2
3
|
import type { QuotaProviderDefinition } from "./quota-providers.js";
|
|
3
4
|
import type { ResolvedAuthIdentity } from "./resolved-auth-identity.js";
|
|
5
|
+
/** Retained (not freshly measured) entries must never carry Claude Agent saved resets. */
|
|
6
|
+
export declare function withoutClaudeAgentSavedResets(entries: readonly QuotaToastEntry[]): QuotaToastEntry[];
|
|
4
7
|
export declare function buildQuotaProviderStateCacheKey(providerId: string, ctx: QuotaProviderContext, options?: {
|
|
5
8
|
runtimeEligibleQuotaProviders?: readonly QuotaProviderDefinition[];
|
|
6
9
|
resolvedAuthIdentity?: ResolvedAuthIdentity;
|
|
7
10
|
}): string;
|
|
8
11
|
export declare function getQuotaProviderStateCacheFilePath(providerId: string, key: string): string;
|
|
12
|
+
/** Private, opaque identity for server-side last-good matching; never a DTO field. */
|
|
13
|
+
export declare function getQuotaProviderResultScope(provider: QuotaProvider, ctx: QuotaProviderContext): Promise<string | undefined>;
|
|
9
14
|
export declare function fetchQuotaProviderResult(params: {
|
|
10
15
|
provider: QuotaProvider;
|
|
11
16
|
ctx: QuotaProviderContext;
|
|
12
17
|
ttlMs: number;
|
|
13
18
|
bypassCache?: boolean;
|
|
19
|
+
forceRefresh?: boolean;
|
|
14
20
|
}): Promise<QuotaProviderResult>;
|
|
15
21
|
export type CachedProviderRead = {
|
|
16
22
|
hit: true;
|
package/dist/lib/quota-state.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { readdir, readFile, rm, stat } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { CLAUDE_AGENT_RESETS_ROW_KEY } from "../contracts/openai-quota.js";
|
|
4
5
|
import { writeJsonAtomic } from "./atomic-json.js";
|
|
6
|
+
import { QUOTA_FORCE_REFRESH } from "./entries.js";
|
|
7
|
+
export { QUOTA_FORCE_REFRESH } from "./entries.js";
|
|
5
8
|
import { getGuiPrivateCacheDir } from "./private-state-paths.js";
|
|
6
9
|
import { getQuotaProviderDisplayLabel, isLiveLocalUsageProviderId } from "./provider-metadata.js";
|
|
7
10
|
import { QUOTA_PROVIDERS_AGGREGATE_ID, selectEligibleQuotaProviderDefinitions, } from "./quota-providers.js";
|
|
@@ -12,8 +15,41 @@ const QUOTA_PROVIDER_CACHE_PACKAGE_VERSION_FALLBACK = "unknown";
|
|
|
12
15
|
const QUOTA_PROVIDER_CACHE_DIRNAME = "quota-provider-state";
|
|
13
16
|
const QUOTA_PROVIDER_CACHE_RETENTION_MS = 24 * 60 * 60 * 1000;
|
|
14
17
|
const QUOTA_PROVIDER_CACHE_PRUNE_INTERVAL_MS = 60 * 60 * 1000;
|
|
18
|
+
function isClaudeResetsEntry(entry) {
|
|
19
|
+
return "rowKey" in entry && entry.rowKey === CLAUDE_AGENT_RESETS_ROW_KEY;
|
|
20
|
+
}
|
|
21
|
+
/** Retained (not freshly measured) entries must never carry Claude Agent saved resets. */
|
|
22
|
+
export function withoutClaudeAgentSavedResets(entries) {
|
|
23
|
+
return entries.filter((entry) => !isClaudeResetsEntry(entry));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cached reads must not show a saved reset past its expiry. Unknown (absent) and explicit-null
|
|
27
|
+
* expiries are kept; once no reset remains the row is dropped.
|
|
28
|
+
*/
|
|
29
|
+
function withoutExpiredClaudeResets(result) {
|
|
30
|
+
if (!result.entries.some(isClaudeResetsEntry))
|
|
31
|
+
return result;
|
|
32
|
+
const nowMs = Date.now();
|
|
33
|
+
const entries = result.entries.flatMap((entry) => {
|
|
34
|
+
if (!isClaudeResetsEntry(entry) || entry.kind !== "value" || !entry.bankedResets)
|
|
35
|
+
return [entry];
|
|
36
|
+
const credits = entry.bankedResets.credits.filter((credit) => typeof credit.expiresAtIso !== "string" || Date.parse(credit.expiresAtIso) > nowMs);
|
|
37
|
+
const availableCount = entry.bankedResets.availableCount - (entry.bankedResets.credits.length - credits.length);
|
|
38
|
+
return availableCount > 0
|
|
39
|
+
? [
|
|
40
|
+
{
|
|
41
|
+
...entry,
|
|
42
|
+
value: `${availableCount} available`,
|
|
43
|
+
bankedResets: { availableCount, credits },
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
: [];
|
|
47
|
+
});
|
|
48
|
+
return { ...result, entries };
|
|
49
|
+
}
|
|
15
50
|
const inMemoryCache = new Map();
|
|
16
51
|
const inFlightByKey = new Map();
|
|
52
|
+
const refreshByKey = new Map();
|
|
17
53
|
let processLocalLatestByRuntime = new WeakMap();
|
|
18
54
|
let lastPruneAtMs = 0;
|
|
19
55
|
export function buildQuotaProviderStateCacheKey(providerId, ctx, options = {}) {
|
|
@@ -187,6 +223,19 @@ async function resolveProviderCacheScope(provider, ctx, cacheContext) {
|
|
|
187
223
|
return null;
|
|
188
224
|
}
|
|
189
225
|
}
|
|
226
|
+
/** Private, opaque identity for server-side last-good matching; never a DTO field. */
|
|
227
|
+
export async function getQuotaProviderResultScope(provider, ctx) {
|
|
228
|
+
const runtimeEligibleQuotaProviders = await resolveRuntimeEligibleQuotaProviders(provider.id, ctx);
|
|
229
|
+
if (runtimeEligibleQuotaProviders === null)
|
|
230
|
+
return undefined;
|
|
231
|
+
const scope = await resolveProviderCacheScope(provider, ctx, { runtimeEligibleQuotaProviders });
|
|
232
|
+
if (!scope)
|
|
233
|
+
return undefined;
|
|
234
|
+
return getQuotaProviderStateCacheLocator(buildQuotaProviderStateCacheKey(provider.id, ctx, {
|
|
235
|
+
runtimeEligibleQuotaProviders,
|
|
236
|
+
resolvedAuthIdentity: scope.resolvedAuthIdentity,
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
190
239
|
async function isProviderCacheScopeCurrent(provider, ctx, scope) {
|
|
191
240
|
if (provider.cachePolicy?.kind === "account-neutral")
|
|
192
241
|
return true;
|
|
@@ -196,8 +245,7 @@ async function isProviderCacheScopeCurrent(provider, ctx, scope) {
|
|
|
196
245
|
const runtimeEligibleQuotaProviders = await resolveRuntimeEligibleQuotaProviders(provider.id, ctx);
|
|
197
246
|
if (runtimeEligibleQuotaProviders === null)
|
|
198
247
|
return false;
|
|
199
|
-
return ((await provider.cachePolicy.resolveIdentity(ctx, { runtimeEligibleQuotaProviders })) ===
|
|
200
|
-
scope.resolvedAuthIdentity);
|
|
248
|
+
return ((await provider.cachePolicy.resolveIdentity(provider.cachePolicy.revalidateWithCycleCache ? ctx : { ...ctx, operationCache: undefined }, { runtimeEligibleQuotaProviders })) === scope.resolvedAuthIdentity);
|
|
201
249
|
}
|
|
202
250
|
catch {
|
|
203
251
|
return false;
|
|
@@ -207,32 +255,41 @@ function getProcessLocalRuntimeOwner(ctx) {
|
|
|
207
255
|
const owner = ctx.client;
|
|
208
256
|
return owner && (typeof owner === "object" || typeof owner === "function") ? owner : null;
|
|
209
257
|
}
|
|
258
|
+
function buildProcessLocalRouteKey(params) {
|
|
259
|
+
return buildQuotaProviderStateCacheKey(params.provider.id, params.ctx, {
|
|
260
|
+
runtimeEligibleQuotaProviders: params.runtimeEligibleQuotaProviders,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
210
263
|
function rememberProcessLocalLatest(params) {
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
264
|
+
const owner = getProcessLocalRuntimeOwner(params.ctx);
|
|
265
|
+
if (!owner)
|
|
213
266
|
return;
|
|
214
|
-
let
|
|
215
|
-
if (!
|
|
216
|
-
|
|
217
|
-
processLocalLatestByRuntime.set(
|
|
267
|
+
let runtime = processLocalLatestByRuntime.get(owner);
|
|
268
|
+
if (!runtime) {
|
|
269
|
+
runtime = new WeakMap();
|
|
270
|
+
processLocalLatestByRuntime.set(owner, runtime);
|
|
271
|
+
}
|
|
272
|
+
let routes = runtime.get(params.provider);
|
|
273
|
+
if (!routes) {
|
|
274
|
+
routes = new Map();
|
|
275
|
+
runtime.set(params.provider, routes);
|
|
218
276
|
}
|
|
219
|
-
|
|
277
|
+
routes.set(buildProcessLocalRouteKey(params), {
|
|
220
278
|
result: cloneQuotaProviderResult(params.result),
|
|
221
279
|
timestamp: Date.now(),
|
|
222
280
|
});
|
|
223
281
|
}
|
|
224
282
|
function readProcessLocalLatest(params) {
|
|
225
|
-
const
|
|
226
|
-
if (!
|
|
283
|
+
const owner = getProcessLocalRuntimeOwner(params.ctx);
|
|
284
|
+
if (!owner)
|
|
227
285
|
return { hit: false };
|
|
228
|
-
const entry = processLocalLatestByRuntime
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
result: cloneQuotaProviderResult(entry.result),
|
|
234
|
-
|
|
235
|
-
};
|
|
286
|
+
const entry = processLocalLatestByRuntime
|
|
287
|
+
.get(owner)
|
|
288
|
+
?.get(params.provider)
|
|
289
|
+
?.get(buildProcessLocalRouteKey(params));
|
|
290
|
+
return entry
|
|
291
|
+
? { hit: true, result: cloneQuotaProviderResult(entry.result), timestamp: entry.timestamp }
|
|
292
|
+
: { hit: false };
|
|
236
293
|
}
|
|
237
294
|
function publishQuotaTelemetry(params) {
|
|
238
295
|
if (!params.ctx.config.telemetryToken)
|
|
@@ -250,10 +307,20 @@ function publishQuotaTelemetry(params) {
|
|
|
250
307
|
});
|
|
251
308
|
}
|
|
252
309
|
export async function fetchQuotaProviderResult(params) {
|
|
253
|
-
const { provider,
|
|
310
|
+
const { provider, ttlMs, bypassCache = false } = params;
|
|
311
|
+
const ctx = params.forceRefresh
|
|
312
|
+
? { ...params.ctx, operationCache: new Map(params.ctx.operationCache) }
|
|
313
|
+
: params.ctx;
|
|
314
|
+
if (params.forceRefresh)
|
|
315
|
+
ctx.operationCache.set(QUOTA_FORCE_REFRESH, true);
|
|
254
316
|
const fetchUncached = async (cacheContext = {}) => {
|
|
255
317
|
const snapshot = await fetchValidatedProviderResult(provider, ctx, cacheContext);
|
|
256
|
-
rememberProcessLocalLatest({
|
|
318
|
+
rememberProcessLocalLatest({
|
|
319
|
+
provider,
|
|
320
|
+
ctx,
|
|
321
|
+
result: snapshot,
|
|
322
|
+
runtimeEligibleQuotaProviders: cacheContext.runtimeEligibleQuotaProviders,
|
|
323
|
+
});
|
|
257
324
|
publishQuotaTelemetry({
|
|
258
325
|
ctx,
|
|
259
326
|
providerId: provider.id,
|
|
@@ -275,6 +342,25 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
275
342
|
runtimeEligibleQuotaProviders,
|
|
276
343
|
resolvedAuthIdentity: scope.resolvedAuthIdentity,
|
|
277
344
|
});
|
|
345
|
+
if (params.forceRefresh && !isLiveLocalUsageProviderId(provider.id)) {
|
|
346
|
+
const existing = refreshByKey.get(key);
|
|
347
|
+
if (existing)
|
|
348
|
+
return cloneQuotaProviderResult(await existing);
|
|
349
|
+
const refresh = (async () => {
|
|
350
|
+
// An earlier ordinary request is not a refresh; wait for it to settle
|
|
351
|
+
// before retrying so its result cannot overwrite the newer measurement.
|
|
352
|
+
await inFlightByKey.get(key)?.catch(() => undefined);
|
|
353
|
+
return fetchQuotaProviderResult({ provider, ctx, ttlMs: 0 });
|
|
354
|
+
})();
|
|
355
|
+
refreshByKey.set(key, refresh);
|
|
356
|
+
try {
|
|
357
|
+
return cloneQuotaProviderResult(await refresh);
|
|
358
|
+
}
|
|
359
|
+
finally {
|
|
360
|
+
if (refreshByKey.get(key) === refresh)
|
|
361
|
+
refreshByKey.delete(key);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
278
364
|
if (isLiveLocalUsageProviderId(provider.id)) {
|
|
279
365
|
const snapshot = await fetchValidatedProviderResult(provider, ctx, cacheContext);
|
|
280
366
|
if (!(await isProviderCacheScopeCurrent(provider, ctx, scope))) {
|
|
@@ -308,6 +394,7 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
308
394
|
await maybePrunePersistedQuotaProviderCache(now);
|
|
309
395
|
const inMemory = forceAggregateRefresh ? undefined : inMemoryCache.get(key);
|
|
310
396
|
if (inMemory &&
|
|
397
|
+
!inMemory.stale &&
|
|
311
398
|
inMemory.packageVersion === packageVersion &&
|
|
312
399
|
ttlMs > 0 &&
|
|
313
400
|
now - inMemory.timestamp < ttlMs) {
|
|
@@ -318,10 +405,14 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
318
405
|
result: inMemory.result,
|
|
319
406
|
cacheTimestamp: inMemory.timestamp,
|
|
320
407
|
});
|
|
321
|
-
return cloneQuotaProviderResult(inMemory.result);
|
|
408
|
+
return withoutExpiredClaudeResets(cloneQuotaProviderResult(inMemory.result));
|
|
322
409
|
}
|
|
323
410
|
const inFlight = inFlightByKey.get(key);
|
|
324
411
|
if (inFlight) {
|
|
412
|
+
if (ctx.operationCache?.get(QUOTA_FORCE_REFRESH) === true) {
|
|
413
|
+
await inFlight.catch(() => undefined);
|
|
414
|
+
return fetchQuotaProviderResult({ provider, ctx, ttlMs: 0 });
|
|
415
|
+
}
|
|
325
416
|
const snapshot = await inFlight;
|
|
326
417
|
publishQuotaTelemetry({
|
|
327
418
|
ctx,
|
|
@@ -341,7 +432,7 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
341
432
|
ttlMs,
|
|
342
433
|
now,
|
|
343
434
|
});
|
|
344
|
-
if (persisted) {
|
|
435
|
+
if (persisted && !inMemoryCache.has(key)) {
|
|
345
436
|
inMemoryCache.set(key, {
|
|
346
437
|
...persisted,
|
|
347
438
|
result: cloneQuotaProviderResult(persisted.result),
|
|
@@ -353,10 +444,14 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
353
444
|
result: persisted.result,
|
|
354
445
|
cacheTimestamp: persisted.timestamp,
|
|
355
446
|
});
|
|
356
|
-
return cloneQuotaProviderResult(persisted.result);
|
|
447
|
+
return withoutExpiredClaudeResets(cloneQuotaProviderResult(persisted.result));
|
|
357
448
|
}
|
|
358
449
|
const inFlightAfterDiskRead = inFlightByKey.get(key);
|
|
359
450
|
if (inFlightAfterDiskRead) {
|
|
451
|
+
if (ctx.operationCache?.get(QUOTA_FORCE_REFRESH) === true) {
|
|
452
|
+
await inFlightAfterDiskRead.catch(() => undefined);
|
|
453
|
+
return fetchQuotaProviderResult({ provider, ctx, ttlMs: 0 });
|
|
454
|
+
}
|
|
360
455
|
const snapshot = await inFlightAfterDiskRead;
|
|
361
456
|
publishQuotaTelemetry({
|
|
362
457
|
ctx,
|
|
@@ -368,7 +463,68 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
368
463
|
return cloneQuotaProviderResult(snapshot);
|
|
369
464
|
}
|
|
370
465
|
const fetchPromise = (async () => {
|
|
371
|
-
|
|
466
|
+
let snapshot;
|
|
467
|
+
try {
|
|
468
|
+
snapshot = await fetchValidatedProviderResult(provider, ctx, cacheContext);
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
if (ctx.operationCache?.get(QUOTA_FORCE_REFRESH) === true) {
|
|
472
|
+
const previous = inMemoryCache.get(key) ??
|
|
473
|
+
(await readPersistedQuotaProviderCacheEntry({
|
|
474
|
+
key,
|
|
475
|
+
providerId: provider.id,
|
|
476
|
+
packageVersion,
|
|
477
|
+
ttlMs,
|
|
478
|
+
now: Date.now(),
|
|
479
|
+
ignoreExpiry: true,
|
|
480
|
+
}));
|
|
481
|
+
if (previous && (await isProviderCacheScopeCurrent(provider, ctx, scope))) {
|
|
482
|
+
inMemoryCache.set(key, {
|
|
483
|
+
...previous,
|
|
484
|
+
stale: true,
|
|
485
|
+
result: {
|
|
486
|
+
...previous.result,
|
|
487
|
+
entries: previous.result.entries.filter((entry) => !isClaudeResetsEntry(entry)),
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
inMemoryCache.delete(key);
|
|
493
|
+
}
|
|
494
|
+
await safeRm(getQuotaProviderStateCacheFilePath(provider.id, key));
|
|
495
|
+
}
|
|
496
|
+
throw error;
|
|
497
|
+
}
|
|
498
|
+
const rateLimited = snapshot.errors.filter((error) => error.retryAtMs !== undefined);
|
|
499
|
+
const previous = inMemoryCache.get(key);
|
|
500
|
+
if (rateLimited.length > 0 &&
|
|
501
|
+
previous &&
|
|
502
|
+
(await isProviderCacheScopeCurrent(provider, ctx, scope))) {
|
|
503
|
+
const failedAccounts = new Set(rateLimited.map((error) => error.sourceId).filter((id) => id !== undefined));
|
|
504
|
+
const accountsWithFreshEntries = new Set(snapshot.entries
|
|
505
|
+
.map((entry) => entry.accounting.sourceId)
|
|
506
|
+
.filter((id) => id !== undefined));
|
|
507
|
+
// A failed refresh proves neither eligibility nor remaining expiry, so saved resets are
|
|
508
|
+
// never carried over from an earlier snapshot.
|
|
509
|
+
const retained = previous.result.entries.filter((entry) => !isClaudeResetsEntry(entry));
|
|
510
|
+
const fallback = snapshot.entries.length === 0 && rateLimited.some((error) => error.sourceId === undefined)
|
|
511
|
+
? provider.id === "openrouter"
|
|
512
|
+
? retained.filter((entry) => entry.accounting.sourceId === undefined)
|
|
513
|
+
: retained
|
|
514
|
+
: retained.filter((entry) => entry.accounting.sourceId !== undefined &&
|
|
515
|
+
failedAccounts.has(entry.accounting.sourceId) &&
|
|
516
|
+
!accountsWithFreshEntries.has(entry.accounting.sourceId));
|
|
517
|
+
if (fallback.length > 0) {
|
|
518
|
+
const stale = { ...snapshot, entries: [...snapshot.entries, ...fallback] };
|
|
519
|
+
inMemoryCache.set(key, {
|
|
520
|
+
...previous,
|
|
521
|
+
stale: true,
|
|
522
|
+
result: cloneQuotaProviderResult(stale),
|
|
523
|
+
});
|
|
524
|
+
await safeRm(getQuotaProviderStateCacheFilePath(provider.id, key));
|
|
525
|
+
return stale;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
372
528
|
if (!snapshot.attempted ||
|
|
373
529
|
snapshot.entries.length === 0 ||
|
|
374
530
|
!(await isProviderCacheScopeCurrent(provider, ctx, scope))) {
|
|
@@ -383,6 +539,11 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
383
539
|
timestamp: Date.now(),
|
|
384
540
|
result: snapshot,
|
|
385
541
|
});
|
|
542
|
+
if (snapshot.errors.some((error) => error.kind !== "intentional-filter")) {
|
|
543
|
+
inMemoryCache.set(key, { ...entry, stale: true, result: cloneQuotaProviderResult(snapshot) });
|
|
544
|
+
await safeRm(getQuotaProviderStateCacheFilePath(provider.id, key));
|
|
545
|
+
return snapshot;
|
|
546
|
+
}
|
|
386
547
|
inMemoryCache.set(key, {
|
|
387
548
|
...entry,
|
|
388
549
|
result: cloneQuotaProviderResult(entry.result),
|
|
@@ -407,12 +568,17 @@ export async function readCachedProviderResult(params) {
|
|
|
407
568
|
const runtimeEligibleQuotaProviders = await resolveRuntimeEligibleQuotaProviders(params.provider.id, params.ctx);
|
|
408
569
|
if (runtimeEligibleQuotaProviders === null)
|
|
409
570
|
return { hit: false };
|
|
571
|
+
if (runtimeEligibleQuotaProviders?.length === 0)
|
|
572
|
+
return { hit: false };
|
|
410
573
|
const cacheContext = { runtimeEligibleQuotaProviders };
|
|
411
574
|
const scope = await resolveProviderCacheScope(params.provider, params.ctx, cacheContext);
|
|
412
575
|
if (!scope) {
|
|
576
|
+
if (params.provider.cachePolicy?.kind === "resolved-auth")
|
|
577
|
+
return { hit: false };
|
|
413
578
|
return readProcessLocalLatest({
|
|
414
579
|
provider: params.provider,
|
|
415
580
|
ctx: params.ctx,
|
|
581
|
+
runtimeEligibleQuotaProviders,
|
|
416
582
|
});
|
|
417
583
|
}
|
|
418
584
|
const key = buildQuotaProviderStateCacheKey(params.provider.id, params.ctx, {
|
|
@@ -431,7 +597,7 @@ export async function readCachedProviderResult(params) {
|
|
|
431
597
|
});
|
|
432
598
|
return {
|
|
433
599
|
hit: true,
|
|
434
|
-
result: cloneQuotaProviderResult(inMemory.result),
|
|
600
|
+
result: withoutExpiredClaudeResets(cloneQuotaProviderResult(inMemory.result)),
|
|
435
601
|
timestamp: inMemory.timestamp,
|
|
436
602
|
};
|
|
437
603
|
}
|
|
@@ -445,21 +611,28 @@ export async function readCachedProviderResult(params) {
|
|
|
445
611
|
ignoreExpiry: true,
|
|
446
612
|
});
|
|
447
613
|
if (persisted) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
614
|
+
if (!(await isProviderCacheScopeCurrent(params.provider, params.ctx, scope))) {
|
|
615
|
+
return { hit: false };
|
|
616
|
+
}
|
|
617
|
+
const current = inMemoryCache.get(key);
|
|
618
|
+
const selected = current ?? persisted;
|
|
619
|
+
if (!current) {
|
|
620
|
+
inMemoryCache.set(key, {
|
|
621
|
+
...persisted,
|
|
622
|
+
result: cloneQuotaProviderResult(persisted.result),
|
|
623
|
+
});
|
|
624
|
+
}
|
|
452
625
|
publishQuotaTelemetry({
|
|
453
626
|
ctx: params.ctx,
|
|
454
627
|
providerId: params.provider.id,
|
|
455
628
|
snapshotId: key,
|
|
456
|
-
result:
|
|
457
|
-
cacheTimestamp:
|
|
629
|
+
result: selected.result,
|
|
630
|
+
cacheTimestamp: selected.timestamp,
|
|
458
631
|
});
|
|
459
632
|
return {
|
|
460
633
|
hit: true,
|
|
461
|
-
result: cloneQuotaProviderResult(
|
|
462
|
-
timestamp:
|
|
634
|
+
result: withoutExpiredClaudeResets(cloneQuotaProviderResult(selected.result)),
|
|
635
|
+
timestamp: selected.timestamp,
|
|
463
636
|
};
|
|
464
637
|
}
|
|
465
638
|
return { hit: false };
|
|
@@ -467,6 +640,7 @@ export async function readCachedProviderResult(params) {
|
|
|
467
640
|
export function __resetQuotaStateForTests() {
|
|
468
641
|
inMemoryCache.clear();
|
|
469
642
|
inFlightByKey.clear();
|
|
643
|
+
refreshByKey.clear();
|
|
470
644
|
processLocalLatestByRuntime = new WeakMap();
|
|
471
645
|
lastPruneAtMs = 0;
|
|
472
646
|
}
|
package/dist/lib/quota-stats.js
CHANGED
|
@@ -95,6 +95,13 @@ function parseModelIdHint(rawModelId) {
|
|
|
95
95
|
* literal instead of deriving nearby versions.
|
|
96
96
|
*/
|
|
97
97
|
const PROVIDER_MODEL_PRICING_ALIASES = {
|
|
98
|
+
// Claude Code Anthropic API family aliases, current list-price estimates only:
|
|
99
|
+
// https://code.claude.com/docs/en/model-config#model-aliases
|
|
100
|
+
anthropic: {
|
|
101
|
+
haiku: "claude-haiku-5-5",
|
|
102
|
+
sonnet: "claude-sonnet-5-5",
|
|
103
|
+
opus: "claude-opus-5-5",
|
|
104
|
+
},
|
|
98
105
|
"opencode-go": {
|
|
99
106
|
"deepseek-v4-flash": "deepseek-v4.1-flash",
|
|
100
107
|
},
|
|
@@ -119,6 +126,7 @@ function resolveExplicitPricingAlias(providerID, ...models) {
|
|
|
119
126
|
return null;
|
|
120
127
|
}
|
|
121
128
|
const SOURCE_PROVIDER_ALIASES = {
|
|
129
|
+
"claude-agent": "anthropic",
|
|
122
130
|
cursor: "cursor",
|
|
123
131
|
"cursor-acp": "cursor",
|
|
124
132
|
"github-copilot": "openai",
|
|
@@ -359,6 +367,19 @@ export function resolvePricingKey(source) {
|
|
|
359
367
|
method: "source_provider",
|
|
360
368
|
};
|
|
361
369
|
}
|
|
370
|
+
// Family aliases require an Anthropic source and its concrete price; do not
|
|
371
|
+
// infer another route from an alias or from an Anthropic model prefix alone.
|
|
372
|
+
if ((sourceProviderHint === "anthropic" || modelProviderHint === "anthropic") &&
|
|
373
|
+
Object.hasOwn(PROVIDER_MODEL_PRICING_ALIASES.anthropic, normalizedModel)) {
|
|
374
|
+
return {
|
|
375
|
+
ok: false,
|
|
376
|
+
unknown: {
|
|
377
|
+
sourceProviderID: srcProvider,
|
|
378
|
+
sourceModelID: srcModel,
|
|
379
|
+
reason: "missing_provider",
|
|
380
|
+
},
|
|
381
|
+
};
|
|
382
|
+
}
|
|
362
383
|
// Only now run same-provider heuristics (free-suffix stripping, -thinking,
|
|
363
384
|
// Gemini preview, Kimi/Anthropic variants).
|
|
364
385
|
const fromSourceProvider = tryProvider(sourceProviderHint, "source_provider");
|