Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/agentHost/common/state/sessionActions.ts
13399 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
// Action and notification types for the sessions process protocol.
7
// Re-exports from the auto-generated protocol layer with local aliases.
8
//
9
// VS Code-specific additions:
10
// - IToolCallStartAction extends protocol with `toolKind` and `language`
11
// - isRootAction / isSessionAction type guards
12
// - INotification alias for ProtocolNotification
13
14
// ---- Re-exports from protocol -----------------------------------------------
15
16
export {
17
ActionType,
18
type ActionEnvelope,
19
type ActionOrigin,
20
type RootAgentsChangedAction,
21
type RootActiveSessionsChangedAction,
22
type SessionCreationFailedAction,
23
type SessionDeltaAction,
24
type SessionDiffsChangedAction,
25
type SessionErrorAction,
26
type SessionModelChangedAction,
27
type SessionReadyAction,
28
type SessionReasoningAction,
29
type SessionResponsePartAction,
30
type SessionToolCallCompleteAction,
31
type SessionToolCallConfirmedAction,
32
type SessionToolCallApprovedAction,
33
type SessionToolCallDeniedAction,
34
type SessionToolCallDeltaAction,
35
type SessionToolCallReadyAction,
36
type SessionToolCallResultConfirmedAction,
37
type SessionToolCallStartAction,
38
type SessionTitleChangedAction,
39
type SessionTurnCancelledAction,
40
type SessionTurnCompleteAction,
41
type SessionTurnStartedAction,
42
type SessionUsageAction,
43
type SessionServerToolsChangedAction,
44
type SessionActiveClientChangedAction,
45
type SessionActiveClientToolsChangedAction,
46
type SessionCustomizationsChangedAction,
47
type SessionCustomizationToggledAction,
48
type SessionPendingMessageSetAction,
49
type SessionPendingMessageRemovedAction,
50
type SessionQueuedMessagesReorderedAction,
51
type SessionInputRequestedAction,
52
type SessionInputCompletedAction,
53
type SessionIsReadChangedAction,
54
type SessionIsArchivedChangedAction,
55
type SessionToolCallContentChangedAction,
56
type StateAction,
57
} from './protocol/actions.js';
58
59
export {
60
NotificationType,
61
AuthRequiredReason,
62
type SessionAddedNotification,
63
type SessionRemovedNotification,
64
type AuthRequiredNotification,
65
} from './protocol/notifications.js';
66
67
// ---- Local aliases for short names ------------------------------------------
68
// Consumers use these shorter names; they're type-only aliases.
69
70
import type {
71
RootAgentsChangedAction,
72
RootActiveSessionsChangedAction,
73
SessionDeltaAction,
74
SessionModelChangedAction,
75
SessionReasoningAction,
76
SessionResponsePartAction,
77
SessionToolCallApprovedAction,
78
SessionToolCallCompleteAction,
79
SessionToolCallConfirmedAction,
80
SessionToolCallDeniedAction,
81
SessionToolCallDeltaAction,
82
SessionToolCallReadyAction,
83
SessionToolCallResultConfirmedAction,
84
SessionToolCallStartAction,
85
SessionTitleChangedAction,
86
SessionTurnCancelledAction,
87
SessionTurnCompleteAction,
88
SessionTurnStartedAction,
89
SessionUsageAction,
90
StateAction,
91
SessionPendingMessageSetAction,
92
SessionPendingMessageRemovedAction,
93
SessionQueuedMessagesReorderedAction,
94
SessionIsReadChangedAction,
95
SessionIsArchivedChangedAction,
96
RootConfigChangedAction,
97
} from './protocol/actions.js';
98
99
import type { ProtocolNotification } from './protocol/notifications.js';
100
import type { RootAction as IRootAction_, SessionAction as ISessionAction_, ClientSessionAction as IClientSessionAction_, ServerSessionAction as IServerSessionAction_, TerminalAction as ITerminalAction_, ClientTerminalAction as IClientTerminalAction_ } from './protocol/action-origin.generated.js';
101
102
export type RootAction = IRootAction_;
103
export type SessionAction = ISessionAction_;
104
export type ClientSessionAction = IClientSessionAction_;
105
export type ServerSessionAction = IServerSessionAction_;
106
export type TerminalAction = ITerminalAction_;
107
export type ClientTerminalAction = IClientTerminalAction_;
108
109
// Root actions
110
export type IAgentsChangedAction = RootAgentsChangedAction;
111
export type IActiveSessionsChangedAction = RootActiveSessionsChangedAction;
112
export type IRootConfigChangedAction = RootConfigChangedAction;
113
114
// Session actions — short aliases
115
export type ITurnStartedAction = SessionTurnStartedAction;
116
export type IDeltaAction = SessionDeltaAction;
117
export type IResponsePartAction = SessionResponsePartAction;
118
export type IToolCallStartAction = SessionToolCallStartAction;
119
export type IToolCallDeltaAction = SessionToolCallDeltaAction;
120
export type IToolCallReadyAction = SessionToolCallReadyAction;
121
export type IToolCallApprovedAction = SessionToolCallApprovedAction;
122
export type IToolCallDeniedAction = SessionToolCallDeniedAction;
123
export type IToolCallConfirmedAction = SessionToolCallConfirmedAction;
124
export type IToolCallCompleteAction = SessionToolCallCompleteAction;
125
export type IToolCallResultConfirmedAction = SessionToolCallResultConfirmedAction;
126
export type ITurnCompleteAction = SessionTurnCompleteAction;
127
export type ITurnCancelledAction = SessionTurnCancelledAction;
128
export type ITitleChangedAction = SessionTitleChangedAction;
129
export type IUsageAction = SessionUsageAction;
130
export type IReasoningAction = SessionReasoningAction;
131
export type IModelChangedAction = SessionModelChangedAction;
132
export type ICustomizationsChangedAction = import('./protocol/actions.js').SessionCustomizationsChangedAction;
133
export type ICustomizationToggledAction = import('./protocol/actions.js').SessionCustomizationToggledAction;
134
135
export type IPendingMessageSetAction = SessionPendingMessageSetAction;
136
export type IPendingMessageRemovedAction = SessionPendingMessageRemovedAction;
137
export type IQueuedMessagesReorderedAction = SessionQueuedMessagesReorderedAction;
138
export type IIsReadChangedAction = SessionIsReadChangedAction;
139
export type IIsArchivedChangedAction = SessionIsArchivedChangedAction;
140
141
// Notifications
142
export type INotification = ProtocolNotification;
143
144
// ---- Type guards ------------------------------------------------------------
145
146
export function isRootAction(action: StateAction): action is RootAction {
147
return action.type.startsWith('root/');
148
}
149
150
export function isSessionAction(action: StateAction): action is SessionAction {
151
return action.type.startsWith('session/');
152
}
153
154
export function isTerminalAction(action: StateAction): action is TerminalAction {
155
return action.type.startsWith('terminal/');
156
}
157
158