/** * Structural types mirroring the subset of `@mariozechner/pi-coding-agent` * this extension touches (extensions.md, July 2026). Kept local so the * monorepo builds and tests without pulling the full pi dependency tree; * pi loads extensions structurally, so these are compatible at runtime. * If pi's API drifts, update here — the conformance is with pi's docs. */ export interface ToolCallEvent { toolName: string; toolCallId: string; /** Mutable tool parameters; shape depends on toolName. */ input: Record; } export interface BlockResult { block: true; reason?: string; } export interface PiUI { confirm(title: string, message: string): Promise; notify(message: string, level?: "info" | "success" | "error"): void; setStatus(key: string, text: string): void; } export interface ExtensionContext { /** false in print (-p) and JSON modes — the non-interactive case (SPEC §3.1). */ hasUI: boolean; ui: PiUI; } export type ToolCallHandler = (event: ToolCallEvent, ctx: ExtensionContext) => Promise | BlockResult | void; export type SessionStartHandler = (event: unknown, ctx: ExtensionContext) => Promise | void; /** * Command handlers receive an ExtensionCommandContext (extends ExtensionContext * with session-control methods in pi; we only need the base UI surface here). * `args` is the raw text after the command, e.g. "init" in `/iota init`. */ export type CommandHandler = (args: string, ctx: ExtensionContext) => Promise | void; export interface CommandDefinition { description: string; handler: CommandHandler; } export interface ExtensionAPI { on(event: "tool_call", handler: ToolCallHandler): void; on(event: "session_start", handler: SessionStartHandler): void; on(event: string, handler: (event: never, ctx: ExtensionContext) => unknown): void; /** Register a user-facing slash command, e.g. `/iota`. */ registerCommand(name: string, def: CommandDefinition): void; }