import { Disposable } from "../../../../../../base/common/lifecycle.js"; import { URI } from "../../../../../../base/common/uri.js"; import { IFileService } from "../../../../../../platform/files/common/files.service.js"; import { ILogService } from "../../../../../../platform/log/common/log.service.js"; import { IMcpServerConfiguration } from "../../../../../../platform/mcp/common/mcpPlatformTypes.js"; import { PromptsType } from "../../../common/promptSyntax/promptTypes.js"; import { AICustomizationSource } from "../../../common/aiCustomizationWorkspaceService.js"; import { type ClientPluginCustomization } from "../../../../../../platform/agentHost/common/state/sessionState.js"; import { type CustomizationEnablement } from "../../../../../../platform/agentHost/common/state/protocol/state.js"; import { SYNCED_CUSTOMIZATION_SCHEME } from "../../../../../services/agentHost/common/agentHostFileSystemService.js"; import { IAgentHostFileSystemService } from "../../../../../services/agentHost/common/agentHostFileSystemService.service.js"; export { SYNCED_CUSTOMIZATION_SCHEME }; export interface ISyncableFile { readonly uri: URI; readonly type: PromptsType; /** Inline content for client-authored rules that have no source file. */ readonly content?: string; /** * Where this file originally came from (extension, plugin, built-in, ...). * Optional because it is only used to populate the provenance reverse map; * files without it simply have no recoverable {@link ISyncedCustomizationOrigin}. */ readonly source?: AICustomizationSource; /** Identifier of the contributing extension, when {@link source} is `extension`. */ readonly extensionId?: string; /** Root URI of the contributing plugin, when {@link source} is `plugin`. */ readonly pluginUri?: URI; } /** * Describes where a file bundled into the synthetic plugin originally came * from. The bundle flattens files from many different sources (extensions, * plugins, built-ins) into a single in-memory plugin, which erases their * provenance. {@link SyncedCustomizationBundler.getOrigin} lets consumers * recover it by mapping a synced (destination) URI back to this record. */ export interface ISyncedCustomizationOrigin { /** The source file URI, or the bundled URI for client-authored content without a source file. */ readonly uri: URI; /** Where the file originally came from (extension, plugin, built-in, ...). */ readonly source: AICustomizationSource; /** Identifier of the contributing extension, when {@link source} is `extension`. */ readonly extensionId?: string; /** Root URI of the contributing plugin, when {@link source} is `plugin`. */ readonly pluginUri?: URI; } /** * An MCP server configured directly in VS Code (i.e. not contributed by an * agent plugin) that should be bundled into the synthetic plugin so the * agent host can launch it. */ export interface ISyncableMcpServer { readonly name: string; readonly configuration: IMcpServerConfiguration; readonly defaultCwd?: URI; readonly enablement: readonly CustomizationEnablement[]; } export interface ISyncedCustomizationBundlerOptions { /** Separates colliding agent filenames without changing paths for uniquely named agents. */ readonly preserveAgentFileCollisions?: boolean; /** * Bundles standalone customizations: user and workspace skills and agents, * and the MCP servers that VS Code forwards. The bundle is marked so that a * host does not deliver its contents as plugin-provided, which lets the * runtime apply `strictPluginOnlyCustomization` to them. */ readonly standalone?: boolean; } interface IBundleResult { readonly ref: ClientPluginCustomization; } /** * Bundles individual customization files into a synthetic Open Plugin * backed by an in-memory filesystem. * * Each bundler instance is namespaced by its authority string so that * multiple agent workspace scopes can coexist under the same scheme without * conflicts. * The plugin is mounted at `vscode-synced-customization:///{authority}/` * and structured as: * * ``` * .plugin/plugin.json * .mcp.json ← MCP servers configured in VS Code * rules/ ← instruction files * commands/ ← prompt files * agents/ ← agent files, optionally namespaced when filenames collide * skills/ ← skill directories * ``` * * The bundler computes a content-based nonce so the agent host can * skip re-loading when nothing has changed. * * A standalone bundler ({@link ISyncedCustomizationBundlerOptions.standalone}) * carries standalone customizations separately from other synced content, so * the host can keep them out of plugin delivery. */ export declare class SyncedCustomizationBundler extends Disposable { private readonly _fileService; private readonly _logService; private readonly _fileOperationLimiter; private readonly _authority; private readonly _standalone; private readonly _preserveAgentFileCollisions; private _lastNonce; private _lastRef; private _isDisposed; /** Maps a synced (destination) URI string back to its original source location. Rebuilt on every {@link bundle}. */ private _originByDest; constructor(authority: string, options: ISyncedCustomizationBundlerOptions | undefined, _fileService: IFileService, agentHostFileSystemService: IAgentHostFileSystemService, _logService: ILogService); /** * Root URI of the virtual plugin directory for this bundler. * The authority is encoded into the path (not the URI authority) because * {@link InMemoryFileSystemProvider} only routes by path. */ private get _rootUri(); private _queueFileOperation; private _throwIfDisposed; /** * Bundles the given files and MCP servers into the in-memory plugin * filesystem. * * Overwrites any previous bundle content. Returns a {@link ClientPluginCustomization} * pointing at the virtual plugin directory with a content-based nonce. * * @returns The bundle result, or `undefined` if there is nothing to sync. */ bundle(files: readonly ISyncableFile[], mcpServers?: readonly ISyncableMcpServer[]): Promise; private _bundle; private _toMeta; private _reuseLastBundle; /** * Returns the last computed nonce, or `undefined` if no bundle has been created. */ get lastNonce(): string | undefined; isBundledMcpServer(pluginUri: string, serverName: string): boolean; /** * Recovers the original provenance of a file that was flattened into the * synthetic bundle, given its synced (destination) URI. Returns `undefined` * for URIs that are not part of the most recent bundle. */ getOrigin(syncedUri: URI): ISyncedCustomizationOrigin | undefined; /** Finds the bundled URI for a source file in the most recent bundle. */ getSyncedUri(sourceUri: URI): URI | undefined; dispose(): void; }