/** * RFC 0005 D-7 enforcement: subscribing to an intercept-class (decision) * event requires an explicit host-side grant — default deny. * * Interception is strictly more powerful than observation: a plugin that can * veto user input or a session switch can change what the user's intent * actually does. So `tui/input`, `tui/rewind-prompt`, `tui/session-switch` * and `tui/compact` are NOT free-for-all `ctx.on` targets: the subscribing * plugin (identified by its verified Component identity) must hold the * matching `domain.resource.intercept` grant. Grant answers * come from the unified 8-permission GrantStore in ./grants.js (registry- * driven defaults, `grants`/`denies` sections, corrupt fail-closed) — this * module is only the subscribe-time CHECKPOINT: which event needs which * permission, and the cordis bail hook that enforces it. * * A denied subscription never enters the dispatch chain — it is "as if * unregistered" (D-7) and the caller gets a no-op disposer plus a logger * warning naming the plugin, the event, and the missing grant. * * Re-check semantics (D-7: subscription, revocation, scope change): every * operation reads the live GrantStore and grant-owned registrations are * released when its change watcher observes a revocation. * * Mechanism: cordis bails `internal/listener` on EVERY `ctx.on` before * registering, with `this` bound to the subscribing context; a truthy bail * result skips the registration and becomes the caller's disposer. That is * the whole hook — no patching of the events service. */ import type { Context } from '@deepseek-ai/cordis'; import { EXTENSION_GRANTS_FILE, type GrantStore } from './grants.js'; import { type VerifiedComponentIdentity } from './component-identity.js'; /** The intercept permission each decision event requires (D-7 naming: * `domain.resource.intercept`). Observe-class events (tui/rewind-done, * tui/session-switched) are deliberately absent. */ export declare const DECISION_EVENT_PERMISSIONS: Readonly>; export { EXTENSION_GRANTS_FILE }; /** @deprecated Use GrantStore from ./grants.js (same shape, plus more). */ export type ExtensionGrants = GrantStore; /** @deprecated Use parseGrantStore from ./grants.js. */ export declare const parseExtensionGrants: (text: string) => GrantStore; /** @deprecated Use readGrantStore from ./grants.js. */ export declare const readExtensionGrants: (dir?: string) => GrantStore; export interface DecisionHandlerMetadata { componentId: string; activationId: string; event: string; order: string; } /** A host-mediated DecisionEvents registration. The registry is deliberately * separate from Cordis' private `_hooks`: admission and dispatch must not * depend on plugin load order or on an implementation detail of the event * service. */ export interface DecisionRegistrationOptions { /** Scope covered by this handler. When omitted it is derived from the * manifest declaration; an unsafe concrete-session declaration is refused. */ scope?: string; /** Deterministic order key. Handlers with the same activation/event must use * distinct keys; registration order is never used as a policy. */ order?: string; } export interface RegisteredDecisionHandler { readonly event: string; readonly scope: string; readonly componentId: string; readonly activationId: string; readonly order: string; readonly identity: VerifiedComponentIdentity; readonly ownerContext: Context; readonly listener: (payload: Record) => unknown; } export interface DecisionRegistry { grants: GrantStore; handlers: Map>; } export declare function decisionRegistryOf(ctx: Context): DecisionRegistry; /** Return a stable snapshot of handlers for one event and payload scope. */ export declare function decisionHandlersOf(ctx: Context, event: string, payloadScope?: string): readonly RegisteredDecisionHandler[]; /** Host-only registration used by TuiPluginHostRuntime. */ export declare function registerDecisionHandler(pluginCtx: Context, identity: VerifiedComponentIdentity, event: string, listener: (payload: Record) => unknown, options?: DecisionRegistrationOptions, onRelease?: () => void): () => boolean; /** Execute ctx.on for one host-mediated decision registration. */ export declare function withDecisionRegistration(ctx: Context, callback: () => T): T; export declare function decisionHandlerMetadataOf(listener: Function): DecisionHandlerMetadata | undefined; export declare function installDecisionGuard(ctx: Context, grants: GrantStore): void; //# sourceMappingURL=decision-guard.d.ts.map