agent-shim 11.76.0 → 11.78.0
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 +236 -110
- package/dist/index.cjs +346 -167
- package/dist/index.mjs +346 -167
- package/dist/types/index.d.ts +180 -174
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -29874,19 +29874,23 @@ function renderReport(rows, style) {
|
|
|
29874
29874
|
const lines = [style(["bold"], REPORT_HEADING)];
|
|
29875
29875
|
for (const row of rows) {
|
|
29876
29876
|
const detail = row.detail === void 0 ? "" : ` ${style(["dim"], `(${row.detail})`)}`;
|
|
29877
|
-
|
|
29877
|
+
const label2 = row.label.padEnd(labelWidth);
|
|
29878
|
+
lines.push(
|
|
29879
|
+
row.notice === true ? `${indent}${style(NOTICE_FORMATS, label2)}${COLUMN_GAP}${style(NOTICE_FORMATS, row.value)}${detail}` : `${indent}${style(["dim"], label2)}${COLUMN_GAP}${row.value}${detail}`
|
|
29880
|
+
);
|
|
29878
29881
|
for (const note of row.notes ?? []) {
|
|
29879
29882
|
lines.push(`${indent}${" ".repeat(labelWidth)}${COLUMN_GAP}${style(["dim"], note)}`);
|
|
29880
29883
|
}
|
|
29881
29884
|
}
|
|
29882
29885
|
return lines;
|
|
29883
29886
|
}
|
|
29884
|
-
var REPORT_HEADING, COLUMN_GAP;
|
|
29887
|
+
var REPORT_HEADING, COLUMN_GAP, NOTICE_FORMATS;
|
|
29885
29888
|
var init_report = __esm({
|
|
29886
29889
|
"src/launcher/report.ts"() {
|
|
29887
29890
|
"use strict";
|
|
29888
29891
|
REPORT_HEADING = "agent-shim";
|
|
29889
29892
|
COLUMN_GAP = " ";
|
|
29893
|
+
NOTICE_FORMATS = ["yellow", "bold"];
|
|
29890
29894
|
}
|
|
29891
29895
|
});
|
|
29892
29896
|
|
|
@@ -38194,7 +38198,7 @@ var init_package = __esm({
|
|
|
38194
38198
|
"package.json"() {
|
|
38195
38199
|
package_default = {
|
|
38196
38200
|
name: "agent-shim",
|
|
38197
|
-
version: "11.
|
|
38201
|
+
version: "11.78.0",
|
|
38198
38202
|
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.",
|
|
38199
38203
|
license: "MIT",
|
|
38200
38204
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -38300,6 +38304,32 @@ var init_package = __esm({
|
|
|
38300
38304
|
}
|
|
38301
38305
|
});
|
|
38302
38306
|
|
|
38307
|
+
// src/usage/candidateText.ts
|
|
38308
|
+
function candidateHeading(candidate) {
|
|
38309
|
+
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
38310
|
+
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
38311
|
+
return `[${candidate.class}${score}]${dry}`;
|
|
38312
|
+
}
|
|
38313
|
+
function percent(fraction) {
|
|
38314
|
+
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
38315
|
+
}
|
|
38316
|
+
function describeWindow(label2, window, effective, nowMs) {
|
|
38317
|
+
if (effective.reset) {
|
|
38318
|
+
return `${label2} window has reset`;
|
|
38319
|
+
}
|
|
38320
|
+
const used = effective.utilization === void 0 ? "usage unknown" : `${percent(effective.utilization)} used`;
|
|
38321
|
+
const resets = effective.resetsAtMs === void 0 ? "" : `, resets in ${formatAge(effective.resetsAtMs - nowMs)}`;
|
|
38322
|
+
return `${label2} ${used}${resets}${window.status === "allowed_warning" ? " (nearly used)" : ""}`;
|
|
38323
|
+
}
|
|
38324
|
+
var PERCENT;
|
|
38325
|
+
var init_candidateText = __esm({
|
|
38326
|
+
"src/usage/candidateText.ts"() {
|
|
38327
|
+
"use strict";
|
|
38328
|
+
init_preflight();
|
|
38329
|
+
PERCENT = 100;
|
|
38330
|
+
}
|
|
38331
|
+
});
|
|
38332
|
+
|
|
38303
38333
|
// src/usage/plan.ts
|
|
38304
38334
|
function planOf(account) {
|
|
38305
38335
|
const userTier = account?.userRateLimitTier;
|
|
@@ -38872,17 +38902,6 @@ function windowRatio(records) {
|
|
|
38872
38902
|
}
|
|
38873
38903
|
return (last.seven - first.seven) / (last.five - first.five);
|
|
38874
38904
|
}
|
|
38875
|
-
function percent(fraction) {
|
|
38876
|
-
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
38877
|
-
}
|
|
38878
|
-
function describeWindow(label2, window, effective, nowMs) {
|
|
38879
|
-
if (effective.reset) {
|
|
38880
|
-
return `${label2} window has reset`;
|
|
38881
|
-
}
|
|
38882
|
-
const used = effective.utilization === void 0 ? "usage unknown" : `${percent(effective.utilization)} used`;
|
|
38883
|
-
const resets = effective.resetsAtMs === void 0 ? "" : `, resets in ${formatAge(effective.resetsAtMs - nowMs)}`;
|
|
38884
|
-
return `${label2} ${used}${resets}${window.status === "allowed_warning" ? " (nearly used)" : ""}`;
|
|
38885
|
-
}
|
|
38886
38905
|
function capacityOf(plan) {
|
|
38887
38906
|
return plan.kind === "subscription" ? plan.capacity : 1;
|
|
38888
38907
|
}
|
|
@@ -39075,11 +39094,12 @@ function rankPool(input2) {
|
|
|
39075
39094
|
...holdForReturn === void 0 ? {} : { holdForReturn }
|
|
39076
39095
|
};
|
|
39077
39096
|
}
|
|
39078
|
-
var MS_PER_SECOND5, MS_PER_HOUR2, HOURS_PER_DAY2, FIVE_HOURS, PROMPT_CACHE_TTL_HOURS,
|
|
39097
|
+
var MS_PER_SECOND5, MS_PER_HOUR2, HOURS_PER_DAY2, FIVE_HOURS, PROMPT_CACHE_TTL_HOURS, SEVEN_DAYS, FIVE_HOUR_WINDOW_MS, SEVEN_DAY_WINDOW_MS, PROMPT_CACHE_TTL_MS, CLASS_ORDER;
|
|
39079
39098
|
var init_pick = __esm({
|
|
39080
39099
|
"src/usage/pick.ts"() {
|
|
39081
39100
|
"use strict";
|
|
39082
39101
|
init_conditions();
|
|
39102
|
+
init_candidateText();
|
|
39083
39103
|
init_plan2();
|
|
39084
39104
|
init_middleware();
|
|
39085
39105
|
init_preflight();
|
|
@@ -39090,7 +39110,6 @@ var init_pick = __esm({
|
|
|
39090
39110
|
HOURS_PER_DAY2 = 24;
|
|
39091
39111
|
FIVE_HOURS = 5;
|
|
39092
39112
|
PROMPT_CACHE_TTL_HOURS = 1;
|
|
39093
|
-
PERCENT = 100;
|
|
39094
39113
|
SEVEN_DAYS = 7;
|
|
39095
39114
|
FIVE_HOUR_WINDOW_MS = FIVE_HOURS * MS_PER_HOUR2;
|
|
39096
39115
|
SEVEN_DAY_WINDOW_MS = SEVEN_DAYS * HOURS_PER_DAY2 * MS_PER_HOUR2;
|
|
@@ -67842,24 +67861,71 @@ var init_hold = __esm({
|
|
|
67842
67861
|
}
|
|
67843
67862
|
});
|
|
67844
67863
|
|
|
67845
|
-
// src/usage/
|
|
67846
|
-
function
|
|
67847
|
-
|
|
67848
|
-
|
|
67849
|
-
|
|
67864
|
+
// src/usage/resets.ts
|
|
67865
|
+
function formatPeriod(window) {
|
|
67866
|
+
if (window.periodMs === void 0) {
|
|
67867
|
+
return window.period ?? "unknown period";
|
|
67868
|
+
}
|
|
67869
|
+
const hours = window.periodMs / MS_PER_HOUR3;
|
|
67870
|
+
return hours >= HOURS_PER_DAY3 && Number.isInteger(hours / HOURS_PER_DAY3) ? `${String(hours / HOURS_PER_DAY3)}d` : `${String(hours)}h`;
|
|
67850
67871
|
}
|
|
67851
|
-
|
|
67852
|
-
|
|
67872
|
+
function groupOf(row) {
|
|
67873
|
+
return row.resetsAt === void 0 ? 2 : row.reset ? 1 : 0;
|
|
67874
|
+
}
|
|
67875
|
+
function compareRows(left, right) {
|
|
67876
|
+
return groupOf(left) - groupOf(right) || (left.resetsAt ?? "").localeCompare(right.resetsAt ?? "") || left.identity.localeCompare(right.identity) || left.provider.localeCompare(right.provider) || left.window.localeCompare(right.window);
|
|
67877
|
+
}
|
|
67878
|
+
function rowOf(snapshot, provider, window, observedAt2, recorded, nowMs) {
|
|
67879
|
+
const effective = effectiveWindow(recorded, nowMs);
|
|
67880
|
+
return {
|
|
67881
|
+
identity: snapshot.identity,
|
|
67882
|
+
provider,
|
|
67883
|
+
window,
|
|
67884
|
+
observedAt: observedAt2,
|
|
67885
|
+
...recorded.resetsAt === void 0 ? {} : { resetsAt: recorded.resetsAt },
|
|
67886
|
+
reset: effective.reset,
|
|
67887
|
+
...effective.utilization === void 0 ? {} : { utilization: effective.utilization },
|
|
67888
|
+
...effective.status === void 0 ? {} : { status: effective.status }
|
|
67889
|
+
};
|
|
67890
|
+
}
|
|
67891
|
+
function collectResets(snapshots, nowMs) {
|
|
67892
|
+
const rows = snapshots.flatMap(
|
|
67893
|
+
(snapshot) => Object.entries(snapshot.providers).flatMap(([provider, state]) => {
|
|
67894
|
+
const unified = state.rateLimit?.unified;
|
|
67895
|
+
const observedAt2 = state.rateLimit?.observedAt;
|
|
67896
|
+
const overage = unified === void 0 ? void 0 : soleOverageWindow(unified);
|
|
67897
|
+
const headerRows = observedAt2 === void 0 || unified === void 0 ? [] : [
|
|
67898
|
+
...unified.fiveHour === void 0 ? [] : [rowOf(snapshot, provider, "5h", observedAt2, unified.fiveHour, nowMs)],
|
|
67899
|
+
...unified.sevenDay === void 0 ? [] : [rowOf(snapshot, provider, "7d", observedAt2, unified.sevenDay, nowMs)],
|
|
67900
|
+
...overage === void 0 ? [] : [rowOf(snapshot, provider, "extra usage", observedAt2, overage, nowMs)]
|
|
67901
|
+
];
|
|
67902
|
+
const quota = state.quota;
|
|
67903
|
+
const quotaRows2 = quota === void 0 ? [] : quota.windows.map((window) => rowOf(snapshot, provider, `${window.measures} ${formatPeriod(window)}`, quota.observedAt, window, nowMs));
|
|
67904
|
+
return [...headerRows, ...quotaRows2];
|
|
67905
|
+
})
|
|
67906
|
+
);
|
|
67907
|
+
return { resets: rows.sort(compareRows) };
|
|
67908
|
+
}
|
|
67909
|
+
function formatResetRow(row, nowMs) {
|
|
67910
|
+
const used = row.utilization === void 0 ? "usage unknown" : `${String(Math.round(row.utilization * PERCENT3))}% used`;
|
|
67911
|
+
const when = row.resetsAt === void 0 ? "no reset time reported" : row.reset ? `reset at ${row.resetsAt}` : `resets ${row.resetsAt} (in ${formatAge(Date.parse(row.resetsAt) - nowMs)})`;
|
|
67912
|
+
return `${row.identity} / ${row.provider}: ${row.window} ${used}, ${when}${row.status === void 0 ? "" : ` (${row.status})`}`;
|
|
67913
|
+
}
|
|
67914
|
+
var MS_PER_HOUR3, HOURS_PER_DAY3, PERCENT3;
|
|
67915
|
+
var init_resets = __esm({
|
|
67916
|
+
"src/usage/resets.ts"() {
|
|
67853
67917
|
"use strict";
|
|
67918
|
+
init_preflight();
|
|
67919
|
+
init_rateLimit();
|
|
67920
|
+
MS_PER_HOUR3 = 36e5;
|
|
67921
|
+
HOURS_PER_DAY3 = 24;
|
|
67922
|
+
PERCENT3 = 100;
|
|
67854
67923
|
}
|
|
67855
67924
|
});
|
|
67856
67925
|
|
|
67857
67926
|
// src/launcher/launchReport.ts
|
|
67858
67927
|
function poolDetail(pool) {
|
|
67859
67928
|
const [reason] = pool.reasons;
|
|
67860
|
-
if (pool.movedOff !== void 0) {
|
|
67861
|
-
return { detail: `moved off ${pool.movedOff.identity}: ${pool.movedOff.reason}`, ...reason === void 0 ? {} : { notes: [reason] } };
|
|
67862
|
-
}
|
|
67863
67929
|
return reason === void 0 ? {} : { detail: reason };
|
|
67864
67930
|
}
|
|
67865
67931
|
function rankingNotes(ranking, picked) {
|
|
@@ -67868,6 +67934,68 @@ function rankingNotes(ranking, picked) {
|
|
|
67868
67934
|
` ${candidate.reasons.join("; ")}`
|
|
67869
67935
|
]);
|
|
67870
67936
|
}
|
|
67937
|
+
function planText(account) {
|
|
67938
|
+
const plan = planOf(account);
|
|
67939
|
+
if (plan.kind === "pay-per-use") {
|
|
67940
|
+
return "pay-per-use";
|
|
67941
|
+
}
|
|
67942
|
+
return plan.recognised ? `${String(plan.capacity)}x` : void 0;
|
|
67943
|
+
}
|
|
67944
|
+
function loginAccountText(account) {
|
|
67945
|
+
const organisation = account.organizationName !== void 0 && account.organizationType !== void 0 && NAMED_ORGANISATION_TYPES.has(account.organizationType) ? account.organizationRole === void 0 ? account.organizationName : `${account.organizationName} (${account.organizationRole})` : void 0;
|
|
67946
|
+
const parts = [account.emailAddress, organisation, planText(account)].filter((part) => part !== void 0);
|
|
67947
|
+
return parts.length === 0 ? void 0 : parts.join(", ");
|
|
67948
|
+
}
|
|
67949
|
+
function accountRows(billing) {
|
|
67950
|
+
if (billing === void 0) {
|
|
67951
|
+
return [];
|
|
67952
|
+
}
|
|
67953
|
+
if (billing.provider !== void 0) {
|
|
67954
|
+
const quota = billing.snapshot?.providers[billing.provider]?.quota;
|
|
67955
|
+
const parts = [quota?.account?.email, quota?.level].filter((part) => part !== void 0);
|
|
67956
|
+
return parts.length === 0 ? [] : [{ label: "account", value: parts.join(", "), detail: `provider ${billing.provider}` }];
|
|
67957
|
+
}
|
|
67958
|
+
const account = billing.login ?? billing.snapshot?.account;
|
|
67959
|
+
const text5 = account === void 0 ? void 0 : loginAccountText(account);
|
|
67960
|
+
return text5 === void 0 ? [] : [{ label: "account", value: text5 }];
|
|
67961
|
+
}
|
|
67962
|
+
function isInformative(window, nowMs) {
|
|
67963
|
+
const effective = effectiveWindow(window, nowMs);
|
|
67964
|
+
return effective.reset || effective.utilization !== void 0 || effective.resetsAtMs !== void 0;
|
|
67965
|
+
}
|
|
67966
|
+
function quotaRows(billing) {
|
|
67967
|
+
if (billing === void 0) {
|
|
67968
|
+
return [];
|
|
67969
|
+
}
|
|
67970
|
+
const { nowMs } = billing;
|
|
67971
|
+
const state = billing.snapshot?.providers[billing.provider ?? ANTHROPIC_PROVIDER];
|
|
67972
|
+
const recorded = billing.provider === void 0 ? {
|
|
67973
|
+
observedAt: state?.rateLimit?.observedAt,
|
|
67974
|
+
windows: [
|
|
67975
|
+
{ label: "5h", window: state?.rateLimit?.unified?.fiveHour },
|
|
67976
|
+
{ label: "7d", window: state?.rateLimit?.unified?.sevenDay }
|
|
67977
|
+
]
|
|
67978
|
+
} : { observedAt: state?.quota?.observedAt, windows: (state?.quota?.windows ?? []).map((window) => ({ label: `${formatPeriod(window)} ${window.measures}`, window })) };
|
|
67979
|
+
const described = recorded.windows.flatMap(({ label: label2, window }) => window !== void 0 && isInformative(window, nowMs) ? [describeWindow(label2, window, effectiveWindow(window, nowMs), nowMs)] : []);
|
|
67980
|
+
return recorded.observedAt === void 0 || described.length === 0 ? [] : [{ label: "quota", value: described.join("; "), detail: `recorded ${formatAge(nowMs - Date.parse(recorded.observedAt))} ago` }];
|
|
67981
|
+
}
|
|
67982
|
+
function movedRows(facts) {
|
|
67983
|
+
const { identity } = facts;
|
|
67984
|
+
if (identity === void 0) {
|
|
67985
|
+
return [];
|
|
67986
|
+
}
|
|
67987
|
+
const moved = (from, detail) => [{ label: "moved", value: `${from} -> ${identity}`, detail, notice: true }];
|
|
67988
|
+
if (facts.limitRelaunchFrom !== void 0) {
|
|
67989
|
+
return moved(facts.limitRelaunchFrom, `${facts.limitRelaunchFrom} ran out of quota; the session resumed here`);
|
|
67990
|
+
}
|
|
67991
|
+
if (facts.pool?.movedOff !== void 0) {
|
|
67992
|
+
return moved(facts.pool.movedOff.identity, `the resumed conversation could not stay: ${facts.pool.movedOff.reason}`);
|
|
67993
|
+
}
|
|
67994
|
+
if (facts.lastRanAs !== void 0 && facts.lastRanAs.identity !== identity) {
|
|
67995
|
+
return moved(facts.lastRanAs.identity, `this directory last ran as ${facts.lastRanAs.identity} ${formatAge(facts.lastRanAs.agoMs)} ago`);
|
|
67996
|
+
}
|
|
67997
|
+
return [];
|
|
67998
|
+
}
|
|
67871
67999
|
function decisionRows(facts) {
|
|
67872
68000
|
return [
|
|
67873
68001
|
{ label: "identity", value: facts.identity ?? "(none)", detail: facts.identitySource },
|
|
@@ -67879,6 +68007,9 @@ function decisionRows(facts) {
|
|
|
67879
68007
|
...facts.ranking === void 0 ? {} : { notes: rankingNotes(facts.ranking, facts.identity) }
|
|
67880
68008
|
}
|
|
67881
68009
|
],
|
|
68010
|
+
...movedRows(facts),
|
|
68011
|
+
...accountRows(facts.billing),
|
|
68012
|
+
...quotaRows(facts.billing),
|
|
67882
68013
|
...facts.profile === void 0 ? [] : [{ label: "profile", value: facts.profile.name, detail: facts.profile.source }],
|
|
67883
68014
|
...facts.provider === void 0 ? [] : [{ label: "provider", value: facts.provider.name, detail: `credential ${facts.provider.credential}` }],
|
|
67884
68015
|
...facts.identityCredential === void 0 ? [] : [{ label: "credential", value: facts.identityCredential, detail: "the identity's own" }]
|
|
@@ -67908,10 +68039,16 @@ function farmRow(links, builtDirectories, adopted) {
|
|
|
67908
68039
|
function noteRow(text5) {
|
|
67909
68040
|
return { label: "note", value: text5 };
|
|
67910
68041
|
}
|
|
68042
|
+
var NAMED_ORGANISATION_TYPES;
|
|
67911
68043
|
var init_launchReport = __esm({
|
|
67912
68044
|
"src/launcher/launchReport.ts"() {
|
|
67913
68045
|
"use strict";
|
|
67914
68046
|
init_candidateText();
|
|
68047
|
+
init_middleware();
|
|
68048
|
+
init_plan2();
|
|
68049
|
+
init_preflight();
|
|
68050
|
+
init_resets();
|
|
68051
|
+
NAMED_ORGANISATION_TYPES = /* @__PURE__ */ new Set(["claude_team", "claude_enterprise"]);
|
|
67915
68052
|
}
|
|
67916
68053
|
});
|
|
67917
68054
|
|
|
@@ -68517,7 +68654,7 @@ function ageQuotaMap(quota, elapsedMs) {
|
|
|
68517
68654
|
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) }])
|
|
68518
68655
|
);
|
|
68519
68656
|
}
|
|
68520
|
-
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,
|
|
68657
|
+
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;
|
|
68521
68658
|
var init_quota = __esm({
|
|
68522
68659
|
"src/antigravity/quota.ts"() {
|
|
68523
68660
|
"use strict";
|
|
@@ -68541,9 +68678,9 @@ var init_quota = __esm({
|
|
|
68541
68678
|
SECONDS_PER_HOUR = 3600;
|
|
68542
68679
|
HOURS_PER_FIVE_HOUR_WINDOW = 5;
|
|
68543
68680
|
DAYS_PER_WEEK = 7;
|
|
68544
|
-
|
|
68681
|
+
HOURS_PER_DAY4 = 24;
|
|
68545
68682
|
FIVE_HOUR_PERIOD_SECONDS = HOURS_PER_FIVE_HOUR_WINDOW * SECONDS_PER_HOUR;
|
|
68546
|
-
WEEK_PERIOD_SECONDS = DAYS_PER_WEEK *
|
|
68683
|
+
WEEK_PERIOD_SECONDS = DAYS_PER_WEEK * HOURS_PER_DAY4 * SECONDS_PER_HOUR;
|
|
68547
68684
|
ANTIGRAVITY_QUOTA_REFRESH_MS = 6e4;
|
|
68548
68685
|
}
|
|
68549
68686
|
});
|
|
@@ -69215,7 +69352,7 @@ async function fetchCatalogue(params) {
|
|
|
69215
69352
|
}
|
|
69216
69353
|
throw new CatalogueFetchError(`no catalogue from ${outcomes.join("; ")}`);
|
|
69217
69354
|
}
|
|
69218
|
-
var import_picomatch3, DEFAULT_CANDIDATE_URLS, MS_PER_SECOND10, SECONDS_PER_HOUR3,
|
|
69355
|
+
var import_picomatch3, DEFAULT_CANDIDATE_URLS, MS_PER_SECOND10, SECONDS_PER_HOUR3, HOURS_PER_DAY5, MS_PER_HOUR4, HOURS_BETWEEN_RETRIES, HTTP_OK, HTTP_MULTIPLE_CHOICES, CATALOGUE_MAX_AGE_MS, CATALOGUE_RETRY_MS, CATALOGUE_REQUEST_SECONDS, CATALOGUE_REQUEST_TIMEOUT_MS, CATALOGUE_REFRESH_TIMEOUT_MS, CatalogueModelSchema, CatalogueCacheSchema, CatalogueFetchError;
|
|
69219
69356
|
var init_providerCatalogue = __esm({
|
|
69220
69357
|
"src/providerCatalogue.ts"() {
|
|
69221
69358
|
"use strict";
|
|
@@ -69225,13 +69362,13 @@ var init_providerCatalogue = __esm({
|
|
|
69225
69362
|
DEFAULT_CANDIDATE_URLS = 2;
|
|
69226
69363
|
MS_PER_SECOND10 = 1e3;
|
|
69227
69364
|
SECONDS_PER_HOUR3 = 3600;
|
|
69228
|
-
|
|
69229
|
-
|
|
69365
|
+
HOURS_PER_DAY5 = 24;
|
|
69366
|
+
MS_PER_HOUR4 = SECONDS_PER_HOUR3 * MS_PER_SECOND10;
|
|
69230
69367
|
HOURS_BETWEEN_RETRIES = 1;
|
|
69231
69368
|
HTTP_OK = 200;
|
|
69232
69369
|
HTTP_MULTIPLE_CHOICES = 300;
|
|
69233
|
-
CATALOGUE_MAX_AGE_MS =
|
|
69234
|
-
CATALOGUE_RETRY_MS = HOURS_BETWEEN_RETRIES *
|
|
69370
|
+
CATALOGUE_MAX_AGE_MS = HOURS_PER_DAY5 * MS_PER_HOUR4;
|
|
69371
|
+
CATALOGUE_RETRY_MS = HOURS_BETWEEN_RETRIES * MS_PER_HOUR4;
|
|
69235
69372
|
CATALOGUE_REQUEST_SECONDS = 10;
|
|
69236
69373
|
CATALOGUE_REQUEST_TIMEOUT_MS = CATALOGUE_REQUEST_SECONDS * MS_PER_SECOND10;
|
|
69237
69374
|
CATALOGUE_REFRESH_TIMEOUT_MS = DEFAULT_CANDIDATE_URLS * CATALOGUE_REQUEST_TIMEOUT_MS;
|
|
@@ -69407,7 +69544,7 @@ function joined(parts) {
|
|
|
69407
69544
|
const last = parts[parts.length - 1];
|
|
69408
69545
|
return last === void 0 || parts.length === 1 ? last ?? "" : `${parts.slice(0, -1).join(", ")} and ${last}`;
|
|
69409
69546
|
}
|
|
69410
|
-
function
|
|
69547
|
+
function rowOf2(model, reaches) {
|
|
69411
69548
|
const lead = reaches.find((reach) => reach.standing === "first") ?? reaches[0];
|
|
69412
69549
|
if (lead === void 0) {
|
|
69413
69550
|
throw new Error(`model ${model} is reached by no tier`);
|
|
@@ -69429,7 +69566,7 @@ function rowsOfTable(table) {
|
|
|
69429
69566
|
reachesByModel.set(model, reaches);
|
|
69430
69567
|
});
|
|
69431
69568
|
}
|
|
69432
|
-
return [...reachesByModel].map(([model, reaches]) =>
|
|
69569
|
+
return [...reachesByModel].map(([model, reaches]) => rowOf2(model, reaches));
|
|
69433
69570
|
}
|
|
69434
69571
|
function antigravityRows(provider) {
|
|
69435
69572
|
const config2 = resolveAntigravityConfig(provider.antigravity);
|
|
@@ -69606,7 +69743,8 @@ function resolvePoolLaunch(params) {
|
|
|
69606
69743
|
explanation: `pool ${poolName}: ${move}${pick2.reasons.slice(0, REASONS_LOGGED).join("; ")}`,
|
|
69607
69744
|
reasons: pick2.reasons,
|
|
69608
69745
|
candidates: graph.ranking.candidates,
|
|
69609
|
-
...movedOff === void 0 ? {} : { movedOff }
|
|
69746
|
+
...movedOff === void 0 ? {} : { movedOff },
|
|
69747
|
+
...stickyRead.sticky === void 0 ? {} : { lastRanAs: stickyRead.sticky }
|
|
69610
69748
|
};
|
|
69611
69749
|
}
|
|
69612
69750
|
if (earliestReturn === void 0) {
|
|
@@ -69801,7 +69939,8 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
69801
69939
|
return {
|
|
69802
69940
|
identityDecision: { ...decided, name: resolution.identity },
|
|
69803
69941
|
poolPick: { name: decided.pool, reasons: resolution.reasons, ...resolution.movedOff === void 0 ? {} : { movedOff: resolution.movedOff } },
|
|
69804
|
-
poolRanking: resolution.candidates
|
|
69942
|
+
poolRanking: resolution.candidates,
|
|
69943
|
+
...resolution.lastRanAs === void 0 ? {} : { lastRanAs: { identity: resolution.lastRanAs.identity, agoMs: farmRuntime.now() - Date.parse(resolution.lastRanAs.at) } }
|
|
69805
69944
|
};
|
|
69806
69945
|
}
|
|
69807
69946
|
function decideLaunch(params, readOnly) {
|
|
@@ -69828,7 +69967,7 @@ function decideLaunch(params, readOnly) {
|
|
|
69828
69967
|
return trimmed === "" ? void 0 : trimmed;
|
|
69829
69968
|
}
|
|
69830
69969
|
});
|
|
69831
|
-
const { identityDecision, poolPick, poolRanking } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
69970
|
+
const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
69832
69971
|
const farmIdentity = configDirEscapeHatchApplies ? void 0 : identityDecision.name;
|
|
69833
69972
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
69834
69973
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
@@ -69905,9 +70044,11 @@ function decideLaunch(params, readOnly) {
|
|
|
69905
70044
|
log.warn(warning);
|
|
69906
70045
|
}
|
|
69907
70046
|
}
|
|
70047
|
+
let billing;
|
|
69908
70048
|
if (farm !== void 0 && farmIdentity !== void 0) {
|
|
70049
|
+
let snapshot;
|
|
69909
70050
|
try {
|
|
69910
|
-
|
|
70051
|
+
snapshot = readUsageSnapshot(farm.fs, paths.usageSnapshotsDir, farmIdentity);
|
|
69911
70052
|
for (const warning of quotaWarnings(snapshot, selectedProvider?.name ?? ANTHROPIC_PROVIDER, farm.now())) {
|
|
69912
70053
|
log.warn(warning);
|
|
69913
70054
|
}
|
|
@@ -69917,6 +70058,16 @@ function decideLaunch(params, readOnly) {
|
|
|
69917
70058
|
}
|
|
69918
70059
|
log.warn(`agent-shim: ${error63.message}`);
|
|
69919
70060
|
}
|
|
70061
|
+
let login;
|
|
70062
|
+
try {
|
|
70063
|
+
login = readAccountMetadata(farm.fs, paths.identitiesDir, farmIdentity);
|
|
70064
|
+
} catch (error63) {
|
|
70065
|
+
if (!(error63 instanceof AccountMetadataError)) {
|
|
70066
|
+
throw error63;
|
|
70067
|
+
}
|
|
70068
|
+
log.warn(`agent-shim: ${error63.message}`);
|
|
70069
|
+
}
|
|
70070
|
+
billing = { login, snapshot, provider: selectedProvider?.name, nowMs: farm.now() };
|
|
69920
70071
|
}
|
|
69921
70072
|
const identityCredentialBlock = selectedProvider === void 0 && farmIdentity !== void 0 ? loadedIdentity?.config.credential : void 0;
|
|
69922
70073
|
const identityResolution = !readOnly && identityCredentialBlock !== void 0 && farmIdentity !== void 0 ? resolveIdentityCredential(farmIdentity, identityCredentialBlock, env, params.credentials) : void 0;
|
|
@@ -70015,6 +70166,8 @@ function decideLaunch(params, readOnly) {
|
|
|
70015
70166
|
identityDecision,
|
|
70016
70167
|
poolPick,
|
|
70017
70168
|
poolRanking,
|
|
70169
|
+
lastRanAs,
|
|
70170
|
+
billing,
|
|
70018
70171
|
notes,
|
|
70019
70172
|
configDirEscapeHatch: configDirEscapeHatchApplies,
|
|
70020
70173
|
farmIdentity,
|
|
@@ -70037,7 +70190,7 @@ function prepareLaunch(params) {
|
|
|
70037
70190
|
const { paths, proc, log } = params;
|
|
70038
70191
|
const { env } = proc;
|
|
70039
70192
|
const decided = decideLaunch(params, false);
|
|
70040
|
-
const { identityDecision, configProfileDecision, resolvedProvider, identityCredential, poolPick, poolRanking, notes, flags: resolvedFlags, args: finalArgv, configDirEscapeHatch: configDirEscapeHatchApplies, decision } = decided;
|
|
70193
|
+
const { identityDecision, configProfileDecision, resolvedProvider, identityCredential, poolPick, poolRanking, lastRanAs, billing, notes, flags: resolvedFlags, args: finalArgv, configDirEscapeHatch: configDirEscapeHatchApplies, decision } = decided;
|
|
70041
70194
|
const rows = [
|
|
70042
70195
|
...decisionRows({
|
|
70043
70196
|
identity: identityDecision.name,
|
|
@@ -70046,7 +70199,10 @@ function prepareLaunch(params) {
|
|
|
70046
70199
|
ranking: resolvedFlags.explain ? poolRanking : void 0,
|
|
70047
70200
|
profile: configProfileDecision.name === void 0 ? void 0 : { name: configProfileDecision.name, source: configProfileDecision.source },
|
|
70048
70201
|
provider: resolvedProvider === void 0 ? void 0 : { name: resolvedProvider.name, credential: `${resolvedProvider.credential.target} from ${describeSource(resolvedProvider.credential.source)}` },
|
|
70049
|
-
identityCredential: identityCredential === void 0 ? void 0 : `${identityCredential.target} from ${describeSource(identityCredential.source)}
|
|
70202
|
+
identityCredential: identityCredential === void 0 ? void 0 : `${identityCredential.target} from ${describeSource(identityCredential.source)}`,
|
|
70203
|
+
billing,
|
|
70204
|
+
lastRanAs,
|
|
70205
|
+
limitRelaunchFrom: params.supervised?.from
|
|
70050
70206
|
})
|
|
70051
70207
|
];
|
|
70052
70208
|
let warnings = [];
|
|
@@ -70235,6 +70391,7 @@ var init_launcher = __esm({
|
|
|
70235
70391
|
init_schema();
|
|
70236
70392
|
init_credential();
|
|
70237
70393
|
init_middleware();
|
|
70394
|
+
init_account();
|
|
70238
70395
|
init_preflight();
|
|
70239
70396
|
init_read();
|
|
70240
70397
|
init_claudeVersion();
|
|
@@ -70489,7 +70646,7 @@ function zaiWindow(limit) {
|
|
|
70489
70646
|
return {
|
|
70490
70647
|
measures: ZAI_MEASURES[limit.type] ?? limit.type.toLowerCase(),
|
|
70491
70648
|
...unitMs === void 0 ? { period: `unit ${String(limit.unit)} x ${String(limit.number)}` } : { periodMs: unitMs * limit.number },
|
|
70492
|
-
utilization: limit.percentage /
|
|
70649
|
+
utilization: limit.percentage / PERCENT4,
|
|
70493
70650
|
...limit.nextResetTime === void 0 ? {} : { resetsAt: new Date(limit.nextResetTime).toISOString() },
|
|
70494
70651
|
...limit.usage === void 0 ? {} : { limit: limit.usage },
|
|
70495
70652
|
...limit.currentValue === void 0 ? {} : { used: limit.currentValue },
|
|
@@ -70524,9 +70681,9 @@ function adapterFor(baseUrl) {
|
|
|
70524
70681
|
}
|
|
70525
70682
|
function quotaFreshnessMs(quota) {
|
|
70526
70683
|
const lengths = quota.windows.flatMap((window) => window.periodMs === void 0 ? [] : [window.periodMs]);
|
|
70527
|
-
return lengths.length === 0 ? Number.POSITIVE_INFINITY : Math.min(...lengths) /
|
|
70684
|
+
return lengths.length === 0 ? Number.POSITIVE_INFINITY : Math.min(...lengths) / PERCENT4;
|
|
70528
70685
|
}
|
|
70529
|
-
var ProviderQuotaError, MS_PER_SECOND11, SECONDS_PER_HOUR4,
|
|
70686
|
+
var ProviderQuotaError, MS_PER_SECOND11, SECONDS_PER_HOUR4, HOURS_PER_DAY6, DAYS_PER_MONTH, PERCENT4, HTTP_OK2, ZAI_SOURCE, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZAI_MEASURES, ZaiLimitSchema, ZaiResponseSchema, zaiQuotaAdapter, OPENROUTER_SOURCE, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, HTTP_FORBIDDEN, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, openRouterQuotaAdapter, ANTIGRAVITY_SOURCE, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, GOOGLE_TOKENINFO_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema, ANTIGRAVITY_WINDOW_MS, antigravityQuotaAdapter, PROVIDER_QUOTA_ADAPTERS;
|
|
70530
70687
|
var init_providerQuota = __esm({
|
|
70531
70688
|
"src/usage/providerQuota.ts"() {
|
|
70532
70689
|
"use strict";
|
|
@@ -70541,9 +70698,9 @@ var init_providerQuota = __esm({
|
|
|
70541
70698
|
};
|
|
70542
70699
|
MS_PER_SECOND11 = 1e3;
|
|
70543
70700
|
SECONDS_PER_HOUR4 = 3600;
|
|
70544
|
-
|
|
70701
|
+
HOURS_PER_DAY6 = 24;
|
|
70545
70702
|
DAYS_PER_MONTH = 30;
|
|
70546
|
-
|
|
70703
|
+
PERCENT4 = 100;
|
|
70547
70704
|
HTTP_OK2 = 200;
|
|
70548
70705
|
ZAI_SOURCE = "z.ai";
|
|
70549
70706
|
ZAI_HOST = "api.z.ai";
|
|
@@ -70552,7 +70709,7 @@ var init_providerQuota = __esm({
|
|
|
70552
70709
|
ZAI_UNIT_MONTHS = 5;
|
|
70553
70710
|
ZAI_UNIT_MS = /* @__PURE__ */ new Map([
|
|
70554
70711
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR4 * MS_PER_SECOND11],
|
|
70555
|
-
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH *
|
|
70712
|
+
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR4 * MS_PER_SECOND11]
|
|
70556
70713
|
]);
|
|
70557
70714
|
ZAI_MEASURES = { TOKENS_LIMIT: "tokens", TIME_LIMIT: "tool-calls" };
|
|
70558
70715
|
ZaiLimitSchema = external_exports.object({
|
|
@@ -70604,7 +70761,7 @@ var init_providerQuota = __esm({
|
|
|
70604
70761
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
70605
70762
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
70606
70763
|
HTTP_FORBIDDEN = 403;
|
|
70607
|
-
MS_PER_DAY3 =
|
|
70764
|
+
MS_PER_DAY3 = HOURS_PER_DAY6 * SECONDS_PER_HOUR4 * MS_PER_SECOND11;
|
|
70608
70765
|
OpenRouterKeySchema = external_exports.object({
|
|
70609
70766
|
data: external_exports.object({
|
|
70610
70767
|
limit: external_exports.number().nonnegative().nullable(),
|
|
@@ -70653,7 +70810,7 @@ var init_providerQuota = __esm({
|
|
|
70653
70810
|
FIVE_HOURS2 = 5;
|
|
70654
70811
|
DAYS_PER_WEEK2 = 7;
|
|
70655
70812
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR4 * MS_PER_SECOND11;
|
|
70656
|
-
WEEK_MS = DAYS_PER_WEEK2 *
|
|
70813
|
+
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR4 * MS_PER_SECOND11;
|
|
70657
70814
|
AntigravityBucketSchema = external_exports.object({
|
|
70658
70815
|
bucketId: external_exports.string(),
|
|
70659
70816
|
remainingFraction: external_exports.number().optional(),
|
|
@@ -117586,7 +117743,7 @@ function summariseIdentityAccount(account) {
|
|
|
117586
117743
|
function loginKeyOf(account) {
|
|
117587
117744
|
return account.accountUuid === void 0 ? void 0 : JSON.stringify([account.accountUuid, account.organizationUuid ?? null]);
|
|
117588
117745
|
}
|
|
117589
|
-
function
|
|
117746
|
+
function collectByLogin(items, loginOf) {
|
|
117590
117747
|
const groups = /* @__PURE__ */ new Map();
|
|
117591
117748
|
for (const item of items) {
|
|
117592
117749
|
const key = loginOf(item) ?? /* @__PURE__ */ Symbol("no login");
|
|
@@ -117597,7 +117754,13 @@ function groupByLogin(items, loginOf) {
|
|
|
117597
117754
|
group.push(item);
|
|
117598
117755
|
}
|
|
117599
117756
|
}
|
|
117600
|
-
return [...groups.values()]
|
|
117757
|
+
return [...groups.values()];
|
|
117758
|
+
}
|
|
117759
|
+
function groupByLogin(items, loginOf) {
|
|
117760
|
+
return collectByLogin(items, loginOf).flat();
|
|
117761
|
+
}
|
|
117762
|
+
function groupSharedLogins(items, loginOf) {
|
|
117763
|
+
return collectByLogin(items, loginOf).filter((group) => group.length > 1);
|
|
117601
117764
|
}
|
|
117602
117765
|
function describeAccountHolder(summary) {
|
|
117603
117766
|
const organisation = describeAccountOrganisation(summary);
|
|
@@ -123366,6 +123529,10 @@ var DOCTOR_SECTIONS = [
|
|
|
123366
123529
|
"frontdoor",
|
|
123367
123530
|
"models"
|
|
123368
123531
|
];
|
|
123532
|
+
function joinNames(names) {
|
|
123533
|
+
const last = names.at(-1);
|
|
123534
|
+
return names.length < 2 || last === void 0 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${last}`;
|
|
123535
|
+
}
|
|
123369
123536
|
function refinePathShadow(status, ownExecutablePath, realpath) {
|
|
123370
123537
|
if (status.status !== "shadowed") {
|
|
123371
123538
|
return status;
|
|
@@ -123613,6 +123780,7 @@ function runDoctor(params) {
|
|
|
123613
123780
|
const validProfileNames = new Set(profileSources.keys());
|
|
123614
123781
|
const validProviderNames = /* @__PURE__ */ new Set([...params.providers.map((entry) => entry.name), ...Object.keys(params.providerAliases ?? {})]);
|
|
123615
123782
|
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
123783
|
+
const signedInAccounts = [];
|
|
123616
123784
|
for (const entry of params.identities) {
|
|
123617
123785
|
const validated2 = validate3(IdentitySchema, entry, "identity", entry.name);
|
|
123618
123786
|
if (!validated2.ok) {
|
|
@@ -123662,6 +123830,18 @@ function runDoctor(params) {
|
|
|
123662
123830
|
signIn.state === "signed-out" ? `${entry.name} is signed out (${signIn.detail}). Run \`agent-shim run @${entry.name}\` and sign in.` : `${entry.name} ${standing} (${signIn.detail}).`,
|
|
123663
123831
|
entry.name
|
|
123664
123832
|
);
|
|
123833
|
+
if (signIn.state === "signed-in" && entry.account !== void 0) {
|
|
123834
|
+
signedInAccounts.push({ name: entry.name, account: entry.account });
|
|
123835
|
+
}
|
|
123836
|
+
}
|
|
123837
|
+
for (const group of groupSharedLogins(signedInAccounts, (entry) => loginKeyOf(entry.account))) {
|
|
123838
|
+
const names = group.map((entry) => entry.name);
|
|
123839
|
+
const holder = group.map((entry) => summariseIdentityAccount(entry.account)).map((summary) => summary === void 0 ? void 0 : describeAccountHolder(summary)).find((described) => described !== void 0);
|
|
123840
|
+
push(
|
|
123841
|
+
"sign-in",
|
|
123842
|
+
"warn",
|
|
123843
|
+
`Identities ${joinNames(names)} hold the same login${holder === void 0 ? "" : ` (${holder})`}, so they share one quota window and all but one are redundant. Remove the redundant ones with \`agent-shim identity remove <name>\`.`
|
|
123844
|
+
);
|
|
123665
123845
|
}
|
|
123666
123846
|
const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
|
|
123667
123847
|
const pools = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.pools ?? {} : {};
|
|
@@ -123950,7 +124130,7 @@ function collectDoctorReport(params) {
|
|
|
123950
124130
|
const identities = identityNames.map((name) => {
|
|
123951
124131
|
const farmRoot = import_node_path47.default.join(paths.identitiesDir, name);
|
|
123952
124132
|
const identityPath = import_node_path47.default.join(farmRoot, "identity.json");
|
|
123953
|
-
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs20.default.existsSync(credentialsFilePath(farmRoot)) };
|
|
124133
|
+
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs20.default.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, name)?.account };
|
|
123954
124134
|
});
|
|
123955
124135
|
const profileNames = import_node_fs20.default.existsSync(paths.configProfilesDir) ? import_node_fs20.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
123956
124136
|
const configProfiles = profileNames.map((name) => {
|
|
@@ -129577,62 +129757,7 @@ var CheckReportJsonSchema = external_exports.strictObject({
|
|
|
129577
129757
|
// src/frontdoor/controlApi.ts
|
|
129578
129758
|
init_middleware();
|
|
129579
129759
|
init_preflight();
|
|
129580
|
-
|
|
129581
|
-
// src/usage/resets.ts
|
|
129582
|
-
init_preflight();
|
|
129583
|
-
init_rateLimit();
|
|
129584
|
-
var MS_PER_HOUR4 = 36e5;
|
|
129585
|
-
var HOURS_PER_DAY6 = 24;
|
|
129586
|
-
var PERCENT4 = 100;
|
|
129587
|
-
function formatPeriod(window) {
|
|
129588
|
-
if (window.periodMs === void 0) {
|
|
129589
|
-
return window.period ?? "unknown period";
|
|
129590
|
-
}
|
|
129591
|
-
const hours = window.periodMs / MS_PER_HOUR4;
|
|
129592
|
-
return hours >= HOURS_PER_DAY6 && Number.isInteger(hours / HOURS_PER_DAY6) ? `${String(hours / HOURS_PER_DAY6)}d` : `${String(hours)}h`;
|
|
129593
|
-
}
|
|
129594
|
-
function groupOf(row) {
|
|
129595
|
-
return row.resetsAt === void 0 ? 2 : row.reset ? 1 : 0;
|
|
129596
|
-
}
|
|
129597
|
-
function compareRows(left, right) {
|
|
129598
|
-
return groupOf(left) - groupOf(right) || (left.resetsAt ?? "").localeCompare(right.resetsAt ?? "") || left.identity.localeCompare(right.identity) || left.provider.localeCompare(right.provider) || left.window.localeCompare(right.window);
|
|
129599
|
-
}
|
|
129600
|
-
function rowOf2(snapshot, provider, window, observedAt2, recorded, nowMs) {
|
|
129601
|
-
const effective = effectiveWindow(recorded, nowMs);
|
|
129602
|
-
return {
|
|
129603
|
-
identity: snapshot.identity,
|
|
129604
|
-
provider,
|
|
129605
|
-
window,
|
|
129606
|
-
observedAt: observedAt2,
|
|
129607
|
-
...recorded.resetsAt === void 0 ? {} : { resetsAt: recorded.resetsAt },
|
|
129608
|
-
reset: effective.reset,
|
|
129609
|
-
...effective.utilization === void 0 ? {} : { utilization: effective.utilization },
|
|
129610
|
-
...effective.status === void 0 ? {} : { status: effective.status }
|
|
129611
|
-
};
|
|
129612
|
-
}
|
|
129613
|
-
function collectResets(snapshots, nowMs) {
|
|
129614
|
-
const rows = snapshots.flatMap(
|
|
129615
|
-
(snapshot) => Object.entries(snapshot.providers).flatMap(([provider, state]) => {
|
|
129616
|
-
const unified = state.rateLimit?.unified;
|
|
129617
|
-
const observedAt2 = state.rateLimit?.observedAt;
|
|
129618
|
-
const overage = unified === void 0 ? void 0 : soleOverageWindow(unified);
|
|
129619
|
-
const headerRows = observedAt2 === void 0 || unified === void 0 ? [] : [
|
|
129620
|
-
...unified.fiveHour === void 0 ? [] : [rowOf2(snapshot, provider, "5h", observedAt2, unified.fiveHour, nowMs)],
|
|
129621
|
-
...unified.sevenDay === void 0 ? [] : [rowOf2(snapshot, provider, "7d", observedAt2, unified.sevenDay, nowMs)],
|
|
129622
|
-
...overage === void 0 ? [] : [rowOf2(snapshot, provider, "extra usage", observedAt2, overage, nowMs)]
|
|
129623
|
-
];
|
|
129624
|
-
const quota = state.quota;
|
|
129625
|
-
const quotaRows = quota === void 0 ? [] : quota.windows.map((window) => rowOf2(snapshot, provider, `${window.measures} ${formatPeriod(window)}`, quota.observedAt, window, nowMs));
|
|
129626
|
-
return [...headerRows, ...quotaRows];
|
|
129627
|
-
})
|
|
129628
|
-
);
|
|
129629
|
-
return { resets: rows.sort(compareRows) };
|
|
129630
|
-
}
|
|
129631
|
-
function formatResetRow(row, nowMs) {
|
|
129632
|
-
const used = row.utilization === void 0 ? "usage unknown" : `${String(Math.round(row.utilization * PERCENT4))}% used`;
|
|
129633
|
-
const when = row.resetsAt === void 0 ? "no reset time reported" : row.reset ? `reset at ${row.resetsAt}` : `resets ${row.resetsAt} (in ${formatAge(Date.parse(row.resetsAt) - nowMs)})`;
|
|
129634
|
-
return `${row.identity} / ${row.provider}: ${row.window} ${used}, ${when}${row.status === void 0 ? "" : ` (${row.status})`}`;
|
|
129635
|
-
}
|
|
129760
|
+
init_resets();
|
|
129636
129761
|
|
|
129637
129762
|
// src/usage/resetsSchema.ts
|
|
129638
129763
|
init_zod();
|
|
@@ -157356,6 +157481,7 @@ init_commandDeps();
|
|
|
157356
157481
|
init_realPorts();
|
|
157357
157482
|
init_account();
|
|
157358
157483
|
init_signIn();
|
|
157484
|
+
init_resets();
|
|
157359
157485
|
init_read();
|
|
157360
157486
|
init_anthropicUsageRefresh();
|
|
157361
157487
|
init_middleware();
|
|
@@ -158297,7 +158423,7 @@ async function supervise(deps, first) {
|
|
|
158297
158423
|
launch = { ...base, conversation: "resume", member: identity };
|
|
158298
158424
|
continue;
|
|
158299
158425
|
}
|
|
158300
|
-
launch = { ...base, conversation: "resume", member: outcome.to, ...outcome.kind === "remodel" ? { model: outcome.model } : {} };
|
|
158426
|
+
launch = { ...base, conversation: "resume", member: outcome.to, from: identity, ...outcome.kind === "remodel" ? { model: outcome.model } : {} };
|
|
158301
158427
|
const compactedOnOld = compactedHere;
|
|
158302
158428
|
compactedHere = false;
|
|
158303
158429
|
if (compaction !== void 0) {
|