opencode-quotas 0.0.1
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 +344 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +42 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/constants.d.ts +9 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +15 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/defaults.d.ts +3 -0
- package/dist/src/defaults.d.ts.map +1 -0
- package/dist/src/defaults.js +52 -0
- package/dist/src/defaults.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +265 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces.d.ts +197 -0
- package/dist/src/interfaces.d.ts.map +1 -0
- package/dist/src/interfaces.js +2 -0
- package/dist/src/interfaces.js.map +1 -0
- package/dist/src/logger.d.ts +14 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +44 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/plugin-state.d.ts +20 -0
- package/dist/src/plugin-state.d.ts.map +1 -0
- package/dist/src/plugin-state.js +53 -0
- package/dist/src/plugin-state.js.map +1 -0
- package/dist/src/providers/antigravity/auth.d.ts +12 -0
- package/dist/src/providers/antigravity/auth.d.ts.map +1 -0
- package/dist/src/providers/antigravity/auth.js +109 -0
- package/dist/src/providers/antigravity/auth.js.map +1 -0
- package/dist/src/providers/antigravity/index.d.ts +2 -0
- package/dist/src/providers/antigravity/index.d.ts.map +1 -0
- package/dist/src/providers/antigravity/index.js +2 -0
- package/dist/src/providers/antigravity/index.js.map +1 -0
- package/dist/src/providers/antigravity/provider.d.ts +34 -0
- package/dist/src/providers/antigravity/provider.d.ts.map +1 -0
- package/dist/src/providers/antigravity/provider.js +216 -0
- package/dist/src/providers/antigravity/provider.js.map +1 -0
- package/dist/src/providers/codex.d.ts +4 -0
- package/dist/src/providers/codex.d.ts.map +1 -0
- package/dist/src/providers/codex.js +242 -0
- package/dist/src/providers/codex.js.map +1 -0
- package/dist/src/providers/github.d.ts +4 -0
- package/dist/src/providers/github.d.ts.map +1 -0
- package/dist/src/providers/github.js +139 -0
- package/dist/src/providers/github.js.map +1 -0
- package/dist/src/quota-cache.d.ts +26 -0
- package/dist/src/quota-cache.d.ts.map +1 -0
- package/dist/src/quota-cache.js +107 -0
- package/dist/src/quota-cache.js.map +1 -0
- package/dist/src/registry.d.ts +3 -0
- package/dist/src/registry.d.ts.map +1 -0
- package/dist/src/registry.js +23 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/services/aggregation-service.d.ts +34 -0
- package/dist/src/services/aggregation-service.d.ts.map +1 -0
- package/dist/src/services/aggregation-service.js +89 -0
- package/dist/src/services/aggregation-service.js.map +1 -0
- package/dist/src/services/config-loader.d.ts +25 -0
- package/dist/src/services/config-loader.d.ts.map +1 -0
- package/dist/src/services/config-loader.js +105 -0
- package/dist/src/services/config-loader.js.map +1 -0
- package/dist/src/services/history-service.d.ts +15 -0
- package/dist/src/services/history-service.d.ts.map +1 -0
- package/dist/src/services/history-service.js +99 -0
- package/dist/src/services/history-service.js.map +1 -0
- package/dist/src/services/prediction-engine.d.ts +47 -0
- package/dist/src/services/prediction-engine.d.ts.map +1 -0
- package/dist/src/services/prediction-engine.js +94 -0
- package/dist/src/services/prediction-engine.js.map +1 -0
- package/dist/src/services/quota-service.d.ts +41 -0
- package/dist/src/services/quota-service.d.ts.map +1 -0
- package/dist/src/services/quota-service.js +257 -0
- package/dist/src/services/quota-service.js.map +1 -0
- package/dist/src/tools/quotas.d.ts +11 -0
- package/dist/src/tools/quotas.d.ts.map +1 -0
- package/dist/src/tools/quotas.js +62 -0
- package/dist/src/tools/quotas.js.map +1 -0
- package/dist/src/ui/progress-bar.d.ts +20 -0
- package/dist/src/ui/progress-bar.d.ts.map +1 -0
- package/dist/src/ui/progress-bar.js +150 -0
- package/dist/src/ui/progress-bar.js.map +1 -0
- package/dist/src/ui/quota-table.d.ts +15 -0
- package/dist/src/ui/quota-table.d.ts.map +1 -0
- package/dist/src/ui/quota-table.js +136 -0
- package/dist/src/ui/quota-table.js.map +1 -0
- package/dist/src/utils/debug.d.ts +1 -0
- package/dist/src/utils/debug.d.ts.map +1 -0
- package/dist/src/utils/debug.js +3 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/paths.d.ts +7 -0
- package/dist/src/utils/paths.d.ts.map +1 -0
- package/dist/src/utils/paths.js +37 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/time.d.ts +3 -0
- package/dist/src/utils/time.d.ts.map +1 -0
- package/dist/src/utils/time.js +38 -0
- package/dist/src/utils/time.js.map +1 -0
- package/dist/src/utils/validation.d.ts +6 -0
- package/dist/src/utils/validation.d.ts.map +1 -0
- package/dist/src/utils/validation.js +66 -0
- package/dist/src/utils/validation.js.map +1 -0
- package/package.json +42 -0
- package/src/cli.ts +53 -0
- package/src/constants.ts +17 -0
- package/src/defaults.ts +53 -0
- package/src/index.ts +338 -0
- package/src/interfaces.ts +258 -0
- package/src/logger.ts +55 -0
- package/src/plugin-state.ts +65 -0
- package/src/providers/antigravity/auth.ts +163 -0
- package/src/providers/antigravity/index.ts +1 -0
- package/src/providers/antigravity/provider.ts +337 -0
- package/src/providers/codex.ts +327 -0
- package/src/providers/github.ts +161 -0
- package/src/quota-cache.ts +157 -0
- package/src/registry.ts +30 -0
- package/src/services/aggregation-service.ts +116 -0
- package/src/services/config-loader.ts +124 -0
- package/src/services/history-service.ts +116 -0
- package/src/services/prediction-engine.ts +133 -0
- package/src/services/quota-service.ts +343 -0
- package/src/tools/quotas.ts +78 -0
- package/src/ui/progress-bar.ts +204 -0
- package/src/ui/quota-table.ts +173 -0
- package/src/utils/debug.ts +1 -0
- package/src/utils/paths.ts +41 -0
- package/src/utils/time.ts +40 -0
- package/src/utils/validation.ts +63 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { QuotaService } from "./services/quota-service";
|
|
2
|
+
import { HistoryService } from "./services/history-service";
|
|
3
|
+
import { renderQuotaTable } from "./ui/quota-table";
|
|
4
|
+
import { QuotaCache } from "./quota-cache";
|
|
5
|
+
import { PLUGIN_FOOTER_SIGNATURE, REASONING_PATTERNS, SKIP_REASONS, } from "./constants";
|
|
6
|
+
import { logger } from "./logger";
|
|
7
|
+
import { getPluginState } from "./plugin-state";
|
|
8
|
+
import { createQuotaTool } from "./tools/quotas";
|
|
9
|
+
/**
|
|
10
|
+
* QuotaHub Plugin for OpenCode.ai
|
|
11
|
+
*/
|
|
12
|
+
export const QuotaHubPlugin = async ({ client, $, directory }) => {
|
|
13
|
+
const state = getPluginState();
|
|
14
|
+
const historyService = new HistoryService();
|
|
15
|
+
const quotaService = new QuotaService();
|
|
16
|
+
let quotaCache;
|
|
17
|
+
let initPromise;
|
|
18
|
+
// Dedicated initialization function
|
|
19
|
+
const ensureInit = async () => {
|
|
20
|
+
if (initPromise)
|
|
21
|
+
return initPromise;
|
|
22
|
+
initPromise = (async () => {
|
|
23
|
+
try {
|
|
24
|
+
await historyService.init();
|
|
25
|
+
await quotaService.init(directory, historyService);
|
|
26
|
+
const config = quotaService.getConfig();
|
|
27
|
+
const providers = quotaService.getProviders();
|
|
28
|
+
logger.debug("init:providers", {
|
|
29
|
+
ids: providers.map((p) => p.id),
|
|
30
|
+
count: providers.length,
|
|
31
|
+
});
|
|
32
|
+
quotaCache = new QuotaCache(providers, {
|
|
33
|
+
refreshIntervalMs: config.pollingInterval ?? 60_000,
|
|
34
|
+
historyService,
|
|
35
|
+
debug: !!config.debug,
|
|
36
|
+
});
|
|
37
|
+
quotaCache.start();
|
|
38
|
+
logger.debug("init:complete");
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.error("Failed to initialize QuotaHubPlugin:", e);
|
|
42
|
+
// Keep the promise but it failed. Future calls will see it as failed.
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
return initPromise;
|
|
47
|
+
};
|
|
48
|
+
// Trigger background initialization
|
|
49
|
+
ensureInit().catch(() => { });
|
|
50
|
+
const hooks = {
|
|
51
|
+
/**
|
|
52
|
+
* The platform calls this hook after a text generation is complete.
|
|
53
|
+
* We use it to append quota information to the end of the final assistant message.
|
|
54
|
+
*/
|
|
55
|
+
"experimental.text.complete": async (input, output) => {
|
|
56
|
+
// Ensure initialization is complete before processing
|
|
57
|
+
await ensureInit().catch((e) => {
|
|
58
|
+
logger.error("init:error", { error: e });
|
|
59
|
+
});
|
|
60
|
+
if (!quotaCache) {
|
|
61
|
+
const config = quotaService.getConfig();
|
|
62
|
+
if (config.debug)
|
|
63
|
+
logger.debug("hook:no_cache", {
|
|
64
|
+
messageID: input.messageID,
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const cache = quotaCache;
|
|
69
|
+
const config = quotaService.getConfig();
|
|
70
|
+
const debugLog = (msg, data) => {
|
|
71
|
+
if (config.debug)
|
|
72
|
+
logger.debug(msg, data);
|
|
73
|
+
};
|
|
74
|
+
if (config.footer === false) {
|
|
75
|
+
debugLog("skip:footer_disabled", {
|
|
76
|
+
messageID: input.messageID,
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Log hook invocation
|
|
81
|
+
debugLog("hook:experimental.text.complete", {
|
|
82
|
+
input,
|
|
83
|
+
processed: state.isProcessed(input.messageID),
|
|
84
|
+
});
|
|
85
|
+
// Fast path check
|
|
86
|
+
if (state.isProcessed(input.messageID)) {
|
|
87
|
+
debugLog("skip:already_processed", {
|
|
88
|
+
messageID: input.messageID,
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Secondary safeguard: check if footer already present
|
|
93
|
+
if (output.text.includes(PLUGIN_FOOTER_SIGNATURE)) {
|
|
94
|
+
debugLog(SKIP_REASONS.FOOTER_PRESENT, {
|
|
95
|
+
messageID: input.messageID,
|
|
96
|
+
});
|
|
97
|
+
state.markProcessed(input.messageID);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
debugLog("lock:acquire_start", { messageID: input.messageID });
|
|
101
|
+
// Acquire lock for this message
|
|
102
|
+
const release = await state.acquireLock(input.messageID);
|
|
103
|
+
debugLog("lock:acquired", { messageID: input.messageID });
|
|
104
|
+
try {
|
|
105
|
+
// After acquiring lock, re-check if processed
|
|
106
|
+
if (state.isProcessed(input.messageID)) {
|
|
107
|
+
debugLog("skip:already_processed_after_lock", {
|
|
108
|
+
messageID: input.messageID,
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// Double-check text content in case another process injected it while we waited for lock
|
|
113
|
+
if (output.text.includes(PLUGIN_FOOTER_SIGNATURE)) {
|
|
114
|
+
debugLog("skip:footer_present_after_lock", {
|
|
115
|
+
messageID: input.messageID,
|
|
116
|
+
});
|
|
117
|
+
state.markProcessed(input.messageID);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Fetch message to check role
|
|
121
|
+
const { data: result } = await client.session.message({
|
|
122
|
+
path: {
|
|
123
|
+
id: input.sessionID,
|
|
124
|
+
messageID: input.messageID,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
if (!result || result.info.role !== "assistant") {
|
|
128
|
+
debugLog("skip:not_assistant", {
|
|
129
|
+
messageID: input.messageID,
|
|
130
|
+
role: result?.info?.role,
|
|
131
|
+
});
|
|
132
|
+
state.markProcessed(input.messageID);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const assistantMsg = result.info;
|
|
136
|
+
// Mark as processed as soon as we've identified it's an assistant message
|
|
137
|
+
// We do this before the quota check to avoid race conditions if no quotas are found.
|
|
138
|
+
state.markProcessed(input.messageID);
|
|
139
|
+
// Log message details
|
|
140
|
+
debugLog("message:details", {
|
|
141
|
+
id: input.messageID,
|
|
142
|
+
mode: assistantMsg.mode,
|
|
143
|
+
tokens: assistantMsg.tokens,
|
|
144
|
+
type: assistantMsg.type,
|
|
145
|
+
modelID: assistantMsg.modelID,
|
|
146
|
+
providerID: assistantMsg.providerID,
|
|
147
|
+
});
|
|
148
|
+
// Skip if it's a subagent mode (thinking step), unless it's a whitelisted agent (plan/build)
|
|
149
|
+
if (assistantMsg.mode === "subagent") {
|
|
150
|
+
let allowed = false;
|
|
151
|
+
if (assistantMsg.parentID) {
|
|
152
|
+
try {
|
|
153
|
+
const { data: parentResult } = await client.session.message({
|
|
154
|
+
path: {
|
|
155
|
+
id: input.sessionID,
|
|
156
|
+
messageID: assistantMsg.parentID,
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
if (parentResult?.info?.role === "user") {
|
|
160
|
+
const userMsg = parentResult.info;
|
|
161
|
+
// Allow plan and build agents even in subagent mode
|
|
162
|
+
if (["plan", "build"].includes(userMsg.agent)) {
|
|
163
|
+
allowed = true;
|
|
164
|
+
debugLog("allow:subagent_exception", {
|
|
165
|
+
agent: userMsg.agent,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
debugLog("error:check_parent_agent", e);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (!allowed) {
|
|
175
|
+
debugLog(SKIP_REASONS.SUBAGENT);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Skip reasoning messages (explicit mode or type)
|
|
180
|
+
if (assistantMsg.mode === "reasoning" ||
|
|
181
|
+
assistantMsg.type === "reasoning") {
|
|
182
|
+
debugLog(SKIP_REASONS.REASONING);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// Skip if it appears to be a reasoning-only message based on tokens
|
|
186
|
+
const reasoningTokens = assistantMsg.tokens?.reasoning ?? 0;
|
|
187
|
+
const outputTokens = assistantMsg.tokens?.output ?? 0;
|
|
188
|
+
if (assistantMsg.tokens &&
|
|
189
|
+
reasoningTokens > 0 &&
|
|
190
|
+
(outputTokens === 0 || outputTokens === reasoningTokens)) {
|
|
191
|
+
debugLog(SKIP_REASONS.REASONING, assistantMsg.tokens);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
// Heuristic: Check if text starts with "Thinking:" or similar
|
|
195
|
+
const trimmedText = output.text.trim();
|
|
196
|
+
for (const pattern of REASONING_PATTERNS) {
|
|
197
|
+
if (pattern.test(trimmedText)) {
|
|
198
|
+
debugLog(SKIP_REASONS.REASONING, {
|
|
199
|
+
pattern: pattern.toString(),
|
|
200
|
+
});
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const snapshot = cache.getSnapshot();
|
|
205
|
+
const rawResults = snapshot.data;
|
|
206
|
+
debugLog("cache:snapshot", {
|
|
207
|
+
fetchedAt: snapshot.fetchedAt?.toISOString(),
|
|
208
|
+
totalCount: rawResults.length,
|
|
209
|
+
hasError: !!snapshot.lastError,
|
|
210
|
+
});
|
|
211
|
+
if (rawResults.length === 0) {
|
|
212
|
+
debugLog("skip:no_cached_quotas", {
|
|
213
|
+
fetchedAt: snapshot.fetchedAt?.toISOString(),
|
|
214
|
+
lastError: snapshot.lastError,
|
|
215
|
+
});
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// Process (filter, sort) using the shared service
|
|
219
|
+
const filteredResults = quotaService.processQuotas(rawResults, {
|
|
220
|
+
providerId: assistantMsg.providerID,
|
|
221
|
+
modelId: assistantMsg.modelID,
|
|
222
|
+
});
|
|
223
|
+
debugLog("quotas:processed", {
|
|
224
|
+
before: rawResults.length,
|
|
225
|
+
after: filteredResults.length,
|
|
226
|
+
providerId: assistantMsg.providerID,
|
|
227
|
+
modelId: assistantMsg.modelID,
|
|
228
|
+
});
|
|
229
|
+
if (filteredResults.length === 0) {
|
|
230
|
+
debugLog("skip:all_quotas_filtered", {
|
|
231
|
+
providerId: assistantMsg.providerID,
|
|
232
|
+
modelId: assistantMsg.modelID,
|
|
233
|
+
});
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const lines = renderQuotaTable(filteredResults, {
|
|
237
|
+
progressBarConfig: config.progressBar,
|
|
238
|
+
tableConfig: config.table,
|
|
239
|
+
}).map((l) => l.line);
|
|
240
|
+
// Append to message text
|
|
241
|
+
const showMode = config.progressBar?.show ?? "used";
|
|
242
|
+
const modeLabel = showMode === "available" ? "(Remaining)" : "(Used)";
|
|
243
|
+
// Build visible header only if enabled in config
|
|
244
|
+
const showTitle = config.showFooterTitle !== false;
|
|
245
|
+
const titleText = showTitle
|
|
246
|
+
? `${PLUGIN_FOOTER_SIGNATURE} ${modeLabel}_\n`
|
|
247
|
+
: "";
|
|
248
|
+
// Append table lines (no invisible marker)
|
|
249
|
+
output.text += "\n\n" + titleText + lines.join("\n");
|
|
250
|
+
debugLog("inject:footer", {
|
|
251
|
+
messageID: input.messageID,
|
|
252
|
+
lines: lines.length,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
finally {
|
|
256
|
+
debugLog("lock:release", { messageID: input.messageID });
|
|
257
|
+
release();
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
// Create the quota tool that can be called by the LLM
|
|
262
|
+
const quotaTool = createQuotaTool(quotaService, () => quotaService.getConfig());
|
|
263
|
+
return hooks;
|
|
264
|
+
};
|
|
265
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,gBAAg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AAG,MAAM,CAAC,eAAe,KAAK,KAAK,CAAC;gBACnD,MAAM,SAAS,GAAG,SAAS;oBACvB,CAAC,CAAC,GAAG,uBAAuB,IAAI,SAAS,KAAK;oBAC9C,CAAC,CAAC,EAAE,CAAC;gBAET,2CAA2C;gBAC3C,MAAM,CAAC,IAAI,IAAI,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrD,QAAQ,CAAC,eAAe,EAAE;oBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,KAAK,EAAE,KAAK,CAAC,MAAM;iBACtB,CAAC,CAAC;YACP,CAAC;oBAAS,CAAC;gBACP,QAAQ,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;gBACzD,OAAO,EAAE,CAAC;YACd,CAAC;QACL,CAAC;KACJ,CAAC;IAEF,sDAAsD;IACtD,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,EAAE,GAAG,EAAE,CACjD,YAAY,CAAC,SAAS,EAAE,CAC3B,CAAC;IAEF,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
export interface QuotaData {
|
|
2
|
+
id: string;
|
|
3
|
+
providerName: string;
|
|
4
|
+
used: number;
|
|
5
|
+
limit: number | null;
|
|
6
|
+
unit: string;
|
|
7
|
+
/**
|
|
8
|
+
* Reset time description (e.g. "in 2h 41m" or "at 12:00").
|
|
9
|
+
*/
|
|
10
|
+
reset?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Predicted time until limit is reached (e.g. "in 12m (predicted)").
|
|
13
|
+
*/
|
|
14
|
+
predictedReset?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Window or period description (e.g. "5h window" or "Monthly").
|
|
17
|
+
*/
|
|
18
|
+
window?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Extra information or alerts (e.g. "!!" or "unlimited").
|
|
21
|
+
*/
|
|
22
|
+
info?: string;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use reset, window, info instead.
|
|
25
|
+
*/
|
|
26
|
+
details?: string;
|
|
27
|
+
}
|
|
28
|
+
export type QuotaColumn = "name" | "bar" | "percent" | "value" | "reset" | "window" | "info" | "status" | "ettl";
|
|
29
|
+
export interface QuotaConfig {
|
|
30
|
+
displayMode: QuotaDisplayMode;
|
|
31
|
+
progressBar?: ProgressBarConfig;
|
|
32
|
+
table?: {
|
|
33
|
+
/**
|
|
34
|
+
* Columns to display in the quota table.
|
|
35
|
+
* Defaults to a smart selection based on data.
|
|
36
|
+
*/
|
|
37
|
+
columns?: QuotaColumn[];
|
|
38
|
+
/**
|
|
39
|
+
* Whether to render the table header row (column labels)
|
|
40
|
+
*/
|
|
41
|
+
header?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Whether to show quotas in the chat footer automatically.
|
|
45
|
+
* Defaults to true.
|
|
46
|
+
*/
|
|
47
|
+
footer?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to show the plugin title/header (bold line) in the footer.
|
|
50
|
+
* Defaults to true.
|
|
51
|
+
*/
|
|
52
|
+
showFooterTitle?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* List of quota IDs to hide from display.
|
|
55
|
+
*/
|
|
56
|
+
disabled?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Only show quotas relevant to the current model (best-effort matching).
|
|
59
|
+
*/
|
|
60
|
+
filterByCurrentModel?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Enable debug logging to ~/.local/share/opencode/quotas-debug.log
|
|
63
|
+
*/
|
|
64
|
+
debug?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Optional aggregation groups.
|
|
67
|
+
*/
|
|
68
|
+
aggregatedGroups?: AggregatedGroup[];
|
|
69
|
+
/**
|
|
70
|
+
* Max history age in hours. Defaults to 24.
|
|
71
|
+
*/
|
|
72
|
+
historyMaxAgeHours?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Polling interval in milliseconds. Defaults to 60000 (1 minute).
|
|
75
|
+
*/
|
|
76
|
+
pollingInterval?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Short time window for regression to capture spikes (minutes). Defaults to 5.
|
|
79
|
+
*/
|
|
80
|
+
predictionShortWindowMinutes?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Whether to show quotas that did not match any aggregation group.
|
|
83
|
+
* Defaults to true.
|
|
84
|
+
*/
|
|
85
|
+
showUnaggregated?: boolean;
|
|
86
|
+
}
|
|
87
|
+
export type AggregationStrategy = "most_critical" | "min" | "max" | "mean" | "median";
|
|
88
|
+
export interface AggregatedGroup {
|
|
89
|
+
/**
|
|
90
|
+
* Unique ID for the resulting group (e.g., "ag-flash", "codex-smart").
|
|
91
|
+
*/
|
|
92
|
+
id: string;
|
|
93
|
+
/**
|
|
94
|
+
* Display name (e.g., "Antigravity Flash", "Codex Usage").
|
|
95
|
+
*/
|
|
96
|
+
name: string;
|
|
97
|
+
/**
|
|
98
|
+
* Explicit IDs of quotas to include in this group.
|
|
99
|
+
* Use this for precise control over which quotas are aggregated.
|
|
100
|
+
*/
|
|
101
|
+
sources?: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Regex/Glob patterns to match against raw quota IDs or provider names.
|
|
104
|
+
* The provider will return raw quotas with IDs like "ag-raw-gemini-1-5-flash".
|
|
105
|
+
* Patterns are matched case-insensitively.
|
|
106
|
+
*/
|
|
107
|
+
patterns?: string[];
|
|
108
|
+
/**
|
|
109
|
+
* Optional: Limit pattern matching to a specific provider ID.
|
|
110
|
+
* If set, only quotas from this provider will be considered for pattern matching.
|
|
111
|
+
*/
|
|
112
|
+
providerId?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Aggregation strategy. Defaults to "most_critical".
|
|
115
|
+
*/
|
|
116
|
+
strategy?: AggregationStrategy;
|
|
117
|
+
/**
|
|
118
|
+
* Time window for regression (default: 60 minutes).
|
|
119
|
+
*/
|
|
120
|
+
predictionWindowMinutes?: number;
|
|
121
|
+
/**
|
|
122
|
+
* Short time window for spikes (default: 5 minutes).
|
|
123
|
+
*/
|
|
124
|
+
predictionShortWindowMinutes?: number;
|
|
125
|
+
}
|
|
126
|
+
export interface HistoryPoint {
|
|
127
|
+
timestamp: number;
|
|
128
|
+
used: number;
|
|
129
|
+
limit: number | null;
|
|
130
|
+
}
|
|
131
|
+
export interface IHistoryService {
|
|
132
|
+
init(): Promise<void>;
|
|
133
|
+
append(snapshot: QuotaData[]): Promise<void>;
|
|
134
|
+
getHistory(quotaId: string, windowMs: number): HistoryPoint[];
|
|
135
|
+
setMaxAge(hours: number): void;
|
|
136
|
+
pruneAll(): Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
export interface IQuotaProvider {
|
|
139
|
+
id: string;
|
|
140
|
+
fetchQuota(): Promise<QuotaData[]>;
|
|
141
|
+
}
|
|
142
|
+
export interface IQuotaRegistry {
|
|
143
|
+
register(provider: IQuotaProvider): void;
|
|
144
|
+
getAll(): IQuotaProvider[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Interface for prediction engines that calculate time-to-limit.
|
|
148
|
+
*/
|
|
149
|
+
export interface IPredictionEngine {
|
|
150
|
+
/**
|
|
151
|
+
* Predicts time to limit in milliseconds using historical usage data.
|
|
152
|
+
* @param quotaId - The quota identifier to predict for
|
|
153
|
+
* @param windowMinutes - The long time window for regression (default: 60)
|
|
154
|
+
* @param shortWindowMinutes - The short time window for capturing spikes
|
|
155
|
+
* @returns Time to limit in milliseconds, or Infinity if usage is stable/decreasing
|
|
156
|
+
*/
|
|
157
|
+
predictTimeToLimit(quotaId: string, windowMinutes?: number, shortWindowMinutes?: number): number;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Interface for aggregation services that combine multiple quotas.
|
|
161
|
+
*/
|
|
162
|
+
export interface IAggregationService {
|
|
163
|
+
/**
|
|
164
|
+
* Aggregates quotas using the most critical (shortest time-to-limit) strategy.
|
|
165
|
+
*/
|
|
166
|
+
aggregateMostCritical(quotas: QuotaData[], windowMinutes?: number, shortWindowMinutes?: number): QuotaData | null;
|
|
167
|
+
/**
|
|
168
|
+
* Aggregates quotas by selecting the one with highest usage ratio.
|
|
169
|
+
*/
|
|
170
|
+
aggregateMax(quotas: QuotaData[]): QuotaData;
|
|
171
|
+
/**
|
|
172
|
+
* Aggregates quotas by selecting the one with lowest usage ratio.
|
|
173
|
+
*/
|
|
174
|
+
aggregateMin(quotas: QuotaData[]): QuotaData;
|
|
175
|
+
/**
|
|
176
|
+
* Aggregates quotas by averaging their usage ratios.
|
|
177
|
+
*/
|
|
178
|
+
aggregateAverage(quotas: QuotaData[], name: string, id: string, strategy: "mean" | "median"): QuotaData;
|
|
179
|
+
}
|
|
180
|
+
export type QuotaDisplayMode = "simple" | "detailed" | "hidden";
|
|
181
|
+
export type AnsiColor = "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "bold" | "dim" | "reset";
|
|
182
|
+
export interface GradientLevel {
|
|
183
|
+
threshold: number;
|
|
184
|
+
color: AnsiColor;
|
|
185
|
+
}
|
|
186
|
+
export interface ProgressBarConfig {
|
|
187
|
+
width?: number;
|
|
188
|
+
filledChar?: string;
|
|
189
|
+
emptyChar?: string;
|
|
190
|
+
show?: "used" | "available";
|
|
191
|
+
/**
|
|
192
|
+
* Enable ANSI colors. Defaults to false.
|
|
193
|
+
*/
|
|
194
|
+
color?: boolean;
|
|
195
|
+
gradients?: GradientLevel[];
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,K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CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class Logger {
|
|
2
|
+
private static instance;
|
|
3
|
+
private debugEnabled;
|
|
4
|
+
private logPath;
|
|
5
|
+
private constructor();
|
|
6
|
+
static getInstance(): Logger;
|
|
7
|
+
setDebug(enabled: boolean): void;
|
|
8
|
+
debug(msg: string, data?: any): void;
|
|
9
|
+
info(msg: string, data?: any): void;
|
|
10
|
+
error(msg: string, data?: any): void;
|
|
11
|
+
private log;
|
|
12
|
+
}
|
|
13
|
+
export declare const logger: Logger;
|
|
14
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAMA,qBAAa,MAAM;IACf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO;WAOO,WAAW,IAAI,MAAM;IAO5B,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIpC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAInC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAI3C,OAAO,CAAC,GAAG;CAWd;AAED,eAAO,MAAM,MAAM,QAAuB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { appendFile } from "node:fs/promises";
|
|
2
|
+
import { DEBUG_LOG_FILE } from "./utils/paths";
|
|
3
|
+
import { inspect } from "node:util";
|
|
4
|
+
export class Logger {
|
|
5
|
+
static instance;
|
|
6
|
+
debugEnabled = false;
|
|
7
|
+
logPath;
|
|
8
|
+
constructor() {
|
|
9
|
+
this.logPath = DEBUG_LOG_FILE();
|
|
10
|
+
if (process.env.OPENCODE_QUOTAS_DEBUG === "1") {
|
|
11
|
+
this.debugEnabled = true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
static getInstance() {
|
|
15
|
+
if (!Logger.instance) {
|
|
16
|
+
Logger.instance = new Logger();
|
|
17
|
+
}
|
|
18
|
+
return Logger.instance;
|
|
19
|
+
}
|
|
20
|
+
setDebug(enabled) {
|
|
21
|
+
this.debugEnabled = enabled;
|
|
22
|
+
}
|
|
23
|
+
debug(msg, data) {
|
|
24
|
+
this.log(msg, data, true);
|
|
25
|
+
}
|
|
26
|
+
info(msg, data) {
|
|
27
|
+
this.log(msg, data, false);
|
|
28
|
+
}
|
|
29
|
+
error(msg, data) {
|
|
30
|
+
this.log(msg, data, false);
|
|
31
|
+
}
|
|
32
|
+
log(msg, data, requiresDebug) {
|
|
33
|
+
if (requiresDebug && !this.debugEnabled)
|
|
34
|
+
return;
|
|
35
|
+
const timestamp = new Date().toISOString();
|
|
36
|
+
const payload = data
|
|
37
|
+
? ` ${inspect(data, { depth: null, colors: false, breakLength: Infinity })}`
|
|
38
|
+
: "";
|
|
39
|
+
const logLine = `[${timestamp}] ${msg}${payload}`;
|
|
40
|
+
appendFile(this.logPath, logLine + "\n").catch(() => { });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export const logger = Logger.getInstance();
|
|
44
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO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AAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE;YAC5E,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,OAAO,GAAG,IAAI,SAAS,KAAK,GAAG,GAAG,OAAO,EAAE,CAAC;QAElD,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singleton state manager for the quota plugin.
|
|
3
|
+
* Uses globalThis to ensure only one instance exists across all plugin instantiations.
|
|
4
|
+
*/
|
|
5
|
+
export declare class PluginState {
|
|
6
|
+
private static readonly MAX_TRACKED_MESSAGES;
|
|
7
|
+
private processedMessages;
|
|
8
|
+
private processedSet;
|
|
9
|
+
private locks;
|
|
10
|
+
isProcessed(messageId: string): boolean;
|
|
11
|
+
markProcessed(messageId: string): void;
|
|
12
|
+
acquireLock(messageId: string): Promise<() => void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns the global singleton PluginState instance.
|
|
16
|
+
* This ensures all plugin instantiations share the same state,
|
|
17
|
+
* preventing duplicate injection when the plugin is loaded multiple times.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPluginState(): PluginState;
|
|
20
|
+
//# sourceMappingURL=plugin-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-state.d.ts","sourceRoot":"","sources":["../../src/plugin-state.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAQ;IACpD,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,KAAK,CAAoC;IAEjD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIvC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAYhC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;CAmB5D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAM5C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const PLUGIN_STATE_KEY = "__OPENCODE_QUOTA_PLUGIN_STATE__";
|
|
2
|
+
/**
|
|
3
|
+
* Singleton state manager for the quota plugin.
|
|
4
|
+
* Uses globalThis to ensure only one instance exists across all plugin instantiations.
|
|
5
|
+
*/
|
|
6
|
+
export class PluginState {
|
|
7
|
+
static MAX_TRACKED_MESSAGES = 1000;
|
|
8
|
+
processedMessages = [];
|
|
9
|
+
processedSet = new Set();
|
|
10
|
+
locks = new Map();
|
|
11
|
+
isProcessed(messageId) {
|
|
12
|
+
return this.processedSet.has(messageId);
|
|
13
|
+
}
|
|
14
|
+
markProcessed(messageId) {
|
|
15
|
+
if (this.processedSet.has(messageId))
|
|
16
|
+
return;
|
|
17
|
+
this.processedSet.add(messageId);
|
|
18
|
+
this.processedMessages.push(messageId);
|
|
19
|
+
while (this.processedMessages.length > PluginState.MAX_TRACKED_MESSAGES) {
|
|
20
|
+
const oldest = this.processedMessages.shift();
|
|
21
|
+
if (oldest)
|
|
22
|
+
this.processedSet.delete(oldest);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async acquireLock(messageId) {
|
|
26
|
+
const existingLock = this.locks.get(messageId) || Promise.resolve();
|
|
27
|
+
let resolveLock;
|
|
28
|
+
const nextLock = new Promise((resolve) => {
|
|
29
|
+
resolveLock = resolve;
|
|
30
|
+
});
|
|
31
|
+
this.locks.set(messageId, nextLock);
|
|
32
|
+
await existingLock;
|
|
33
|
+
return () => {
|
|
34
|
+
resolveLock();
|
|
35
|
+
if (this.locks.get(messageId) === nextLock) {
|
|
36
|
+
this.locks.delete(messageId);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the global singleton PluginState instance.
|
|
43
|
+
* This ensures all plugin instantiations share the same state,
|
|
44
|
+
* preventing duplicate injection when the plugin is loaded multiple times.
|
|
45
|
+
*/
|
|
46
|
+
export function getPluginState() {
|
|
47
|
+
const globalRef = globalThis;
|
|
48
|
+
if (!globalRef[PLUGIN_STATE_KEY]) {
|
|
49
|
+
globalRef[PLUGIN_STATE_KEY] = new PluginState();
|
|
50
|
+
}
|
|
51
|
+
return globalRef[PLUGIN_STATE_KEY];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=plugin-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-state.js","sourceRoot":"","sources":["../../src/plugin-state.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,iCAAiC,CAAC;AAM3D;;;GAGG;AACH,MAAM,OAAO,WAAW;IACZ,MAAM,CAAU,oBAAoB,GAAG,IAAI,CAAC;IAC5C,iBAAiB,GAAa,EAAE,CAAC;IACjC,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEjD,WAAW,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,aAAa,CAAC,SAAiB;QAC3B,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,OAAO;QAE7C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACjC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEvC,OAAO,IAAI,CAAC,iBAAiB,CAAC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
|
|
5
|
+
}
|
|
6
|
+
export declare function hasCloudCredentials(): Promise<boolean>;
|
|
7
|
+
export declare function getCloudCredentials(): Promise<CloudAuthCredentials>;
|
|
8
|
+
/**
|
|
9
|
+
* Reset the credential cache. Internal use only (primarily for tests).
|
|
10
|
+
*/
|
|
11
|
+
export declare function resetCredentialCache(): void;
|
|
12
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/providers/antigravity/auth.ts"],"names":[],"mappings":"AAuCA,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAmCD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO5D;AAiCD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAqCzE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|