Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/agentHost/browser/nullAgentHostService.ts
13394 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Event } from '../../../base/common/event.js';
7
import { IReference } from '../../../base/common/lifecycle.js';
8
import { constObservable, IObservable } from '../../../base/common/observable.js';
9
import { URI } from '../../../base/common/uri.js';
10
import type { IAgentCreateSessionConfig, IAgentHostInspectInfo, IAgentHostService, IAgentHostSocketInfo, IAgentResolveSessionConfigParams, IAgentSessionConfigCompletionsParams, IAgentSessionMetadata, AuthenticateParams, AuthenticateResult } from '../common/agentService.js';
11
import type { IAgentSubscription } from '../common/state/agentSubscription.js';
12
import type { CreateTerminalParams, ResolveSessionConfigResult, SessionConfigCompletionsResult } from '../common/state/protocol/commands.js';
13
import type { ActionEnvelope, INotification, IRootConfigChangedAction, SessionAction, TerminalAction } from '../common/state/sessionActions.js';
14
import type { ResourceCopyParams, ResourceCopyResult, ResourceDeleteParams, ResourceDeleteResult, ResourceListResult, ResourceMoveParams, ResourceMoveResult, ResourceReadResult, ResourceWriteParams, ResourceWriteResult } from '../common/state/sessionProtocol.js';
15
import type { ComponentToState, RootState, StateComponents } from '../common/state/sessionState.js';
16
17
const notSupported = () => { throw new Error('Local agent host is not supported in the browser.'); };
18
19
/**
20
* Null implementation of {@link IAgentHostService} for browser contexts
21
* where a local agent host process is not available.
22
*/
23
export class NullAgentHostService implements IAgentHostService {
24
declare readonly _serviceBrand: undefined;
25
26
readonly clientId = '';
27
readonly onAgentHostExit = Event.None;
28
readonly onAgentHostStart = Event.None;
29
readonly onDidNotification: Event<INotification> = Event.None;
30
readonly onDidAction: Event<ActionEnvelope> = Event.None;
31
32
readonly authenticationPending: IObservable<boolean> = constObservable(false);
33
setAuthenticationPending(_pending: boolean): void { /* no-op */ }
34
35
get rootState(): IAgentSubscription<RootState> { return notSupported(); }
36
37
getSubscription<T extends StateComponents>(_kind: T, _resource: URI): IReference<IAgentSubscription<ComponentToState[T]>> { return notSupported(); }
38
getSubscriptionUnmanaged<T extends StateComponents>(_kind: T, _resource: URI): IAgentSubscription<ComponentToState[T]> | undefined { return undefined; }
39
dispatch(_action: SessionAction | TerminalAction | IRootConfigChangedAction): void { notSupported(); }
40
41
async restartAgentHost(): Promise<void> { notSupported(); }
42
async authenticate(_params: AuthenticateParams): Promise<AuthenticateResult> { return notSupported(); }
43
async listSessions(): Promise<IAgentSessionMetadata[]> { return []; }
44
async createSession(_config?: IAgentCreateSessionConfig): Promise<URI> { return notSupported(); }
45
async resolveSessionConfig(_params: IAgentResolveSessionConfigParams): Promise<ResolveSessionConfigResult> { return notSupported(); }
46
async sessionConfigCompletions(_params: IAgentSessionConfigCompletionsParams): Promise<SessionConfigCompletionsResult> { return notSupported(); }
47
async startWebSocketServer(): Promise<IAgentHostSocketInfo> { return notSupported(); }
48
async getInspectInfo(_tryEnable: boolean): Promise<IAgentHostInspectInfo | undefined> { return undefined; }
49
async disposeSession(_session: URI): Promise<void> { }
50
async createTerminal(_params: CreateTerminalParams): Promise<void> { notSupported(); }
51
async disposeTerminal(_terminal: URI): Promise<void> { }
52
async resourceList(_uri: URI): Promise<ResourceListResult> { return notSupported(); }
53
async resourceRead(_uri: URI): Promise<ResourceReadResult> { return notSupported(); }
54
async resourceWrite(_params: ResourceWriteParams): Promise<ResourceWriteResult> { return notSupported(); }
55
async resourceCopy(_params: ResourceCopyParams): Promise<ResourceCopyResult> { return notSupported(); }
56
async resourceDelete(_params: ResourceDeleteParams): Promise<ResourceDeleteResult> { return notSupported(); }
57
async resourceMove(_params: ResourceMoveParams): Promise<ResourceMoveResult> { return notSupported(); }
58
}
59
60