Path: blob/main/src/vs/platform/agentHost/common/state/protocol/notifications.ts
13405 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*--------------------------------------------------------------------------------------------*/45// allow-any-unicode-comment-file6// DO NOT EDIT -- auto-generated by scripts/sync-agent-host-protocol.ts78import type { URI, SessionSummary } from './state.js';910/**11* Reason why authentication is required.12*13* @category Protocol Notifications14*/15export const enum AuthRequiredReason {16/** The client has not yet authenticated for the resource */17Required = 'required',18/** A previously valid token has expired or been revoked */19Expired = 'expired',20}2122// ─── Protocol Notifications ──────────────────────────────────────────────────2324/**25* Discriminant values for all protocol notifications.26*27* @category Protocol Notifications28*/29export const enum NotificationType {30SessionAdded = 'notify/sessionAdded',31SessionRemoved = 'notify/sessionRemoved',32SessionSummaryChanged = 'notify/sessionSummaryChanged',33AuthRequired = 'notify/authRequired',34}3536/**37* Broadcast to all connected clients when a new session is created.38*39* @category Protocol Notifications40* @version 141* @example42* ```json43* {44* "jsonrpc": "2.0",45* "method": "notification",46* "params": {47* "notification": {48* "type": "notify/sessionAdded",49* "summary": {50* "resource": "copilot:/<uuid>",51* "provider": "copilot",52* "title": "New Session",53* "status": 1,54* "createdAt": 1710000000000,55* "modifiedAt": 171000000000056* }57* }58* }59* }60* ```61*/62export interface SessionAddedNotification {63type: NotificationType.SessionAdded;64/** Summary of the new session */65summary: SessionSummary;66}6768/**69* Broadcast to all connected clients when a session is disposed.70*71* @category Protocol Notifications72* @version 173* @example74* ```json75* {76* "jsonrpc": "2.0",77* "method": "notification",78* "params": {79* "notification": {80* "type": "notify/sessionRemoved",81* "session": "copilot:/<uuid>"82* }83* }84* }85* ```86*/87export interface SessionRemovedNotification {88type: NotificationType.SessionRemoved;89/** URI of the removed session */90session: URI;91}9293/**94* Broadcast to all connected clients when an existing session's summary95* changes (title, status, `modifiedAt`, model, working directory, read/done96* state, or diff statistics).97*98* This notification lets clients that maintain a cached session list — for99* example, the result of a previous `listSessions()` call — stay in sync with100* in-flight sessions without having to subscribe to every session URI101* individually. It is complementary to, not a replacement for,102* `notify/sessionAdded` and `notify/sessionRemoved`: those signal lifecycle103* (creation/disposal), while this signals summary-level mutations on an104* already-known session.105*106* Semantics:107*108* - Only fields present in `changes` have new values; omitted fields are109* unchanged on the client's cached summary.110* - Identity fields (`resource`, `provider`, `createdAt`) never change and111* are not carried.112* - Like all protocol notifications, this is ephemeral: it is **not**113* replayed on reconnect. On reconnect, clients should re-fetch the full114* catalog via `listSessions()` as usual.115* - The server SHOULD emit this notification whenever any mutable field on116* {@link SessionSummary | `SessionSummary`} changes for a session the117* server has surfaced via `listSessions()` or `notify/sessionAdded`.118* Servers MAY coalesce or debounce updates for noisy fields (for example,119* `modifiedAt` bumps while a turn is streaming, or rapidly changing120* `diffs`) at their discretion.121* - Clients that have no cached entry for `session` MAY ignore the122* notification; it is not a substitute for `notify/sessionAdded`.123*124* @category Protocol Notifications125* @version 1126* @example127* ```json128* {129* "jsonrpc": "2.0",130* "method": "notification",131* "params": {132* "notification": {133* "type": "notify/sessionSummaryChanged",134* "session": "copilot:/<uuid>",135* "changes": {136* "title": "Refactor auth middleware",137* "status": 8,138* "modifiedAt": 1710000123456139* }140* }141* }142* }143* ```144*/145export interface SessionSummaryChangedNotification {146type: NotificationType.SessionSummaryChanged;147/** URI of the session whose summary changed */148session: URI;149/**150* Mutable summary fields that changed; omitted fields are unchanged.151*152* Identity fields (`resource`, `provider`, `createdAt`) never change and153* MUST be omitted by senders; receivers SHOULD ignore them if present.154*/155changes: Partial<SessionSummary>;156}157158/**159* Sent by the server when a protected resource requires (re-)authentication.160*161* This notification is sent when a previously valid token expires or is162* revoked, or when the server discovers a new authentication requirement.163* Clients should obtain a fresh token and push it via the `authenticate`164* command.165*166* @category Protocol Notifications167* @version 1168* @see {@link /specification/authentication | Authentication}169* @example170* ```json171* {172* "jsonrpc": "2.0",173* "method": "notification",174* "params": {175* "notification": {176* "type": "notify/authRequired",177* "resource": "https://api.github.com",178* "reason": "expired"179* }180* }181* }182* ```183*/184export interface AuthRequiredNotification {185type: NotificationType.AuthRequired;186/** The protected resource identifier that requires authentication */187resource: string;188/** Why authentication is required */189reason?: AuthRequiredReason;190}191192/**193* Discriminated union of all protocol notifications.194*/195export type ProtocolNotification =196| SessionAddedNotification197| SessionRemovedNotification198| SessionSummaryChangedNotification199| AuthRequiredNotification;200201202