/** * PiRoleSwitcher — in-session "switch active role" capability for the Pi platform. * * Pi is a minimal single-agent harness with no built-in agent picker. rolebox * already resolves every role into an {@link AgentDefinition} (id, name, * description, systemPrompt, model) and registers them on the * {@link PiAgentRegistrar}. This module turns that registry into an * opencode-style role switcher, implemented purely through Pi's extension API: * * - `/role [name]` — pick a primary role via arg or interactive selector * - `/role none|off` — clear the active role (back to the base agent) * - `Ctrl+Shift+R` — cycle to the next primary role * * Switching a role does three things: * 1. `pi.setModel()` — adopt the role's model (alias already resolved) * 2. `before_agent_start` injection — append the role's system prompt each turn * 3. `pi.appendEntry()` + restore — persist the choice across `/resume` * * This lives in the Pi adapter only. opencode has its own native agent picker * and is unaffected. Gated by `PlatformCapabilities.hasRoleSwitch`. * * `pi` is loosely typed (`any`) because it is an optional peer dependency, matching * the convention in `pi-extension.ts`. * * @module */ import type { PiAgentRegistrar } from "./agent-registrar.ts"; import type { ActiveAgentRef } from "./active-agent.ts"; /** * Options for {@link wireRoleSwitcher}. */ export interface RoleSwitcherOptions { /** Pi ExtensionAPI instance (loosely typed optional peer dependency). */ pi: any; /** Registry holding all resolved agent definitions (roles + subagents). */ registrar: PiAgentRegistrar; /** Keybinding for cycling roles. Defaults to {@link CYCLE_SHORTCUT}. */ cycleShortcut?: string; /** * Shared active-agent ref bridging the switched role into the dispatch * tool's "direct child" gate. When omitted, a private ref is created (the * switcher still works, but dispatch scoping is not shared). */ activeAgent?: ActiveAgentRef; } /** * Wire the role switcher into a Pi extension runtime. * * Registers the `/role` command, the cycle shortcut, the per-turn system-prompt * injection hook, and cross-session restore. All handlers are defensively * guarded so a missing/limited Pi API (e.g. print or JSON mode) degrades * gracefully instead of throwing into the Pi runtime. * * @param options - See {@link RoleSwitcherOptions}. */ export declare function wireRoleSwitcher(options: RoleSwitcherOptions): void; //# sourceMappingURL=role-switcher.d.ts.map