agent-shim 11.83.5 → 11.83.7
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/dist/cli.cjs +226 -87
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -39986,7 +39986,7 @@ var init_package = __esm({
|
|
|
39986
39986
|
"package.json"() {
|
|
39987
39987
|
package_default = {
|
|
39988
39988
|
name: "agent-shim",
|
|
39989
|
-
version: "11.83.
|
|
39989
|
+
version: "11.83.7",
|
|
39990
39990
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
39991
39991
|
license: "MIT",
|
|
39992
39992
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -68706,33 +68706,41 @@ async function* callCloudAntigravity(params, fetchFn = fetch) {
|
|
|
68706
68706
|
}
|
|
68707
68707
|
const decoder = new TextDecoder("utf-8");
|
|
68708
68708
|
let buffer2 = "";
|
|
68709
|
-
const sseDataPrefix = "data:";
|
|
68710
68709
|
for await (const rawChunk of response.body) {
|
|
68711
68710
|
const chunk2 = rawChunk instanceof Uint8Array ? rawChunk : Buffer.from(String(rawChunk));
|
|
68712
68711
|
buffer2 += decoder.decode(chunk2, { stream: true });
|
|
68713
68712
|
const lines = buffer2.split("\n");
|
|
68714
68713
|
buffer2 = lines.pop() ?? "";
|
|
68715
68714
|
for (const line of lines) {
|
|
68716
|
-
|
|
68717
|
-
if (trimmed.startsWith(sseDataPrefix)) {
|
|
68718
|
-
const jsonStr = trimmed.slice(sseDataPrefix.length).trim();
|
|
68719
|
-
if (jsonStr.length > 0) {
|
|
68720
|
-
try {
|
|
68721
|
-
const parsed = JSON.parse(jsonStr);
|
|
68722
|
-
if (isRecord6(parsed)) {
|
|
68723
|
-
const unwrapped = isRecord6(parsed.response) ? parsed.response : parsed;
|
|
68724
|
-
if (isGeminiChunk(unwrapped)) {
|
|
68725
|
-
yield unwrapped;
|
|
68726
|
-
}
|
|
68727
|
-
}
|
|
68728
|
-
} catch {
|
|
68729
|
-
}
|
|
68730
|
-
}
|
|
68731
|
-
}
|
|
68715
|
+
yield* chunksOfLine(line);
|
|
68732
68716
|
}
|
|
68733
68717
|
}
|
|
68718
|
+
buffer2 += decoder.decode();
|
|
68719
|
+
yield* chunksOfLine(buffer2);
|
|
68734
68720
|
}
|
|
68735
|
-
|
|
68721
|
+
function* chunksOfLine(line) {
|
|
68722
|
+
const trimmed = line.trim();
|
|
68723
|
+
if (!trimmed.startsWith(SSE_DATA_PREFIX)) {
|
|
68724
|
+
return;
|
|
68725
|
+
}
|
|
68726
|
+
const jsonStr = trimmed.slice(SSE_DATA_PREFIX.length).trim();
|
|
68727
|
+
if (jsonStr.length === 0) {
|
|
68728
|
+
return;
|
|
68729
|
+
}
|
|
68730
|
+
let parsed;
|
|
68731
|
+
try {
|
|
68732
|
+
parsed = JSON.parse(jsonStr);
|
|
68733
|
+
} catch {
|
|
68734
|
+
return;
|
|
68735
|
+
}
|
|
68736
|
+
if (isRecord6(parsed)) {
|
|
68737
|
+
const unwrapped = isRecord6(parsed.response) ? parsed.response : parsed;
|
|
68738
|
+
if (isGeminiChunk(unwrapped)) {
|
|
68739
|
+
yield unwrapped;
|
|
68740
|
+
}
|
|
68741
|
+
}
|
|
68742
|
+
}
|
|
68743
|
+
var import_node_crypto18, CCPA_ENDPOINT, CCPA_DEFAULT_PROJECT_ID, CCPA_USER_AGENT, AntigravityUpstreamError, SSE_DATA_PREFIX;
|
|
68736
68744
|
var init_cloudUpstream = __esm({
|
|
68737
68745
|
"src/antigravity/cloudUpstream.ts"() {
|
|
68738
68746
|
"use strict";
|
|
@@ -68743,13 +68751,17 @@ var init_cloudUpstream = __esm({
|
|
|
68743
68751
|
AntigravityUpstreamError = class extends Error {
|
|
68744
68752
|
status;
|
|
68745
68753
|
retryAfter;
|
|
68754
|
+
/** The backend's own answer, as it sent it, which carries more than the message says (the model a 429 names and when its allowance lifts). */
|
|
68755
|
+
body;
|
|
68746
68756
|
constructor(status, message, retryAfter) {
|
|
68747
68757
|
super(`Google Antigravity API error (${String(status)}): ${message}`);
|
|
68748
68758
|
this.name = "AntigravityUpstreamError";
|
|
68759
|
+
this.body = message;
|
|
68749
68760
|
this.status = status;
|
|
68750
68761
|
this.retryAfter = retryAfter;
|
|
68751
68762
|
}
|
|
68752
68763
|
};
|
|
68764
|
+
SSE_DATA_PREFIX = "data:";
|
|
68753
68765
|
}
|
|
68754
68766
|
});
|
|
68755
68767
|
|
|
@@ -68794,6 +68806,60 @@ function antigravityQuotaPressure(quota, model) {
|
|
|
68794
68806
|
const pressures = [windowPressure(fiveHour, FIVE_HOUR_PERIOD_SECONDS), windowPressure(weekly, WEEK_PERIOD_SECONDS)].filter((pressure) => pressure !== void 0);
|
|
68795
68807
|
return pressures.length === 0 ? void 0 : Math.min(...pressures);
|
|
68796
68808
|
}
|
|
68809
|
+
function parseQuotaExhaustion(body, nowMs) {
|
|
68810
|
+
let parsed;
|
|
68811
|
+
try {
|
|
68812
|
+
parsed = JSON.parse(body);
|
|
68813
|
+
} catch {
|
|
68814
|
+
return void 0;
|
|
68815
|
+
}
|
|
68816
|
+
const details = isRecord7(parsed) && isRecord7(parsed.error) && Array.isArray(parsed.error.details) ? parsed.error.details : [];
|
|
68817
|
+
let model;
|
|
68818
|
+
let resetAtMs;
|
|
68819
|
+
for (const detail of details) {
|
|
68820
|
+
if (!isRecord7(detail)) {
|
|
68821
|
+
continue;
|
|
68822
|
+
}
|
|
68823
|
+
if (detail.reason === "QUOTA_EXHAUSTED" && isRecord7(detail.metadata)) {
|
|
68824
|
+
const named = detail.metadata.model;
|
|
68825
|
+
const stamp = typeof detail.metadata.quotaResetTimeStamp === "string" ? Date.parse(detail.metadata.quotaResetTimeStamp) : Number.NaN;
|
|
68826
|
+
model = typeof named === "string" && named !== "" ? named : void 0;
|
|
68827
|
+
resetAtMs = Number.isNaN(stamp) ? void 0 : stamp;
|
|
68828
|
+
} else if (typeof detail.retryDelay === "string" && resetAtMs === void 0) {
|
|
68829
|
+
const seconds = RETRY_DELAY.exec(detail.retryDelay)?.groups?.seconds;
|
|
68830
|
+
resetAtMs = seconds === void 0 ? void 0 : nowMs + Math.ceil(Number(seconds) * MS_PER_SECOND9);
|
|
68831
|
+
}
|
|
68832
|
+
}
|
|
68833
|
+
return model === void 0 || resetAtMs === void 0 ? void 0 : { model, resetAtMs };
|
|
68834
|
+
}
|
|
68835
|
+
function bucketKeyOf(model, resetInSeconds) {
|
|
68836
|
+
const lower = model.toLowerCase();
|
|
68837
|
+
if (lower.includes("argon")) {
|
|
68838
|
+
return "gemini-argon-wtu-weekly";
|
|
68839
|
+
}
|
|
68840
|
+
const withinFiveHours = resetInSeconds <= FIVE_HOUR_PERIOD_SECONDS;
|
|
68841
|
+
if (lower.includes("gemini")) {
|
|
68842
|
+
return withinFiveHours ? "gemini-5h" : "gemini-weekly";
|
|
68843
|
+
}
|
|
68844
|
+
return withinFiveHours ? "3p-5h" : "3p-weekly";
|
|
68845
|
+
}
|
|
68846
|
+
function quotaWithExhaustions(quota, exhaustions, nowMs) {
|
|
68847
|
+
const spent = [...exhaustions].filter(([, resetAtMs]) => resetAtMs > nowMs);
|
|
68848
|
+
if (spent.length === 0) {
|
|
68849
|
+
return quota;
|
|
68850
|
+
}
|
|
68851
|
+
const merged = { ...quota };
|
|
68852
|
+
for (const [model, resetAtMs] of spent) {
|
|
68853
|
+
const resetIn = Math.ceil((resetAtMs - nowMs) / MS_PER_SECOND9);
|
|
68854
|
+
const key = bucketKeyOf(model, resetIn);
|
|
68855
|
+
const known = merged[key];
|
|
68856
|
+
if (known?.remaining_fraction === 0 && (known.reset_in_seconds ?? 0) >= resetIn) {
|
|
68857
|
+
continue;
|
|
68858
|
+
}
|
|
68859
|
+
merged[key] = { remaining_fraction: 0, reset_in_seconds: resetIn };
|
|
68860
|
+
}
|
|
68861
|
+
return merged;
|
|
68862
|
+
}
|
|
68797
68863
|
function calculateUtilization(remainingFraction) {
|
|
68798
68864
|
if (remainingFraction === void 0 || !Number.isFinite(remainingFraction)) {
|
|
68799
68865
|
return void 0;
|
|
@@ -68975,7 +69041,7 @@ function ageQuotaMap(quota, elapsedMs) {
|
|
|
68975
69041
|
Object.entries(quota).map(([key, bucket]) => [key, bucket?.reset_in_seconds === void 0 ? bucket : { ...bucket, reset_in_seconds: Math.max(0, bucket.reset_in_seconds - elapsedSec) }])
|
|
68976
69042
|
);
|
|
68977
69043
|
}
|
|
68978
|
-
var MS_PER_SECOND9, DEFAULT_RETRY_AFTER_SECONDS, FRACTION_DIGITS, GEMINI_5H_KEYS, GEMINI_WEEKLY_KEYS, ARGON_WEEKLY_KEYS, THIRD_PARTY_5H_KEYS, THIRD_PARTY_WEEKLY_KEYS, QUOTA_FAMILY_WINDOWS, SECONDS_PER_HOUR, HOURS_PER_FIVE_HOUR_WINDOW, DAYS_PER_WEEK, HOURS_PER_DAY4, FIVE_HOUR_PERIOD_SECONDS, WEEK_PERIOD_SECONDS, ANTIGRAVITY_QUOTA_REFRESH_MS;
|
|
69044
|
+
var MS_PER_SECOND9, DEFAULT_RETRY_AFTER_SECONDS, FRACTION_DIGITS, GEMINI_5H_KEYS, GEMINI_WEEKLY_KEYS, ARGON_WEEKLY_KEYS, THIRD_PARTY_5H_KEYS, THIRD_PARTY_WEEKLY_KEYS, QUOTA_FAMILY_WINDOWS, SECONDS_PER_HOUR, HOURS_PER_FIVE_HOUR_WINDOW, DAYS_PER_WEEK, HOURS_PER_DAY4, FIVE_HOUR_PERIOD_SECONDS, WEEK_PERIOD_SECONDS, RETRY_DELAY, ANTIGRAVITY_QUOTA_REFRESH_MS;
|
|
68979
69045
|
var init_quota = __esm({
|
|
68980
69046
|
"src/antigravity/quota.ts"() {
|
|
68981
69047
|
"use strict";
|
|
@@ -69002,6 +69068,7 @@ var init_quota = __esm({
|
|
|
69002
69068
|
HOURS_PER_DAY4 = 24;
|
|
69003
69069
|
FIVE_HOUR_PERIOD_SECONDS = HOURS_PER_FIVE_HOUR_WINDOW * SECONDS_PER_HOUR;
|
|
69004
69070
|
WEEK_PERIOD_SECONDS = DAYS_PER_WEEK * HOURS_PER_DAY4 * SECONDS_PER_HOUR;
|
|
69071
|
+
RETRY_DELAY = /^(?<seconds>\d+(?:\.\d+)?)s$/u;
|
|
69005
69072
|
ANTIGRAVITY_QUOTA_REFRESH_MS = 6e4;
|
|
69006
69073
|
}
|
|
69007
69074
|
});
|
|
@@ -71168,7 +71235,13 @@ var init_providerQuota = __esm({
|
|
|
71168
71235
|
/** The account's paid subscription; absent when the account has none. */
|
|
71169
71236
|
paidTier: external_exports.object({ name: external_exports.string().optional(), id: external_exports.string().optional() }).optional()
|
|
71170
71237
|
});
|
|
71171
|
-
ANTIGRAVITY_WINDOW_MS = {
|
|
71238
|
+
ANTIGRAVITY_WINDOW_MS = {
|
|
71239
|
+
"gemini-5h": FIVE_HOURS_MS,
|
|
71240
|
+
"3p-5h": FIVE_HOURS_MS,
|
|
71241
|
+
"gemini-weekly": WEEK_MS,
|
|
71242
|
+
"3p-weekly": WEEK_MS,
|
|
71243
|
+
"gemini-argon-wtu-weekly": WEEK_MS
|
|
71244
|
+
};
|
|
71172
71245
|
antigravityQuotaAdapter = {
|
|
71173
71246
|
source: ANTIGRAVITY_SOURCE,
|
|
71174
71247
|
matches: (baseUrl) => URL.canParse(baseUrl) && new URL(baseUrl).hostname === ANTIGRAVITY_HOST,
|
|
@@ -141846,6 +141919,15 @@ function exhaustedMessage(exhaustion) {
|
|
|
141846
141919
|
function createAntigravityRoute(ports) {
|
|
141847
141920
|
const fallbackId = ports.fallbackId ?? (() => (0, import_node_crypto24.randomUUID)());
|
|
141848
141921
|
const lastRouted = ports.lastRouted ?? /* @__PURE__ */ new Map();
|
|
141922
|
+
const exhaustedModels = ports.exhaustedModels ?? /* @__PURE__ */ new Map();
|
|
141923
|
+
const liveQuota = (nowMs) => {
|
|
141924
|
+
for (const [model, resetAtMs] of exhaustedModels) {
|
|
141925
|
+
if (resetAtMs <= nowMs) {
|
|
141926
|
+
exhaustedModels.delete(model);
|
|
141927
|
+
}
|
|
141928
|
+
}
|
|
141929
|
+
return quotaWithExhaustions(ports.quotaSource?.(), exhaustedModels, nowMs);
|
|
141930
|
+
};
|
|
141849
141931
|
return async (request7) => {
|
|
141850
141932
|
await Promise.resolve();
|
|
141851
141933
|
if (request7.method !== "POST") {
|
|
@@ -141899,71 +141981,90 @@ function createAntigravityRoute(ports) {
|
|
|
141899
141981
|
const requestedModel = parsed.data.model ?? config2.defaultModel;
|
|
141900
141982
|
const nowMs = ports.now?.() ?? Date.now();
|
|
141901
141983
|
const sessionKey = parsed.data.metadata?.user_id === void 0 ? void 0 : `${parsed.data.metadata.user_id}\0${parsed.data.model ?? ""}`;
|
|
141902
|
-
const
|
|
141903
|
-
|
|
141904
|
-
|
|
141905
|
-
|
|
141906
|
-
|
|
141907
|
-
|
|
141908
|
-
|
|
141909
|
-
|
|
141984
|
+
const routeRequest = () => {
|
|
141985
|
+
const routed = translateRequest(parsed.data, config2, { quota: liveQuota(nowMs), nowMs, previous: sessionKey === void 0 ? void 0 : lastRouted.get(sessionKey) });
|
|
141986
|
+
if (sessionKey !== void 0) {
|
|
141987
|
+
lastRouted.delete(sessionKey);
|
|
141988
|
+
lastRouted.set(sessionKey, routed.model);
|
|
141989
|
+
if (lastRouted.size > ROUTING_MEMORY_SESSIONS) {
|
|
141990
|
+
const oldest = lastRouted.keys().next();
|
|
141991
|
+
if (oldest.done !== true) {
|
|
141992
|
+
lastRouted.delete(oldest.value);
|
|
141993
|
+
}
|
|
141910
141994
|
}
|
|
141911
141995
|
}
|
|
141912
|
-
|
|
141913
|
-
|
|
141914
|
-
|
|
141915
|
-
|
|
141916
|
-
|
|
141917
|
-
|
|
141918
|
-
|
|
141919
|
-
|
|
141920
|
-
|
|
141921
|
-
model: translated.model,
|
|
141922
|
-
request: translated.request,
|
|
141923
|
-
signal: request7.signal,
|
|
141924
|
-
connector: ports.localConnector
|
|
141925
|
-
}) : callCloudAntigravity(
|
|
141926
|
-
{
|
|
141996
|
+
return routed;
|
|
141997
|
+
};
|
|
141998
|
+
let translated = routeRequest();
|
|
141999
|
+
const tried = /* @__PURE__ */ new Set();
|
|
142000
|
+
let iterator;
|
|
142001
|
+
let firstResult;
|
|
142002
|
+
for (; ; ) {
|
|
142003
|
+
tried.add(translated.model);
|
|
142004
|
+
const upstreamChunks2 = config2.mode === "local" ? callLocalAntigravity({
|
|
141927
142005
|
config: config2,
|
|
141928
142006
|
model: translated.model,
|
|
141929
142007
|
request: translated.request,
|
|
141930
|
-
|
|
141931
|
-
|
|
141932
|
-
|
|
141933
|
-
|
|
141934
|
-
|
|
141935
|
-
|
|
141936
|
-
|
|
141937
|
-
|
|
141938
|
-
|
|
141939
|
-
|
|
141940
|
-
|
|
141941
|
-
|
|
141942
|
-
|
|
141943
|
-
|
|
141944
|
-
|
|
141945
|
-
|
|
141946
|
-
|
|
141947
|
-
|
|
142008
|
+
signal: request7.signal,
|
|
142009
|
+
connector: ports.localConnector
|
|
142010
|
+
}) : callCloudAntigravity(
|
|
142011
|
+
{
|
|
142012
|
+
config: config2,
|
|
142013
|
+
model: translated.model,
|
|
142014
|
+
request: translated.request,
|
|
142015
|
+
token,
|
|
142016
|
+
credentialTarget,
|
|
142017
|
+
signal: request7.signal
|
|
142018
|
+
},
|
|
142019
|
+
ports.fetchFn
|
|
142020
|
+
);
|
|
142021
|
+
iterator = upstreamChunks2[Symbol.asyncIterator]();
|
|
142022
|
+
try {
|
|
142023
|
+
firstResult = await iterator.next();
|
|
142024
|
+
break;
|
|
142025
|
+
} catch (error63) {
|
|
142026
|
+
if (error63 instanceof AntigravityUpstreamError) {
|
|
142027
|
+
const is429 = error63.status === HTTP_STATUS.tooManyRequests;
|
|
142028
|
+
const learned = is429 ? parseQuotaExhaustion(error63.body, nowMs) : void 0;
|
|
142029
|
+
if (learned !== void 0) {
|
|
142030
|
+
exhaustedModels.set(learned.model, learned.resetAtMs);
|
|
142031
|
+
const next = routeRequest();
|
|
142032
|
+
if (!tried.has(next.model)) {
|
|
142033
|
+
translated = next;
|
|
142034
|
+
continue;
|
|
142035
|
+
}
|
|
142036
|
+
}
|
|
142037
|
+
const quota = liveQuota(nowMs);
|
|
142038
|
+
const quotaHeaders3 = unifiedAntigravityQuotaHeaders({ quota, rejected: is429, nowMs, model: translated.model });
|
|
142039
|
+
const retryAfter = is429 && quotaHeaders3["retry-after"] === void 0 ? parseRetryAfterSeconds(error63.retryAfter) : void 0;
|
|
142040
|
+
const exhaustion = is429 ? antigravityQuotaExhaustion(quota, translated.model, nowMs) : void 0;
|
|
142041
|
+
const errorType = is429 ? "rate_limit_error" : "api_error";
|
|
142042
|
+
return {
|
|
142043
|
+
status: error63.status,
|
|
142044
|
+
headers: {
|
|
142045
|
+
"Content-Type": "application/json",
|
|
142046
|
+
...quotaHeaders3,
|
|
142047
|
+
...retryAfter !== void 0 ? { "retry-after": String(retryAfter) } : {}
|
|
142048
|
+
},
|
|
142049
|
+
body: JSON.stringify({ type: "error", error: { type: errorType, message: exhaustion === void 0 ? error63.message : exhaustedMessage(exhaustion) } })
|
|
142050
|
+
};
|
|
142051
|
+
}
|
|
142052
|
+
const errMsg = error63 instanceof Error ? error63.message : String(error63);
|
|
141948
142053
|
return {
|
|
141949
|
-
status:
|
|
141950
|
-
headers: {
|
|
141951
|
-
|
|
141952
|
-
...quotaHeaders3,
|
|
141953
|
-
...retryAfter !== void 0 ? { "retry-after": String(retryAfter) } : {}
|
|
141954
|
-
},
|
|
141955
|
-
body: JSON.stringify({ type: "error", error: { type: errorType, message: exhaustion === void 0 ? error63.message : exhaustedMessage(exhaustion) } })
|
|
142054
|
+
status: HTTP_STATUS.badGateway,
|
|
142055
|
+
headers: { "Content-Type": "application/json" },
|
|
142056
|
+
body: JSON.stringify({ type: "error", error: { type: "api_error", message: errMsg } })
|
|
141956
142057
|
};
|
|
141957
142058
|
}
|
|
141958
|
-
const errMsg = error63 instanceof Error ? error63.message : String(error63);
|
|
141959
|
-
return {
|
|
141960
|
-
status: HTTP_STATUS.badGateway,
|
|
141961
|
-
headers: { "Content-Type": "application/json" },
|
|
141962
|
-
body: JSON.stringify({ type: "error", error: { type: "api_error", message: errMsg } })
|
|
141963
|
-
};
|
|
141964
142059
|
}
|
|
142060
|
+
const relay = createAntigravityRelay({
|
|
142061
|
+
// The frame carries the model that actually served the request, as the real API echoes the concrete model behind an alias: a usage record read from the response then attributes quota to the backend model, not the tier alias the session typed.
|
|
142062
|
+
servedModel: translated.model,
|
|
142063
|
+
toolNames: translated.toolNames,
|
|
142064
|
+
fallbackId
|
|
142065
|
+
});
|
|
141965
142066
|
const quotaHeaders2 = unifiedAntigravityQuotaHeaders({
|
|
141966
|
-
quota:
|
|
142067
|
+
quota: liveQuota(nowMs),
|
|
141967
142068
|
rejected: false,
|
|
141968
142069
|
nowMs,
|
|
141969
142070
|
model: translated.model
|
|
@@ -142427,6 +142528,7 @@ function createProviderRouteResolver(deps) {
|
|
|
142427
142528
|
const resolveCredential2 = shareInFlightResolutions(resolveCredentialAsync);
|
|
142428
142529
|
const antigravityQuotaSources = /* @__PURE__ */ new Map();
|
|
142429
142530
|
const antigravityRoutingMemory = /* @__PURE__ */ new Map();
|
|
142531
|
+
const antigravityExhaustedModels = /* @__PURE__ */ new Map();
|
|
142430
142532
|
const definesProvider = (name) => {
|
|
142431
142533
|
try {
|
|
142432
142534
|
return loadProvider(deps.providersDir, name, deps.fs) !== void 0;
|
|
@@ -142445,6 +142547,15 @@ function createProviderRouteResolver(deps) {
|
|
|
142445
142547
|
antigravityRoutingMemory.set(provider, created);
|
|
142446
142548
|
return created;
|
|
142447
142549
|
};
|
|
142550
|
+
const exhaustedModelsFor = (provider) => {
|
|
142551
|
+
const existing = antigravityExhaustedModels.get(provider);
|
|
142552
|
+
if (existing !== void 0) {
|
|
142553
|
+
return existing;
|
|
142554
|
+
}
|
|
142555
|
+
const created = /* @__PURE__ */ new Map();
|
|
142556
|
+
antigravityExhaustedModels.set(provider, created);
|
|
142557
|
+
return created;
|
|
142558
|
+
};
|
|
142448
142559
|
const antigravityQuotaOf = (provider, definition, config2) => {
|
|
142449
142560
|
const existing = antigravityQuotaSources.get(provider);
|
|
142450
142561
|
if (existing !== void 0) {
|
|
@@ -142540,7 +142651,8 @@ function createProviderRouteResolver(deps) {
|
|
|
142540
142651
|
};
|
|
142541
142652
|
},
|
|
142542
142653
|
quotaSource: antigravityQuotaOf(provider, antigravityProvider, config2),
|
|
142543
|
-
lastRouted: memoryFor(provider)
|
|
142654
|
+
lastRouted: memoryFor(provider),
|
|
142655
|
+
exhaustedModels: exhaustedModelsFor(provider)
|
|
142544
142656
|
},
|
|
142545
142657
|
directOrigin2(deps.directPort()),
|
|
142546
142658
|
provider
|
|
@@ -146837,20 +146949,21 @@ function windowsOf(states, nowMs) {
|
|
|
146837
146949
|
let fiveHourResetAt;
|
|
146838
146950
|
let sevenDayUsed;
|
|
146839
146951
|
let sevenDayResetAt;
|
|
146952
|
+
let bindingUsed;
|
|
146840
146953
|
for (const state of states) {
|
|
146841
146954
|
const unified = state.rateLimit?.unified;
|
|
146842
146955
|
if (unified === void 0) {
|
|
146843
146956
|
continue;
|
|
146844
146957
|
}
|
|
146845
146958
|
const five = livePercentOf(unified.fiveHour, nowMs);
|
|
146846
|
-
if (five !== void 0 && (fiveHourUsed === void 0 || five > fiveHourUsed)) {
|
|
146847
|
-
fiveHourUsed = five;
|
|
146848
|
-
fiveHourResetAt = unified.fiveHour?.resetsAt;
|
|
146849
|
-
}
|
|
146850
146959
|
const seven = livePercentOf(unified.sevenDay, nowMs);
|
|
146851
|
-
|
|
146960
|
+
const max = five === void 0 ? seven : seven === void 0 ? five : Math.max(five, seven);
|
|
146961
|
+
if (max !== void 0 && (bindingUsed === void 0 || max > bindingUsed)) {
|
|
146962
|
+
bindingUsed = max;
|
|
146963
|
+
fiveHourUsed = five;
|
|
146964
|
+
fiveHourResetAt = five === void 0 ? void 0 : unified.fiveHour?.resetsAt;
|
|
146852
146965
|
sevenDayUsed = seven;
|
|
146853
|
-
sevenDayResetAt = unified.sevenDay?.resetsAt;
|
|
146966
|
+
sevenDayResetAt = seven === void 0 ? void 0 : unified.sevenDay?.resetsAt;
|
|
146854
146967
|
}
|
|
146855
146968
|
}
|
|
146856
146969
|
return { fiveHourUsed, fiveHourResetAt, sevenDayUsed, sevenDayResetAt };
|
|
@@ -146896,8 +147009,9 @@ function antigravityQuotaMapOf(payload) {
|
|
|
146896
147009
|
);
|
|
146897
147010
|
}
|
|
146898
147011
|
function bucketView(bucket, nowMs) {
|
|
147012
|
+
const expired = bucket?.reset_in_seconds !== void 0 && Number.isFinite(bucket.reset_in_seconds) && bucket.reset_in_seconds <= 0;
|
|
146899
147013
|
return {
|
|
146900
|
-
used: bucket?.remaining_fraction === void 0 || !Number.isFinite(bucket.remaining_fraction) ? void 0 : (1 - Math.min(1, Math.max(0, bucket.remaining_fraction))) * FULL_PERCENT2,
|
|
147014
|
+
used: bucket?.remaining_fraction === void 0 || !Number.isFinite(bucket.remaining_fraction) ? void 0 : expired ? 0 : (1 - Math.min(1, Math.max(0, bucket.remaining_fraction))) * FULL_PERCENT2,
|
|
146901
147015
|
resetAt: bucket?.reset_in_seconds === void 0 || !Number.isFinite(bucket.reset_in_seconds) ? void 0 : isoOf(nowMs + bucket.reset_in_seconds * MS_PER_SECOND18)
|
|
146902
147016
|
};
|
|
146903
147017
|
}
|
|
@@ -146947,10 +147061,12 @@ function enrichStatuslinePayload(params) {
|
|
|
146947
147061
|
...params.modelChoice === void 0 ? {} : { modelChoice: params.modelChoice },
|
|
146948
147062
|
...params.doorCostUsd === void 0 ? {} : { doorCostUsd: params.doorCostUsd }
|
|
146949
147063
|
};
|
|
147064
|
+
let scopedName;
|
|
146950
147065
|
if (params.snapshot !== void 0) {
|
|
146951
|
-
const
|
|
147066
|
+
const routedProvider = routedProviderOf(params);
|
|
147067
|
+
scopedName = providerScopedState(params.snapshot, params.providerName, params.env.AGENT_SHIM_PROVIDER) ?? providerScopedState(params.snapshot, routedProvider, routedProvider);
|
|
146952
147068
|
const scopedState = scopedName === void 0 ? void 0 : params.snapshot.providers[scopedName];
|
|
146953
|
-
const states = summary.provider === void 0 ? Object.values(params.snapshot.providers) : scopedState === void 0 ? [] : [scopedState];
|
|
147069
|
+
const states = summary.provider === void 0 && scopedState === void 0 ? Object.values(params.snapshot.providers) : scopedState === void 0 ? [] : [scopedState];
|
|
146954
147070
|
let email3;
|
|
146955
147071
|
let sub;
|
|
146956
147072
|
let plan;
|
|
@@ -146981,7 +147097,7 @@ function enrichStatuslinePayload(params) {
|
|
|
146981
147097
|
);
|
|
146982
147098
|
summary = { ...summary, ...windowsOf(states, params.nowMs), providerAccountEmail: email3, providerAccountSub: sub, providerPlan: plan, providerQuotaWindows, quotaFamilies: quotaFamiliesOf(providerBuckets, params.nowMs) };
|
|
146983
147099
|
}
|
|
146984
|
-
if (summary.provider === void 0) {
|
|
147100
|
+
if (summary.provider === void 0 && scopedName === void 0) {
|
|
146985
147101
|
const agyBuckets = antigravityQuotaMapOf(params.payload);
|
|
146986
147102
|
if (agyBuckets !== void 0) {
|
|
146987
147103
|
summary = { ...summary, quotaFamilies: quotaFamiliesOf(agyBuckets, params.nowMs) };
|
|
@@ -147003,6 +147119,29 @@ function enrichStatuslinePayload(params) {
|
|
|
147003
147119
|
}
|
|
147004
147120
|
return { payload: enriched, summary };
|
|
147005
147121
|
}
|
|
147122
|
+
function routedProviderOf(params) {
|
|
147123
|
+
if (params.modelChoice?.provider !== void 0 && params.modelChoice.provider !== "") {
|
|
147124
|
+
return params.modelChoice.provider;
|
|
147125
|
+
}
|
|
147126
|
+
const targetPrefix = prefixBeforeSlash(params.routedTarget);
|
|
147127
|
+
if (targetPrefix !== void 0) {
|
|
147128
|
+
return targetPrefix;
|
|
147129
|
+
}
|
|
147130
|
+
const model = isObject4(params.payload) && isObject4(params.payload.model) ? params.payload.model : void 0;
|
|
147131
|
+
return prefixBeforeSlash(typeof model?.id === "string" ? model.id : void 0) ?? prefixBeforeSlash(typeof model?.display_name === "string" ? model.display_name : void 0);
|
|
147132
|
+
}
|
|
147133
|
+
function prefixBeforeSlash(value3) {
|
|
147134
|
+
if (value3 === void 0) {
|
|
147135
|
+
return void 0;
|
|
147136
|
+
}
|
|
147137
|
+
const slash = value3.indexOf("/");
|
|
147138
|
+
if (slash <= 0) {
|
|
147139
|
+
return void 0;
|
|
147140
|
+
}
|
|
147141
|
+
const prefix = value3.slice(0, slash).trim();
|
|
147142
|
+
const rest = value3.slice(slash + 1).trim();
|
|
147143
|
+
return prefix === "" || rest === "" ? void 0 : prefix;
|
|
147144
|
+
}
|
|
147006
147145
|
function providerScopedState(snapshot, providerName, providerDisplayName) {
|
|
147007
147146
|
if (providerName !== void 0 && providerName in snapshot.providers) {
|
|
147008
147147
|
return providerName;
|
package/dist/index.cjs
CHANGED
|
@@ -4853,7 +4853,7 @@ var init_package = __esm({
|
|
|
4853
4853
|
"package.json"() {
|
|
4854
4854
|
package_default = {
|
|
4855
4855
|
name: "agent-shim",
|
|
4856
|
-
version: "11.83.
|
|
4856
|
+
version: "11.83.7",
|
|
4857
4857
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
4858
4858
|
license: "MIT",
|
|
4859
4859
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
package/dist/index.mjs
CHANGED
|
@@ -4829,7 +4829,7 @@ var init_package = __esm({
|
|
|
4829
4829
|
"package.json"() {
|
|
4830
4830
|
package_default = {
|
|
4831
4831
|
name: "agent-shim",
|
|
4832
|
-
version: "11.83.
|
|
4832
|
+
version: "11.83.7",
|
|
4833
4833
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
4834
4834
|
license: "MIT",
|
|
4835
4835
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-shim",
|
|
3
|
-
"version": "11.83.
|
|
3
|
+
"version": "11.83.7",
|
|
4
4
|
"description": "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Joseph Mearman <joseph@mearman.co.uk>",
|