import { T as ToolHost } from '../tool-host-BqJRPr_T.js'; import { B as Bridge } from '../types-D_TzdBsK.js'; import '../types-ITRQFAir.js'; /** * Headless bridge for `@particle-academy/fancy-features` — feature management * with NO UI surface. The adapter is the `FeatureManager` (a `FeatureSource` * consumer): define features in the registry, check access for a subject, * grant/revoke via group assignment, and meter resource usage. Mutations * funnel through `wrapToolWithActivity` so presence + undo compose; `grant` / * `revoke` are `pendingMode`-gated (they change what a real user can do). * * The adapter shapes mirror fancy-features' public `FeatureManager` + * `FeatureRegistry` + `GroupStore`, defined LOCALLY so the bridge builds with * the sibling absent (optional peer). A live `FeatureManager` (plus its * `.registry` / `.groupStore`) satisfies this structurally with no import. * * SUBJECTS over the wire: `Subject` is opaque (`unknown`) in fancy-features. * Agents pass a JSON-serializable subject (string id or `{ id, … }` object); * the host's stores key on it via their `defaultSubjectKey`. */ type FeatureGrant = { key: string; type: "boolean" | "resource"; enabled: boolean; includedQuantity?: number | null; overageLimit?: number | null; source?: string; config?: Record; }; /** Normalized feature definition (mirror of fancy-features `FeatureDefinition`). */ type FeatureDefinition = { key?: string; name?: string; description?: string; type?: "boolean" | "resource"; enabled?: boolean; limit?: number; [k: string]: unknown; }; /** * Adapter = the `FeatureManager` + its registry + group store. The bridge only * needs these members; a real manager exposes them directly. */ type FeaturesBridgeAdapter = { /** Stable id for this feature manager instance. */ id?: string; title?: string; screenId?: string; /** Can the subject access the feature now? `manager.canAccess`. */ canAccess(feature: string, subject?: unknown, context?: unknown): boolean | Promise; /** Remaining quota for a resource feature (null = unlimited / n-a). `manager.remaining`. */ remaining(feature: string, subject?: unknown, context?: unknown): number | null | Promise; /** All enabled feature keys for the subject. `manager.enabled`. */ enabled(subject?: unknown, context?: unknown): string[] | Promise; /** Trace a feature's resolution to an AccessResult. `manager.explain`. */ explain?(feature: string, subject?: unknown, context?: unknown): Promise | unknown; /** Register a programmatic feature. `manager.registerFeature` / `manager.registry.register`. */ registerFeature(key: string, definition: FeatureDefinition): void; /** Registered feature keys. `manager.registry.keys`. */ registryKeys(): string[]; /** Resolve a registered definition (or null). `manager.registry.definition`. */ definition?(key: string): FeatureDefinition | null | Promise; /** Assign a subject to a feature group (the grant primitive). `manager.groupStore.assign`. */ assignGroup(subject: unknown, groupKey: string): void | Promise; /** Detach a subject from a group (the revoke primitive). `manager.groupStore.detach`. */ detachGroup(subject: unknown, groupKey: string): void | Promise; /** Group keys assigned to a subject. `manager.groupStore.list`. */ listGroups(subject: unknown): string[] | Promise; /** Current usage for a resource feature. `manager.usageFor`. Optional. */ usageFor?(feature: string, subject: unknown): number | Promise; /** Atomic check-and-increment quota. `manager.tryConsume`. Optional. */ tryConsume?(feature: string, subject: unknown, amount?: number, context?: unknown): boolean | Promise; }; type FeaturesBridgeOptions = { adapter: FeaturesBridgeAdapter; agent?: { id: string; name?: string; color?: string; }; /** * Trust-but-verify. When on (default), `features_grant` / `features_revoke` * (they change a real subject's entitlements) require `confirm:true` OR a * host `confirm` hook. Checks + define + usage are unaffected. */ pendingMode?: boolean; confirm?: (req: { action: string; subject: unknown; groupKey: string; }) => Promise | boolean; }; /** * registerFeaturesBridge — full MCP tool set over a headless feature manager. * * features_list enabled feature keys for a subject * features_check can a subject access a feature? (+ remaining for resources) * features_explain trace why a feature is on/off for a subject * features_define register a feature definition (boolean / resource) * features_grant assign a subject to a group (pendingMode-gated, undoable) * features_revoke detach a subject from a group (pendingMode-gated, undoable) * features_groups list a subject's assigned groups * features_consume meter a resource feature (atomic check-and-increment) */ declare function registerFeaturesBridge(host: ToolHost, options: FeaturesBridgeOptions): Bridge; export { type FeatureDefinition, type FeatureGrant, type FeaturesBridgeAdapter, type FeaturesBridgeOptions, registerFeaturesBridge };