Path: blob/main/src/vs/platform/agentHost/common/agentHostFileSystemService.ts
13394 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Disposable, IDisposable } from '../../../base/common/lifecycle.js';6import { IFileService } from '../../files/common/files.js';7import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';8import { createDecorator } from '../../instantiation/common/instantiation.js';9import { ILabelService } from '../../label/common/label.js';10import { AgentHostFileSystemProvider, type IRemoteFilesystemConnection } from './agentHostFileSystemProvider.js';11import { AGENT_HOST_LABEL_FORMATTER, AGENT_HOST_SCHEME } from './agentHostUri.js';1213export type { IRemoteFilesystemConnection } from './agentHostFileSystemProvider.js';1415export const IAgentHostFileSystemService = createDecorator<IAgentHostFileSystemService>('agentHostFileSystemService');1617export interface IAgentHostFileSystemService {18readonly _serviceBrand: undefined;1920/**21* Register a mapping from a URI authority to a connection so that22* `vscode-agent-host://[authority]/…` URIs resolve through this connection.23*/24registerAuthority(authority: string, connection: IRemoteFilesystemConnection): IDisposable;25}2627class AgentHostFileSystemService extends Disposable implements IAgentHostFileSystemService {28declare readonly _serviceBrand: undefined;2930private readonly _fsProvider: AgentHostFileSystemProvider;3132constructor(33@IFileService fileService: IFileService,34@ILabelService labelService: ILabelService,35) {36super();3738this._fsProvider = this._register(new AgentHostFileSystemProvider());39this._register(fileService.registerProvider(AGENT_HOST_SCHEME, this._fsProvider));40this._register(labelService.registerFormatter(AGENT_HOST_LABEL_FORMATTER));41}4243registerAuthority(authority: string, connection: IRemoteFilesystemConnection): IDisposable {44return this._fsProvider.registerAuthority(authority, connection);45}46}4748registerSingleton(IAgentHostFileSystemService, AgentHostFileSystemService, InstantiationType.Delayed);495051