Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/chatSessions/claude/common/claudeToolPermissionRegistry.ts
13405 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 { IClaudeToolPermissionHandlerCtor } from './claudeToolPermission';
7
import { ClaudeToolNames } from './claudeTools';
8
9
/**
10
* Registry entry for tool permission handlers
11
*/
12
export interface IToolPermissionHandlerRegistration {
13
readonly toolNames: readonly ClaudeToolNames[];
14
readonly ctor: IClaudeToolPermissionHandlerCtor;
15
}
16
17
/**
18
* Registry of tool permission handlers.
19
* Handlers can register from common/, node/, or vscode-node/ folders.
20
*/
21
const handlerRegistry: IToolPermissionHandlerRegistration[] = [];
22
23
/**
24
* Register a tool permission handler for one or more tools.
25
* Handlers are instantiated lazily via the instantiation service.
26
*
27
* @param toolNames The tool name(s) to register the handler for
28
* @param ctor The handler constructor
29
*/
30
export function registerToolPermissionHandler<T extends ClaudeToolNames>(
31
toolNames: readonly T[],
32
ctor: IClaudeToolPermissionHandlerCtor<T>
33
): void {
34
handlerRegistry.push({ toolNames, ctor });
35
}
36
37
/**
38
* Get all registered tool permission handlers.
39
* Used by ClaudeToolPermissionService to look up handlers.
40
*/
41
export function getToolPermissionHandlerRegistry(): readonly IToolPermissionHandlerRegistration[] {
42
return handlerRegistry;
43
}
44
45