import { z } from 'zod';
import { MAX_CONNECTORS_PER_PLUGIN, MAX_HOOKS_PER_PLUGIN, MAX_MCP_SERVERS_PER_PLUGIN, MAX_PERSONAS_PER_PLUGIN, MAX_SKILLS_PER_PLUGIN, MAX_TOOLS_PER_PLUGIN, PLUGIN_NAME_MAX_LENGTH, } from '../../constants/plugin/index.js';
export function assertPluginScope(scope) {
    switch (scope) {
        case 'project':
        case 'user':
            return;
        default: {
            const _exhaustive = scope;
            throw new Error(`Unknown PluginScope: ${_exhaustive}`);
        }
    }
}
export function assertPluginStatus(status) {
    switch (status) {
        case 'installed':
        case 'enabled':
        case 'disabled':
        case 'error':
            return;
        default: {
            const _exhaustive = status;
            throw new Error(`Unknown PluginStatus: ${_exhaustive}`);
        }
    }
}
export function assertPluginContributionType(type) {
    switch (type) {
        case 'tool':
        case 'skill':
        case 'hook':
        case 'mcp_server':
        case 'connector':
        case 'persona':
            return;
        default: {
            const _exhaustive = type;
            throw new Error(`Unknown PluginContributionType: ${_exhaustive}`);
        }
    }
}
export function assertPluginHookEvent(event) {
    switch (event) {
        case 'run_start':
        case 'run_end':
        case 'pre_tool_use':
        case 'post_tool_use':
        case 'pre_llm_call':
        case 'post_llm_call':
        case 'iteration_start':
        case 'iteration_end':
            return;
        default: {
            const _exhaustive = event;
            throw new Error(`Unknown PluginHookEvent: ${_exhaustive}`);
        }
    }
}
export function assertPluginHookResult(result) {
    const action = result.action;
    switch (action) {
        case 'continue':
        case 'skip':
        case 'modify':
        case 'error':
        case 'resume':
        case 'retry':
            break;
        default: {
            const _exhaustive = action;
            throw new Error(`Unknown PluginHookResult action: ${_exhaustive}`);
        }
    }
}
export const PluginMCPServerConfigSchema = z.object({
    name: z.string().min(1),
    command: z.string().min(1),
    args: z.array(z.string()).optional(),
    env: z.record(z.string()).optional(),
});
export const PluginManifestSchema = z.object({
    name: z
        .string()
        .min(1)
        .max(PLUGIN_NAME_MAX_LENGTH)
        .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Plugin name must be lowercase kebab-case'),
    version: z.string().min(1),
    description: z.string().min(1),
    author: z.string().optional(),
    tools: z.array(z.string()).max(MAX_TOOLS_PER_PLUGIN).optional(),
    skills: z.array(z.string()).max(MAX_SKILLS_PER_PLUGIN).optional(),
    hooks: z.array(z.string()).max(MAX_HOOKS_PER_PLUGIN).optional(),
    mcpServers: z.array(PluginMCPServerConfigSchema).max(MAX_MCP_SERVERS_PER_PLUGIN).optional(),
    connectors: z.array(z.string()).max(MAX_CONNECTORS_PER_PLUGIN).optional(),
    personas: z.array(z.string()).max(MAX_PERSONAS_PER_PLUGIN).optional(),
});
//# sourceMappingURL=index.js.map