@bitkyc08/opencodex 2.100.0 → 2.100.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/gui/dist/assets/App-g3Cm2xhZ.js +59 -0
- package/gui/dist/assets/{Tray-CeKVWQyB.js → Tray-BMDkAiXy.js} +1 -1
- package/gui/dist/assets/brand-mark-nr3ziR-T.js +1 -0
- package/gui/dist/assets/{index-DmDooSAG.css → index-Bziu8gTy.css} +1 -1
- package/gui/dist/assets/{index-BP47do6-.js → index-OYzhQUNP.js} +2 -2
- package/gui/dist/assets/{segment-thumb-features-CcxZBnxv.js → segment-thumb-features-DKCVUUTi.js} +1 -1
- package/gui/dist/classic/assets/{App-aYgIQMxI.js → App-CgPBKUP-.js} +3 -3
- package/gui/dist/classic/assets/{Tray-D8jfUXpQ.js → Tray-BedmOsE7.js} +1 -1
- package/gui/dist/classic/assets/{index-CfGqHooN.js → index-BR-HhNrp.js} +2 -2
- package/gui/dist/classic/assets/{quota-summary-R-ih7OlS.js → quota-summary-CXKhvSmQ.js} +1 -1
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +2 -2
- package/src/adapters/anthropic-image-normalize.ts +1 -1
- package/src/adapters/client-fingerprint.ts +1 -1
- package/src/adapters/openai-chat/mistral-image-limit.ts +28 -15
- package/src/adapters/openai-chat-images.ts +100 -0
- package/src/adapters/openai-chat.ts +6 -9
- package/src/generated/compatibility-version.json +21 -21
- package/src/lib/config-ownership.ts +9 -2
- package/src/oauth/anthropic-model-quota.ts +12 -0
- package/src/oauth/anthropic-routing.ts +11 -4
- package/src/oauth/kiro-iam-identity-center.ts +4 -1
- package/src/providers/claude-cli-identity.ts +9 -3
- package/src/providers/claude-cli-usage.ts +3 -2
- package/src/providers/quota/anthropic-family-headers.ts +8 -1
- package/src/providers/quota/anthropic-usage-windows.ts +49 -2
- package/src/providers/quota-types.ts +7 -0
- package/src/providers/registry/entries-extended.ts +3 -1
- package/src/providers/registry/model-ids.ts +1 -0
- package/src/providers/registry/types.ts +6 -0
- package/src/responses/retained-compaction.ts +31 -5
- package/src/server/responses/compact.ts +13 -1
- package/src/web-search/parse.ts +23 -2
- package/gui/dist/assets/App-CitvEefy.js +0 -59
- package/gui/dist/assets/brand-mark-M92UnxX2.js +0 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"path": "package.json",
|
|
13
|
-
"sha256": "
|
|
13
|
+
"sha256": "3f87d1ddd727370f129c13f6cc4250dce8bf8fe4bdf0353db6376b0a0abef1a3"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"path": "scripts/model-metadata.source.json",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
"path": "src/adapters/anthropic-image-normalize.ts",
|
|
37
|
-
"sha256": "
|
|
37
|
+
"sha256": "4350fe2863b47a88288090b904be143831cbdadba68d0aea64dbeaa39f0466d6"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"path": "src/adapters/anthropic-model-contract.ts",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
"path": "src/adapters/client-fingerprint.ts",
|
|
129
|
-
"sha256": "
|
|
129
|
+
"sha256": "a1a313e37c7bff576ad55da823c06f24e5c9b58fe4b6a11252434521f428b0bd"
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
"path": "src/adapters/cline-pass-deepseek-v4-tool-replay.ts",
|
|
@@ -638,7 +638,7 @@
|
|
|
638
638
|
},
|
|
639
639
|
{
|
|
640
640
|
"path": "src/adapters/openai-chat-images.ts",
|
|
641
|
-
"sha256": "
|
|
641
|
+
"sha256": "96ec5d49f88226fd9aa151eb43572617ed9496fb8306d42bfdb93599fd800df8"
|
|
642
642
|
},
|
|
643
643
|
{
|
|
644
644
|
"path": "src/adapters/openai-chat-url.ts",
|
|
@@ -646,7 +646,7 @@
|
|
|
646
646
|
},
|
|
647
647
|
{
|
|
648
648
|
"path": "src/adapters/openai-chat.ts",
|
|
649
|
-
"sha256": "
|
|
649
|
+
"sha256": "31c426d6359f205758c8ab334bd37bc3022617b33617a02b34f53c09f7a09e4f"
|
|
650
650
|
},
|
|
651
651
|
{
|
|
652
652
|
"path": "src/adapters/openai-chat/completed-tool-blocks.ts",
|
|
@@ -674,7 +674,7 @@
|
|
|
674
674
|
},
|
|
675
675
|
{
|
|
676
676
|
"path": "src/adapters/openai-chat/mistral-image-limit.ts",
|
|
677
|
-
"sha256": "
|
|
677
|
+
"sha256": "8055b5e542dee72e468f333e28233f7f8cc4ea33b4ba1fbb326d38ea8d8955b9"
|
|
678
678
|
},
|
|
679
679
|
{
|
|
680
680
|
"path": "src/adapters/openai-chat/native-content.ts",
|
|
@@ -5014,7 +5014,7 @@
|
|
|
5014
5014
|
},
|
|
5015
5015
|
{
|
|
5016
5016
|
"path": "src/lib/config-ownership.ts",
|
|
5017
|
-
"sha256": "
|
|
5017
|
+
"sha256": "1d72ed0ecf418374d72e5b13fef1ec0e14100acb1177d38dfddcbdd24caebb12"
|
|
5018
5018
|
},
|
|
5019
5019
|
{
|
|
5020
5020
|
"path": "src/lib/context-overflow-verdict.ts",
|
|
@@ -5854,7 +5854,7 @@
|
|
|
5854
5854
|
},
|
|
5855
5855
|
{
|
|
5856
5856
|
"path": "src/oauth/anthropic-model-quota.ts",
|
|
5857
|
-
"sha256": "
|
|
5857
|
+
"sha256": "3e594e587a216481e5e4afd8e8a2f44035f5cf1a8f909df70363f70726ca17d9"
|
|
5858
5858
|
},
|
|
5859
5859
|
{
|
|
5860
5860
|
"path": "src/oauth/anthropic-model-routes.ts",
|
|
@@ -5874,7 +5874,7 @@
|
|
|
5874
5874
|
},
|
|
5875
5875
|
{
|
|
5876
5876
|
"path": "src/oauth/anthropic-routing.ts",
|
|
5877
|
-
"sha256": "
|
|
5877
|
+
"sha256": "ccd80eb010e7a095a26017e5cdfac6d999e98027b5b5f51cccd9a3fa7321884a"
|
|
5878
5878
|
},
|
|
5879
5879
|
{
|
|
5880
5880
|
"path": "src/oauth/anthropic-send-ownership.ts",
|
|
@@ -6002,7 +6002,7 @@
|
|
|
6002
6002
|
},
|
|
6003
6003
|
{
|
|
6004
6004
|
"path": "src/oauth/kiro-iam-identity-center.ts",
|
|
6005
|
-
"sha256": "
|
|
6005
|
+
"sha256": "26790fdff3c2a55837fb234ada5686208517be9d429a92d4db05a9577141d45a"
|
|
6006
6006
|
},
|
|
6007
6007
|
{
|
|
6008
6008
|
"path": "src/oauth/kiro-terminal-failover.ts",
|
|
@@ -6362,7 +6362,7 @@
|
|
|
6362
6362
|
},
|
|
6363
6363
|
{
|
|
6364
6364
|
"path": "src/providers/claude-cli-identity.ts",
|
|
6365
|
-
"sha256": "
|
|
6365
|
+
"sha256": "3ab8a888931f4609205436362fe8c782cd898363267a98dd83e7be26252eaa80"
|
|
6366
6366
|
},
|
|
6367
6367
|
{
|
|
6368
6368
|
"path": "src/providers/claude-cli-usage-state.ts",
|
|
@@ -6370,7 +6370,7 @@
|
|
|
6370
6370
|
},
|
|
6371
6371
|
{
|
|
6372
6372
|
"path": "src/providers/claude-cli-usage.ts",
|
|
6373
|
-
"sha256": "
|
|
6373
|
+
"sha256": "254b3afc4694f7a484849a5891c53e9753af81bcdcee8111c016b0183bc4e8fd"
|
|
6374
6374
|
},
|
|
6375
6375
|
{
|
|
6376
6376
|
"path": "src/providers/codebuddy-models.ts",
|
|
@@ -6618,7 +6618,7 @@
|
|
|
6618
6618
|
},
|
|
6619
6619
|
{
|
|
6620
6620
|
"path": "src/providers/quota-types.ts",
|
|
6621
|
-
"sha256": "
|
|
6621
|
+
"sha256": "e3f468204d9989502c7ecbed12543e1ddd77a8faa4f077cf486bc49c7163e9e1"
|
|
6622
6622
|
},
|
|
6623
6623
|
{
|
|
6624
6624
|
"path": "src/providers/quota-wire.ts",
|
|
@@ -6650,11 +6650,11 @@
|
|
|
6650
6650
|
},
|
|
6651
6651
|
{
|
|
6652
6652
|
"path": "src/providers/quota/anthropic-family-headers.ts",
|
|
6653
|
-
"sha256": "
|
|
6653
|
+
"sha256": "dbe243ae6140e2f75c6ac4a0f7cc37017bd3ca9f89ba6f76d0b808cbf82eef5f"
|
|
6654
6654
|
},
|
|
6655
6655
|
{
|
|
6656
6656
|
"path": "src/providers/quota/anthropic-usage-windows.ts",
|
|
6657
|
-
"sha256": "
|
|
6657
|
+
"sha256": "bdff2ea93a42d3b553aed3bf5287f164c117f3e4a7cb82998e2f48ff3a4c8a0e"
|
|
6658
6658
|
},
|
|
6659
6659
|
{
|
|
6660
6660
|
"path": "src/providers/quota/antigravity.ts",
|
|
@@ -6710,11 +6710,11 @@
|
|
|
6710
6710
|
},
|
|
6711
6711
|
{
|
|
6712
6712
|
"path": "src/providers/registry/entries-extended.ts",
|
|
6713
|
-
"sha256": "
|
|
6713
|
+
"sha256": "1b3025b009181082c53f5a40822428565cd5d3ca8419ff9af071fddbf9b055bd"
|
|
6714
6714
|
},
|
|
6715
6715
|
{
|
|
6716
6716
|
"path": "src/providers/registry/model-ids.ts",
|
|
6717
|
-
"sha256": "
|
|
6717
|
+
"sha256": "a65e3344d2bdc5acaff4c4cdec74059d1e46b35840cc0d60f12f942edff35d7f"
|
|
6718
6718
|
},
|
|
6719
6719
|
{
|
|
6720
6720
|
"path": "src/providers/registry/model-seeds.ts",
|
|
@@ -6722,7 +6722,7 @@
|
|
|
6722
6722
|
},
|
|
6723
6723
|
{
|
|
6724
6724
|
"path": "src/providers/registry/types.ts",
|
|
6725
|
-
"sha256": "
|
|
6725
|
+
"sha256": "423df6ad4d25ecaca7ebdef2a869d42ba6483431c337a3a939bb9714d21110bb"
|
|
6726
6726
|
},
|
|
6727
6727
|
{
|
|
6728
6728
|
"path": "src/providers/request-pacing.ts",
|
|
@@ -7134,7 +7134,7 @@
|
|
|
7134
7134
|
},
|
|
7135
7135
|
{
|
|
7136
7136
|
"path": "src/responses/retained-compaction.ts",
|
|
7137
|
-
"sha256": "
|
|
7137
|
+
"sha256": "ff25e990165cebe4bb0299cd91eb362c1a79369f64d141589b58f4825732497c"
|
|
7138
7138
|
},
|
|
7139
7139
|
{
|
|
7140
7140
|
"path": "src/responses/schema.ts",
|
|
@@ -8406,7 +8406,7 @@
|
|
|
8406
8406
|
},
|
|
8407
8407
|
{
|
|
8408
8408
|
"path": "src/server/responses/compact.ts",
|
|
8409
|
-
"sha256": "
|
|
8409
|
+
"sha256": "f3730670ee5e79060f614a89dc384269aa72b63bef78404a5e4b586b21c98d05"
|
|
8410
8410
|
},
|
|
8411
8411
|
{
|
|
8412
8412
|
"path": "src/server/responses/compaction-recovery-policy.ts",
|
|
@@ -9974,7 +9974,7 @@
|
|
|
9974
9974
|
},
|
|
9975
9975
|
{
|
|
9976
9976
|
"path": "src/web-search/parse.ts",
|
|
9977
|
-
"sha256": "
|
|
9977
|
+
"sha256": "62b3e39a98984901f4b85709b9a5e5ef9253165cebd61e608fa7af1f9164f6b4"
|
|
9978
9978
|
},
|
|
9979
9979
|
{
|
|
9980
9980
|
"path": "src/web-search/passthrough-bridge.ts",
|
|
@@ -566,11 +566,18 @@ export function initializeConfigOwnership(configDir: string): boolean {
|
|
|
566
566
|
// stalls every request to that home. Either file changing re-arms a single wait.
|
|
567
567
|
const observed = creationWaitIdentity(configDir);
|
|
568
568
|
if (observed !== null && expiredCreationWait.get(cacheKey) === observed) {
|
|
569
|
-
|
|
569
|
+
// A spent wait suppresses only the wait itself, never the reload: the identity it keeps
|
|
570
|
+
// may already name a completed pair. One plain load stays cheap for an unchanged invalid
|
|
571
|
+
// pair and lets a valid one register instead of sticking unowned.
|
|
572
|
+
ownership = loadOwnership(configDir);
|
|
573
|
+
if (ownership !== null) expiredCreationWait.delete(cacheKey);
|
|
570
574
|
} else {
|
|
571
575
|
ownership = loadOrCreateOwnership(configDir);
|
|
572
576
|
const current = creationWaitIdentity(configDir);
|
|
573
|
-
|
|
577
|
+
// Record only the identity the wait actually ran out on: unchanged across it, so its last
|
|
578
|
+
// failed read describes the same state. A pair that changed during the wait, including one
|
|
579
|
+
// that completed just after that read, spends its own wait on the next registration.
|
|
580
|
+
if (ownership === null && current !== null && current === observed) expiredCreationWait.set(cacheKey, current);
|
|
574
581
|
else expiredCreationWait.delete(cacheKey);
|
|
575
582
|
}
|
|
576
583
|
ownershipCache.set(cacheKey, ownership);
|
|
@@ -4,6 +4,7 @@ import { getCachedProviderAccountQuota } from "../providers/quota/account-cache"
|
|
|
4
4
|
import type { ProviderQuota, ProviderQuotaWindow } from "../providers/quota-types";
|
|
5
5
|
import type { AnthropicInstanceId } from "../providers/anthropic-instance-id";
|
|
6
6
|
import type { GenerationContext } from "../lib/state-store-sweeper";
|
|
7
|
+
import { familyWeeklyEquivalentPercent } from "../providers/quota/anthropic-usage-windows";
|
|
7
8
|
|
|
8
9
|
export const ANTHROPIC_PASSIVE_FAMILY_MAX_AGE_MS = 30 * 60_000;
|
|
9
10
|
import { anthropicModelFamily } from "./anthropic-model-family";
|
|
@@ -161,3 +162,14 @@ export function anthropicModelWeeklyPercent(quota: ProviderQuota | null, model?:
|
|
|
161
162
|
const family = anthropicModelFamily(model);
|
|
162
163
|
return family ? quota?.customWindows?.find(window => window.scope === "model" && window.label === family)?.percent : undefined;
|
|
163
164
|
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The requested family's usage for comparing accounts, restated on the shared weekly scale when
|
|
168
|
+
* upstream reported its allowance. Thresholds keep `anthropicModelWeeklyPercent`: a fresh Fable
|
|
169
|
+
* seat reads 50 here, which ranks correctly but is not usage an operator's threshold means.
|
|
170
|
+
*/
|
|
171
|
+
export function anthropicModelRankPercent(quota: ProviderQuota | null, model?: string): number | undefined {
|
|
172
|
+
const family = anthropicModelFamily(model);
|
|
173
|
+
const window = family ? quota?.customWindows?.find(window => window.scope === "model" && window.label === family) : undefined;
|
|
174
|
+
return window ? familyWeeklyEquivalentPercent(window) : undefined;
|
|
175
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clearAllAnthropicFamilyQuota, anthropicModelQuotaFor, anthropicModelPercents, anthropicModelWeeklyPercent } from "./anthropic-model-quota";
|
|
1
|
+
import { clearAllAnthropicFamilyQuota, anthropicModelQuotaFor, anthropicModelPercents, anthropicModelRankPercent, anthropicModelWeeklyPercent } from "./anthropic-model-quota";
|
|
2
2
|
/**
|
|
3
3
|
* Opt-in Anthropic OAuth account pool (#294).
|
|
4
4
|
*
|
|
@@ -584,9 +584,16 @@ function createAnthropicRouting(instance: AnthropicInstanceId): AnthropicRouting
|
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
586
|
|
|
587
|
-
|
|
587
|
+
/**
|
|
588
|
+
* `rank` compares accounts, restating a family allowance on the weekly scale where the configured
|
|
589
|
+
* window ranks on weekly usage. Five-hour ranking has no five-hour tie-break, so a fresh Fable
|
|
590
|
+
* seat's 50 would mask every lower five-hour reading there; it and thresholds keep the family's own percent.
|
|
591
|
+
*/
|
|
592
|
+
function usageScore(config: OcxConfig, accountId: string, model?: string, rank = false): number {
|
|
588
593
|
if (model) {
|
|
589
|
-
const
|
|
594
|
+
const quota = getCachedProviderAccountQuota(PROVIDER, accountId);
|
|
595
|
+
const weeklyScale = rank && anthropicQuotaWindow(anthropicAccountPoolConfig(config)) !== "five-hour";
|
|
596
|
+
const family = weeklyScale ? anthropicModelRankPercent(quota, model) : anthropicModelWeeklyPercent(quota, model);
|
|
590
597
|
if (family === undefined) return usageScore(config, accountId);
|
|
591
598
|
return hasKnownUsage(config, accountId) ? Math.max(family, usageScore(config, accountId)) : family;
|
|
592
599
|
}
|
|
@@ -804,7 +811,7 @@ function createAnthropicRouting(instance: AnthropicInstanceId): AnthropicRouting
|
|
|
804
811
|
const scored: ScoredAccount[] = eligible.map(accountId => ({
|
|
805
812
|
accountId,
|
|
806
813
|
hasKnownUsage: hasKnownUsage(config, accountId, model),
|
|
807
|
-
score: usageScore(config, accountId, model),
|
|
814
|
+
score: usageScore(config, accountId, model, true),
|
|
808
815
|
fiveHourTieBreak: window === "five-hour" ? 0 : fiveHourScore(accountId),
|
|
809
816
|
// Every window EXCEPT the legacy five-hour default is an explicit opt-in, so
|
|
810
817
|
// known-before-unknown applies to all of them and to none of the default path.
|
|
@@ -55,7 +55,10 @@ async function listProfilesInRegion(reply: KiroIamReply, access: string, region:
|
|
|
55
55
|
const tokens = new Set<string>();
|
|
56
56
|
let nextToken: string | undefined;
|
|
57
57
|
for (let page = 0; page < 8; page++) {
|
|
58
|
-
|
|
58
|
+
// No maxResults: AWS answers maxResults above 10 with 400 ValidationException, and other
|
|
59
|
+
// Kiro clients report 400 REQUEST_BODY_INVALID for any maxResults; the default page plus
|
|
60
|
+
// nextToken pagination works for both.
|
|
61
|
+
const data = await call(reply, access, region, "ListAvailableProfiles", nextToken ? { nextToken } : {});
|
|
59
62
|
if (!Array.isArray(data.profiles)) throw new Error("Kiro IAM profiles unavailable");
|
|
60
63
|
for (const item of data.profiles) {
|
|
61
64
|
const profile = record(item);
|
|
@@ -7,8 +7,14 @@
|
|
|
7
7
|
* "cli_version"`; `claude-code/<ver>` is answered with `"surface"`. Only the
|
|
8
8
|
* `claude-cli/<ver> (external, cli)` form of a current release is treated as the
|
|
9
9
|
* Claude Code CLI surface. Bump the version together with a live GET check.
|
|
10
|
+
*
|
|
11
|
+
* Model access is gated on it too: Anthropic answers claude-fable-5-2 with
|
|
12
|
+
* "Claude Code 2.1.280 does not support this model; version 2.1.290 or newer is required".
|
|
13
|
+
* The three values below are one coherent client: Claude Code 2.1.321 sends @anthropic-ai/sdk 0.128.0 on
|
|
14
|
+
* runtime v26.12.1 (mitmproxy capture in router-for-me/CLIProxyAPI#7392; the locally installed 2.1.319
|
|
15
|
+
* binary carries the same SDK and runtime strings).
|
|
10
16
|
*/
|
|
11
|
-
export const CLAUDE_CLI_VERSION = "2.1.
|
|
17
|
+
export const CLAUDE_CLI_VERSION = "2.1.321";
|
|
12
18
|
export const CLAUDE_CLI_USER_AGENT = `claude-cli/${CLAUDE_CLI_VERSION} (external, cli)`;
|
|
13
|
-
export const CLAUDE_CLI_SDK_PACKAGE_VERSION = "0.
|
|
14
|
-
export const CLAUDE_CLI_RUNTIME_VERSION = "v26.
|
|
19
|
+
export const CLAUDE_CLI_SDK_PACKAGE_VERSION = "0.128.0";
|
|
20
|
+
export const CLAUDE_CLI_RUNTIME_VERSION = "v26.12.1";
|
|
@@ -40,7 +40,7 @@ export async function probeAnthropicUsageQuota(accessToken: string): Promise<Ant
|
|
|
40
40
|
const { buckets, familyEnumeration } = anthropicUsageBuckets(body);
|
|
41
41
|
const shared: Partial<ProviderQuota> = {};
|
|
42
42
|
const customWindows: ProviderQuotaWindow[] = [];
|
|
43
|
-
for (const { window, row, percentField } of buckets) {
|
|
43
|
+
for (const { window, row, percentField, weeklyAllowancePercent } of buckets) {
|
|
44
44
|
const percent = normalizePercent(row[percentField]);
|
|
45
45
|
const resetAt = normalizeResetAt(row.resets_at);
|
|
46
46
|
if (window === "5h" || window === "weekly") {
|
|
@@ -48,7 +48,8 @@ export async function probeAnthropicUsageQuota(accessToken: string): Promise<Ant
|
|
|
48
48
|
if (resetAt !== undefined) shared[window === "5h" ? "fiveHourResetAt" : "weeklyResetAt"] = resetAt;
|
|
49
49
|
} else if (percent !== undefined) {
|
|
50
50
|
const label = { fable: "Fable", opus: "Opus", sonnet: "Sonnet" }[window];
|
|
51
|
-
customWindows.push({ label, scope: "model", percent, ...(resetAt !== undefined ? { resetAt } : {})
|
|
51
|
+
customWindows.push({ label, scope: "model", percent, ...(resetAt !== undefined ? { resetAt } : {}),
|
|
52
|
+
...(weeklyAllowancePercent !== undefined ? { weeklyAllowancePercent } : {}) });
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
const quota: ProviderQuota = {
|
|
@@ -14,7 +14,14 @@ export function parseAnthropicFamilyHeaders(headers: Headers, now: number, statu
|
|
|
14
14
|
...(resetAt !== undefined && resetAt > 0 && Number.isFinite(new Date(resetAt).getTime()) ? { resetAt } : {}) }];
|
|
15
15
|
}
|
|
16
16
|
export function mergeAnthropicFamilyWindows(previous: ProviderQuotaWindow[] = [], observed: ProviderQuotaWindow[] = []): ProviderQuotaWindow[] {
|
|
17
|
-
|
|
17
|
+
const same = (a: ProviderQuotaWindow, b: ProviderQuotaWindow) => a.label === b.label && a.scope === b.scope;
|
|
18
|
+
// Headers carry no allowance; the share is a seat policy the last usage probe already read.
|
|
19
|
+
// A probe window (no passiveObservedAt) is itself that reading, so a missing share stays missing.
|
|
20
|
+
return [...previous.filter(window => !observed.some(update => same(update, window))), ...observed.map(update => {
|
|
21
|
+
const allowance = update.weeklyAllowancePercent === undefined && update.passiveObservedAt !== undefined
|
|
22
|
+
? previous.find(window => same(window, update))?.weeklyAllowancePercent : undefined;
|
|
23
|
+
return allowance === undefined ? update : { ...update, weeklyAllowancePercent: allowance };
|
|
24
|
+
})];
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
const enumerated = new WeakSet<object>();
|
|
@@ -6,6 +6,8 @@ export interface AnthropicUsageBucket {
|
|
|
6
6
|
window: UsageWindow;
|
|
7
7
|
row: Record<string, unknown>;
|
|
8
8
|
percentField: "percent" | "utilization";
|
|
9
|
+
/** Share of the weekly limit this scoped family may consume, from `weekly_scoped_shares`. */
|
|
10
|
+
weeklyAllowancePercent?: number;
|
|
9
11
|
}
|
|
10
12
|
const legacyFields = { "5h": "five_hour", weekly: "seven_day", fable: "seven_day_fable",
|
|
11
13
|
opus: "seven_day_opus", sonnet: "seven_day_sonnet" } as const;
|
|
@@ -18,6 +20,47 @@ function scopedFamily(row: Record<string, unknown>): "fable" | "opus" | "sonnet"
|
|
|
18
20
|
return (["fable", "opus", "sonnet"] as const).find(family => label.includes(family));
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
/**
|
|
24
|
+
* A family window's usage restated on the shared weekly scale.
|
|
25
|
+
*
|
|
26
|
+
* A scoped percent is relative to the family's own allowance: Fable at 60% of an allowance
|
|
27
|
+
* that is 50% of the week has 20 weekly points left, not 40. Ranking that compares a family
|
|
28
|
+
* request across accounts must use this figure alongside the shared weekly percent; a window
|
|
29
|
+
* without a valid allowance keeps its own percent. 100 maps to 100, so exhaustion is unchanged.
|
|
30
|
+
*/
|
|
31
|
+
export function familyWeeklyEquivalentPercent(window: { percent?: number; weeklyAllowancePercent?: number }): number | undefined {
|
|
32
|
+
const percent = window.percent;
|
|
33
|
+
if (typeof percent !== "number" || !Number.isFinite(percent)) return undefined;
|
|
34
|
+
const allowance = window.weeklyAllowancePercent;
|
|
35
|
+
if (typeof allowance !== "number" || !Number.isFinite(allowance) || allowance <= 0 || allowance > 100) return percent;
|
|
36
|
+
const used = Math.max(0, Math.min(100, percent));
|
|
37
|
+
return percent >= 100 ? percent : 100 - allowance * (100 - used) / 100;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `weekly_scoped_shares[]` names, by raw `limits` index, the share of the weekly limit a scoped
|
|
42
|
+
* row may consume (Fable: "up to 50% of your weekly limit"). Only a selected scoped row
|
|
43
|
+
* receives it; a malformed, out-of-range or conflicting share is ignored.
|
|
44
|
+
*/
|
|
45
|
+
function applyWeeklyShares(body: Record<string, unknown>, scopedRows: Map<number, AnthropicUsageBucket>): void {
|
|
46
|
+
if (!Array.isArray(body.weekly_scoped_shares)) return;
|
|
47
|
+
const conflicted = new Set<AnthropicUsageBucket>();
|
|
48
|
+
for (const raw of body.weekly_scoped_shares) {
|
|
49
|
+
const share = asRecord(raw);
|
|
50
|
+
const index = share?.limit_index;
|
|
51
|
+
const allowance = toFiniteNumber(share?.allowance_percent_of_weekly);
|
|
52
|
+
if (typeof index !== "number" || !Number.isInteger(index) || allowance === undefined || allowance <= 0 || allowance > 100) continue;
|
|
53
|
+
const bucket = scopedRows.get(index);
|
|
54
|
+
if (!bucket || conflicted.has(bucket)) continue;
|
|
55
|
+
if (bucket.weeklyAllowancePercent !== undefined && bucket.weeklyAllowancePercent !== allowance) {
|
|
56
|
+
delete bucket.weeklyAllowancePercent;
|
|
57
|
+
conflicted.add(bucket);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
bucket.weeklyAllowancePercent = allowance;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
21
64
|
/**
|
|
22
65
|
* Recognized rows supersede legacy duplicates even when skipped or malformed; duplicates
|
|
23
66
|
* and malformed shared measurements make family enumeration incomplete. Shared finite
|
|
@@ -30,9 +73,10 @@ export function anthropicUsageBuckets(body: Record<string, unknown>): {
|
|
|
30
73
|
} {
|
|
31
74
|
const selected = new Map<UsageWindow, AnthropicUsageBucket>();
|
|
32
75
|
const represented = new Set<UsageWindow>();
|
|
76
|
+
const scopedRows = new Map<number, AnthropicUsageBucket>();
|
|
33
77
|
const limits = Array.isArray(body.limits) ? body.limits : [];
|
|
34
78
|
let familyEnumeration = Array.isArray(body.limits);
|
|
35
|
-
for (const raw of limits) {
|
|
79
|
+
for (const [index, raw] of limits.entries()) {
|
|
36
80
|
const row = asRecord(raw);
|
|
37
81
|
const window = row?.kind === "session" ? "5h" : row?.kind === "weekly_all" ? "weekly"
|
|
38
82
|
: row?.kind === "weekly_scoped" ? scopedFamily(row) : undefined;
|
|
@@ -50,8 +94,11 @@ export function anthropicUsageBuckets(body: Record<string, unknown>): {
|
|
|
50
94
|
if (row.is_active === false) continue;
|
|
51
95
|
if (row.is_active !== undefined && row.is_active !== true) { familyEnumeration = false; continue; }
|
|
52
96
|
if (toFiniteNumber(row.percent) === undefined) familyEnumeration = false;
|
|
53
|
-
|
|
97
|
+
const bucket: AnthropicUsageBucket = { window, row, percentField: "percent" };
|
|
98
|
+
selected.set(window, bucket);
|
|
99
|
+
scopedRows.set(index, bucket);
|
|
54
100
|
}
|
|
101
|
+
applyWeeklyShares(body, scopedRows);
|
|
55
102
|
for (const window of Object.keys(legacyFields) as UsageWindow[]) {
|
|
56
103
|
if (represented.has(window)) continue;
|
|
57
104
|
const row = asRecord(body[legacyFields[window]]);
|
|
@@ -37,6 +37,13 @@ export interface ProviderQuotaWindow {
|
|
|
37
37
|
* provider-wide group named "Opus" there would otherwise be mistaken for a per-model window.
|
|
38
38
|
*/
|
|
39
39
|
scope?: "model";
|
|
40
|
+
/**
|
|
41
|
+
* Share of the provider-wide weekly limit a model-scoped window may consume, in percent:
|
|
42
|
+
* Anthropic's `weekly_scoped_shares[].allowance_percent_of_weekly` (Fable is "up to 50% of
|
|
43
|
+
* your weekly limit"). `percent` stays relative to this allowance. Read from upstream, never
|
|
44
|
+
* inferred from a plan; ranking restates family usage on the weekly scale with it.
|
|
45
|
+
*/
|
|
46
|
+
weeklyAllowancePercent?: number;
|
|
40
47
|
/** Passive family readings have their own freshness clock, independent of active probes. */
|
|
41
48
|
passiveObservedAt?: number;
|
|
42
49
|
/** Upstream refusal evidence, distinct from a measured utilization counter. */
|
|
@@ -522,7 +522,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
522
522
|
preserveReasoningContentModels: NVIDIA_NIM_KIMI_THINKING_MODELS,
|
|
523
523
|
note: "Free tier on NVIDIA NIM — API key still required (get a free key at build.nvidia.com).",
|
|
524
524
|
},
|
|
525
|
-
|
|
525
|
+
// Venice returns 400 for any image under 64x64, which a wide screenshot hits after
|
|
526
|
+
// the shared normalizer floors older images to a 320px long edge (320x25).
|
|
527
|
+
{ id: "venice", label: "Venice", baseUrl: "https://api.venice.ai/api/v1", adapter: "openai-chat", authKind: "key", dashboardUrl: "https://venice.ai/settings/api", minImageEdge: 64 },
|
|
526
528
|
// 260710 GLM-5.2 context and path-specific ids: Tier-2 evidence in
|
|
527
529
|
// devlog/_plan/260710_provider_hardening/002_research_cn.md.
|
|
528
530
|
// 260814: glm-5.3 / glm-5.3[1m] added per docs.z.ai/devpack/latest-model, which lists them as
|
|
@@ -81,6 +81,7 @@ export const REGISTRY_FIELD_MODEL_ID_ROLES = {
|
|
|
81
81
|
annotateEmptyToolOutputs: NONE,
|
|
82
82
|
supportsServiceTier: NONE,
|
|
83
83
|
supportsOpenAiWebSearchToolFields: NONE,
|
|
84
|
+
minImageEdge: NONE,
|
|
84
85
|
supportsResponsesCustomTools: NONE,
|
|
85
86
|
modelSupportsServiceTier: RECORD_KEYS,
|
|
86
87
|
keyAuthServiceTier: KEY_AUTH_SERVICE_TIER,
|
|
@@ -260,6 +260,12 @@ export interface ProviderRegistryEntry {
|
|
|
260
260
|
supportsServiceTier?: boolean;
|
|
261
261
|
/** Registry default for OpenAI extended hosted web_search field support. */
|
|
262
262
|
supportsOpenAiWebSearchToolFields?: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Registry-only smallest image edge, in pixels, that the upstream accepts on the
|
|
265
|
+
* `openai-chat` wire. Inline images below it are upscaled before sending, because the
|
|
266
|
+
* upstream rejects the whole request otherwise (Venice: "images must be at least 64x64").
|
|
267
|
+
*/
|
|
268
|
+
minImageEdge?: number;
|
|
263
269
|
/** Registry default for native Responses custom-tool support. */
|
|
264
270
|
supportsResponsesCustomTools?: boolean;
|
|
265
271
|
/** Registry default for exact model service-tier capability; explicit config keys win. */
|
|
@@ -8,6 +8,14 @@ export interface RetainedCompaction {
|
|
|
8
8
|
reasoning: string[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/** Raised when a proxy-owned retained compaction envelope fails to decode. */
|
|
12
|
+
export class InvalidRetainedCompactionEnvelopeError extends Error {
|
|
13
|
+
constructor() {
|
|
14
|
+
super("Invalid OpenCodex retained compaction envelope");
|
|
15
|
+
this.name = "InvalidRetainedCompactionEnvelopeError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
export function encodeRetainedCompaction(summary: string, reasoning: string[]): string {
|
|
12
20
|
return RETAINED_COMPACTION_PREFIX + Buffer.from(JSON.stringify({ version: 2, summary, reasoning }), "utf-8").toString("base64");
|
|
13
21
|
}
|
|
@@ -28,16 +36,34 @@ export function decodeRetainedCompaction(value: string): RetainedCompaction | nu
|
|
|
28
36
|
} catch { return null; }
|
|
29
37
|
}
|
|
30
38
|
|
|
39
|
+
/** True when `item` carries a proxy-owned retained envelope marker, valid payload or not. */
|
|
40
|
+
function isRetainedCompactionEnvelopeItem(item: unknown): item is { type: string; encrypted_content: string } {
|
|
41
|
+
if (!item || typeof item !== "object") return false;
|
|
42
|
+
const candidate = item as { type?: unknown; encrypted_content?: unknown };
|
|
43
|
+
return typeof candidate.type === "string"
|
|
44
|
+
&& ["compaction", "compaction_summary", "context_compaction"].includes(candidate.type)
|
|
45
|
+
&& typeof candidate.encrypted_content === "string"
|
|
46
|
+
&& candidate.encrypted_content.startsWith(RETAINED_COMPACTION_PREFIX);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** First malformed proxy-owned retained envelope in `input`, if any. */
|
|
50
|
+
export function findInvalidRetainedCompactionEnvelope(input: unknown): InvalidRetainedCompactionEnvelopeError | null {
|
|
51
|
+
if (!Array.isArray(input)) return null;
|
|
52
|
+
for (const item of input) {
|
|
53
|
+
if (!isRetainedCompactionEnvelopeItem(item)) continue;
|
|
54
|
+
if (!decodeRetainedCompaction(item.encrypted_content)) return new InvalidRetainedCompactionEnvelopeError();
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
31
59
|
/** Expand only our structured envelopes; callers retain their existing native/ocx1 policy. */
|
|
32
60
|
export function expandRetainedCompactionInput(input: unknown): unknown {
|
|
33
61
|
if (!Array.isArray(input)) return input;
|
|
34
|
-
if (!input.some(
|
|
35
|
-
&& typeof item.encrypted_content === "string" && item.encrypted_content.startsWith(RETAINED_COMPACTION_PREFIX))) return input;
|
|
62
|
+
if (!input.some(isRetainedCompactionEnvelopeItem)) return input;
|
|
36
63
|
return input.flatMap(item => {
|
|
37
|
-
if (!item
|
|
38
|
-
|| typeof item.encrypted_content !== "string" || !item.encrypted_content.startsWith(RETAINED_COMPACTION_PREFIX)) return [item];
|
|
64
|
+
if (!isRetainedCompactionEnvelopeItem(item)) return [item];
|
|
39
65
|
const data = decodeRetainedCompaction(item.encrypted_content);
|
|
40
|
-
if (!data) throw new
|
|
66
|
+
if (!data) throw new InvalidRetainedCompactionEnvelopeError();
|
|
41
67
|
return [
|
|
42
68
|
{ ...item, encrypted_content: "ocx1:" + Buffer.from(data.summary, "utf-8").toString("base64") },
|
|
43
69
|
...data.reasoning.map(text => ({ type: "message", role: "user", content: [{ type: "input_text", text }] })),
|
|
@@ -152,6 +152,7 @@ import { requiresPlaintextReasoningReplay } from "../../adapters/openai-response
|
|
|
152
152
|
import { destinationDecodesNativeCompactionBlob, isOpenAiOperatedResponsesDestination } from "../../providers/openai-tiers-destination";
|
|
153
153
|
import { bindRouteReasoningReplayScope } from "./core-replay";
|
|
154
154
|
import { commitReasoningReplayServingIdentity } from "../../responses/reasoning-replay-cache";
|
|
155
|
+
import { findInvalidRetainedCompactionEnvelope, InvalidRetainedCompactionEnvelopeError } from "../../responses/retained-compaction";
|
|
155
156
|
import { nativeCompactResponseSchema } from "../../responses/schema";
|
|
156
157
|
import { NATIVE_RESERVE_MODEL } from "../../codex/catalog/native-models";
|
|
157
158
|
import {
|
|
@@ -670,6 +671,11 @@ export async function bufferCompactResponse(
|
|
|
670
671
|
|
|
671
672
|
|
|
672
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Route one `/v1/responses/compact` request: validate the body (rejecting malformed
|
|
676
|
+
* proxy-owned retained envelopes before routing or credential resolution), select the
|
|
677
|
+
* compact target, and dispatch through the adapter pipeline.
|
|
678
|
+
*/
|
|
673
679
|
export async function handleResponsesCompact(
|
|
674
680
|
req: Request,
|
|
675
681
|
config: OcxConfig,
|
|
@@ -699,6 +705,10 @@ export async function handleResponsesCompact(
|
|
|
699
705
|
if (typeof raw.model !== "string" || raw.model.length === 0) {
|
|
700
706
|
return formatErrorResponse(400, "invalid_request_error", "compaction request requires a model");
|
|
701
707
|
}
|
|
708
|
+
// A malformed proxy-owned envelope is a caller error, so reject it before routing or
|
|
709
|
+
// credential resolution can spend a token refresh on a request that cannot succeed.
|
|
710
|
+
const invalidEnvelope = findInvalidRetainedCompactionEnvelope(raw.input);
|
|
711
|
+
if (invalidEnvelope) return formatErrorResponse(400, "invalid_request_error", invalidEnvelope.message);
|
|
702
712
|
options.onRequestBodyRead?.();
|
|
703
713
|
// Correct the IDENTITY before routing, or the synthetic id does not route at all. Held in
|
|
704
714
|
// a local rather than written back to `raw.model`: assigning to the property widens it out
|
|
@@ -1305,7 +1315,9 @@ export async function handleResponsesCompact(
|
|
|
1305
1315
|
let outcomeCtx = authCtx;
|
|
1306
1316
|
const localDispatchRefusal = (error: unknown): Response | undefined => {
|
|
1307
1317
|
const cause = unwrapUpstreamRetryEvidenceError(error);
|
|
1308
|
-
const response =
|
|
1318
|
+
const response = cause instanceof InvalidRetainedCompactionEnvelopeError
|
|
1319
|
+
? formatErrorResponse(400, "invalid_request_error", cause.message)
|
|
1320
|
+
: requestPacingOverloadResponse(cause) ?? spendLedgerStorageErrorResponse(error, logCtx) ?? (cause instanceof SendBudgetExhaustedError
|
|
1309
1321
|
? unboundPoolSpendRefusalResponse(logCtx) ?? formatErrorResponse(429, "request_send_budget_exhausted", cause.message)
|
|
1310
1322
|
: mapCodexAuthContextErrorToResponse(cause, {
|
|
1311
1323
|
now: Date.now(), accountSelector: route.codexAccountNamespace,
|
package/src/web-search/parse.ts
CHANGED
|
@@ -39,6 +39,8 @@ type CompletedOutput = WebSearchResult & {
|
|
|
39
39
|
incomplete: boolean;
|
|
40
40
|
parts: Map<string, string>;
|
|
41
41
|
slots: Map<string, { itemId?: string; outputIndex: number; contentIndex: number; singleContent: boolean }>;
|
|
42
|
+
/** Unique message positions survive malformed content; null marks a repeated item ID. */
|
|
43
|
+
items: Map<string, { outputIndex: number; missingContent: boolean } | null>;
|
|
42
44
|
};
|
|
43
45
|
/** Streamed text for one `output_text` content part. */
|
|
44
46
|
interface StreamedPart {
|
|
@@ -136,12 +138,20 @@ function streamedPartKey(data: Record<string, unknown>, parts: Map<string, Strea
|
|
|
136
138
|
// content index. Only inspect the buckets when their total proves there are at most two parts.
|
|
137
139
|
if (data.type === "response.output_text.done" && itemId && match
|
|
138
140
|
&& outputCandidates === (match.outputIndex === undefined ? 1 : 2)) {
|
|
141
|
+
const matchedContent = match.contentIndex;
|
|
139
142
|
const buckets = contentIndex === undefined ? [outputBucket] : [outputContentBucket, outputUnknownContentBucket];
|
|
140
143
|
const anonymous = buckets.flatMap(bucket => bucket ? [...bucket] : [])
|
|
141
|
-
.find(part => part !== match && !part.itemId && compatible(part)
|
|
144
|
+
.find(part => part !== match && !part.itemId && compatible(part)
|
|
145
|
+
&& (matchedContent === undefined || part.contentIndex === undefined || matchedContent === part.contentIndex));
|
|
142
146
|
if (anonymous) {
|
|
143
147
|
indexPart(lookup, match, false);
|
|
144
148
|
parts.delete(match.key);
|
|
149
|
+
// The linking frame can omit a field that the identified draft already supplied.
|
|
150
|
+
if (anonymous.contentIndex === undefined && matchedContent !== undefined) {
|
|
151
|
+
indexPart(lookup, anonymous, false);
|
|
152
|
+
anonymous.contentIndex = matchedContent;
|
|
153
|
+
indexPart(lookup, anonymous, true);
|
|
154
|
+
}
|
|
145
155
|
return anonymous.key;
|
|
146
156
|
}
|
|
147
157
|
}
|
|
@@ -288,6 +298,13 @@ function reconcileCompletedParts(final: CompletedOutput, streamed: Map<string, S
|
|
|
288
298
|
reconciled.delete(part.key);
|
|
289
299
|
reconciled.set(key, { ...part, key });
|
|
290
300
|
}
|
|
301
|
+
for (const [key, part] of reconciled) {
|
|
302
|
+
const item = part.itemId ? final.items.get(part.itemId) : undefined;
|
|
303
|
+
if (item?.missingContent && part.outputIndex === undefined && !isIndexedPartKey(key)) {
|
|
304
|
+
// The message identifies an output position, but cannot invent a content index.
|
|
305
|
+
reconciled.set(key, { ...part, outputIndex: item.outputIndex });
|
|
306
|
+
}
|
|
307
|
+
}
|
|
291
308
|
return reconciled;
|
|
292
309
|
}
|
|
293
310
|
|
|
@@ -510,10 +527,14 @@ function fromOutputArray(output: OutputItem[], seen: Set<string>): CompletedOutp
|
|
|
510
527
|
let incomplete = false;
|
|
511
528
|
const parts = new Map<string, string>();
|
|
512
529
|
const slots: CompletedOutput["slots"] = new Map();
|
|
530
|
+
const items: CompletedOutput["items"] = new Map();
|
|
513
531
|
const sources: WebSearchSource[] = [];
|
|
514
532
|
for (const [outputIndex, item] of output.entries()) {
|
|
515
533
|
if (!item || typeof item !== "object") { incomplete = true; continue; }
|
|
516
534
|
if (item.type !== "message") continue;
|
|
535
|
+
if (typeof item.id === "string" && item.id) {
|
|
536
|
+
items.set(item.id, items.has(item.id) ? null : { outputIndex, missingContent: !Array.isArray(item.content) });
|
|
537
|
+
}
|
|
517
538
|
if (!Array.isArray(item.content)) { incomplete = true; continue; }
|
|
518
539
|
for (const [contentIndex, block] of item.content.entries()) {
|
|
519
540
|
if (!block || typeof block !== "object") { incomplete = true; continue; }
|
|
@@ -528,7 +549,7 @@ function fromOutputArray(output: OutputItem[], seen: Set<string>): CompletedOutp
|
|
|
528
549
|
}
|
|
529
550
|
}
|
|
530
551
|
}
|
|
531
|
-
return { text, sources, incomplete, parts, slots };
|
|
552
|
+
return { text, sources, incomplete, parts, slots, items };
|
|
532
553
|
}
|
|
533
554
|
|
|
534
555
|
export function cancelReaderWithoutWaiting(
|