Path: blob/main/src/vs/workbench/contrib/chat/common/constants.ts
5283 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 { Schemas } from '../../../../base/common/network.js';6import { IChatSessionsService } from './chatSessionsService.js';7import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';8import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';910export enum ChatConfiguration {11AIDisabled = 'chat.disableAIFeatures',12AgentEnabled = 'chat.agent.enabled',13PlanAgentDefaultModel = 'chat.planAgent.defaultModel',14RequestQueueingEnabled = 'chat.requestQueuing.enabled',15RequestQueueingDefaultAction = 'chat.requestQueuing.defaultAction',16AgentStatusEnabled = 'chat.agentsControl.enabled',17EditorAssociations = 'chat.editorAssociations',18UnifiedAgentsBar = 'chat.unifiedAgentsBar.enabled',19AgentSessionProjectionEnabled = 'chat.agentSessionProjection.enabled',20EditModeHidden = 'chat.editMode.hidden',21AlternativeToolAction = 'chat.alternativeToolAction.enabled',22Edits2Enabled = 'chat.edits2.enabled',23ExtensionToolsEnabled = 'chat.extensionTools.enabled',24RepoInfoEnabled = 'chat.repoInfo.enabled',25EditRequests = 'chat.editRequests',26InlineReferencesStyle = 'chat.inlineReferences.style',27AutoReply = 'chat.autoReply',28GlobalAutoApprove = 'chat.tools.global.autoApprove',29AutoApproveEdits = 'chat.tools.edits.autoApprove',30AutoApprovedUrls = 'chat.tools.urls.autoApprove',31EligibleForAutoApproval = 'chat.tools.eligibleForAutoApproval',32EnableMath = 'chat.math.enabled',33CheckpointsEnabled = 'chat.checkpoints.enabled',34ThinkingStyle = 'chat.agent.thinkingStyle',35ThinkingGenerateTitles = 'chat.agent.thinking.generateTitles',36TerminalToolsInThinking = 'chat.agent.thinking.terminalTools',37AutoExpandToolFailures = 'chat.tools.autoExpandFailures',38TodosShowWidget = 'chat.tools.todos.showWidget',39NotifyWindowOnResponseReceived = 'chat.notifyWindowOnResponseReceived',40ChatViewSessionsEnabled = 'chat.viewSessions.enabled',41ChatViewSessionsGrouping = 'chat.viewSessions.grouping',42ChatViewSessionsOrientation = 'chat.viewSessions.orientation',43ChatViewProgressBadgeEnabled = 'chat.viewProgressBadge.enabled',44SubagentToolCustomAgents = 'chat.customAgentInSubagent.enabled',45ShowCodeBlockProgressAnimation = 'chat.agent.codeBlockProgress',46RestoreLastPanelSession = 'chat.restoreLastPanelSession',47ExitAfterDelegation = 'chat.exitAfterDelegation',48AgentsControlClickBehavior = 'chat.agentsControl.clickBehavior',49ExplainChangesEnabled = 'chat.editing.explainChanges.enabled',50}5152/**53* The "kind" of agents for custom agents.54*/55export enum ChatModeKind {56Ask = 'ask',57Edit = 'edit',58Agent = 'agent'59}6061export function validateChatMode(mode: unknown): ChatModeKind | undefined {62switch (mode) {63case ChatModeKind.Ask:64case ChatModeKind.Edit:65case ChatModeKind.Agent:66return mode as ChatModeKind;67default:68return undefined;69}70}7172export function isChatMode(mode: unknown): mode is ChatModeKind {73return !!validateChatMode(mode);74}7576// Thinking display modes for pinned content77export enum ThinkingDisplayMode {78Collapsed = 'collapsed',79CollapsedPreview = 'collapsedPreview',80FixedScrolling = 'fixedScrolling',81}8283export enum CollapsedToolsDisplayMode {84Off = 'off',85WithThinking = 'withThinking',86Always = 'always',87}8889export enum AgentsControlClickBehavior {90Default = 'default',91Cycle = 'cycle',92Focus = 'focus',93}9495export type RawChatParticipantLocation = 'panel' | 'terminal' | 'notebook' | 'editing-session';9697export enum ChatAgentLocation {98/**99* This is chat, whether it's in the sidebar, a chat editor, or quick chat.100* Leaving the values alone as they are in stored data so we don't have to normalize them.101*/102Chat = 'panel',103Terminal = 'terminal',104Notebook = 'notebook',105/**106* EditorInline means inline chat in a text editor.107*/108EditorInline = 'editor',109}110111export namespace ChatAgentLocation {112export function fromRaw(value: RawChatParticipantLocation | string): ChatAgentLocation {113switch (value) {114case 'panel': return ChatAgentLocation.Chat;115case 'terminal': return ChatAgentLocation.Terminal;116case 'notebook': return ChatAgentLocation.Notebook;117case 'editor': return ChatAgentLocation.EditorInline;118}119return ChatAgentLocation.Chat;120}121}122123/**124* List of file schemes that are always unsupported for use in chat125*/126const chatAlwaysUnsupportedFileSchemes = new Set([127Schemas.vscodeChatEditor,128Schemas.walkThrough,129Schemas.vscodeLocalChatSession,130Schemas.vscodeSettings,131Schemas.webviewPanel,132Schemas.vscodeUserData,133Schemas.extension,134'ccreq',135'openai-codex', // Codex session custom editor scheme136]);137138export function isSupportedChatFileScheme(accessor: ServicesAccessor, scheme: string): boolean {139const chatService = accessor.get(IChatSessionsService);140141// Exclude schemes we always know are bad142if (chatAlwaysUnsupportedFileSchemes.has(scheme)) {143return false;144}145146// Plus any schemes used by content providers147if (chatService.getContentProviderSchemes().includes(scheme)) {148return false;149}150151// Everything else is supported152return true;153}154155export const MANAGE_CHAT_COMMAND_ID = 'workbench.action.chat.manage';156export const ChatEditorTitleMaxLength = 30;157158export const CHAT_TERMINAL_OUTPUT_MAX_PREVIEW_LINES = 1000;159export const CONTEXT_MODELS_EDITOR = new RawContextKey<boolean>('inModelsEditor', false);160export const CONTEXT_MODELS_SEARCH_FOCUS = new RawContextKey<boolean>('inModelsSearch', false);161162163