import type { PluginText } from "../text.js"; import type { ComponentType } from "react"; import type { PaseoApi } from "@getpaseo/client"; import type { AgentTimelineItem } from "@getpaseo/protocol/agent-types"; import type { ZodType, input as ZodInput, output as ZodOutput } from "zod"; import type { PluginRpcContract } from "../rpc.js"; import type { PluginButtonRegistration, PluginHeaderButtonContribution, PluginComposerPillContribution, } from "./buttons.js"; import type { PluginTheme, PluginWorkspaceSnapshot, PluginAgentSnapshot, PluginThemeContribution, PluginAttachmentSourceContribution, PluginTimelineTransformResult, PluginCleanup, } from "../contracts.js"; import type { PluginIconProps, PluginSerializableIcon } from "../icons.js"; export interface PluginHostProps { theme: PluginTheme; host: { id: string; label: string; }; layout: { compact: boolean; platform: "ios" | "android" | "web"; }; } interface PluginNavigableHostProps extends PluginHostProps { /** Client-owned navigation. Undefined on older hosts; hide dependent affordances when absent. */ readonly navigation?: { /** Present only on Electron. The browser runs locally; serverId selects workspace ownership. */ readonly openBrowser?: (input: { readonly url: string; readonly workspaceId: string; readonly serverId?: string; }) => void; readonly openAgent: (input: { readonly agentId: string; readonly serverId?: string }) => void; readonly openWorkspace: (input: { readonly workspaceId: string; readonly serverId?: string; }) => void; }; } /** String keys and values: params travel in the screen's URL. */ export type PluginScreenParams = Record; export interface PluginOpenScreenInput { screenId: string; params?: PluginScreenParams; } export interface PluginScreenLocation { screenId: string; params: PluginScreenParams; } export interface PluginSurfaceProps extends PluginNavigableHostProps {} export interface PluginScreenProps extends PluginSurfaceProps { /** The params the screen was opened with; `{}` when none. */ params: PluginScreenParams; } export interface PluginPopoverProps extends PluginHostProps { close(): void; openScreen(input: PluginOpenScreenInput): void; } export interface PluginSidebarItemProps extends PluginHostProps { /** This plugin's screen open on this item's host, with its params, else null. */ currentScreen: PluginScreenLocation | null; openScreen(input: PluginOpenScreenInput): void; /** Anchored to the item on wide layouts; a bottom sheet on compact layouts. */ openPopover(Content: ComponentType): void; } export interface PluginSidebarItemContribution { id: string; /** Settings row label, accessibility label, and default label for SidebarRow. */ title: Text; Component: ComponentType; } /** * A Lucide icon name, inline SVG markup, or a component. Components receive the surface's size * and color; buttons widen the props with their host and target context. */ export type PluginIcon = | PluginSerializableIcon | ComponentType; export type PluginPanelLocation = "workspace" | "explorer"; export interface PluginOpenPanelOptions { location?: PluginPanelLocation; } interface PluginWorkspacePanelBase { id: string; title: Text; icon: PluginIcon; locations?: readonly PluginPanelLocation[]; } export interface PluginWorkspacePanelProps extends PluginNavigableHostProps { context: "workspace"; workspaceId: string; } export interface PluginAgentPanelProps extends PluginNavigableHostProps { context: "agent"; workspaceId: string; agentId: string; } export interface PluginClientOpenPanelOptions extends PluginOpenPanelOptions { workspaceId: string; agentId?: string; } // COMPAT(pluginSidebarAliases): added in v0.11.0, remove after 2027-03-29 interface PluginClientContextAliases { /** @deprecated Use `addScreen`. */ addSurface(id: string, Component: ComponentType): PluginCleanup; /** @deprecated Use `addSidebarHeaderItem`. */ addSidebarItem(contribution: PluginSidebarContribution): PluginCleanup; } export interface PluginClientContext extends PluginCommandCapabilities, PluginClientContextAliases { readonly i18n: import("./translations.js").PluginI18n; /** Play a base64-encoded audio file on this client; resolves when playback ends. */ playAudio(source: { base64: string; mimeType: string }): Promise; addSettingsScreen(contribution: PluginSettingsScreenContribution): PluginCleanup; addScreen(contribution: PluginScreenContribution): PluginCleanup; addSidebarHeaderItem(contribution: PluginSidebarItemContribution): PluginCleanup; addSidebarFooterItem(contribution: PluginSidebarItemContribution): PluginCleanup; addWorkspacePanel(contribution: PluginWorkspacePanelContribution): PluginCleanup; addCommandCenterItem( contribution: PluginCommandCenterItemContribution, ): PluginCleanup; addSlashCommand(contribution: PluginClientSlashCommandContribution): PluginCleanup; addHeaderButton( contribution: PluginHeaderButtonContribution, ): PluginButtonRegistration; addComposerPill( contribution: PluginComposerPillContribution, ): PluginButtonRegistration; addAttachmentSource(contribution: PluginAttachmentSourceContribution): PluginCleanup; addTheme(contribution: PluginThemeContribution): PluginCleanup; addTimelineTransformer( contribution: PluginTimelineTransformerContribution, ): PluginCleanup; addTimelineRenderer( contribution: PluginTimelineRendererContribution, ): PluginCleanup; openPanel(id: string, options: PluginClientOpenPanelOptions): void; } export type PluginClientContribution = (client: PluginClientContext) => PluginCleanup; export type PluginWorkspacePanelContribution = | (PluginWorkspacePanelBase & { context: "workspace"; Component: ComponentType; }) | (PluginWorkspacePanelBase & { context: "agent"; Component: ComponentType; }); export interface PluginSettingsScreenContribution { id: string; title: Text; icon: PluginIcon; Component: ComponentType; } /** The screen header's title: fixed, or derived from the params the screen was opened with. */ export type PluginScreenTitle = | Text | ((params: PluginScreenParams) => Text); export interface PluginScreenContribution { id: string; title: PluginScreenTitle; Component: ComponentType; } export interface PluginSurfaceContribution { id: string; Component: ComponentType; } /** @deprecated Use `PluginSidebarItemContribution` with `addSidebarHeaderItem`. */ export interface PluginSidebarContribution { id: string; title: Text; icon: PluginIcon; surface: string; } export type PluginTimelineTransformerContribution< ItemType extends AgentTimelineItem["type"] = AgentTimelineItem["type"], > = ItemType extends AgentTimelineItem["type"] ? { id: string; query: { itemType: ItemType; }; transform(input: { item: Extract; phase: "streaming" | "complete"; }): PluginTimelineTransformResult | undefined; } : never; export interface PluginTimelineItemProps extends PluginHostProps { agentId: string; item: { type: "plugin"; kind: string; version: number; data: Data; }; timestamp: Date; } export interface PluginTimelineRendererContribution { kind: string; version: number; schema: Schema; Component: ComponentType>>; } export interface PluginCommandCapabilities { paseo: PaseoApi; rpc( contract: PluginRpcContract, input: ZodInput, ): Promise>; openScreen(input: PluginOpenScreenInput): void; /** @deprecated Use `openScreen`. */ openSurface(id: string): void; openSettings(id: string): void; } export interface PluginGlobalCommandContext extends PluginCommandCapabilities { context: "global"; } export interface PluginWorkspaceCommandContext extends PluginCommandCapabilities { context: "workspace"; workspace: PluginWorkspaceSnapshot; openPanel(id: string, options?: PluginOpenPanelOptions): void; } export interface PluginAgentCommandContext extends PluginCommandCapabilities { context: "agent"; workspace: PluginWorkspaceSnapshot; agent: PluginAgentSnapshot; openPanel(id: string, options?: PluginOpenPanelOptions): void; } interface PluginCommandCenterItemBase { id: string; title: Text; icon: PluginIcon; keywords?: readonly string[]; } export type PluginCommandCenterItemContribution = | (PluginCommandCenterItemBase & { context: "global"; onSelect(context: PluginGlobalCommandContext): void | Promise; }) | (PluginCommandCenterItemBase & { context: "workspace"; onSelect(context: PluginWorkspaceCommandContext): void | Promise; }) | (PluginCommandCenterItemBase & { context: "agent"; onSelect(context: PluginAgentCommandContext): void | Promise; }); interface PluginClientSlashCommandBase { name: string; description: Text; argumentHint: Text; } export type PluginClientSlashCommandContribution = | (PluginClientSlashCommandBase & { context: "workspace"; onSubmit(context: PluginWorkspaceCommandContext & { args: string }): void | Promise; }) | (PluginClientSlashCommandBase & { context: "agent"; onSubmit(context: PluginAgentCommandContext & { args: string }): void | Promise; }); export type SettingsState = ( | { status: "loading" } | { status: "error"; error: string } | { status: "invalid"; error: string; revision: string } | { status: "ready"; values: ZodOutput; revision: string } ) & { saving: boolean; saveError: string | null; /** Save an entire document against the revision currently displayed. Never throws. */ save(values: ZodOutput, revision: string): Promise; reset(): Promise; reload(): Promise; };