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