zcode-acp-server 0.85.3 → 0.86.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/README.md +1 -1
- package/dist/bin/quota.d.ts +1 -1
- package/dist/bin/quota.d.ts.map +1 -1
- package/dist/bin/quota.js +5 -20
- package/dist/bin/quota.js.map +1 -1
- package/dist/code-fingerprint.json +2 -2
- package/dist/config/user-config.d.ts +0 -8
- package/dist/config/user-config.d.ts.map +1 -1
- package/dist/config/user-config.js +0 -2
- package/dist/config/user-config.js.map +1 -1
- package/dist/handlers/account.d.ts +3 -34
- package/dist/handlers/account.d.ts.map +1 -1
- package/dist/handlers/account.js +5 -38
- package/dist/handlers/account.js.map +1 -1
- package/dist/quota/combined.d.ts +1 -5
- package/dist/quota/combined.d.ts.map +1 -1
- package/dist/quota/combined.js +6 -24
- package/dist/quota/combined.js.map +1 -1
- package/dist/quota/format.d.ts +0 -9
- package/dist/quota/format.d.ts.map +1 -1
- package/dist/quota/format.js +0 -19
- package/dist/quota/format.js.map +1 -1
- package/dist/quota/live.d.ts.map +1 -1
- package/dist/quota/live.js +5 -12
- package/dist/quota/live.js.map +1 -1
- package/dist/remote/hub-server.d.ts.map +1 -1
- package/dist/remote/hub-server.js +3 -7
- package/dist/remote/hub-server.js.map +1 -1
- package/package.json +1 -1
- package/dist/quota/cliproxy/aggregate.d.ts +0 -48
- package/dist/quota/cliproxy/aggregate.d.ts.map +0 -1
- package/dist/quota/cliproxy/aggregate.js +0 -118
- package/dist/quota/cliproxy/aggregate.js.map +0 -1
- package/dist/quota/cliproxy/client.d.ts +0 -45
- package/dist/quota/cliproxy/client.d.ts.map +0 -1
- package/dist/quota/cliproxy/client.js +0 -140
- package/dist/quota/cliproxy/client.js.map +0 -1
- package/dist/quota/cliproxy/config.d.ts +0 -24
- package/dist/quota/cliproxy/config.d.ts.map +0 -1
- package/dist/quota/cliproxy/config.js +0 -27
- package/dist/quota/cliproxy/config.js.map +0 -1
- package/dist/quota/cliproxy/format.d.ts +0 -18
- package/dist/quota/cliproxy/format.d.ts.map +0 -1
- package/dist/quota/cliproxy/format.js +0 -71
- package/dist/quota/cliproxy/format.js.map +0 -1
- package/dist/quota/cliproxy/index.d.ts +0 -44
- package/dist/quota/cliproxy/index.d.ts.map +0 -1
- package/dist/quota/cliproxy/index.js +0 -148
- package/dist/quota/cliproxy/index.js.map +0 -1
- package/dist/quota/cliproxy/parse.d.ts +0 -46
- package/dist/quota/cliproxy/parse.d.ts.map +0 -1
- package/dist/quota/cliproxy/parse.js +0 -176
- package/dist/quota/cliproxy/parse.js.map +0 -1
- package/dist/quota/cliproxy/types.d.ts +0 -82
- package/dist/quota/cliproxy/types.d.ts.map +0 -1
- package/dist/quota/cliproxy/types.js +0 -33
- package/dist/quota/cliproxy/types.js.map +0 -1
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parsers for the two CLIProxyAPI response shapes. Both are reconstructed
|
|
3
|
-
* from the v8.0.28 source + CPAMC web-UI readers (undocumented on the wire) —
|
|
4
|
-
* every field is read defensively: missing/odd shapes degrade to empty, never
|
|
5
|
-
* throw. The management API accepts both camelCase and snake_case INPUT, but
|
|
6
|
-
* its OUTPUT spelling is not contractual, so both variants are read.
|
|
7
|
-
*/
|
|
8
|
-
/** Antigravity accounts' provider id in the credentials listing (CPAMC's own
|
|
9
|
-
* quota support is antigravity-only — there is no separate gemini provider). */
|
|
10
|
-
export const ANTIGRAVITY_PROVIDER = "antigravity";
|
|
11
|
-
function asRecord(v) {
|
|
12
|
-
return typeof v === "object" && v !== null && !Array.isArray(v)
|
|
13
|
-
? v
|
|
14
|
-
: null;
|
|
15
|
-
}
|
|
16
|
-
function str(v) {
|
|
17
|
-
return typeof v === "string" && v.trim().length > 0 ? v : undefined;
|
|
18
|
-
}
|
|
19
|
-
function num(v) {
|
|
20
|
-
return typeof v === "number" && Number.isFinite(v) ? v : undefined;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Parse the credentials listing. The response is an array of entries (the
|
|
24
|
-
* field-carrying object may nest one level under `auth_files`/`credentials`/
|
|
25
|
-
* `files` on some builds), each with `auth_index`/`authIndex` and
|
|
26
|
-
* `provider`. The Gemini quota relay needs the account's CloudCode project
|
|
27
|
-
* id: `file.project_id` → `metadata` → `attributes` → the entry itself
|
|
28
|
-
* (CPAMC's resolution ladder).
|
|
29
|
-
*/
|
|
30
|
-
export function parseCredentialEntries(text) {
|
|
31
|
-
let parsed;
|
|
32
|
-
try {
|
|
33
|
-
parsed = JSON.parse(text);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
let arr = Array.isArray(parsed) ? parsed : null;
|
|
39
|
-
if (!arr) {
|
|
40
|
-
const doc = asRecord(parsed);
|
|
41
|
-
if (doc) {
|
|
42
|
-
for (const key of ["auth_files", "credentials", "files", "data"]) {
|
|
43
|
-
if (Array.isArray(doc[key])) {
|
|
44
|
-
arr = doc[key];
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (!arr)
|
|
51
|
-
return [];
|
|
52
|
-
const entries = [];
|
|
53
|
-
for (const raw of arr) {
|
|
54
|
-
const e = asRecord(raw);
|
|
55
|
-
if (!e)
|
|
56
|
-
continue;
|
|
57
|
-
const authIndex = str(e.auth_index ?? e.authIndex ?? e.id);
|
|
58
|
-
const provider = str(e.provider ?? e.type) ?? "";
|
|
59
|
-
if (!authIndex)
|
|
60
|
-
continue;
|
|
61
|
-
const file = asRecord(e.file);
|
|
62
|
-
const metadata = asRecord(e.metadata);
|
|
63
|
-
const attributes = asRecord(e.attributes);
|
|
64
|
-
const email = str(file?.email) ?? str(metadata?.email) ?? str(attributes?.email) ?? str(e.email);
|
|
65
|
-
entries.push({
|
|
66
|
-
authIndex,
|
|
67
|
-
provider,
|
|
68
|
-
label: email ? email.split("@")[0] : authIndex,
|
|
69
|
-
projectId: str(file?.project_id ?? file?.projectId) ??
|
|
70
|
-
str(metadata?.project_id ?? metadata?.projectId) ??
|
|
71
|
-
str(attributes?.project_id ?? attributes?.projectId) ??
|
|
72
|
-
str(e.project_id ?? e.projectId),
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return entries;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Parse one relayed `retrieveUserQuotaSummary` body into per-family windowed
|
|
79
|
-
* rows.
|
|
80
|
-
*
|
|
81
|
-
* Shape (live-verified 2026-10, CPAMC `builders.ts`): `{groups: [{displayName,
|
|
82
|
-
* buckets: [{window, remainingFraction, resetTime, …}]}]}` — each group is a
|
|
83
|
-
* model family ("Gemini Models", "Claude and GPT models") with one bucket per
|
|
84
|
-
* window. Bucket `window` spellings normalize to `5h` / `week` (CPAMC's
|
|
85
|
-
* accepted spellings); buckets with an unknown window or an out-of-range
|
|
86
|
-
* fraction are dropped. Multiple buckets sharing a window keep the TIGHTEST.
|
|
87
|
-
* Missing/odd fields degrade to empty, never throw.
|
|
88
|
-
*/
|
|
89
|
-
export function parseQuotaSummary(bodyText) {
|
|
90
|
-
let parsed;
|
|
91
|
-
try {
|
|
92
|
-
parsed = JSON.parse(bodyText);
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
const doc = asRecord(parsed);
|
|
98
|
-
if (!doc || !Array.isArray(doc.groups))
|
|
99
|
-
return [];
|
|
100
|
-
const models = [];
|
|
101
|
-
for (const [index, gRaw] of doc.groups.entries()) {
|
|
102
|
-
const g = asRecord(gRaw);
|
|
103
|
-
if (!g)
|
|
104
|
-
continue;
|
|
105
|
-
const name = str(g.displayName ?? g.display_name) ?? `Quota Group ${index + 1}`;
|
|
106
|
-
// window → tightest bucket seen for it
|
|
107
|
-
const tightest = new Map();
|
|
108
|
-
if (Array.isArray(g.buckets)) {
|
|
109
|
-
for (const bRaw of g.buckets) {
|
|
110
|
-
const b = asRecord(bRaw);
|
|
111
|
-
if (!b)
|
|
112
|
-
continue;
|
|
113
|
-
const window = windowOf(b.window);
|
|
114
|
-
if (window === null)
|
|
115
|
-
continue;
|
|
116
|
-
const remaining = num(b.remainingFraction ?? b.remaining_fraction);
|
|
117
|
-
if (remaining === undefined || remaining < 0 || remaining > 1)
|
|
118
|
-
continue;
|
|
119
|
-
const used = 1 - remaining;
|
|
120
|
-
const prev = tightest.get(window);
|
|
121
|
-
if (prev && prev.used >= used)
|
|
122
|
-
continue;
|
|
123
|
-
const resetRaw = str(b.resetTime ?? b.reset_time);
|
|
124
|
-
const resetAt = resetRaw !== undefined ? Date.parse(resetRaw) : Number.NaN;
|
|
125
|
-
tightest.set(window, {
|
|
126
|
-
used,
|
|
127
|
-
...(Number.isFinite(resetAt) && { resetAt }),
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (tightest.size === 0)
|
|
132
|
-
continue;
|
|
133
|
-
models.push({ name, windows: orderWindows(tightest) });
|
|
134
|
-
}
|
|
135
|
-
return models;
|
|
136
|
-
}
|
|
137
|
-
/** Bucket window spellings → canonical window (mirrors CPAMC's
|
|
138
|
-
* `antigravityPeriodHours` accepted spellings; anything else is dropped). */
|
|
139
|
-
function windowOf(raw) {
|
|
140
|
-
const v = typeof raw === "string" ? raw.trim().toLowerCase() : "";
|
|
141
|
-
if (v === "5h" || v === "five-hour" || v === "five_hour")
|
|
142
|
-
return "5h";
|
|
143
|
-
if (v === "weekly" || v === "week")
|
|
144
|
-
return "week";
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
function orderWindows(tightest) {
|
|
148
|
-
const out = [];
|
|
149
|
-
for (const window of ["5h", "week"]) {
|
|
150
|
-
const hit = tightest.get(window);
|
|
151
|
-
if (hit)
|
|
152
|
-
out.push({ window, ...hit });
|
|
153
|
-
}
|
|
154
|
-
return out;
|
|
155
|
-
}
|
|
156
|
-
/** Convenience: the relay envelope's upstream status (200 unless malformed). */
|
|
157
|
-
export function relayUpstreamStatus(text) {
|
|
158
|
-
try {
|
|
159
|
-
const doc = asRecord(JSON.parse(text));
|
|
160
|
-
return num(doc?.status_code ?? doc?.statusCode) ?? 200;
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
return 200;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/** Convenience: the relay envelope's upstream body (a STRING inside). */
|
|
167
|
-
export function relayUpstreamBody(text) {
|
|
168
|
-
try {
|
|
169
|
-
const doc = asRecord(JSON.parse(text));
|
|
170
|
-
return str(doc?.body);
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
//# sourceMappingURL=parse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/quota/cliproxy/parse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;iFACiF;AACjF,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAElD,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAE,CAA6B;QAChC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,SAAS,GAAG,CAAC,CAAU;IACrB,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC;AAED,SAAS,GAAG,CAAC,CAAU;IACrB,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC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;QACjC,IAAI,GAAG;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACvC,OAAO,GAAG,CAAC,GAAG,EAAE,WAAW,IAAI,GAAG,EAAE,UAAU,CAAC,IAAI,GAAG,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACvC,OAAO,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the CLIProxyAPI quota feature.
|
|
3
|
-
*
|
|
4
|
-
* `zcode-acp quota cp` talks to a (typically REMOTE, user-deployed)
|
|
5
|
-
* CLIProxyAPI instance's management API — the same channel its management web
|
|
6
|
-
* UI uses (source-verified against CLIProxyAPI v8.0.28 + the CPAMC web UI,
|
|
7
|
-
* 2026-10-14; see `.zcode/scratch/research-cliproxyapi-quota.md`):
|
|
8
|
-
*
|
|
9
|
-
* 1. `GET /v8/management/credentials` (v8 spelling; v0 servers answer
|
|
10
|
-
* `GET /v0/management/auth-files`) — one entry per upstream OAuth
|
|
11
|
-
* account. Gemini accounts are provider `antigravity`.
|
|
12
|
-
* 2. For each Gemini account, `POST …/api-call` — a credential-scoped
|
|
13
|
-
* upstream call relay: the proxy substitutes `$TOKEN$` in the header
|
|
14
|
-
* with that account's OAuth token and forwards to
|
|
15
|
-
* `daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary`
|
|
16
|
-
* (CPAMC tries three URL variants in order). The response wraps the
|
|
17
|
-
* upstream body: `{status_code, header, body}` with `body` a STRING.
|
|
18
|
-
*
|
|
19
|
-
* The management key is a shared secret that can drive credential-bearing
|
|
20
|
-
* upstream calls — HTTPS is mandatory, never plain HTTP over a network.
|
|
21
|
-
*
|
|
22
|
-
* REFRESH CADENCE: the Gemini quota summary rides a Google INTERNAL endpoint
|
|
23
|
-
* with the account's own OAuth token, so every refresh is charged to that
|
|
24
|
-
* Google account. The orchestrator therefore caches for 5 MINUTES regardless
|
|
25
|
-
* of caller cadence (watch mode's 30s ticks included — they do not clear
|
|
26
|
-
* this cache), and the renderer stamps the section's age when serving
|
|
27
|
-
* cached values.
|
|
28
|
-
*
|
|
29
|
-
* Everything here is undocumented/best-effort: parse failures degrade to
|
|
30
|
-
* `unavailable`, never a crash.
|
|
31
|
-
*/
|
|
32
|
-
/** Canonical quota window — bucket spellings normalize to these at parse time. */
|
|
33
|
-
export type CpWindow = "5h" | "week";
|
|
34
|
-
/** One window of one model family. */
|
|
35
|
-
export interface CpWindowQuota {
|
|
36
|
-
window: CpWindow;
|
|
37
|
-
/** Used fraction [0, 1] — 1 minus the bucket's remainingFraction. */
|
|
38
|
-
used: number;
|
|
39
|
-
/** Reset moment of that window's tightest bucket (epoch ms), when reported. */
|
|
40
|
-
resetAt?: number;
|
|
41
|
-
}
|
|
42
|
-
/** One model family's quota rows — one per reported window. */
|
|
43
|
-
export interface CpModelQuota {
|
|
44
|
-
/** Family display name (e.g. "Gemini Models"). */
|
|
45
|
-
name: string;
|
|
46
|
-
/** Per-window rows, `5h` before `week`. */
|
|
47
|
-
windows: CpWindowQuota[];
|
|
48
|
-
}
|
|
49
|
-
/** One upstream account's quota block. */
|
|
50
|
-
export interface CpAccountQuota {
|
|
51
|
-
/** Short account label (email local-part, or the auth index). */
|
|
52
|
-
label: string;
|
|
53
|
-
/** Provider id from the credential entry — `antigravity` for Gemini. */
|
|
54
|
-
provider: string;
|
|
55
|
-
/** Per-model rows, tightest-first. Empty when the summary carried none. */
|
|
56
|
-
models: CpModelQuota[];
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Result of querying CLIProxyAPI — a 4-state sum type mirroring
|
|
60
|
-
* {@link ../ollama-cloud/types.js OcQueryResult}.
|
|
61
|
-
*
|
|
62
|
-
* `not_configured` = no URL/key resolved; the CLI silently skips the section
|
|
63
|
-
* in all-provider mode. `success` with zero accounts = reachable server, no
|
|
64
|
-
* Gemini accounts routed through it.
|
|
65
|
-
*/
|
|
66
|
-
export type CpQueryResult = {
|
|
67
|
-
kind: "success";
|
|
68
|
-
accounts: CpAccountQuota[];
|
|
69
|
-
fetchedAt: number;
|
|
70
|
-
} | {
|
|
71
|
-
kind: "not_configured";
|
|
72
|
-
} | {
|
|
73
|
-
kind: "auth_error";
|
|
74
|
-
} | {
|
|
75
|
-
kind: "unavailable";
|
|
76
|
-
};
|
|
77
|
-
/** Raw fetch result — status + body text (shared by both endpoints). */
|
|
78
|
-
export interface CpResponse {
|
|
79
|
-
status: number;
|
|
80
|
-
text: string;
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/quota/cliproxy/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,kFAAkF;AAClF,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAErC,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,QAAQ,CAAC;IACjB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,0CAA0C;AAC1C,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAE5B,wEAAwE;AACxE,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the CLIProxyAPI quota feature.
|
|
3
|
-
*
|
|
4
|
-
* `zcode-acp quota cp` talks to a (typically REMOTE, user-deployed)
|
|
5
|
-
* CLIProxyAPI instance's management API — the same channel its management web
|
|
6
|
-
* UI uses (source-verified against CLIProxyAPI v8.0.28 + the CPAMC web UI,
|
|
7
|
-
* 2026-10-14; see `.zcode/scratch/research-cliproxyapi-quota.md`):
|
|
8
|
-
*
|
|
9
|
-
* 1. `GET /v8/management/credentials` (v8 spelling; v0 servers answer
|
|
10
|
-
* `GET /v0/management/auth-files`) — one entry per upstream OAuth
|
|
11
|
-
* account. Gemini accounts are provider `antigravity`.
|
|
12
|
-
* 2. For each Gemini account, `POST …/api-call` — a credential-scoped
|
|
13
|
-
* upstream call relay: the proxy substitutes `$TOKEN$` in the header
|
|
14
|
-
* with that account's OAuth token and forwards to
|
|
15
|
-
* `daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary`
|
|
16
|
-
* (CPAMC tries three URL variants in order). The response wraps the
|
|
17
|
-
* upstream body: `{status_code, header, body}` with `body` a STRING.
|
|
18
|
-
*
|
|
19
|
-
* The management key is a shared secret that can drive credential-bearing
|
|
20
|
-
* upstream calls — HTTPS is mandatory, never plain HTTP over a network.
|
|
21
|
-
*
|
|
22
|
-
* REFRESH CADENCE: the Gemini quota summary rides a Google INTERNAL endpoint
|
|
23
|
-
* with the account's own OAuth token, so every refresh is charged to that
|
|
24
|
-
* Google account. The orchestrator therefore caches for 5 MINUTES regardless
|
|
25
|
-
* of caller cadence (watch mode's 30s ticks included — they do not clear
|
|
26
|
-
* this cache), and the renderer stamps the section's age when serving
|
|
27
|
-
* cached values.
|
|
28
|
-
*
|
|
29
|
-
* Everything here is undocumented/best-effort: parse failures degrade to
|
|
30
|
-
* `unavailable`, never a crash.
|
|
31
|
-
*/
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/quota/cliproxy/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG"}
|