Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/agentHost/common/state/protocol/notifications.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
// allow-any-unicode-comment-file
7
// DO NOT EDIT -- auto-generated by scripts/sync-agent-host-protocol.ts
8
9
import type { URI, SessionSummary } from './state.js';
10
11
/**
12
* Reason why authentication is required.
13
*
14
* @category Protocol Notifications
15
*/
16
export const enum AuthRequiredReason {
17
/** The client has not yet authenticated for the resource */
18
Required = 'required',
19
/** A previously valid token has expired or been revoked */
20
Expired = 'expired',
21
}
22
23
// ─── Protocol Notifications ──────────────────────────────────────────────────
24
25
/**
26
* Discriminant values for all protocol notifications.
27
*
28
* @category Protocol Notifications
29
*/
30
export const enum NotificationType {
31
SessionAdded = 'notify/sessionAdded',
32
SessionRemoved = 'notify/sessionRemoved',
33
SessionSummaryChanged = 'notify/sessionSummaryChanged',
34
AuthRequired = 'notify/authRequired',
35
}
36
37
/**
38
* Broadcast to all connected clients when a new session is created.
39
*
40
* @category Protocol Notifications
41
* @version 1
42
* @example
43
* ```json
44
* {
45
* "jsonrpc": "2.0",
46
* "method": "notification",
47
* "params": {
48
* "notification": {
49
* "type": "notify/sessionAdded",
50
* "summary": {
51
* "resource": "copilot:/<uuid>",
52
* "provider": "copilot",
53
* "title": "New Session",
54
* "status": 1,
55
* "createdAt": 1710000000000,
56
* "modifiedAt": 1710000000000
57
* }
58
* }
59
* }
60
* }
61
* ```
62
*/
63
export interface SessionAddedNotification {
64
type: NotificationType.SessionAdded;
65
/** Summary of the new session */
66
summary: SessionSummary;
67
}
68
69
/**
70
* Broadcast to all connected clients when a session is disposed.
71
*
72
* @category Protocol Notifications
73
* @version 1
74
* @example
75
* ```json
76
* {
77
* "jsonrpc": "2.0",
78
* "method": "notification",
79
* "params": {
80
* "notification": {
81
* "type": "notify/sessionRemoved",
82
* "session": "copilot:/<uuid>"
83
* }
84
* }
85
* }
86
* ```
87
*/
88
export interface SessionRemovedNotification {
89
type: NotificationType.SessionRemoved;
90
/** URI of the removed session */
91
session: URI;
92
}
93
94
/**
95
* Broadcast to all connected clients when an existing session's summary
96
* changes (title, status, `modifiedAt`, model, working directory, read/done
97
* state, or diff statistics).
98
*
99
* This notification lets clients that maintain a cached session list — for
100
* example, the result of a previous `listSessions()` call — stay in sync with
101
* in-flight sessions without having to subscribe to every session URI
102
* individually. It is complementary to, not a replacement for,
103
* `notify/sessionAdded` and `notify/sessionRemoved`: those signal lifecycle
104
* (creation/disposal), while this signals summary-level mutations on an
105
* already-known session.
106
*
107
* Semantics:
108
*
109
* - Only fields present in `changes` have new values; omitted fields are
110
* unchanged on the client's cached summary.
111
* - Identity fields (`resource`, `provider`, `createdAt`) never change and
112
* are not carried.
113
* - Like all protocol notifications, this is ephemeral: it is **not**
114
* replayed on reconnect. On reconnect, clients should re-fetch the full
115
* catalog via `listSessions()` as usual.
116
* - The server SHOULD emit this notification whenever any mutable field on
117
* {@link SessionSummary | `SessionSummary`} changes for a session the
118
* server has surfaced via `listSessions()` or `notify/sessionAdded`.
119
* Servers MAY coalesce or debounce updates for noisy fields (for example,
120
* `modifiedAt` bumps while a turn is streaming, or rapidly changing
121
* `diffs`) at their discretion.
122
* - Clients that have no cached entry for `session` MAY ignore the
123
* notification; it is not a substitute for `notify/sessionAdded`.
124
*
125
* @category Protocol Notifications
126
* @version 1
127
* @example
128
* ```json
129
* {
130
* "jsonrpc": "2.0",
131
* "method": "notification",
132
* "params": {
133
* "notification": {
134
* "type": "notify/sessionSummaryChanged",
135
* "session": "copilot:/<uuid>",
136
* "changes": {
137
* "title": "Refactor auth middleware",
138
* "status": 8,
139
* "modifiedAt": 1710000123456
140
* }
141
* }
142
* }
143
* }
144
* ```
145
*/
146
export interface SessionSummaryChangedNotification {
147
type: NotificationType.SessionSummaryChanged;
148
/** URI of the session whose summary changed */
149
session: URI;
150
/**
151
* Mutable summary fields that changed; omitted fields are unchanged.
152
*
153
* Identity fields (`resource`, `provider`, `createdAt`) never change and
154
* MUST be omitted by senders; receivers SHOULD ignore them if present.
155
*/
156
changes: Partial<SessionSummary>;
157
}
158
159
/**
160
* Sent by the server when a protected resource requires (re-)authentication.
161
*
162
* This notification is sent when a previously valid token expires or is
163
* revoked, or when the server discovers a new authentication requirement.
164
* Clients should obtain a fresh token and push it via the `authenticate`
165
* command.
166
*
167
* @category Protocol Notifications
168
* @version 1
169
* @see {@link /specification/authentication | Authentication}
170
* @example
171
* ```json
172
* {
173
* "jsonrpc": "2.0",
174
* "method": "notification",
175
* "params": {
176
* "notification": {
177
* "type": "notify/authRequired",
178
* "resource": "https://api.github.com",
179
* "reason": "expired"
180
* }
181
* }
182
* }
183
* ```
184
*/
185
export interface AuthRequiredNotification {
186
type: NotificationType.AuthRequired;
187
/** The protected resource identifier that requires authentication */
188
resource: string;
189
/** Why authentication is required */
190
reason?: AuthRequiredReason;
191
}
192
193
/**
194
* Discriminated union of all protocol notifications.
195
*/
196
export type ProtocolNotification =
197
| SessionAddedNotification
198
| SessionRemovedNotification
199
| SessionSummaryChangedNotification
200
| AuthRequiredNotification;
201
202