@cortexkit/opencode-antigravity-auth 3.0.20 → 3.0.22
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 +354 -278
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +66 -21
- package/dist/index.js +841 -392
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +123 -28
- package/dist/server.js +860 -411
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/custody.js +25 -0
- package/dist/src/common-auth-embedded/claustrum/hub.js +20 -1
- package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
- package/dist/src/common-auth-embedded/fs/with-lock.js +37 -10
- package/dist/src/common-auth-embedded/quota/format.d.ts +9 -4
- package/dist/src/common-auth-embedded/quota/format.js +45 -26
- package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
- package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
- package/dist/src/common-auth-embedded/routing-accessor/index.js +128 -0
- package/dist/src/common-auth-embedded/source-output.json +69 -29
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +2 -2
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +2 -0
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +1 -0
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +6 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +89 -2
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +4 -0
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
- package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-routing-purpose.js +18 -0
- package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -0
- package/dist/src/plugin/shared/vault-routing.d.ts +36 -0
- package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-routing.js +213 -0
- package/dist/src/plugin/shared/vault-routing.js.map +1 -0
- package/dist/src/plugin/types.d.ts +1 -0
- package/dist/src/plugin/types.d.ts.map +1 -1
- package/dist/src/tui/quota-layout.d.ts +4 -58
- package/dist/src/tui/quota-layout.d.ts.map +1 -1
- package/dist/src/tui/quota-layout.js +4 -90
- package/dist/src/tui/quota-layout.js.map +1 -1
- package/dist/src/tui/sidebar-frame.d.ts +4 -34
- package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
- package/dist/src/tui/sidebar-frame.js +93 -167
- package/dist/src/tui/sidebar-frame.js.map +1 -1
- package/dist/src/tui.js +2 -2
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +31 -17
- package/dist/tui-ga-build-map.json +32 -17
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +9 -4
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +6 -0
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
- package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/vault-routing.d.ts +36 -0
- package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -0
- package/dist/types/src/plugin/types.d.ts +1 -0
- package/dist/types/src/plugin/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/custody.js +25 -0
- package/src/common-auth-embedded/claustrum/hub.js +20 -1
- package/src/common-auth-embedded/claustrum/insula.js +6 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
- package/src/common-auth-embedded/fs/with-lock.js +37 -10
- package/src/common-auth-embedded/quota/format.d.ts +9 -4
- package/src/common-auth-embedded/quota/format.js +45 -26
- package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
- package/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
- package/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
- package/src/common-auth-embedded/routing-accessor/index.js +128 -0
- package/src/common-auth-embedded/source-output.json +69 -29
- package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
- package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +683 -0
- package/src/tui-compiled/tui/quota-layout.js +5 -330
- package/src/tui-compiled/tui/sidebar-frame.js +243 -467
- package/src/tui-compiled/tui.js +2 -2
- package/src/tui-ga-compiled/host-ga.js +2 -2
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +243 -467
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
- package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +683 -0
- package/src/tui-ga-raw/host-ga.tsx +2 -2
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +214 -400
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
- package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +654 -0
- package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
- package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +654 -0
- package/src/tui-raw/tui/quota-layout.tsx +10 -301
- package/src/tui-raw/tui/sidebar-frame.tsx +214 -400
- package/src/tui-raw/tui.tsx +2 -2
- package/src/tui.tsx +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-routing-purpose.d.ts","sourceRoot":"","sources":["../../../../src/plugin/shared/vault-routing-purpose.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,2CACC,CAAA;AAE1C,wGAAwG;AACxG,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,IAExD,OAAO;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACvD,QAAQ;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,mBAQ9C;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAIT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const VAULT_ROUTING_PURPOSE_HEADER = 'x-antigravity-internal-request-purpose';
|
|
2
|
+
/** Only known agent turns positively identify primary work; unknown and maintenance agents stay out. */
|
|
3
|
+
export function createVaultRoutingHeaders(providerId) {
|
|
4
|
+
return async (input, output) => {
|
|
5
|
+
if (input.model.providerID !== providerId)
|
|
6
|
+
return;
|
|
7
|
+
output.headers[VAULT_ROUTING_PURPOSE_HEADER] =
|
|
8
|
+
input.agent === 'build' || input.agent === 'plan'
|
|
9
|
+
? 'primary'
|
|
10
|
+
: 'auxiliary';
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function isPrimaryVaultRequest(kind, headers) {
|
|
14
|
+
return kind === undefined
|
|
15
|
+
? new Headers(headers).get(VAULT_ROUTING_PURPOSE_HEADER) === 'primary'
|
|
16
|
+
: kind === 'primary';
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=vault-routing-purpose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-routing-purpose.js","sourceRoot":"","sources":["../../../../src/plugin/shared/vault-routing-purpose.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GACvC,wCAAwC,CAAA;AAE1C,wGAAwG;AACxG,MAAM,UAAU,yBAAyB,CAAC,UAAkB;IAC1D,OAAO,KAAK,EACV,KAAuD,EACvD,MAA2C,EAC3C,EAAE;QACF,IAAI,KAAK,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU;YAAE,OAAM;QACjD,MAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC;YAC1C,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;gBAC/C,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,WAAW,CAAA;IACnB,CAAC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAAwB,EACxB,OAAqB;IAErB,OAAO,IAAI,KAAK,SAAS;QACvB,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,4BAA4B,CAAC,KAAK,SAAS;QACtE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { QuotaGroup, QuotaGroupSummary } from '@cortexkit/antigravity-auth-core';
|
|
2
|
+
import { type RoutingCandidate, reportRouting } from '../../common-auth-embedded/routing-accessor/index.js';
|
|
3
|
+
export declare const ROUTING_GROUP_SCOPED_EXHAUSTION = false;
|
|
4
|
+
/** The bridge may arrive or disappear after plugin load; never cache its presence. */
|
|
5
|
+
export declare function hasVaultRoutingAccessor(): boolean;
|
|
6
|
+
export interface RoutingIdentity extends RoutingCandidate {
|
|
7
|
+
sessionId: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function routingQuotaScope(group: QuotaGroup, window: string): {
|
|
10
|
+
pool: 'gemini' | '3p' | 'gemini-argon';
|
|
11
|
+
limitWindow: 'five_hour' | 'seven_day';
|
|
12
|
+
} | undefined;
|
|
13
|
+
/** common-auth 0.33.0 carries pool separately from the window length; its routing relay translates 5h/7d. */
|
|
14
|
+
export declare function routingExhaustionFields(scope: NonNullable<ReturnType<typeof routingQuotaScope>>): {
|
|
15
|
+
pool: string;
|
|
16
|
+
window: '5h' | '7d';
|
|
17
|
+
};
|
|
18
|
+
/** A refusal alone does not establish exhaustion: large requests can fail while quota remains. */
|
|
19
|
+
export declare function reportVaultExhaustion(input: {
|
|
20
|
+
identity: RoutingIdentity;
|
|
21
|
+
status: number;
|
|
22
|
+
reason: string;
|
|
23
|
+
group: QuotaGroup;
|
|
24
|
+
quota?: QuotaGroupSummary;
|
|
25
|
+
observedAt?: number;
|
|
26
|
+
signal?: AbortSignal | null;
|
|
27
|
+
}, groupScopedExhaustion?: boolean, report?: typeof reportRouting): void;
|
|
28
|
+
export interface VaultUpstreamObservation {
|
|
29
|
+
response: Response;
|
|
30
|
+
completedSuccessfully(): boolean;
|
|
31
|
+
}
|
|
32
|
+
/** transformAntigravityResponse can stop at a finish reason before upstream EOF, hiding a later error. */
|
|
33
|
+
export declare function observeVaultUpstream(response: Response, signal?: AbortSignal | null): VaultUpstreamObservation | undefined;
|
|
34
|
+
/** Observe only the body the caller consumes; cancellation and failed reads never count as served. */
|
|
35
|
+
export declare function observeVaultServed(identity: RoutingIdentity, response: Response, signal?: AbortSignal | null, upstream?: VaultUpstreamObservation): Response;
|
|
36
|
+
//# sourceMappingURL=vault-routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-routing.d.ts","sourceRoot":"","sources":["../../../../src/plugin/shared/vault-routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU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AAE,WAAW,GAAG,IAAI,GAC1B,wBAAwB,GAAG,SAAS,CAUtC;AAED,sGAAsG;AACtG,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,EAC3B,QAAQ,CAAC,EAAE,wBAAwB,GAClC,QAAQ,CAkBV"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { reportRouting, } from '../../common-auth-embedded/routing-accessor/index.js';
|
|
2
|
+
// The external routing relay (THALAMUS) must forward the quota-group pool field
|
|
3
|
+
// before scoped exhaustion is enabled; losing it would block the whole account.
|
|
4
|
+
export const ROUTING_GROUP_SCOPED_EXHAUSTION = false;
|
|
5
|
+
/** The bridge may arrive or disappear after plugin load; never cache its presence. */
|
|
6
|
+
export function hasVaultRoutingAccessor() {
|
|
7
|
+
try {
|
|
8
|
+
return (typeof Reflect.get(globalThis, Symbol.for('cortexkit.routing')) ===
|
|
9
|
+
'function');
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function routingQuotaScope(group, window) {
|
|
16
|
+
const limitWindow = window === '5h'
|
|
17
|
+
? 'five_hour'
|
|
18
|
+
: window === 'weekly'
|
|
19
|
+
? 'seven_day'
|
|
20
|
+
: undefined;
|
|
21
|
+
return limitWindow
|
|
22
|
+
? { pool: group === 'non-gemini' ? '3p' : group, limitWindow }
|
|
23
|
+
: undefined;
|
|
24
|
+
}
|
|
25
|
+
/** common-auth 0.33.0 carries pool separately from the window length; its routing relay translates 5h/7d. */
|
|
26
|
+
export function routingExhaustionFields(scope) {
|
|
27
|
+
return {
|
|
28
|
+
pool: scope.pool,
|
|
29
|
+
window: scope.limitWindow === 'five_hour' ? '5h' : '7d',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** A refusal alone does not establish exhaustion: large requests can fail while quota remains. */
|
|
33
|
+
export function reportVaultExhaustion(input, groupScopedExhaustion = ROUTING_GROUP_SCOPED_EXHAUSTION, report = reportRouting) {
|
|
34
|
+
if (!hasVaultRoutingAccessor() ||
|
|
35
|
+
input.signal?.aborted ||
|
|
36
|
+
input.status !== 429 ||
|
|
37
|
+
input.reason !== 'QUOTA_EXHAUSTED' ||
|
|
38
|
+
!Number.isFinite(input.observedAt) ||
|
|
39
|
+
(input.observedAt ?? 0) <= 0 ||
|
|
40
|
+
(input.observedAt ?? Infinity) > Date.now())
|
|
41
|
+
return;
|
|
42
|
+
for (const window of input.quota?.windows ?? []) {
|
|
43
|
+
if (window.remainingFraction !== 0)
|
|
44
|
+
continue;
|
|
45
|
+
const scope = routingQuotaScope(input.group, window.window);
|
|
46
|
+
const resetsAt = Date.parse(window.resetTime);
|
|
47
|
+
if (!scope || !Number.isFinite(resetsAt) || resetsAt <= Date.now())
|
|
48
|
+
continue;
|
|
49
|
+
if (groupScopedExhaustion)
|
|
50
|
+
report({
|
|
51
|
+
...input.identity,
|
|
52
|
+
outcome: 'exhausted',
|
|
53
|
+
...routingExhaustionFields(scope),
|
|
54
|
+
resetsAt,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const RATE_LIMIT_HEADERS = [
|
|
59
|
+
'retry-after',
|
|
60
|
+
'retry-after-ms',
|
|
61
|
+
'ratelimit-limit',
|
|
62
|
+
'ratelimit-remaining',
|
|
63
|
+
'ratelimit-reset',
|
|
64
|
+
'ratelimit-policy',
|
|
65
|
+
'x-ratelimit-limit',
|
|
66
|
+
'x-ratelimit-remaining',
|
|
67
|
+
'x-ratelimit-reset',
|
|
68
|
+
'x-ratelimit-limit-requests',
|
|
69
|
+
'x-ratelimit-remaining-requests',
|
|
70
|
+
'x-ratelimit-reset-requests',
|
|
71
|
+
'x-ratelimit-limit-tokens',
|
|
72
|
+
'x-ratelimit-remaining-tokens',
|
|
73
|
+
'x-ratelimit-reset-tokens',
|
|
74
|
+
];
|
|
75
|
+
function streamFailure(value) {
|
|
76
|
+
if (!value || typeof value !== 'object')
|
|
77
|
+
return false;
|
|
78
|
+
if (Array.isArray(value))
|
|
79
|
+
return value.some(streamFailure);
|
|
80
|
+
const event = value;
|
|
81
|
+
return (event.error != null ||
|
|
82
|
+
event.type === 'error' ||
|
|
83
|
+
event.type === 'response.failed' ||
|
|
84
|
+
event.status === 'failed' ||
|
|
85
|
+
streamFailure(event.response));
|
|
86
|
+
}
|
|
87
|
+
/** transformAntigravityResponse can stop at a finish reason before upstream EOF, hiding a later error. */
|
|
88
|
+
export function observeVaultUpstream(response, signal) {
|
|
89
|
+
if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
|
|
90
|
+
return undefined;
|
|
91
|
+
let completed = false;
|
|
92
|
+
return {
|
|
93
|
+
response: observeBody(response, () => {
|
|
94
|
+
completed = !signal?.aborted;
|
|
95
|
+
}),
|
|
96
|
+
completedSuccessfully: () => completed,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Observe only the body the caller consumes; cancellation and failed reads never count as served. */
|
|
100
|
+
export function observeVaultServed(identity, response, signal, upstream) {
|
|
101
|
+
if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
|
|
102
|
+
return response;
|
|
103
|
+
const report = () => {
|
|
104
|
+
if (signal?.aborted ||
|
|
105
|
+
(upstream && !upstream.completedSuccessfully()) ||
|
|
106
|
+
!hasVaultRoutingAccessor())
|
|
107
|
+
return;
|
|
108
|
+
const headers = {};
|
|
109
|
+
for (const name of RATE_LIMIT_HEADERS) {
|
|
110
|
+
const value = response.headers.get(name);
|
|
111
|
+
if (value !== null)
|
|
112
|
+
headers[name] = value;
|
|
113
|
+
}
|
|
114
|
+
reportRouting({ ...identity, outcome: 'served', headers });
|
|
115
|
+
};
|
|
116
|
+
return observeBody(response, report);
|
|
117
|
+
}
|
|
118
|
+
function observeBody(response, complete) {
|
|
119
|
+
if (!response.body) {
|
|
120
|
+
complete();
|
|
121
|
+
return response;
|
|
122
|
+
}
|
|
123
|
+
const sse = response.headers
|
|
124
|
+
.get('content-type')
|
|
125
|
+
?.includes('text/event-stream');
|
|
126
|
+
const reader = response.body.getReader();
|
|
127
|
+
const decoder = new TextDecoder();
|
|
128
|
+
let pending = '';
|
|
129
|
+
let failed = false;
|
|
130
|
+
const inspect = (line) => {
|
|
131
|
+
if (line.length > 1024 * 1024) {
|
|
132
|
+
failed = true;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (line.startsWith('event:') && line.slice(6).trim() === 'error')
|
|
136
|
+
failed = true;
|
|
137
|
+
if (!line.startsWith('data:') ||
|
|
138
|
+
!/"(?:error|response.failed|failed)"/.test(line))
|
|
139
|
+
return;
|
|
140
|
+
try {
|
|
141
|
+
failed ||= streamFailure(JSON.parse(line.slice(5)));
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
failed = true;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const body = new ReadableStream({
|
|
148
|
+
async pull(controller) {
|
|
149
|
+
try {
|
|
150
|
+
const chunk = await reader.read();
|
|
151
|
+
if (chunk.done) {
|
|
152
|
+
if (sse)
|
|
153
|
+
inspect(pending + decoder.decode());
|
|
154
|
+
else if (/"(?:error|response.failed|failed)"/.test(pending)) {
|
|
155
|
+
try {
|
|
156
|
+
failed ||= streamFailure(JSON.parse(pending + decoder.decode()));
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
failed = true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!failed)
|
|
163
|
+
complete();
|
|
164
|
+
controller.close();
|
|
165
|
+
reader.releaseLock();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!failed) {
|
|
169
|
+
pending += decoder.decode(chunk.value, { stream: true });
|
|
170
|
+
if (sse) {
|
|
171
|
+
let newline = pending.indexOf('\n');
|
|
172
|
+
while (newline >= 0) {
|
|
173
|
+
inspect(pending.slice(0, newline));
|
|
174
|
+
pending = pending.slice(newline + 1);
|
|
175
|
+
newline = pending.indexOf('\n');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// A malformed, unbounded event cannot establish successful completion.
|
|
179
|
+
if (pending.length > 1024 * 1024) {
|
|
180
|
+
failed = true;
|
|
181
|
+
pending = '';
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
controller.enqueue(chunk.value);
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
failed = true;
|
|
188
|
+
controller.error(error);
|
|
189
|
+
reader.releaseLock();
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
async cancel(reason) {
|
|
193
|
+
failed = true;
|
|
194
|
+
try {
|
|
195
|
+
await reader.cancel(reason);
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
reader.releaseLock();
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
}, { highWaterMark: 0 });
|
|
202
|
+
const observed = new Response(body, {
|
|
203
|
+
status: response.status,
|
|
204
|
+
statusText: response.statusText,
|
|
205
|
+
headers: response.headers,
|
|
206
|
+
});
|
|
207
|
+
Object.defineProperties(observed, {
|
|
208
|
+
url: { value: response.url },
|
|
209
|
+
redirected: { value: response.redirected },
|
|
210
|
+
});
|
|
211
|
+
return observed;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=vault-routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-routing.js","sourceRoot":"","sources":["../../../../src/plugin/shared/vault-routing.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,aAAa,GACd,MAAM,sDAAsD,CAAA;AAE7D,gFAAgF;AAChF,gFAAgF;AAChF,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAA;AAEpD,sFAAsF;AACtF,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC;QACH,OAAO,CACL,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,C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,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;wBACjC,MAAM,GAAG,IAAI,CAAA;wBACb,OAAO,GAAG,EAAE,CAAA;oBACd,CAAC;gBACH,CAAC;gBACD,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACjC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,GAAG,IAAI,CAAA;gBACb,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBACvB,MAAM,CAAC,WAAW,EAAE,CAAA;YACtB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,MAAM;YACjB,MAAM,GAAG,IAAI,CAAA;YACb,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAC7B,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,WAAW,EAAE,CAAA;YACtB,CAAC;QACH,CAAC;KACF,EACD,EAAE,aAAa,EAAE,CAAC,EAAE,CACrB,CAAA;IACD,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE;QAClC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAC,CAAA;IACF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE;QAChC,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE;QAC5B,UAAU,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,UAAU,EAAE;KAC3C,CAAC,CAAA;IACF,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -32,5 +32,6 @@ export type PluginResult = {
|
|
|
32
32
|
event: NonNullable<Hooks['event']>;
|
|
33
33
|
dispose: NonNullable<Hooks['dispose']>;
|
|
34
34
|
'command.execute.before': NonNullable<Hooks['command.execute.before']>;
|
|
35
|
+
'chat.headers'?: Hooks['chat.headers'];
|
|
35
36
|
};
|
|
36
37
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,MAAM,EACN,KAAK,EACL,WAAW,EACX,cAAc,EACf,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE/D,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,GACb,MAAM,kCAAkC,CAAA;AAEzC,YAAY,EACV,QAAQ,EACR,eAAe,EACf,MAAM,EACN,KAAK,EACL,WAAW,EACX,cAAc,GACf,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAA;AAChD,MAAM,MAAM,aAAa,GAAG,WAAW,CAAA;AACvC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AACjC,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3E,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;AACpD,MAAM,MAAM,UAAU,GAAG,cAAc,CAAA;AAEvC,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAA;AAElC,MAAM,WAAW,YAAY;IAC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AC,CAAC,CAAA;IAClC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;IACtC,wBAAwB,EAAE,WAAW,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAA;IACtE,cAAc,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;CACvC,CAAA"}
|
|
@@ -1,38 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
* Quota layout shared by the OpenCode 1 sidebar (`tui.tsx`) and the OpenCode 2
|
|
4
|
-
* sidebar (`ga/tui/host-ga.tsx`): one account block with its header line, the
|
|
5
|
-
* reading age once per account, plain-word group headers and one width-fitted
|
|
6
|
-
* row per quota window.
|
|
7
|
-
*
|
|
8
|
-
* Each renderer supplies its own data source and colors. This module imports
|
|
9
|
-
* only the pure quota presentation helpers, so it stays inside both TUI
|
|
10
|
-
* import graphs: no sidebar file, preferences file, RPC, account store,
|
|
11
|
-
* OAuth, token or host SDK module, and nothing that writes to the terminal.
|
|
12
|
-
*/
|
|
13
|
-
import type { RGBA } from '@opentui/core';
|
|
14
|
-
import { type JSX } from 'solid-js';
|
|
1
|
+
/** Pure account-window inputs shared by the two sidebar hosts. */
|
|
2
|
+
import type { SidebarAppearance, Tone } from '../common-auth-embedded/quota-sidebar/index.js';
|
|
15
3
|
import { type QuotaReading, type QuotaWindowText } from '../quota-presentation.js';
|
|
16
|
-
export type
|
|
17
|
-
/** A text color; `undefined` leaves the host's default color in place. */
|
|
18
|
-
export type QuotaColor = string | RGBA | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* How a renderer colors the quota layout. OpenCode 1 maps these onto its live
|
|
21
|
-
* host theme; a renderer without a theme returns `undefined` everywhere.
|
|
22
|
-
*/
|
|
23
|
-
export interface QuotaPalette {
|
|
24
|
-
readonly text: () => QuotaColor;
|
|
25
|
-
readonly muted: () => QuotaColor;
|
|
26
|
-
readonly tone: (tone: QuotaTone) => QuotaColor;
|
|
27
|
-
}
|
|
28
|
-
/** The bar and threshold settings the layout reads. */
|
|
29
|
-
export interface QuotaAppearance {
|
|
30
|
-
readonly barWidth: number;
|
|
31
|
-
readonly barFilledChar: string;
|
|
32
|
-
readonly barEmptyChar: string;
|
|
33
|
-
readonly warnThreshold: number;
|
|
34
|
-
readonly errorThreshold: number;
|
|
35
|
-
}
|
|
4
|
+
export type QuotaAppearance = SidebarAppearance;
|
|
36
5
|
/**
|
|
37
6
|
* The OpenCode 1 preference defaults for the quota bar, for a renderer that
|
|
38
7
|
* has no preferences file. A test keeps it equal to `DEFAULT_PREFS.appearance`.
|
|
@@ -63,34 +32,11 @@ export interface QuotaLayoutAccount {
|
|
|
63
32
|
}
|
|
64
33
|
export declare const GROUP_NAMES: Record<QuotaGroupKey, string>;
|
|
65
34
|
export declare const QUOTA_ORDER: readonly QuotaGroupKey[];
|
|
66
|
-
export declare
|
|
67
|
-
export declare const ASSUMED_CONTENT_WIDTH = 28;
|
|
68
|
-
export declare function quotaTone(usedPct: number, appearance: QuotaAppearance): QuotaTone;
|
|
35
|
+
export declare function quotaTone(usedPct: number, appearance: QuotaAppearance): Tone;
|
|
69
36
|
export interface AccountWindow {
|
|
70
37
|
key: QuotaGroupKey;
|
|
71
38
|
reading: QuotaReading;
|
|
72
39
|
text: QuotaWindowText;
|
|
73
40
|
}
|
|
74
41
|
export declare function accountWindows(account: QuotaLayoutAccount, now: number): AccountWindow[];
|
|
75
|
-
export declare function showsFigure(window: AccountWindow): boolean;
|
|
76
|
-
export declare function fitLabel(label: string, max: number): string;
|
|
77
|
-
/**
|
|
78
|
-
* One account's quota block. The header line is the account label, the
|
|
79
|
-
* reading age when the oldest reading is stale, and the caller's status word
|
|
80
|
-
* right-aligned; the age moves to its own dim line when the three do not
|
|
81
|
-
* fit. Below it each quota group present gets a plain-word header and one
|
|
82
|
-
* row per window, or a single dim line when there is no reading at all.
|
|
83
|
-
* `children`, when given, render after the quota rows.
|
|
84
|
-
*/
|
|
85
|
-
export declare function QuotaAccountBlock(props: {
|
|
86
|
-
palette: QuotaPalette;
|
|
87
|
-
appearance: QuotaAppearance;
|
|
88
|
-
account: QuotaLayoutAccount;
|
|
89
|
-
status: string;
|
|
90
|
-
statusTone: QuotaTone;
|
|
91
|
-
now: () => number;
|
|
92
|
-
width: () => number;
|
|
93
|
-
marginTop?: number;
|
|
94
|
-
children?: JSX.Element;
|
|
95
|
-
}): JSX.Element;
|
|
96
42
|
//# sourceMappingURL=quota-layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-layout.d.ts","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"quota-layout.d.ts","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,KAAK,EACV,iBAAiB,EACjB,IAAI,EACL,MAAM,6CAA6C,CAAA;AACpD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EAErB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAA;AAE/C;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAMtC,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,YAAY,GAAG,cAAc,CAAA;AAEpE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAChD;AAED,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAA;QAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,gBAAgB,CAAA;QACxC,qEAAqE;QACrE,QAAQ,CAAC,cAAc,CAAC,EAAE,gBAAgB,CAAA;KAC3C,CAAA;CACF;AAGD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAIrD,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,SAAS,aAAa,EAI/C,CAAA;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI,CAI5E;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,aAAa,CAAA;IAClB,OAAO,EAAE,YAAY,CAAA;IACrB,IAAI,EAAE,eAAe,CAAA;CACtB;AAID,wBAAgB,cAAc,CAC5B,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,MAAM,GACV,aAAa,EAAE,CAwBjB"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { For, Show } from 'solid-js';
|
|
3
|
-
import { NO_QUOTA_READING, quotaReadingAge, quotaWindowText, } from '../quota-presentation';
|
|
1
|
+
import { quotaWindowText, } from '../quota-presentation';
|
|
4
2
|
/**
|
|
5
3
|
* The OpenCode 1 preference defaults for the quota bar, for a renderer that
|
|
6
4
|
* has no preferences file. A test keeps it equal to `DEFAULT_PREFS.appearance`.
|
|
@@ -23,33 +21,12 @@ export const QUOTA_ORDER = [
|
|
|
23
21
|
'non-gemini',
|
|
24
22
|
'gemini-argon',
|
|
25
23
|
];
|
|
26
|
-
// Shown instead of a stored figure once the window has reset since it was
|
|
27
|
-
// read: the stored figure describes the window before the reset.
|
|
28
|
-
export const RESET_SINCE_READING = 'reset since last check';
|
|
29
|
-
// Content width used until the first layout pass reports the real one. It
|
|
30
|
-
// fits the narrowest OpenCode sidebar.
|
|
31
|
-
export const ASSUMED_CONTENT_WIDTH = 28;
|
|
32
|
-
// A window row is `<name> <bar> <figure> <reset>`. The bar shrinks to this
|
|
33
|
-
// before the reset column is dropped; below it the bar is dropped too.
|
|
34
|
-
const MIN_BAR_WIDTH = 4;
|
|
35
|
-
// The widest figure the formatter writes: `100% left`.
|
|
36
|
-
const FIGURE_WIDTH = 9;
|
|
37
|
-
// A window name (`5h`, `7d`) and the space after it.
|
|
38
|
-
const NAME_WIDTH = 3;
|
|
39
24
|
export function quotaTone(usedPct, appearance) {
|
|
40
25
|
if (usedPct < appearance.warnThreshold)
|
|
41
|
-
return '
|
|
26
|
+
return 'success';
|
|
42
27
|
if (usedPct < appearance.errorThreshold)
|
|
43
|
-
return '
|
|
44
|
-
return '
|
|
45
|
-
}
|
|
46
|
-
function quotaBarSegments(remainingPct, width, appearance) {
|
|
47
|
-
const usedCells = Math.max(0, Math.min(Math.round((remainingPct / 100) * width), width));
|
|
48
|
-
const tone = quotaTone(100 - remainingPct, appearance);
|
|
49
|
-
return [
|
|
50
|
-
{ text: appearance.barFilledChar.repeat(usedCells), tone },
|
|
51
|
-
{ text: appearance.barEmptyChar.repeat(width - usedCells), tone },
|
|
52
|
-
].filter((segment) => segment.text.length > 0);
|
|
28
|
+
return 'warning';
|
|
29
|
+
return 'error';
|
|
53
30
|
}
|
|
54
31
|
// One entry per stored window, in group order. A pool stored before
|
|
55
32
|
// per-window readings existed contributes one window without a name.
|
|
@@ -78,67 +55,4 @@ export function accountWindows(account, now) {
|
|
|
78
55
|
}
|
|
79
56
|
return result;
|
|
80
57
|
}
|
|
81
|
-
// A window shows its figure only while no reset has happened since it was
|
|
82
|
-
// read and it has a read time at all.
|
|
83
|
-
export function showsFigure(window) {
|
|
84
|
-
return window.text.remaining != null && !window.text.resetSinceReading;
|
|
85
|
-
}
|
|
86
|
-
// Column widths for one `<name> <bar> <figure> <reset>` row within `width`
|
|
87
|
-
// cells. The bar shrinks first, down to MIN_BAR_WIDTH; then the reset column
|
|
88
|
-
// is dropped; when even that leaves less than MIN_BAR_WIDTH cells for the
|
|
89
|
-
// bar, the bar is left out and the row is just the name and figure.
|
|
90
|
-
function windowRowLayout(width, named, resetWidth, maxBar) {
|
|
91
|
-
const room = width - (named ? NAME_WIDTH : 0) - FIGURE_WIDTH;
|
|
92
|
-
if (resetWidth > 0) {
|
|
93
|
-
const bar = Math.min(maxBar, room - resetWidth - 2);
|
|
94
|
-
if (bar >= MIN_BAR_WIDTH)
|
|
95
|
-
return { bar, reset: true };
|
|
96
|
-
}
|
|
97
|
-
const bar = Math.min(maxBar, room - 1);
|
|
98
|
-
return { bar: bar >= MIN_BAR_WIDTH ? bar : 0, reset: false };
|
|
99
|
-
}
|
|
100
|
-
// Shorten a label to `max` cells, marking the cut with an ellipsis.
|
|
101
|
-
export function fitLabel(label, max) {
|
|
102
|
-
if (label.length <= max)
|
|
103
|
-
return label;
|
|
104
|
-
if (max <= 0)
|
|
105
|
-
return '';
|
|
106
|
-
if (max === 1)
|
|
107
|
-
return '…';
|
|
108
|
-
return `${label.slice(0, max - 1)}…`;
|
|
109
|
-
}
|
|
110
|
-
// One quota window on one line. The bar fills with remaining quota; the
|
|
111
|
-
// figure and reset come from the shared formatter. A window that reset since
|
|
112
|
-
// its reading shows that fact, dim, in place of the stale figure.
|
|
113
|
-
function WindowRow(props) {
|
|
114
|
-
const text = () => props.window.text;
|
|
115
|
-
const tone = () => quotaTone(100 - (text().remaining ?? 0), props.appearance);
|
|
116
|
-
return (_jsxs("box", { width: '100%', flexDirection: 'row', children: [_jsx(Show, { when: text().name !== '', children: _jsx("text", { width: NAME_WIDTH, flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: text().name }) }), _jsxs(Show, { when: showsFigure(props.window), fallback: _jsx("text", { flexShrink: 1, wrapMode: 'none', fg: props.palette.muted(), children: text().resetSinceReading ? RESET_SINCE_READING : text().figure }), children: [_jsx(Show, { when: props.layout.bar > 0, children: _jsx("box", { width: props.layout.bar + 1, flexShrink: 0, flexDirection: 'row', children: _jsx(For, { each: quotaBarSegments(text().remaining ?? 0, props.layout.bar, props.appearance), children: (segment) => (_jsx("text", { wrapMode: 'none', fg: props.palette.tone(segment.tone), children: segment.text })) }) }) }), _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.tone(tone()), children: text().figure }), _jsx("box", { flexGrow: 1 }), _jsx(Show, { when: props.layout.reset && text().reset !== '', children: _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: text().reset }) })] })] }));
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* One account's quota block. The header line is the account label, the
|
|
120
|
-
* reading age when the oldest reading is stale, and the caller's status word
|
|
121
|
-
* right-aligned; the age moves to its own dim line when the three do not
|
|
122
|
-
* fit. Below it each quota group present gets a plain-word header and one
|
|
123
|
-
* row per window, or a single dim line when there is no reading at all.
|
|
124
|
-
* `children`, when given, render after the quota rows.
|
|
125
|
-
*/
|
|
126
|
-
export function QuotaAccountBlock(props) {
|
|
127
|
-
const windows = () => accountWindows(props.account, props.now());
|
|
128
|
-
const age = () => quotaReadingAge(windows().map((window) => window.reading), props.now());
|
|
129
|
-
const ageInline = () => age() !== '' &&
|
|
130
|
-
props.account.label.length + 3 + age().length + 1 + props.status.length <=
|
|
131
|
-
props.width();
|
|
132
|
-
const label = () => fitLabel(props.account.label, props.width() - 1 - props.status.length);
|
|
133
|
-
// One reset column width per account, so bars line up across its rows.
|
|
134
|
-
const resetWidth = () => Math.max(0, ...windows()
|
|
135
|
-
.filter(showsFigure)
|
|
136
|
-
.map((window) => window.text.reset.length));
|
|
137
|
-
const layoutFor = (window) => windowRowLayout(props.width(), window.text.name !== '', resetWidth(), props.appearance.barWidth);
|
|
138
|
-
const groups = () => QUOTA_ORDER.map((key) => ({
|
|
139
|
-
key,
|
|
140
|
-
windows: windows().filter((window) => window.key === key),
|
|
141
|
-
})).filter((group) => group.windows.length > 0);
|
|
142
|
-
return (_jsxs("box", { width: '100%', flexDirection: 'column', marginTop: props.marginTop ?? 0, children: [_jsxs("box", { width: '100%', flexDirection: 'row', children: [_jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.text(), children: _jsx("b", { children: label() }) }), _jsx(Show, { when: ageInline(), children: _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: ` · ${age()}` }) }), _jsx("box", { flexGrow: 1 }), _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.tone(props.statusTone), children: _jsx("b", { children: props.status }) })] }), _jsx(Show, { when: age() !== '' && !ageInline(), children: _jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: age() }) }), _jsx(Show, { when: groups().length > 0, fallback: _jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: NO_QUOTA_READING }), children: _jsx(For, { each: groups(), children: (group) => (_jsxs(_Fragment, { children: [_jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: GROUP_NAMES[group.key] }), _jsx(For, { each: group.windows, children: (window) => (_jsx(WindowRow, { palette: props.palette, appearance: props.appearance, window: window, layout: layoutFor(window) })) })] })) }) }), props.children] }));
|
|
143
|
-
}
|
|
144
58
|
//# sourceMappingURL=quota-layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-layout.js","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-layout.js","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGL,eAAe,GAChB,MAAM,uBAAuB,CAAA;AAI9B;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACvD,QAAQ,EAAE,EAAE;I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AgB;oBACxC,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;iBAC3B;aACF,CAAA;QACP,KAAK,MAAM,OAAO,IAAI,QAAQ;YAC5B,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
|
-
/**
|
|
3
|
-
* The Antigravity sidebar frame, shared by the OpenCode 1 sidebar (`tui.tsx`)
|
|
4
|
-
* and the OpenCode 2 sidebar (`ga/tui/host-ga.tsx`): the padded
|
|
5
|
-
* panel, the clickable `▼`/`▶` header badge with the optional plugin version
|
|
6
|
-
* at the right, one line per account when collapsed, and the
|
|
7
|
-
* `Quota`, `Routing` and `Health` sections when expanded.
|
|
8
|
-
*
|
|
9
|
-
* Each renderer reads its own data source (the sidebar file, or the
|
|
10
|
-
* location's `state` answer), maps its own host theme onto `FrameTheme` and
|
|
11
|
-
* owns its own collapse state; everything drawn is decided here, so a change
|
|
12
|
-
* of shape is made once for both hosts.
|
|
13
|
-
*
|
|
14
|
-
* This module stays inside both TUI import graphs: besides Solid and
|
|
15
|
-
* OpenTUI it imports only the pure quota and sidebar-projection helpers and
|
|
16
|
-
* the shared layouts. No sidebar file, preferences file, RPC, account
|
|
17
|
-
* store, OAuth, token or host SDK module, no Node built-in, and nothing
|
|
18
|
-
* that writes to the terminal.
|
|
19
|
-
*/
|
|
2
|
+
/** Plugin-owned projection and Routing/Health sections for the shared quota frame. */
|
|
20
3
|
import type { RGBA } from '@opentui/core';
|
|
21
4
|
import { type JSX } from 'solid-js';
|
|
22
5
|
import { type ProjectedQuota } from '../common-auth-embedded/quota/index.js';
|
|
23
|
-
import { type QuotaAppearance, type QuotaLayoutAccount
|
|
24
|
-
type Tone = QuotaTone;
|
|
6
|
+
import { type QuotaAppearance, type QuotaLayoutAccount } from './quota-layout.js';
|
|
25
7
|
/** A theme color; `undefined` leaves the host's default color in place. */
|
|
26
8
|
export type FrameColor = string | RGBA | undefined;
|
|
27
9
|
/**
|
|
@@ -39,10 +21,9 @@ export interface FrameTheme {
|
|
|
39
21
|
readonly warning: FrameColor;
|
|
40
22
|
readonly error: FrameColor;
|
|
41
23
|
}
|
|
42
|
-
export declare function toneColor(theme: FrameTheme, tone: Tone): FrameColor;
|
|
43
|
-
export declare function themePalette(theme: () => FrameTheme): QuotaPalette;
|
|
44
24
|
/** The account fields the frame reads: the quota layout's plus the state. */
|
|
45
25
|
export interface FrameAccount extends QuotaLayoutAccount {
|
|
26
|
+
readonly id: string;
|
|
46
27
|
readonly enabled: boolean;
|
|
47
28
|
readonly current: boolean;
|
|
48
29
|
readonly cooldownUntil?: number;
|
|
@@ -76,16 +57,6 @@ export interface FrameSettings {
|
|
|
76
57
|
* `DEFAULT_PREFS`.
|
|
77
58
|
*/
|
|
78
59
|
export declare const DEFAULT_FRAME_SETTINGS: FrameSettings;
|
|
79
|
-
export declare function SectionHeader(props: {
|
|
80
|
-
theme: () => FrameTheme;
|
|
81
|
-
title: string;
|
|
82
|
-
}): JSX.Element;
|
|
83
|
-
export declare function StatRow(props: {
|
|
84
|
-
theme: () => FrameTheme;
|
|
85
|
-
label: string;
|
|
86
|
-
value: string;
|
|
87
|
-
tone?: Tone;
|
|
88
|
-
}): JSX.Element;
|
|
89
60
|
export declare function sidebarQuotaProjection(account: QuotaLayoutAccount, now: number): ProjectedQuota | undefined;
|
|
90
61
|
export interface SidebarFrameProps {
|
|
91
62
|
readonly theme: () => FrameTheme;
|
|
@@ -103,6 +74,5 @@ export interface SidebarFrameProps {
|
|
|
103
74
|
readonly lastError: () => string | null | undefined;
|
|
104
75
|
readonly now: () => number;
|
|
105
76
|
}
|
|
106
|
-
export declare function
|
|
107
|
-
export {};
|
|
77
|
+
export declare function AntigravitySidebar(props: SidebarFrameProps): JSX.Element;
|
|
108
78
|
//# sourceMappingURL=sidebar-frame.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-frame.d.ts","sourceRoot":"","sources":["../../../src/tui/sidebar-frame.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC
|
|
1
|
+
{"version":3,"file":"sidebar-frame.d.ts","sourceRoot":"","sources":["../../../src/tui/sidebar-frame.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,sFAAsF;AAEtF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAiC,KAAK,GAAG,EAAQ,MAAM,UAAU,CAAA;AAExE,OAAO,EAIL,KAAK,cAAc,EAEpB,MAAM,wCAAwC,CAAA;AAU/C,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAExB,MAAM,gBAAgB,CAAA;AAKvB,2EAA2E;AAC3E,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAElD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IAC/B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAC3B;AAID,6EAA6E;AAC7E,MAAM,WAAW,YAAa,SAAQ,kBAAkB;IACtD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,Q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