import { RebookPlugin } from './types'; export type RebookExtensionCategory = 'ai' | 'annotation' | 'export' | 'reader' | 'renderer' | 'theme' | 'translation' | 'tts' | 'utility' | 'other'; export type RebookExtensionCapability = 'ai.chat' | 'book.transform' | 'content.read' | 'content.rewrite' | 'reader.access' | 'renderer.route' | 'search' | 'theme' | 'translation' | 'tts.playback' | 'ui.panel'; export type RebookExtensionSettingType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object'; export type RebookExtensionPanelLocation = 'sidebar' | 'bottom' | 'reader' | 'settings'; export interface RebookExtensionCommandContribution { readonly id: string; readonly title: string; readonly category?: string; readonly icon?: string; readonly when?: string; } export interface RebookExtensionPanelContribution { readonly id: string; readonly title: string; readonly location?: RebookExtensionPanelLocation; readonly icon?: string; readonly when?: string; } export interface RebookExtensionSettingContribution { readonly type: RebookExtensionSettingType; readonly title?: string; readonly description?: string; readonly default?: unknown; readonly enum?: readonly unknown[]; readonly order?: number; readonly scope?: 'global' | 'book' | 'session'; readonly secret?: boolean; } export interface RebookExtensionToolContribution { readonly id: string; readonly title: string; readonly description?: string; readonly inputSchema?: Record; } export interface RebookExtensionContributions { readonly commands?: readonly RebookExtensionCommandContribution[]; readonly panels?: readonly RebookExtensionPanelContribution[]; readonly settings?: Record; readonly tools?: readonly RebookExtensionToolContribution[]; } export interface RebookResolvedExtensionContribution { readonly extensionId: string; readonly manifest: RebookExtensionManifest; readonly contribution: TContribution; } export interface RebookResolvedExtensionSettingContribution { readonly extensionId: string; readonly manifest: RebookExtensionManifest; readonly key: string; readonly contribution: RebookExtensionSettingContribution; } export interface RebookExtensionContributionIndex { readonly commands: readonly RebookResolvedExtensionContribution[]; readonly panels: readonly RebookResolvedExtensionContribution[]; readonly settings: readonly RebookResolvedExtensionSettingContribution[]; readonly tools: readonly RebookResolvedExtensionContribution[]; } export interface RebookDisposable { dispose(): void; } export type RebookExtensionCommandHandler = (...args: readonly unknown[]) => unknown | Promise; export interface RebookExtensionCommandRegistration { readonly id: string; readonly extensionId: string; readonly manifest: RebookExtensionManifest; readonly handler: RebookExtensionCommandHandler; } export interface RebookExtensionCommandService { registerCommand(id: string, handler: RebookExtensionCommandHandler): RebookDisposable; executeCommand(id: string, ...args: readonly unknown[]): Promise; hasCommand(id: string): boolean; listCommands(): readonly RebookExtensionCommandRegistration[]; } export interface RebookExtensionSettingInspection { readonly extensionId: string; readonly key: string; readonly manifest?: RebookExtensionManifest; readonly contribution?: RebookExtensionSettingContribution; readonly defaultValue?: unknown; readonly value?: T; readonly effectiveValue?: T; } export interface RebookExtensionSettingsService { get(key: string, fallback?: T): T; update(key: string, value: T): void; inspect(key: string): RebookExtensionSettingInspection; list(): readonly RebookExtensionSettingInspection[]; } export interface RebookExtensionHost { readonly commands: RebookExtensionCommandRegistry; readonly settings: RebookExtensionSettingsRegistry; readonly subscriptions: RebookExtensionSubscriptionRegistry; } export interface RebookExtensionManifest { /** Stable marketplace/package id, for example "rebook.ai-chat". */ readonly id: string; /** Human-readable extension name. */ readonly name: string; /** Semver-compatible extension version. */ readonly version: string; readonly displayName?: string; readonly description?: string; readonly publisher?: string; readonly license?: string; readonly homepage?: string; readonly repository?: string; readonly icon?: string; readonly keywords?: readonly string[]; readonly categories?: readonly RebookExtensionCategory[]; /** Capability declarations let hosts and future marketplaces filter extensions before loading code. */ readonly capabilities?: readonly RebookExtensionCapability[]; /** Package entry path for marketplace/distribution metadata. Runtime hosts may ignore it. */ readonly entry?: string; readonly engines?: { readonly rebook?: string; }; /** Future extension-point contributions such as commands, panels, tools, or settings schemas. */ readonly contributes?: RebookExtensionContributions; } export interface RebookExtensionContext { readonly apiVersion: 1; readonly extensionId: string; readonly manifest: RebookExtensionManifest; readonly subscriptions: RebookDisposable[]; readonly commands: RebookExtensionCommandService; readonly settings: RebookExtensionSettingsService; } export interface RebookExtension { readonly manifest: RebookExtensionManifest; /** * Static book transform. Useful for simple extensions that only wrap the Book API. */ readonly plugin?: RebookPlugin; /** * Static book transforms applied in order. */ readonly plugins?: readonly RebookPlugin[]; /** * Activate the extension and return zero or more book transforms. * Hosts call this before opening a book for now; future hosts can cache activation. */ activate?(context: RebookExtensionContext): void | RebookPlugin | readonly RebookPlugin[] | Promise; } export type RebookPluginLike = RebookPlugin | RebookExtension; export interface ResolvedRebookExtension { readonly manifest: RebookExtensionManifest; readonly plugins: readonly RebookPlugin[]; } export type RebookExtensionCatalogSource = 'builtin' | 'marketplace' | 'local' | 'remote' | string; export interface RebookExtensionCatalogEntry { readonly manifest: RebookExtensionManifest; /** Where this listing came from. Hosts can use this to distinguish built-ins from marketplace results. */ readonly source?: RebookExtensionCatalogSource; /** Optional URL or package locator used by an installer to fetch the extension bundle. */ readonly installUrl?: string; readonly verified?: boolean; readonly publishedAt?: string; readonly updatedAt?: string; } export interface RebookExtensionModuleFactoryContext { readonly manifest: RebookExtensionManifest; readonly catalogEntry?: RebookExtensionCatalogEntry; readonly installUrl?: string; } export type RebookExtensionModuleFactory = (context: RebookExtensionModuleFactoryContext) => RebookExtension | Promise; export interface RebookExtensionModuleExports { readonly default?: RebookExtension | RebookExtensionModuleFactory; readonly extension?: RebookExtension | RebookExtensionModuleFactory; readonly rebookExtension?: RebookExtension | RebookExtensionModuleFactory; readonly manifest?: RebookExtensionManifest; readonly plugin?: RebookPlugin; readonly plugins?: readonly RebookPlugin[]; readonly activate?: RebookExtension['activate']; } export interface RebookExtensionModuleLoadOptions { readonly manifest?: RebookExtensionManifest; readonly catalogEntry?: RebookExtensionCatalogEntry; } export type RebookExtensionModuleImporter = (installUrl: string) => Promise>; export interface RebookExtensionCatalogDocument { readonly schemaVersion?: 1; readonly source?: RebookExtensionCatalogSource; readonly entries?: readonly RebookExtensionCatalogEntry[]; readonly extensions?: readonly RebookExtensionCatalogEntry[]; readonly generatedAt?: string; } export interface RebookExtensionCatalogParseOptions { readonly source?: RebookExtensionCatalogSource; } export interface RebookExtensionInstallation { readonly id: string; readonly version?: string; readonly enabled?: boolean; readonly source?: RebookExtensionCatalogSource; readonly installedAt?: string; readonly updatedAt?: string; } export type RebookExtensionInstallState = 'available' | 'installed' | 'disabled'; export interface RebookExtensionCatalogItem extends RebookExtensionCatalogEntry { readonly installation?: RebookExtensionInstallation; readonly installState: RebookExtensionInstallState; readonly installed: boolean; readonly enabled: boolean; } export interface RebookExtensionCatalogQuery { readonly query?: string; readonly categories?: readonly RebookExtensionCategory[]; readonly capabilities?: readonly RebookExtensionCapability[]; readonly source?: RebookExtensionCatalogSource; readonly installed?: boolean; readonly enabled?: boolean; } export interface RebookExtensionManagerOptions { readonly catalog?: RebookExtensionCatalog | readonly RebookExtensionCatalogEntry[]; readonly installations?: readonly RebookExtensionInstallation[]; readonly now?: () => string; } export interface RebookExtensionManagerInstallOptions extends Omit { readonly version?: string; } export declare class RebookExtensionCommandRegistry { private readonly commands; registerExtensionCommand(manifest: RebookExtensionManifest, id: string, handler: RebookExtensionCommandHandler): RebookDisposable; executeCommand(id: string, ...args: readonly unknown[]): Promise; hasCommand(id: string): boolean; listCommands(): readonly RebookExtensionCommandRegistration[]; unregisterCommand(id: string): boolean; unregisterExtension(extensionId: string): number; clear(): void; } export declare function createRebookExtensionCommandRegistry(): RebookExtensionCommandRegistry; export declare class RebookExtensionSettingsRegistry { private readonly values; private readonly contributions; registerExtension(manifest: RebookExtensionManifest): RebookDisposable; unregisterExtension(extensionId: string): boolean; get(extensionId: string, key: string, fallback?: T): T; update(extensionId: string, key: string, value: T): void; inspect(extensionId: string, key: string): RebookExtensionSettingInspection; list(extensionId?: string): readonly RebookExtensionSettingInspection[]; toJSON(): Record>; load(snapshot: Record> | undefined): void; clearValues(extensionId?: string): void; clear(): void; private getContribution; } export declare function createRebookExtensionSettingsRegistry(): RebookExtensionSettingsRegistry; export declare class RebookExtensionSubscriptionRegistry { private readonly subscriptions; setExtensionSubscriptions(extensionId: string, subscriptions: readonly RebookDisposable[]): void; list(extensionId?: string): readonly RebookDisposable[]; count(extensionId?: string): number; deactivateExtension(extensionId: string): number; clear(): void; } export declare function createRebookExtensionSubscriptionRegistry(): RebookExtensionSubscriptionRegistry; export declare function createRebookExtensionHost(): RebookExtensionHost; export declare function defineRebookExtension(extension: RebookExtension): RebookExtension; export declare function defineRebookPlugin(manifest: RebookExtensionManifest, plugin: RebookPlugin): RebookExtension; export declare function normalizeRebookExtensionModule(moduleExports: RebookExtensionModuleExports | Record, options?: RebookExtensionModuleLoadOptions): Promise; export declare function loadRebookExtensionModule(installUrl: string, importer: RebookExtensionModuleImporter, options?: RebookExtensionModuleLoadOptions): Promise; export declare function isRebookExtension(value: RebookPluginLike | unknown): value is RebookExtension; export declare function getRebookExtensionManifest(value: RebookPluginLike): RebookExtensionManifest | null; export declare function getRebookExtensionContributionIndex(entries: readonly (RebookExtension | RebookExtensionManifest)[]): RebookExtensionContributionIndex; export declare function resolveRebookExtension(value: RebookExtension, host?: RebookExtensionHost): Promise; export declare function resolveRebookPlugins(entries: readonly RebookPluginLike[] | undefined, host?: RebookExtensionHost): Promise; export interface RebookExtensionRegistryInstallOptions { readonly replace?: boolean; } export declare class RebookExtensionRegistry { private readonly extensions; install(extension: RebookExtension, options?: RebookExtensionRegistryInstallOptions): RebookExtension; uninstall(id: string): boolean; get(id: string): RebookExtension | undefined; has(id: string): boolean; list(): readonly RebookExtension[]; manifests(): readonly RebookExtensionManifest[]; contributions(): RebookExtensionContributionIndex; getPlugins(host?: RebookExtensionHost): Promise; clear(): void; } export declare function createRebookExtensionRegistry(extensions?: readonly RebookExtension[]): RebookExtensionRegistry; export declare class RebookExtensionCatalog { private readonly entries; constructor(entries?: readonly RebookExtensionCatalogEntry[]); upsert(entry: RebookExtensionCatalogEntry): RebookExtensionCatalogEntry; remove(id: string): boolean; get(id: string): RebookExtensionCatalogEntry | undefined; has(id: string): boolean; list(query?: RebookExtensionCatalogQuery): readonly RebookExtensionCatalogEntry[]; search(query: string, options?: Omit): readonly RebookExtensionCatalogEntry[]; items(installations?: readonly RebookExtensionInstallation[], query?: RebookExtensionCatalogQuery): readonly RebookExtensionCatalogItem[]; clear(): void; private filter; } export declare function createRebookExtensionCatalog(entries?: readonly RebookExtensionCatalogEntry[]): RebookExtensionCatalog; export declare function parseRebookExtensionCatalogEntries(input: unknown, options?: RebookExtensionCatalogParseOptions): readonly RebookExtensionCatalogEntry[]; export declare function createRebookExtensionCatalogFromJSON(input: unknown, options?: RebookExtensionCatalogParseOptions): RebookExtensionCatalog; export declare function createRebookExtensionCatalogEntry(manifest: RebookExtensionManifest, entry?: Omit): RebookExtensionCatalogEntry; export declare function createRebookExtensionInstallation(extension: RebookExtension | RebookExtensionManifest, installation?: Omit): RebookExtensionInstallation; export declare class RebookExtensionManager { private readonly catalog; private readonly installations; private readonly now; constructor(options?: RebookExtensionManagerOptions); getCatalog(): RebookExtensionCatalog; upsertCatalogEntry(entry: RebookExtensionCatalogEntry): RebookExtensionCatalogEntry; getCatalogEntry(id: string): RebookExtensionCatalogEntry | undefined; listCatalogEntries(query?: RebookExtensionCatalogQuery): readonly RebookExtensionCatalogEntry[]; listItems(query?: RebookExtensionCatalogQuery): readonly RebookExtensionCatalogItem[]; getItem(id: string): RebookExtensionCatalogItem | undefined; install(extension: RebookExtension | RebookExtensionManifest | string, options?: RebookExtensionManagerInstallOptions): RebookExtensionInstallation; uninstall(id: string): boolean; enable(id: string): RebookExtensionInstallation; disable(id: string): RebookExtensionInstallation; setEnabled(id: string, enabled: boolean): RebookExtensionInstallation; getInstallation(id: string): RebookExtensionInstallation | undefined; listInstallations(): readonly RebookExtensionInstallation[]; isInstalled(id: string): boolean; isEnabled(id: string): boolean; toJSON(): readonly RebookExtensionInstallation[]; loadInstallations(installations: readonly RebookExtensionInstallation[] | undefined): void; clearInstallations(): void; private resolveInstallManifest; } export declare function createRebookExtensionManager(options?: RebookExtensionManagerOptions): RebookExtensionManager; export declare function assertRebookExtensionManifest(manifest: RebookExtensionManifest): RebookExtensionManifest; //# sourceMappingURL=extensions.d.ts.map