import { pluginHost } from '../../core/plugin-host/host.js';
import { endpointSlug } from '../../services/slug.js';
import { endpointSerializer } from './serializer.js';
import { endpointSystemPrompt } from './system-prompt.js';
import { endpointsRouter } from './routes.js';
import { EndpointService } from './services.js';
import { createEndpointToolsServer } from './mcp-server.js';
export const endpointBackendModule = {
    type: 'endpoint',
    table: 'endpoint',
    label: 'Endpoint',
    labelPlural: 'Endpoints',
    displayOrder: 10,
    pathPrefix: '/endpoints',
    slugFrom: (data) => {
        const d = data;
        return endpointSlug(d.method ?? 'GET', d.path ?? '');
    },
    serializer: endpointSerializer,
    systemPrompt: endpointSystemPrompt,
    backend: {
        mount(ctx) {
            const service = new EndpointService(ctx.db, ctx.tagsService, ctx.versionService);
            ctx.app.use(`/api${endpointBackendModule.pathPrefix}`, endpointsRouter(service, ctx.referencesService));
            ctx.registerMcpServer(`${endpointBackendModule.type}-tools`, () => createEndpointToolsServer({
                endpointService: service,
                referencesService: ctx.referencesService,
                ws: ctx.ws,
            }));
            ctx.setIdResolver(endpointBackendModule.type, (slug) => service.getIdBySlug(slug));
            ctx.registerEntityService(endpointBackendModule.type, service);
        },
    },
};
pluginHost.registerBackendModule(endpointBackendModule);
//# sourceMappingURL=plugin.js.map