@cortexkit/opencode-antigravity-auth 3.0.6 → 3.0.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.js +620 -120
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +128 -44
- package/dist/index.js +1469 -675
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +154 -73
- package/dist/server.js +1075 -280
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +11 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +38 -1
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +29 -0
- package/dist/src/common-auth-embedded/claustrum/custody.js +17 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +6 -1
- package/dist/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/dist/src/common-auth-embedded/quota/format.d.ts +14 -3
- package/dist/src/common-auth-embedded/quota/format.js +135 -18
- package/dist/src/common-auth-embedded/quota/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/quota/index.js +1 -1
- package/dist/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/src/common-auth-embedded/setup/command-error.js +79 -0
- package/dist/src/common-auth-embedded/setup/command-runner.js +118 -24
- package/dist/src/common-auth-embedded/setup/command.js +75 -19
- package/dist/src/common-auth-embedded/setup/enroll.js +17 -5
- package/dist/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/dist/src/common-auth-embedded/setup/index.js +1 -0
- package/dist/src/common-auth-embedded/setup/register.js +8 -2
- package/dist/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/dist/src/common-auth-embedded/source-output.json +92 -76
- package/dist/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/src/common-auth-embedded/store/pool.js +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +4 -2
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +37 -3
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +2 -1
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +4 -3
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +2 -5
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +3 -3
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/src/plugin/logging-utils.js +2 -5
- package/dist/src/plugin/logging-utils.js.map +1 -1
- package/dist/src/plugin/request.d.ts +1 -2
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +8 -12
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +8 -1
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +140 -58
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +12 -3
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +3 -0
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +14 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +57 -10
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/sidebar-projection.d.ts +4 -0
- package/dist/src/sidebar-projection.d.ts.map +1 -1
- package/dist/src/sidebar-projection.js +6 -2
- package/dist/src/sidebar-projection.js.map +1 -1
- package/dist/src/tui/quota-layout.d.ts +94 -0
- package/dist/src/tui/quota-layout.d.ts.map +1 -0
- package/dist/src/tui/quota-layout.js +139 -0
- package/dist/src/tui/quota-layout.js.map +1 -0
- package/dist/src/tui/route-layout.d.ts +8 -0
- package/dist/src/tui/route-layout.d.ts.map +1 -0
- package/dist/src/tui/route-layout.js +36 -0
- package/dist/src/tui/route-layout.js.map +1 -0
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +26 -128
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +42 -13
- package/dist/tui-ga-build-map.json +46 -17
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +11 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +29 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +14 -3
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/types/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts +1 -2
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +8 -1
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +12 -3
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +14 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +11 -1
- package/src/common-auth-embedded/claustrum/consumer.js +38 -1
- package/src/common-auth-embedded/claustrum/custody.d.ts +29 -0
- package/src/common-auth-embedded/claustrum/custody.js +17 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.js +6 -1
- package/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/src/common-auth-embedded/quota/format.d.ts +14 -3
- package/src/common-auth-embedded/quota/format.js +135 -18
- package/src/common-auth-embedded/quota/index.d.ts +1 -1
- package/src/common-auth-embedded/quota/index.js +1 -1
- package/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/src/common-auth-embedded/setup/command-error.js +79 -0
- package/src/common-auth-embedded/setup/command-runner.js +118 -24
- package/src/common-auth-embedded/setup/command.js +75 -19
- package/src/common-auth-embedded/setup/enroll.js +17 -5
- package/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/src/common-auth-embedded/setup/index.js +1 -0
- package/src/common-auth-embedded/setup/register.js +8 -2
- package/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/src/common-auth-embedded/source-output.json +92 -76
- package/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/src/common-auth-embedded/store/pool.js +0 -1
- package/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/src/tui-compiled/common-auth-embedded/quota/format.js +135 -18
- package/src/tui-compiled/common-auth-embedded/quota/index.js +1 -1
- package/src/tui-compiled/tui/quota-layout.js +378 -0
- package/src/tui-compiled/tui/route-layout.js +30 -0
- package/src/tui-compiled/tui.js +145 -427
- package/src/tui-ga-compiled/host-ga.js +82 -52
- package/src/tui-ga-compiled/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +135 -18
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +1 -1
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +378 -0
- package/src/tui-ga-raw/host-ga.tsx +71 -30
- package/src/tui-ga-raw/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +135 -18
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +1 -1
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +391 -0
- package/src/tui-raw/common-auth-embedded/quota/format.js +135 -18
- package/src/tui-raw/common-auth-embedded/quota/index.js +1 -1
- package/src/tui-raw/tui/quota-layout.tsx +391 -0
- package/src/tui-raw/tui/route-layout.js +30 -0
- package/src/tui-raw/tui.tsx +50 -309
- package/src/tui.tsx +50 -309
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
1
2
|
import { insert as _$insert } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
3
|
import { createComponent as _$createComponent } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
3
4
|
import { createTextNode as _$createTextNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
4
5
|
import { insertNode as _$insertNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
6
|
+
import { use as _$use } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
5
7
|
import { setProp as _$setProp } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
6
8
|
import { createElement as _$createElement } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
7
9
|
/** @jsxImportSource @opentui/solid */
|
|
@@ -51,6 +53,8 @@ import { createSignal, For, Show } from "opentui:runtime-module:solid-js";
|
|
|
51
53
|
import { projectAccount, projectSidebar } from "./shared/8ae1927e5910ea81-sidebar-projection.js";
|
|
52
54
|
import { MenuRefusedError, openAntigravityMenu } from "./shared/0e19a88ff3535906-command-dialogs.js";
|
|
53
55
|
import { ANTIGRAVITY_MENU_COMMAND, ANTIGRAVITY_MENU_TITLE } from "./shared/07365a7d2ccade4c-host-api.js";
|
|
56
|
+
import { ASSUMED_CONTENT_WIDTH, DEFAULT_QUOTA_APPEARANCE, QuotaAccountBlock } from "./shared/dd4c9e1a907f8ef0-quota-layout.js";
|
|
57
|
+
import { fitRouteParts } from "./shared/6ca47cd4ec33fe72-route-layout.js";
|
|
54
58
|
export const GA_TUI_ID = 'cortexkit.antigravity-auth';
|
|
55
59
|
export const GA_RPC_ID = 'antigravity-auth';
|
|
56
60
|
export const GA_RPC_VERSION = 1;
|
|
@@ -1019,6 +1023,13 @@ export async function pollGaOnce(options) {
|
|
|
1019
1023
|
|
|
1020
1024
|
// ── Sidebar ─────────────────────────────────────────────────────────────────
|
|
1021
1025
|
|
|
1026
|
+
// The GA context carries no theme, so the quota layout keeps the host's
|
|
1027
|
+
// default text color everywhere.
|
|
1028
|
+
const HOST_COLORS = {
|
|
1029
|
+
text: () => undefined,
|
|
1030
|
+
muted: () => undefined,
|
|
1031
|
+
tone: () => undefined
|
|
1032
|
+
};
|
|
1022
1033
|
function GaSidebar(props) {
|
|
1023
1034
|
// The route line belongs to one session; show it only in that session's
|
|
1024
1035
|
// sidebar, never another session's.
|
|
@@ -1027,85 +1038,101 @@ function GaSidebar(props) {
|
|
|
1027
1038
|
if (view === undefined || view.scope.kind !== 'session') return null;
|
|
1028
1039
|
return view.scope.sessionID === props.sessionID ? view.projected.route : null;
|
|
1029
1040
|
};
|
|
1041
|
+
const routeLine = () => {
|
|
1042
|
+
const value = route();
|
|
1043
|
+
if (value === null) return null;
|
|
1044
|
+
return `Route ${fitRouteParts('Route', value.split(' · '), contentWidth())}`;
|
|
1045
|
+
};
|
|
1046
|
+
// The quota rows are sized to the sidebar's width so none of them wraps.
|
|
1047
|
+
// Layout reports the width during a render pass, so the signal is updated
|
|
1048
|
+
// afterwards rather than rebuilding rows mid-pass.
|
|
1049
|
+
const [contentWidth, setContentWidth] = createSignal(ASSUMED_CONTENT_WIDTH);
|
|
1050
|
+
let titleRow;
|
|
1051
|
+
const measureContentWidth = () => {
|
|
1052
|
+
const width = titleRow?.width;
|
|
1053
|
+
if (typeof width !== 'number' || width <= 0) return;
|
|
1054
|
+
queueMicrotask(() => {
|
|
1055
|
+
if (width !== contentWidth()) setContentWidth(width);
|
|
1056
|
+
});
|
|
1057
|
+
};
|
|
1030
1058
|
return (() => {
|
|
1031
1059
|
var _el$ = _$createElement("box"),
|
|
1032
|
-
_el$2 = _$createElement("
|
|
1033
|
-
_el$3 = _$createElement("
|
|
1060
|
+
_el$2 = _$createElement("box"),
|
|
1061
|
+
_el$3 = _$createElement("text"),
|
|
1062
|
+
_el$4 = _$createElement("b");
|
|
1034
1063
|
_$insertNode(_el$, _el$2);
|
|
1035
1064
|
_$setProp(_el$, "flexDirection", 'column');
|
|
1036
1065
|
_$setProp(_el$, "width", '100%');
|
|
1037
1066
|
_$insertNode(_el$2, _el$3);
|
|
1038
|
-
_$
|
|
1067
|
+
_$use(element => {
|
|
1068
|
+
titleRow = element;
|
|
1069
|
+
}, _el$2);
|
|
1070
|
+
_$setProp(_el$2, "onSizeChange", measureContentWidth);
|
|
1071
|
+
_$setProp(_el$2, "width", '100%');
|
|
1072
|
+
_$setProp(_el$2, "flexDirection", 'row');
|
|
1073
|
+
_$insertNode(_el$3, _el$4);
|
|
1074
|
+
_$insertNode(_el$4, _$createTextNode(`Antigravity`));
|
|
1039
1075
|
_$insert(_el$, _$createComponent(Show, {
|
|
1040
1076
|
get when() {
|
|
1041
1077
|
return props.view();
|
|
1042
1078
|
},
|
|
1043
1079
|
get fallback() {
|
|
1044
1080
|
return (() => {
|
|
1045
|
-
var _el$
|
|
1046
|
-
_$insertNode(_el$
|
|
1047
|
-
return _el$
|
|
1081
|
+
var _el$6 = _$createElement("text");
|
|
1082
|
+
_$insertNode(_el$6, _$createTextNode(`connecting…`));
|
|
1083
|
+
return _el$6;
|
|
1048
1084
|
})();
|
|
1049
1085
|
},
|
|
1050
1086
|
children: view => [_$createComponent(For, {
|
|
1051
1087
|
get each() {
|
|
1052
1088
|
return view().projected.accounts;
|
|
1053
1089
|
},
|
|
1054
|
-
children: account => (
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
_$setProp(_el$7, "width", '100%');
|
|
1064
|
-
_$insertNode(_el$8, _el$9);
|
|
1065
|
-
_$insertNode(_el$8, _el$0);
|
|
1066
|
-
_$setProp(_el$8, "flexDirection", 'row');
|
|
1067
|
-
_$setProp(_el$8, "justifyContent", 'space-between');
|
|
1068
|
-
_$setProp(_el$8, "width", '100%');
|
|
1069
|
-
_$insert(_el$9, () => account.label);
|
|
1070
|
-
_$insert(_el$0, () => account.status);
|
|
1071
|
-
_$insert(_el$7, _$createComponent(For, {
|
|
1072
|
-
get each() {
|
|
1073
|
-
return account.quota;
|
|
1090
|
+
children: (account, index) => _$createComponent(Show, {
|
|
1091
|
+
get when() {
|
|
1092
|
+
return view().accounts[index()];
|
|
1093
|
+
},
|
|
1094
|
+
children: source => _$createComponent(QuotaAccountBlock, {
|
|
1095
|
+
palette: HOST_COLORS,
|
|
1096
|
+
appearance: DEFAULT_QUOTA_APPEARANCE,
|
|
1097
|
+
get account() {
|
|
1098
|
+
return source();
|
|
1074
1099
|
},
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1100
|
+
get status() {
|
|
1101
|
+
return account.status;
|
|
1102
|
+
},
|
|
1103
|
+
get statusTone() {
|
|
1104
|
+
return account.statusTone;
|
|
1105
|
+
},
|
|
1106
|
+
now: () => view().readAt,
|
|
1107
|
+
width: contentWidth,
|
|
1108
|
+
get marginTop() {
|
|
1109
|
+
return index() === 0 ? 0 : 1;
|
|
1110
|
+
},
|
|
1111
|
+
get children() {
|
|
1112
|
+
var _el$8 = _$createElement("text");
|
|
1113
|
+
_$insert(_el$8, () => ` ${account.health}`);
|
|
1114
|
+
return _el$8;
|
|
1115
|
+
}
|
|
1116
|
+
})
|
|
1117
|
+
})
|
|
1092
1118
|
}), _$createComponent(Show, {
|
|
1093
1119
|
get when() {
|
|
1094
|
-
return
|
|
1120
|
+
return routeLine();
|
|
1095
1121
|
},
|
|
1096
1122
|
children: line => (() => {
|
|
1097
|
-
var _el$
|
|
1098
|
-
_$
|
|
1099
|
-
|
|
1123
|
+
var _el$9 = _$createElement("text");
|
|
1124
|
+
_$setProp(_el$9, "wrapMode", 'none');
|
|
1125
|
+
_$insert(_el$9, line);
|
|
1126
|
+
return _el$9;
|
|
1100
1127
|
})()
|
|
1101
1128
|
}), _$createComponent(For, {
|
|
1102
1129
|
get each() {
|
|
1103
1130
|
return view().projected.notices;
|
|
1104
1131
|
},
|
|
1105
1132
|
children: notice => (() => {
|
|
1106
|
-
var _el$
|
|
1107
|
-
_$insert(_el$
|
|
1108
|
-
return _el$
|
|
1133
|
+
var _el$0 = _$createElement("text");
|
|
1134
|
+
_$insert(_el$0, notice);
|
|
1135
|
+
return _el$0;
|
|
1109
1136
|
})()
|
|
1110
1137
|
})]
|
|
1111
1138
|
}), null);
|
|
@@ -1153,14 +1180,17 @@ export function setupGaTui(context, options = {}) {
|
|
|
1153
1180
|
const latest = new Map();
|
|
1154
1181
|
const showSnapshot = snapshot => {
|
|
1155
1182
|
latest.set(scopeKey(snapshot.scope), snapshot);
|
|
1183
|
+
const readAt = now();
|
|
1156
1184
|
setView({
|
|
1157
1185
|
scope: snapshot.scope,
|
|
1186
|
+
accounts: snapshot.accounts,
|
|
1158
1187
|
projected: projectSidebar({
|
|
1159
1188
|
accounts: snapshot.accounts,
|
|
1160
1189
|
route: snapshot.route,
|
|
1161
1190
|
status: snapshot.status,
|
|
1162
|
-
now:
|
|
1163
|
-
})
|
|
1191
|
+
now: readAt
|
|
1192
|
+
}),
|
|
1193
|
+
readAt
|
|
1164
1194
|
});
|
|
1165
1195
|
};
|
|
1166
1196
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function routeLineFits(label, value, width) {
|
|
2
|
+
return label.length + 1 + value.length <= width;
|
|
3
|
+
}
|
|
4
|
+
function fitPrimaryPart(value, maxWidth) {
|
|
5
|
+
if (value.length <= maxWidth)
|
|
6
|
+
return value;
|
|
7
|
+
if (maxWidth <= 0)
|
|
8
|
+
return "";
|
|
9
|
+
let fitted = "";
|
|
10
|
+
for (const word of value.trim().split(/\s+/)) {
|
|
11
|
+
const candidate = fitted ? `${fitted} ${word}` : word;
|
|
12
|
+
if (candidate.length > maxWidth) {
|
|
13
|
+
const marked = fitted ? `${fitted}\u2026` : "\u2026";
|
|
14
|
+
return marked.length <= maxWidth ? marked : fitted;
|
|
15
|
+
}
|
|
16
|
+
fitted = candidate;
|
|
17
|
+
}
|
|
18
|
+
return fitted;
|
|
19
|
+
}
|
|
20
|
+
export function fitRouteParts(label, parts, width) {
|
|
21
|
+
const [primary = "", ...optional] = parts;
|
|
22
|
+
let value = fitPrimaryPart(primary, width - label.length - 1);
|
|
23
|
+
for (const part of optional) {
|
|
24
|
+
const candidate = `${value} \xB7 ${part}`;
|
|
25
|
+
if (!routeLineFits(label, candidate, width))
|
|
26
|
+
break;
|
|
27
|
+
value = candidate;
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { quotaReadingParts } from "./98cc0c186c46c42d-quota-presentation.js";
|
|
2
2
|
export const QUOTA_POOL_LABELS = {
|
|
3
|
-
gemini: "
|
|
4
|
-
"non-gemini": "
|
|
3
|
+
gemini: "Gemini",
|
|
4
|
+
"non-gemini": "Other models"
|
|
5
5
|
};
|
|
6
6
|
const POOL_ORDER = ["gemini", "non-gemini"];
|
|
7
7
|
function clamp(value) {
|
|
@@ -63,8 +63,12 @@ export function quotaWindowName(limit) {
|
|
|
63
63
|
function clampPercent(remaining) {
|
|
64
64
|
return Math.min(100, Math.max(0, remaining));
|
|
65
65
|
}
|
|
66
|
+
/** A remaining percentage as the whole number every form shows. */
|
|
67
|
+
function wholePercent(remaining) {
|
|
68
|
+
return Math.round(clampPercent(remaining));
|
|
69
|
+
}
|
|
66
70
|
function percentLeft(remaining) {
|
|
67
|
-
return `${
|
|
71
|
+
return `${wholePercent(remaining)}% left`;
|
|
68
72
|
}
|
|
69
73
|
function resetDetails(resetsAt, checkedAt, now) {
|
|
70
74
|
const at = resetsAt === undefined ? Number.NaN : Date.parse(resetsAt);
|
|
@@ -98,6 +102,16 @@ function displayOrder(left, right) {
|
|
|
98
102
|
* and the optional age keep the shared formatter's wording.
|
|
99
103
|
*/
|
|
100
104
|
export function quotaWindowParts(quota, options) {
|
|
105
|
+
const { windows, age } = scopedWindowParts(quota, options);
|
|
106
|
+
const parts = windows.map(({ part }) => part);
|
|
107
|
+
return age === undefined ? { windows: parts } : { windows: parts, age };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* `quotaWindowParts` with each window's scope kept beside it. The narrow form
|
|
111
|
+
* needs the scope to name and pick model-scoped windows; the public parts do
|
|
112
|
+
* not carry it, so their shape stays as it was.
|
|
113
|
+
*/
|
|
114
|
+
function scopedWindowParts(quota, options) {
|
|
101
115
|
if (!quota)
|
|
102
116
|
return { windows: [] };
|
|
103
117
|
const { now } = options;
|
|
@@ -107,12 +121,15 @@ export function quotaWindowParts(quota, options) {
|
|
|
107
121
|
const windows = readings.map((limit) => {
|
|
108
122
|
const remainingPercent = clampPercent(limit.remainingPercent ?? 0);
|
|
109
123
|
return {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
124
|
+
scope: limit.scope,
|
|
125
|
+
part: {
|
|
126
|
+
kind: 'window',
|
|
127
|
+
name: quotaWindowName(limit),
|
|
128
|
+
figure: percentLeft(limit.remainingPercent ?? 0),
|
|
129
|
+
remainingPercent,
|
|
130
|
+
checkedAt: limit.checkedAt,
|
|
131
|
+
...resetDetails(limit.resetsAt, limit.checkedAt, now),
|
|
132
|
+
},
|
|
116
133
|
};
|
|
117
134
|
});
|
|
118
135
|
const budget = quota.budget;
|
|
@@ -124,32 +141,131 @@ export function quotaWindowParts(quota, options) {
|
|
|
124
141
|
? `credits ${percentLeft(remainingPercent)}`
|
|
125
142
|
: 'credits available';
|
|
126
143
|
windows.push({
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
144
|
+
scope: ALL_SCOPE,
|
|
145
|
+
spent: budget.reached,
|
|
146
|
+
part: {
|
|
147
|
+
kind: 'budget',
|
|
148
|
+
name: 'credits',
|
|
149
|
+
figure,
|
|
150
|
+
...(remainingPercent === undefined
|
|
151
|
+
? {}
|
|
152
|
+
: { remainingPercent: clampPercent(remainingPercent) }),
|
|
153
|
+
checkedAt: budget.checkedAt,
|
|
154
|
+
...resetDetails(budget.resetsAt, budget.checkedAt, now),
|
|
155
|
+
},
|
|
135
156
|
});
|
|
136
157
|
}
|
|
137
158
|
if (windows.length > 0) {
|
|
138
|
-
const age = now - Math.min(...windows.map((part) => part.checkedAt));
|
|
159
|
+
const age = now - Math.min(...windows.map(({ part }) => part.checkedAt));
|
|
139
160
|
if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
|
|
140
161
|
return { windows, age: `checked ${shortSpan(age)} ago` };
|
|
141
162
|
}
|
|
142
163
|
}
|
|
143
164
|
return { windows };
|
|
144
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Whether the reading is stale: true exactly when the compact and full forms
|
|
168
|
+
* would end with `checked … ago`. The narrow form leaves that age out to stay
|
|
169
|
+
* short, so a caller drawing a narrow line uses this to dim it instead.
|
|
170
|
+
*/
|
|
171
|
+
export function isQuotaStale(quota, options) {
|
|
172
|
+
return scopedWindowParts(quota, options).age !== undefined;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The model a scope names, as a display name: any namespace before a colon
|
|
176
|
+
* is dropped (`model:claude-opus-4` → `claude-opus-4`) and the first letter is
|
|
177
|
+
* capitalized (`fable` → `Fable`); the rest stays as written.
|
|
178
|
+
*/
|
|
179
|
+
function scopeDisplayName(scope) {
|
|
180
|
+
const model = scope.slice(scope.indexOf(':') + 1);
|
|
181
|
+
return model.charAt(0).toUpperCase() + model.slice(1);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Short names for the model scopes in one row: the first two letters of each
|
|
185
|
+
* display name. Names that would read the same for different models are each
|
|
186
|
+
* extended one letter at a time until they differ (`Fable` and `Fabric` read
|
|
187
|
+
* `Fabl` and `Fabr`); a name that runs out of letters stays whole.
|
|
188
|
+
*/
|
|
189
|
+
function scopeAbbreviations(scopes) {
|
|
190
|
+
const names = [...new Set(scopes.map(scopeDisplayName))];
|
|
191
|
+
const lengths = new Map(names.map((name) => [name, 2]));
|
|
192
|
+
const short = (name) => name.slice(0, lengths.get(name));
|
|
193
|
+
for (;;) {
|
|
194
|
+
const byShort = new Map();
|
|
195
|
+
for (const name of names) {
|
|
196
|
+
byShort.set(short(name), [...(byShort.get(short(name)) ?? []), name]);
|
|
197
|
+
}
|
|
198
|
+
let extended = false;
|
|
199
|
+
for (const group of byShort.values()) {
|
|
200
|
+
if (group.length < 2)
|
|
201
|
+
continue;
|
|
202
|
+
for (const name of group) {
|
|
203
|
+
const length = lengths.get(name) ?? 2;
|
|
204
|
+
if (length < name.length) {
|
|
205
|
+
lengths.set(name, length + 1);
|
|
206
|
+
extended = true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (!extended)
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
return new Map(scopes.map((scope) => [scope, short(scopeDisplayName(scope))]));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The narrow form's pieces: every account-wide window as `5h 92%`, then at
|
|
217
|
+
* most one more item, with ` left` added once to the last piece. That item is
|
|
218
|
+
* the tightest (least remaining) of the model-scoped windows and the credit
|
|
219
|
+
* budget, so the line stays bounded whatever the account carries: a scoped
|
|
220
|
+
* window reads under its short model name (`Fa 98%`), the budget as `cr 75%`
|
|
221
|
+
* (`cr 0%` when spent). On a tie a scoped window wins over the budget, and
|
|
222
|
+
* among scoped windows the first in display order wins. The choice depends
|
|
223
|
+
* only on the reading, never on a width. A budget without a percentage cannot
|
|
224
|
+
* be chosen; when nothing at all is shown it keeps its compact wording
|
|
225
|
+
* (`credits available`). No age is added; `isQuotaStale` says whether the
|
|
226
|
+
* reading is stale. A window whose reset arrived after the reading keeps its
|
|
227
|
+
* figure, as in the other forms.
|
|
228
|
+
*/
|
|
229
|
+
function narrowTextParts(quota, options) {
|
|
230
|
+
const { windows } = scopedWindowParts(quota, options);
|
|
231
|
+
const general = windows.filter(({ part, scope }) => part.kind === 'window' && scope === ALL_SCOPE);
|
|
232
|
+
const scoped = windows.filter(({ part, scope }) => part.kind === 'window' && scope !== ALL_SCOPE);
|
|
233
|
+
const abbreviations = scopeAbbreviations(scoped.map(({ scope }) => scope));
|
|
234
|
+
// The items competing for the one slot after the account-wide windows, in
|
|
235
|
+
// tie-break order: scoped windows in display order, then the budget. A
|
|
236
|
+
// spent budget counts as 0% left; one without a percentage cannot compete.
|
|
237
|
+
const budget = windows.find(({ part }) => part.kind === 'budget');
|
|
238
|
+
const budgetLeft = budget?.spent ? 0 : budget?.part.remainingPercent;
|
|
239
|
+
const extras = [
|
|
240
|
+
...scoped.map(({ scope, part }) => ({
|
|
241
|
+
label: abbreviations.get(scope) ?? scope,
|
|
242
|
+
remaining: part.remainingPercent ?? 0,
|
|
243
|
+
})),
|
|
244
|
+
...(budgetLeft === undefined
|
|
245
|
+
? []
|
|
246
|
+
: [{ label: 'cr', remaining: budgetLeft }]),
|
|
247
|
+
];
|
|
248
|
+
// Strictly lower wins, so on a tie the earlier item keeps the slot.
|
|
249
|
+
const tightest = extras.reduce((best, item) => best === undefined || item.remaining < best.remaining ? item : best, undefined);
|
|
250
|
+
const pieces = general.map(({ part }) => `${part.name} ${wholePercent(part.remainingPercent ?? 0)}%`);
|
|
251
|
+
if (tightest) {
|
|
252
|
+
pieces.push(`${tightest.label} ${wholePercent(tightest.remaining)}%`);
|
|
253
|
+
}
|
|
254
|
+
if (pieces.length === 0)
|
|
255
|
+
return windows.map(({ part }) => part.figure);
|
|
256
|
+
return pieces.map((piece, index) => index === pieces.length - 1 ? `${piece} left` : piece);
|
|
257
|
+
}
|
|
145
258
|
/**
|
|
146
259
|
* The pieces of a quota text, in order: one per reported window
|
|
147
260
|
* (`5h 58% left, resets 2h`), then the credit budget when there is one, then
|
|
148
261
|
* `checked 3h ago` when the oldest piece shown is stale. Empty when nothing
|
|
149
262
|
* was reported; `formatQuota` turns that into a sentence. A caller printing
|
|
150
|
-
* one line per window (the terminal auth menu) uses these directly.
|
|
263
|
+
* one line per window (the terminal auth menu) uses these directly. In the
|
|
264
|
+
* narrow form the pieces are the narrow line's (`5h 92%`, `7d 66% left`).
|
|
151
265
|
*/
|
|
152
266
|
export function quotaTextParts(quota, options) {
|
|
267
|
+
if (options.form === 'narrow')
|
|
268
|
+
return narrowTextParts(quota, options);
|
|
153
269
|
const parts = quotaWindowParts(quota, options);
|
|
154
270
|
const full = (options.form ?? 'full') === 'full';
|
|
155
271
|
const text = parts.windows.map((part) => {
|
|
@@ -160,7 +276,8 @@ export function quotaTextParts(quota, options) {
|
|
|
160
276
|
}
|
|
161
277
|
/**
|
|
162
278
|
* A row's quota as one line: `5h 58% left · 7d 90% left` in the compact
|
|
163
|
-
* form, with `, resets 2h` after each window in the full form
|
|
279
|
+
* form, with `, resets 2h` after each window in the full form, and
|
|
280
|
+
* `5h 58% · 7d 90% left` in the narrow form. With nothing
|
|
164
281
|
* reported it is `NO_QUOTA_READING`, or `NO_LIMITS_REPORTED` when the
|
|
165
282
|
* provider answered without a limit for any window.
|
|
166
283
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { quotaCodec } from "./ca21dc417b36dc5d-codec.js";
|
|
2
|
-
export { formatQuota, NO_LIMITS_REPORTED, NO_QUOTA_READING, QUOTA_STALE_AFTER_MS, quotaTextParts, quotaWindowName, quotaWindowParts, } from "./aef2402f8fc342f0-format.js";
|
|
2
|
+
export { formatQuota, isQuotaStale, NO_LIMITS_REPORTED, NO_QUOTA_READING, QUOTA_STALE_AFTER_MS, quotaTextParts, quotaWindowName, quotaWindowParts, } from "./aef2402f8fc342f0-format.js";
|
|
3
3
|
export { ALL_SCOPE, DEFAULT_REQUIRED_LABELS, decodeQuotaMap, emptyQuotaMap, isQuotaMap, } from "./77138df80c7ae006-map.js";
|
|
4
4
|
export { isQuotaObservation, mergeQuotaObservation, QuotaCodecError, } from "./ecc214300932dfb6-merge.js";
|
|
5
5
|
export { budgetExhaustedResetAt, futureResetAt, projectQuota, readsExhausted, } from "./1ff34afa7c42d196-projection.js";
|