import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; /** * Codex Fast Mode Extension * * Adds /fast command to toggle service_tier=priority for OpenAI Codex models. * This gives 1.5x speed at 2.5x credit cost (equivalent to Codex CLI's /fast). * * Usage: * /fast - Toggle fast mode on/off * /fast on - Enable fast mode * /fast off - Disable fast mode * /fast status - Show current state */ let fastMode = false; export default function (pi: ExtensionAPI) { // Intercept provider requests to inject service_tier pi.on("before_provider_request", (event) => { if (!fastMode) return; const payload = event.payload as Record | undefined; if (payload && typeof payload === "object") { payload.service_tier = "priority"; } return payload; }); // Register /fast command pi.registerCommand("fast", { description: "Toggle Codex fast mode (1.5x speed, 2.5x credits). Usage: /fast [on|off|status]", handler: async (args: string, ctx) => { const arg = args.trim().toLowerCase(); if (arg === "on") { fastMode = true; ctx.ui.notify("⚡ Fast mode ON (service_tier=priority, 1.5x speed, 2.5x credits)", "info"); } else if (arg === "off") { fastMode = false; ctx.ui.notify("Fast mode OFF (standard speed)", "info"); } else if (arg === "status") { ctx.ui.notify(fastMode ? "⚡ Fast mode is ON" : "Fast mode is OFF", "info"); } else { // Toggle fastMode = !fastMode; ctx.ui.notify( fastMode ? "⚡ Fast mode ON (service_tier=priority, 1.5x speed, 2.5x credits)" : "Fast mode OFF (standard speed)", "info" ); } }, }); }