/** * bundle-manifest.ts * * The capability-bundle manifest format. A bundle is a distributable unit * (plugin/skill/hook-pack/policy-pack) that declares EXACTLY which capabilities * it needs, up front, so the runtime can grant it ONLY what it declared, * deny-by-default at the surface level, not just the security-capability level. * * This layers on the existing plugin capability model (`PluginCapability`, * `resolveCapabilityManifest`, `filterCapabilitiesByTrust`) in * `../plugins/`. The security capabilities (`filesystem.*`, `network.*`, * `shell.exec`, `register.*`) are reused verbatim; the bundle adds four * *surface* declarations the plugin model did not capture: * * - `tools` , gateway/agent tool ids the bundle registers * - `hooks` , runtime hook/event names the bundle subscribes to * - `configDomains`: config domains the bundle reads * - `channels` , channel surfaces the bundle touches * * The enforcement contract (`createBundleCapabilityGuard`) is the load-bearing * piece: a bundle that tries to register a tool, subscribe a hook, read a config * domain, touch a channel, or exercise a security capability it did NOT declare * is refused. The declaration IS the grant; nothing outside it is reachable. */ import type { PluginCapability } from '../plugins/types.js'; /** The four capability surfaces a bundle declares beyond security capabilities. */ export type BundleSurfaceKind = 'tool' | 'hook' | 'config-domain' | 'channel'; /** * The capability declaration block of a bundle manifest. Every field is a * closed list: the runtime grants the bundle these and nothing else. */ export interface BundleCapabilityDeclaration { /** Deny-by-default security capabilities (reused from the plugin model). */ readonly runtime: readonly PluginCapability[]; /** Gateway/agent tool ids this bundle registers. */ readonly tools: readonly string[]; /** Runtime hook / event names this bundle subscribes to. */ readonly hooks: readonly string[]; /** Config domains this bundle reads. */ readonly configDomains: readonly string[]; /** Channel surfaces this bundle touches. */ readonly channels: readonly string[]; } /** * A capability-bundle manifest. `schemaVersion` is fixed at 1 so a future * format change is a representable, checkable bump rather than a silent drift. */ export interface CapabilityBundleManifest { readonly schemaVersion: 1; readonly id: string; readonly name: string; readonly version: string; readonly description: string; readonly kind: 'plugin' | 'skill' | 'hook-pack' | 'policy-pack'; readonly capabilities: BundleCapabilityDeclaration; readonly author?: string | undefined; /** Minimum runtime version (semver). Advisory; the installer enforces fit. */ readonly minRuntimeVersion?: string | undefined; } /** A concise, index-embeddable summary of what a bundle can do. */ export interface BundleCapabilitySummary { readonly runtime: readonly PluginCapability[]; readonly toolCount: number; readonly hookCount: number; readonly configDomainCount: number; readonly channelCount: number; /** True when the bundle declares any high-risk security capability. */ readonly highRisk: boolean; } /** Result of validating an untrusted value as a capability-bundle manifest. */ export type BundleManifestValidation = { readonly ok: true; readonly manifest: CapabilityBundleManifest; } | { readonly ok: false; readonly errors: readonly string[]; }; /** * Validate an untrusted value as a capability-bundle manifest. Returns the typed * manifest on success or the full list of reasons it was rejected. Unknown * security capabilities are a hard error (not silently dropped) so a bundle * cannot smuggle a typo past review. */ export declare function validateCapabilityBundleManifest(value: unknown): BundleManifestValidation; /** Summarize a bundle's declared capabilities for a marketplace index entry. */ export declare function summarizeBundleCapabilities(manifest: CapabilityBundleManifest): BundleCapabilitySummary; /** * A guard that answers "may this bundle do X?" for each capability surface. * Deny-by-default: anything not present in the declaration returns false. */ export interface BundleCapabilityGuard { readonly manifest: CapabilityBundleManifest; mayUseCapability(capability: PluginCapability): boolean; mayRegisterTool(toolId: string): boolean; maySubscribeHook(hookName: string): boolean; mayReadConfigDomain(domain: string): boolean; mayTouchChannel(surface: string): boolean; } /** Build a deny-by-default guard from a validated bundle manifest. */ export declare function createBundleCapabilityGuard(manifest: CapabilityBundleManifest): BundleCapabilityGuard; /** Raised when a bundle exercises a capability it did not declare. */ export declare class BundleCapabilityViolation extends Error { readonly bundleId: string; readonly surface: BundleSurfaceKind | 'runtime'; readonly capabilityName: string; constructor(bundleId: string, surface: BundleSurfaceKind | 'runtime', capabilityName: string); } /** * Enforce a bundle action against its guard, throwing `BundleCapabilityViolation` * when the action was not declared. The single choke-point runtime registration * paths call before honoring a bundle's request. */ export declare function enforceBundleCapability(guard: BundleCapabilityGuard, surface: BundleSurfaceKind | 'runtime', name: string): void; /** A blank capability-bundle manifest for `plugin-bundle init` scaffolding. */ export declare function scaffoldCapabilityBundleManifest(id: string, kind?: CapabilityBundleManifest['kind']): CapabilityBundleManifest; //# sourceMappingURL=bundle-manifest.d.ts.map