From 419c78c357a1824ab0131e24737e087d21cbda1f Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Sun, 3 May 2026 21:15:43 -0400 Subject: [PATCH] refactor: replace any types with proper SDK types in event handlers --- index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.ts b/index.ts index de9ed0d..85706a8 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,4 @@ -import { AuthStorage, type AuthCredential, type ExtensionAPI } from "@mariozechner/pi-coding-agent"; +import { AuthStorage, type AuthCredential, type ExtensionAPI, type ExtensionContext, type ExtensionCommandContext, type SessionStartEvent, type SessionShutdownEvent, type AgentEndEvent } from "@mariozechner/pi-coding-agent"; import { statusbarConfig } from "./config"; import { contextModule, costModule, directoryModule, modelModule, thinkingModule } from "./modules/basic"; import { usageModule } from "./modules/usage"; @@ -64,7 +64,7 @@ async function readPiCredential(authStorage: AuthStorage, provider: Provider): P async function forceRefreshPiCredential(authStorage: AuthStorage, provider: Provider): Promise { authStorage.reload(); const raw = authStorage.get(provider); - const oauthProvider = authStorage.getOAuthProviders().find((candidate: any) => candidate.id === provider); + const oauthProvider = authStorage.getOAuthProviders().find(candidate => candidate.id === provider); if (raw?.type !== "oauth" || !oauthProvider) throw new Error("login expired"); // Refresh Provider OAuth Token @@ -211,7 +211,7 @@ export default function piStatusbarExtension(pi: ExtensionAPI) { if (lastProvider === provider) rerender(ctx); } - pi.on("session_start", async (_event: any, ctx: any) => { + pi.on("session_start", async (_event: SessionStartEvent, ctx: ExtensionContext) => { updateThinkingLevel(); installFooter(ctx); await refresh(ctx, true); @@ -220,7 +220,7 @@ export default function piStatusbarExtension(pi: ExtensionAPI) { timer = setInterval(() => void refresh(latestCtx ?? ctx), REFRESH_MS); }); - pi.on("session_shutdown", async (_event: any, ctx: any) => { + pi.on("session_shutdown", async (_event: SessionShutdownEvent, ctx: ExtensionContext) => { if (timer) clearInterval(timer); timer = undefined; inFlight?.abort(); @@ -232,24 +232,24 @@ export default function piStatusbarExtension(pi: ExtensionAPI) { } }); - pi.on("model_select", async (_event: any, ctx: any) => { + pi.on("model_select", async (_event, ctx) => { updateThinkingLevel(); await refresh(ctx, true); }); - pi.on("thinking_level_select", async (event: any, ctx: any) => { + pi.on("thinking_level_select", async (event, ctx) => { statusbarState.thinkingLevel = event.level; rerender(ctx); }); - pi.on("agent_end", async (_event: any, ctx: any) => { + pi.on("agent_end", async (_event: AgentEndEvent, ctx: ExtensionContext) => { updateThinkingLevel(); await refresh(ctx); }); pi.registerCommand("refresh-usage", { description: "Refresh account usage for the active provider", - handler: async (_args: any, ctx: any) => { + handler: async (_args: string, ctx: ExtensionCommandContext) => { await refresh(ctx, true); ctx.ui.notify(usageSummary(statusbarState.report, statusbarState.error), statusbarState.error ? "warning" : "info"); },