import { KnownMarketplace, KnownMarketplacesRegistry, InstalledPlugin, InstalledPluginsRegistry, MarketplaceManifest, MarketplaceSource } from "../types/marketplace.js"; import { ConfigurationService } from "./configurationService.js"; import type { Scope } from "../types/configuration.js"; /** * Marketplace Service * * Handles local plugin marketplace registration, plugin installation, * and state management for installed plugins. * * Marketplace declarations are now scoped (user/project/local) via settings files. * known_marketplaces.json is kept as a cache for installLocation/lastUpdated metadata. */ export declare class MarketplaceService { private static isLockedInProcess; private pluginsDir; private knownMarketplacesPath; private installedPluginsPath; private lockPath; private tmpDir; private cacheDir; private marketplacesDir; private gitService; private configurationService; private workdir; private static readonly BUILTIN_MARKETPLACE; constructor(workdir?: string, configurationService?: ConfigurationService); /** * Ensures the required directory structure exists in ~/.wave/plugins */ private ensureDirectoryStructure; /** * Backwards compatibility migration: migrate entries from known_marketplaces.json * to user-level settings if they aren't already declared there. */ private runMigration; /** * Seeds the builtin marketplace on first startup. * Adds it to user-scope settings and marks the cache as seeded. */ private seedBuiltinMarketplace; /** * Sets the builtinSeeded flag in the cache registry, preserving all other fields. */ private setBuiltinSeeded; /** * Check if a lock file is stale by reading its PID and checking if the process is alive. * Returns true if the lock is stale and safe to remove. */ private isStaleLock; /** * Acquires a file-based lock (with PID tracking for stale lock detection) and executes the provided function. * Supports re-entrancy within the same process. */ private withLock; /** * Loads the cache registry from known_marketplaces.json * Returns null if the file doesn't exist or has no parseable content (for first-run detection). */ getCacheRegistry(): Promise; /** * Legacy method: loads known marketplaces from cache. * @deprecated Use listMarketplaces() instead, which combines scoped settings. */ getKnownMarketplaces(): Promise; /** * Updates the cache registry with metadata for a marketplace */ private updateCacheMarketplace; /** * Removes a marketplace from the cache registry */ private removeFromCache; /** * Loads the installed plugins registry */ getInstalledPlugins(): Promise; /** * Saves the installed plugins registry */ saveInstalledPlugins(registry: InstalledPluginsRegistry): Promise; /** * Loads a marketplace manifest from a local path */ loadMarketplaceManifest(marketplacePath: string): Promise; /** * Resolves the local path for a marketplace */ getMarketplacePath(source: MarketplaceSource): string; /** * Builds a KnownMarketplace from a scoped config, enriched with cache metadata */ private buildMarketplaceEntry; /** * Finds which scope declared a marketplace (user, project, local, or builtin) */ getMarketplaceDeclaringSource(name: string): Scope | "builtin" | null; /** * Adds a new marketplace (local directory, GitHub repo, or Git URL) */ addMarketplace(input: string, scope?: Scope): Promise; /** * Lists all registered marketplaces by combining scoped settings + cache */ listMarketplaces(): Promise; /** * Removes a marketplace by name from the specified scope */ removeMarketplace(name: string, scope?: Scope): Promise; /** * Uninstalls all plugins belonging to a given marketplace. * Removes them from installed_plugins.json, deletes cache files, * and cleans up enabledPlugins entries from all scopes. */ private uninstallPluginsByMarketplace; /** * Updates a specific marketplace or all marketplaces */ updateMarketplace(name?: string, options?: { updatePlugins?: boolean; }): Promise; /** * Automatically updates all marketplaces that have auto-update enabled */ autoUpdateAll(): Promise; /** * Toggles auto-update for a marketplace */ toggleAutoUpdate(name: string, enabled: boolean): Promise; /** * Installs a plugin from a marketplace */ installPlugin(pluginAtMarketplace: string, projectPath?: string): Promise; /** * Uninstalls a plugin */ uninstallPlugin(pluginAtMarketplace: string, projectPath?: string): Promise; /** * Updates a plugin (uninstall followed by install) */ updatePlugin(pluginAtMarketplace: string): Promise; }