1
>
/*---------------------------------------------------------------------------------------------
actions.ts
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
>
// allow-any-unicode-comment-file
7
>
// DO NOT EDIT -- auto-generated by scripts/sync-agent-host-protocol.ts
8
>
9
>
import type { URI } from './state.js';
10
>
11
>
import type { RootAgentsChangedAction, RootActiveSessionsChangedAction, RootTerminalsChangedAction, RootConfigChangedAction } from '../channels-root/actions.js';
12
>
13
>
import type { SessionReadyAction, SessionCreationFailedAction, SessionChatAddedAction, SessionChatRemovedAction, SessionChatUpdatedAction, SessionDefaultChatChangedAction, SessionTitleChangedAction, SessionServerToolsChangedAction, SessionActiveClientSetAction, SessionActiveClientRemovedAction, SessionWorkingDirectorySetAction, SessionWorkingDirectoryRemovedAction, SessionInputNeededSetAction, SessionInputNeededRemovedAction, SessionCustomizationsChangedAction, SessionCustomizationToggledAction, SessionCustomizationUpdatedAction, SessionCustomizationRemovedAction, SessionMcpServerStateChangedAction, SessionMcpServerStartRequestedAction, SessionMcpServerStopRequestedAction, SessionIsReadChangedAction, SessionIsArchivedChangedAction, SessionActivityChangedAction, SessionChangesetsChangedAction, SessionConfigChangedAction, SessionMetaChangedAction } from '../channels-session/actions.js';
14
>
15
>
import type { ChatTurnStartedAction, ChatDeltaAction, ChatResponsePartAction, ChatToolCallStartAction, ChatToolCallDeltaAction, ChatToolCallReadyAction, ChatToolCallConfirmedAction, ChatToolCallCompleteAction, ChatToolCallResultConfirmedAction, ChatToolCallContentChangedAction, ChatToolCallAuthRequiredAction, ChatToolCallAuthResolvedAction, ChatTurnCompleteAction, ChatTurnCancelledAction, ChatErrorAction, ChatActivityChangedAction, ChatWorkingDirectorySetAction, ChatWorkingDirectoryRemovedAction, ChatUsageAction, ChatReasoningAction, ChatPendingMessageSetAction, ChatPendingMessageRemovedAction, ChatQueuedMessagesReorderedAction, ChatDraftChangedAction, ChatInputRequestedAction, ChatInputAnswerChangedAction, ChatInputCompletedAction, ChatTruncatedAction, ChatTurnsLoadedAction } from '../channels-chat/actions.js';
16
>
17
>
import type { ChangesetStatusChangedAction, ChangesetFileSetAction, ChangesetFileRemovedAction, ChangesetFilesReviewChangedAction, ChangesetContentChangedAction, ChangesetOperationsChangedAction, ChangesetOperationStatusChangedAction, ChangesetClearedAction } from '../channels-changeset/actions.js';
18
>
19
>
import type { AnnotationsSetAction, AnnotationsUpdatedAction, AnnotationsRemovedAction, AnnotationsEntrySetAction, AnnotationsEntryRemovedAction } from '../channels-annotations/actions.js';
20
>
21
>
import type { TerminalDataAction, TerminalInputAction, TerminalResizedAction, TerminalClaimedAction, TerminalTitleChangedAction, TerminalCwdChangedAction, TerminalExitedAction, TerminalClearedAction, TerminalCommandDetectionAvailableAction, TerminalCommandExecutedAction, TerminalCommandFinishedAction } from '../channels-terminal/actions.js';
22
>
23
>
import type { ResourceWatchChangedAction } from '../channels-resource-watch/actions.js';
24
>
25
>
// ─── Action Type Enum ────────────────────────────────────────────────────────
26
>
27
>
/**
28
>
* Discriminant values for all state actions.
29
>
*
30
>
* @category Actions
31
>
*/
32
>
export const enum ActionType {
33
>
RootAgentsChanged = 'root/agentsChanged',
34
>
RootActiveSessionsChanged = 'root/activeSessionsChanged',
35
>
SessionReady = 'session/ready',
36
>
SessionCreationFailed = 'session/creationFailed',
37
>
SessionChatAdded = 'session/chatAdded',
38
>
SessionChatRemoved = 'session/chatRemoved',
39
>
SessionChatUpdated = 'session/chatUpdated',
40
>
SessionDefaultChatChanged = 'session/defaultChatChanged',
41
>
ChatTurnStarted = 'chat/turnStarted',
42
>
ChatDelta = 'chat/delta',
43
>
ChatResponsePart = 'chat/responsePart',
44
>
ChatToolCallStart = 'chat/toolCallStart',
45
>
ChatToolCallDelta = 'chat/toolCallDelta',
46
>
ChatToolCallReady = 'chat/toolCallReady',
47
>
ChatToolCallConfirmed = 'chat/toolCallConfirmed',
48
>
ChatToolCallComplete = 'chat/toolCallComplete',
49
>
ChatToolCallResultConfirmed = 'chat/toolCallResultConfirmed',
50
>
ChatToolCallContentChanged = 'chat/toolCallContentChanged',
51
>
ChatToolCallAuthRequired = 'chat/toolCallAuthRequired',
52
>
ChatToolCallAuthResolved = 'chat/toolCallAuthResolved',
53
>
ChatTurnComplete = 'chat/turnComplete',
54
>
ChatTurnCancelled = 'chat/turnCancelled',
55
>
ChatError = 'chat/error',
56
>
ChatActivityChanged = 'chat/activityChanged',
57
>
ChatWorkingDirectorySet = 'chat/workingDirectorySet',
58
>
ChatWorkingDirectoryRemoved = 'chat/workingDirectoryRemoved',
59
>
SessionTitleChanged = 'session/titleChanged',
60
>
ChatUsage = 'chat/usage',
61
>
ChatReasoning = 'chat/reasoning',
62
>
SessionServerToolsChanged = 'session/serverToolsChanged',
63
>
SessionActiveClientSet = 'session/activeClientSet',
64
>
SessionActiveClientRemoved = 'session/activeClientRemoved',
65
>
SessionWorkingDirectorySet = 'session/workingDirectorySet',
66
>
SessionWorkingDirectoryRemoved = 'session/workingDirectoryRemoved',
67
>
SessionInputNeededSet = 'session/inputNeededSet',
68
>
SessionInputNeededRemoved = 'session/inputNeededRemoved',
69
>
ChatPendingMessageSet = 'chat/pendingMessageSet',
70
>
ChatPendingMessageRemoved = 'chat/pendingMessageRemoved',
71
>
ChatQueuedMessagesReordered = 'chat/queuedMessagesReordered',
72
>
ChatDraftChanged = 'chat/draftChanged',
73
>
ChatInputRequested = 'chat/inputRequested',
74
>
ChatInputAnswerChanged = 'chat/inputAnswerChanged',
75
>
ChatInputCompleted = 'chat/inputCompleted',
76
>
SessionCustomizationsChanged = 'session/customizationsChanged',
77
>
SessionCustomizationToggled = 'session/customizationToggled',
78
>
SessionCustomizationUpdated = 'session/customizationUpdated',
79
>
SessionCustomizationRemoved = 'session/customizationRemoved',
80
>
SessionMcpServerStateChanged = 'session/mcpServerStateChanged',
81
>
SessionMcpServerStartRequested = 'session/mcpServerStartRequested',
82
>
SessionMcpServerStopRequested = 'session/mcpServerStopRequested',
83
>
ChatTruncated = 'chat/truncated',
84
>
ChatTurnsLoaded = 'chat/turnsLoaded',
85
>
SessionIsReadChanged = 'session/isReadChanged',
86
>
SessionIsArchivedChanged = 'session/isArchivedChanged',
87
>
SessionActivityChanged = 'session/activityChanged',
88
>
SessionChangesetsChanged = 'session/changesetsChanged',
89
>
SessionConfigChanged = 'session/configChanged',
90
>
SessionMetaChanged = 'session/metaChanged',
91
>
ChangesetStatusChanged = 'changeset/statusChanged',
92
>
ChangesetFileSet = 'changeset/fileSet',
93
>
ChangesetFileRemoved = 'changeset/fileRemoved',
94
>
ChangesetFilesReviewChanged = 'changeset/filesReviewChanged',
95
>
ChangesetContentChanged = 'changeset/contentChanged',
96
>
ChangesetOperationsChanged = 'changeset/operationsChanged',
97
>
ChangesetOperationStatusChanged = 'changeset/operationStatusChanged',
98
>
ChangesetCleared = 'changeset/cleared',
99
>
AnnotationsSet = 'annotations/set',
100
>
AnnotationsUpdated = 'annotations/updated',
101
>
AnnotationsRemoved = 'annotations/removed',
102
>
AnnotationsEntrySet = 'annotations/entrySet',
103
>
AnnotationsEntryRemoved = 'annotations/entryRemoved',
104
>
RootTerminalsChanged = 'root/terminalsChanged',
105
>
RootConfigChanged = 'root/configChanged',
106
>
TerminalData = 'terminal/data',
107
>
TerminalInput = 'terminal/input',
108
>
TerminalResized = 'terminal/resized',
109
>
TerminalClaimed = 'terminal/claimed',
110
>
TerminalTitleChanged = 'terminal/titleChanged',
111
>
TerminalCwdChanged = 'terminal/cwdChanged',
112
>
TerminalExited = 'terminal/exited',
113
>
TerminalCleared = 'terminal/cleared',
114
>
TerminalCommandDetectionAvailable = 'terminal/commandDetectionAvailable',
115
>
TerminalCommandExecuted = 'terminal/commandExecuted',
116
>
TerminalCommandFinished = 'terminal/commandFinished',
117
>
ResourceWatchChanged = 'resourceWatch/changed',
118
>
}
119
>
120
>
// ─── Action Envelope ─────────────────────────────────────────────────────────
121
>
122
>
/**
123
>
* Identifies the client that originally dispatched an action.
124
>
*/
125
>
export interface ActionOrigin {
126
>
clientId: string;
127
>
clientSeq: number;
128
>
}
129
>
130
>
/**
131
>
* Every action is wrapped in an `ActionEnvelope`.
132
>
*
133
>
* The envelope identifies the channel the action belongs to (e.g.
134
>
* `ahp-root://` for root actions, the session URI for session actions, the
135
>
* terminal URI for terminal actions). Individual action payloads carry only
136
>
* fields that are intrinsic to the action; the channel comes from the
137
>
* envelope so that any subscribable resource can route its actions uniformly.
138
>
*/
139
>
export interface ActionEnvelope {
140
>
/** Channel URI this action belongs to. */
141
>
readonly channel: URI;
142
>
readonly action: StateAction;
143
>
readonly serverSeq: number;
144
>
readonly origin: ActionOrigin | undefined;
145
>
readonly rejectionReason?: string;
146
>
}
147
>
148
>
// ─── Discriminated Union ─────────────────────────────────────────────────────
149
>
150
>
/**
151
>
* Discriminated union of all state actions.
152
>
*/
153
>
export type StateAction =
154
>
| RootAgentsChangedAction
155
>
| RootActiveSessionsChangedAction
156
>
| RootTerminalsChangedAction
157
>
| RootConfigChangedAction
158
>
| SessionReadyAction
159
>
| SessionCreationFailedAction
160
>
| SessionChatAddedAction
161
>
| SessionChatRemovedAction
162
>
| SessionChatUpdatedAction
163
>
| SessionDefaultChatChangedAction
164
>
| SessionTitleChangedAction
165
>
| SessionServerToolsChangedAction
166
>
| SessionActiveClientSetAction
167
>
| SessionActiveClientRemovedAction
168
>
| SessionWorkingDirectorySetAction
169
>
| SessionWorkingDirectoryRemovedAction
170
>
| SessionInputNeededSetAction
171
>
| SessionInputNeededRemovedAction
172
>
| SessionCustomizationsChangedAction
173
>
| SessionCustomizationToggledAction
174
>
| SessionCustomizationUpdatedAction
175
>
| SessionCustomizationRemovedAction
176
>
| SessionMcpServerStateChangedAction
177
>
| SessionMcpServerStartRequestedAction
178
>
| SessionMcpServerStopRequestedAction
179
>
| SessionIsReadChangedAction
180
>
| SessionIsArchivedChangedAction
181
>
| SessionActivityChangedAction
182
>
| SessionChangesetsChangedAction
183
>
| SessionConfigChangedAction
184
>
| SessionMetaChangedAction
185
>
| ChatTurnStartedAction
186
>
| ChatDeltaAction
187
>
| ChatResponsePartAction
188
>
| ChatToolCallStartAction
189
>
| ChatToolCallDeltaAction
190
>
| ChatToolCallReadyAction
191
>
| ChatToolCallConfirmedAction
192
>
| ChatToolCallCompleteAction
193
>
| ChatToolCallResultConfirmedAction
194
>
| ChatToolCallContentChangedAction
195
>
| ChatToolCallAuthRequiredAction
196
>
| ChatToolCallAuthResolvedAction
197
>
| ChatTurnCompleteAction
198
>
| ChatTurnCancelledAction
199
>
| ChatErrorAction
200
>
| ChatActivityChangedAction
201
>
| ChatWorkingDirectorySetAction
202
>
| ChatWorkingDirectoryRemovedAction
203
>
| ChatUsageAction
204
>
| ChatReasoningAction
205
>
| ChatPendingMessageSetAction
206
>
| ChatPendingMessageRemovedAction
207
>
| ChatQueuedMessagesReorderedAction
208
>
| ChatDraftChangedAction
209
>
| ChatInputRequestedAction
210
>
| ChatInputAnswerChangedAction
211
>
| ChatInputCompletedAction
212
>
| ChatTruncatedAction
213
>
| ChatTurnsLoadedAction
214
>
| ChangesetStatusChangedAction
215
>
| ChangesetFileSetAction
216
>
| ChangesetFileRemovedAction
217
>
| ChangesetFilesReviewChangedAction
218
>
| ChangesetContentChangedAction
219
>
| ChangesetOperationsChangedAction
220
>
| ChangesetOperationStatusChangedAction
221
>
| ChangesetClearedAction
222
>
| AnnotationsSetAction
223
>
| AnnotationsUpdatedAction
224
>
| AnnotationsRemovedAction
225
>
| AnnotationsEntrySetAction
226
>
| AnnotationsEntryRemovedAction
227
>
| TerminalDataAction
228
>
| TerminalInputAction
229
>
| TerminalResizedAction
230
>
| TerminalClaimedAction
231
>
| TerminalTitleChangedAction
232
>
| TerminalCwdChangedAction
233
>
| TerminalExitedAction
234
>
| TerminalClearedAction
235
>
| TerminalCommandDetectionAvailableAction
236
>
| TerminalCommandExecutedAction
237
>
| TerminalCommandFinishedAction
238
>
| ResourceWatchChangedAction;