import { CanActivate, Injectable, NotFoundException } from '@nestjs/common'; import { InstanceSettingsService } from '../settings/instance-settings.service'; /** * Instance-wide plugin kill switch (issue #200, ADR 0025): while * `plugins.enabled` is false, every guarded plugin surface answers 404 — * existence stays hidden, the same semantics as `api.enabled` and * `mcp.enabled`. The fallback-metadata route is deliberately NOT guarded * (it serves no plugin code and existing blocks need it for their declared * fallback). The settings cache is in-process, so flipping the switch is * followed by an api restart like every other instance setting * (operations.md); the admin UI toggle documents that. */ @Injectable() export class PluginsEnabledGuard implements CanActivate { constructor(private readonly settings: InstanceSettingsService) {} async canActivate(): Promise { if (!(await this.settings.get('plugins.enabled'))) throw new NotFoundException(); return true; } }