pi update
This commit is contained in:
@@ -79,6 +79,7 @@ const PROVIDER_LABELS: Record<ProviderKey, string> = {
|
||||
zai: "Z.AI",
|
||||
gemini: "Gemini",
|
||||
antigravity: "Antigravity",
|
||||
"opencode-go": "Go",
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -163,6 +164,7 @@ class UsageSelectorComponent extends Container implements Focusable {
|
||||
{ key: "zai", name: "Z.AI" },
|
||||
{ key: "gemini", name: "Gemini" },
|
||||
{ key: "antigravity", name: "Antigravity" },
|
||||
{ key: "opencode-go", name: "Go" },
|
||||
];
|
||||
this.allItems = [];
|
||||
for (const p of providers) {
|
||||
@@ -287,7 +289,7 @@ interface PollOptions {
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const endpoints = resolveUsageEndpoints();
|
||||
const state: UsageState = {
|
||||
codex: null, claude: null, zai: null, gemini: null, antigravity: null,
|
||||
codex: null, claude: null, zai: null, gemini: null, antigravity: null, "opencode-go": null,
|
||||
lastPoll: 0, activeProvider: null,
|
||||
};
|
||||
|
||||
@@ -433,6 +435,10 @@ export default function (pi: ExtensionAPI) {
|
||||
result = creds?.access
|
||||
? await fetchGoogleUsage(creds.access, endpoints.gemini, creds.projectId, "gemini", { endpoints })
|
||||
: { session: 0, weekly: 0, error: "missing access token (try /login again)" };
|
||||
} else if (active === "opencode-go") {
|
||||
// OpenCode Go uses local tracking (no public usage API yet)
|
||||
const { getOpenCodeGoUsageData } = await import("./core");
|
||||
result = getOpenCodeGoUsageData();
|
||||
} else {
|
||||
const creds = effectiveAuth["google-antigravity"];
|
||||
result = creds?.access
|
||||
@@ -561,6 +567,22 @@ export default function (pi: ExtensionAPI) {
|
||||
void poll({ forceFresh: true });
|
||||
});
|
||||
|
||||
// Listen for OpenCode Go spend events from other extensions
|
||||
pi.events.on("opencode-go:spend", async (amount: number) => {
|
||||
if (typeof amount === "number" && amount > 0) {
|
||||
const { addOpenCodeGoSpend } = await import("./core");
|
||||
addOpenCodeGoSpend(amount);
|
||||
// Invalidate cache and re-poll
|
||||
const cache = readUsageCache();
|
||||
if (cache?.data?.["opencode-go"]) {
|
||||
const nextCache: import("./core").UsageCache = { ...cache, data: { ...cache.data } };
|
||||
delete nextCache.data["opencode-go"];
|
||||
writeUsageCache(nextCache);
|
||||
}
|
||||
void poll({ forceFresh: true });
|
||||
}
|
||||
});
|
||||
|
||||
// ── /usage command ───────────────────────────────────────────────────────
|
||||
|
||||
pi.registerCommand("usage", {
|
||||
|
||||
Reference in New Issue
Block a user