Path: blob/main/src/vs/platform/agentHost/browser/nullAgentHostService.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 { Event } from '../../../base/common/event.js';6import { IReference } from '../../../base/common/lifecycle.js';7import { constObservable, IObservable } from '../../../base/common/observable.js';8import { URI } from '../../../base/common/uri.js';9import type { IAgentCreateSessionConfig, IAgentHostInspectInfo, IAgentHostService, IAgentHostSocketInfo, IAgentResolveSessionConfigParams, IAgentSessionConfigCompletionsParams, IAgentSessionMetadata, AuthenticateParams, AuthenticateResult } from '../common/agentService.js';10import type { IAgentSubscription } from '../common/state/agentSubscription.js';11import type { CreateTerminalParams, ResolveSessionConfigResult, SessionConfigCompletionsResult } from '../common/state/protocol/commands.js';12import type { ActionEnvelope, INotification, IRootConfigChangedAction, SessionAction, TerminalAction } from '../common/state/sessionActions.js';13import type { ResourceCopyParams, ResourceCopyResult, ResourceDeleteParams, ResourceDeleteResult, ResourceListResult, ResourceMoveParams, ResourceMoveResult, ResourceReadResult, ResourceWriteParams, ResourceWriteResult } from '../common/state/sessionProtocol.js';14import type { ComponentToState, RootState, StateComponents } from '../common/state/sessionState.js';1516const notSupported = () => { throw new Error('Local agent host is not supported in the browser.'); };1718/**19* Null implementation of {@link IAgentHostService} for browser contexts20* where a local agent host process is not available.21*/22export class NullAgentHostService implements IAgentHostService {23declare readonly _serviceBrand: undefined;2425readonly clientId = '';26readonly onAgentHostExit = Event.None;27readonly onAgentHostStart = Event.None;28readonly onDidNotification: Event<INotification> = Event.None;29readonly onDidAction: Event<ActionEnvelope> = Event.None;3031readonly authenticationPending: IObservable<boolean> = constObservable(false);32setAuthenticationPending(_pending: boolean): void { /* no-op */ }3334get rootState(): IAgentSubscription<RootState> { return notSupported(); }3536getSubscription<T extends StateComponents>(_kind: T, _resource: URI): IReference<IAgentSubscription<ComponentToState[T]>> { return notSupported(); }37getSubscriptionUnmanaged<T extends StateComponents>(_kind: T, _resource: URI): IAgentSubscription<ComponentToState[T]> | undefined { return undefined; }38dispatch(_action: SessionAction | TerminalAction | IRootConfigChangedAction): void { notSupported(); }3940async restartAgentHost(): Promise<void> { notSupported(); }41async authenticate(_params: AuthenticateParams): Promise<AuthenticateResult> { return notSupported(); }42async listSessions(): Promise<IAgentSessionMetadata[]> { return []; }43async createSession(_config?: IAgentCreateSessionConfig): Promise<URI> { return notSupported(); }44async resolveSessionConfig(_params: IAgentResolveSessionConfigParams): Promise<ResolveSessionConfigResult> { return notSupported(); }45async sessionConfigCompletions(_params: IAgentSessionConfigCompletionsParams): Promise<SessionConfigCompletionsResult> { return notSupported(); }46async startWebSocketServer(): Promise<IAgentHostSocketInfo> { return notSupported(); }47async getInspectInfo(_tryEnable: boolean): Promise<IAgentHostInspectInfo | undefined> { return undefined; }48async disposeSession(_session: URI): Promise<void> { }49async createTerminal(_params: CreateTerminalParams): Promise<void> { notSupported(); }50async disposeTerminal(_terminal: URI): Promise<void> { }51async resourceList(_uri: URI): Promise<ResourceListResult> { return notSupported(); }52async resourceRead(_uri: URI): Promise<ResourceReadResult> { return notSupported(); }53async resourceWrite(_params: ResourceWriteParams): Promise<ResourceWriteResult> { return notSupported(); }54async resourceCopy(_params: ResourceCopyParams): Promise<ResourceCopyResult> { return notSupported(); }55async resourceDelete(_params: ResourceDeleteParams): Promise<ResourceDeleteResult> { return notSupported(); }56async resourceMove(_params: ResourceMoveParams): Promise<ResourceMoveResult> { return notSupported(); }57}585960