import { RegistryError } from './types.js';
export const manualAdapter = {
    descriptor: {
        id: 'manual',
        label: 'Manual paste',
        kinds: ['skill', 'mcp'],
        requiresAuth: false,
        enabled: true
    },
    async search() {
        return [];
    },
    async resolveInstall(entry) {
        const raw = entry.installManifest;
        if (raw.kind === 'skill') {
            if (!raw.skillMarkdown)
                throw new RegistryError('skillMarkdown is required', 400);
            const nameFromFrontmatter = raw.skillMarkdown.match(/^---[\s\S]*?\nname:\s*([^\n]+)/m);
            return {
                name: raw.name ?? nameFromFrontmatter?.[1]?.trim() ?? 'manual-skill',
                skillMarkdown: raw.skillMarkdown,
                source: { registry: 'manual', ref: null, version: null, url: null }
            };
        }
        if (raw.kind === 'mcp') {
            if (!raw.server || !raw.name)
                throw new RegistryError('mcp server payload is required', 400);
            return {
                name: raw.name,
                transport: raw.server.transport,
                command: raw.server.command,
                args: raw.server.args ?? [],
                env: raw.server.env ?? {},
                url: raw.server.url,
                headers: raw.server.headers ?? {},
                source: { registry: 'manual', ref: null, version: null, url: null }
            };
        }
        throw new RegistryError('Unsupported manual payload', 400);
    }
};
//# sourceMappingURL=manual.js.map