import { Command } from 'commander';
import { IncomingMessage, ServerResponse } from 'node:http';

interface Logger {
    info(message: string): void;
    warn(message: string): void;
    error(message: string): void;
    debug(message: string): void;
}
interface PluginConfig {
    [key: string]: any;
}
interface Message {
    role: string;
    content: string;
    sender?: {
        id: string;
        [key: string]: any;
    };
    [key: string]: any;
}
interface EventContext {
    sessionKey?: string;
    sendMessage?: (message: Message) => Promise<void>;
    terminateSession?: (options: {
        reason: string;
        silent: boolean;
    }) => Promise<void>;
    [key: string]: any;
}
type OpenClawPluginCliContext = {
    program: Command;
    config?: {
        [key: string]: any;
    };
    workspaceDir?: string;
    logger: Logger;
};
type OpenClawPluginCliRegistrar = (ctx: OpenClawPluginCliContext) => void | Promise<void>;
type OpenClawPluginHttpRouteAuth = "gateway" | "plugin";
type OpenClawPluginHttpRouteMatch = "exact" | "prefix";
type OpenClawPluginHttpRouteHandler = (req: IncomingMessage, res: ServerResponse, logger: Logger) => Promise<boolean | void> | boolean | void;
type OpenClawPluginHttpRouteParams = {
    path: string;
    handler: OpenClawPluginHttpRouteHandler;
    auth: OpenClawPluginHttpRouteAuth;
    match?: OpenClawPluginHttpRouteMatch;
    replaceExisting?: boolean;
};
interface OpenClawPluginApi {
    logger: Logger;
    config: PluginConfig;
    pluginConfig: PluginConfig;
    resolvePath: (input: string) => string;
    version: string;
    registerHttpRoute: (params: OpenClawPluginHttpRouteParams) => void;
    registerCli: (registrar: OpenClawPluginCliRegistrar, opts?: {
        commands?: string[];
    }) => void;
    on(event: string, handler: (event: any, ctx: EventContext) => Promise<void | {
        block: boolean;
        blockReason: string;
    }>): void;
}

declare function register(api: OpenClawPluginApi): Promise<void>;

export { register as default };
