import type { PaseoApi } from "@getpaseo/client"; import type { ZodType, input as ZodInput, output as ZodOutput } from "zod"; import type { PluginRpcContract } from "../rpc.js"; import type { PluginCleanup } from "../contracts.js"; import type { ProviderRegistration } from "./provider.js"; import type { UsageSourceRegistration } from "./usage.js"; import type { PluginLifecycleRegistration } from "./lifecycle.js"; export interface PluginHandlerContext { paseo: PaseoApi; } export type PluginSettingsState = | { status: "ready"; revision: string; values: ZodOutput; } | { status: "invalid"; revision: string; error: string; }; export interface PluginSettings { read(): Promise>; subscribe(listener: (state: PluginSettingsState) => void | Promise): PluginCleanup; } export interface PluginServerContext extends PluginLifecycleRegistration { registerSettings( definition: import("../settings.js").SettingsDefinition, ): PluginSettings; handle( contract: PluginRpcContract, handler: ( input: ZodOutput, context: PluginHandlerContext, ) => ZodInput | Promise>, ): void; registerProvider(provider: ProviderRegistration): void; registerUsageSource(source: UsageSourceRegistration): void; } export type PluginServerContribution = (server: PluginServerContext) => PluginCleanup;