Skip to content

Commit 5f9062c

Browse files
authored
revert: revert: subscription details protocols #620 (#623)" (#625)
This reverts commit 9cec0d7.
1 parent 6063e62 commit 5f9062c

File tree

6 files changed

+66
-0
lines changed

6 files changed

+66
-0
lines changed

runtimes/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ The runtime supports chat by default
208208
| Send tab bar action request (e.g., export). | `aws/chat/tabBarAction` | `TabBarActionParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) Client to Server | `TabBarActionResult` |
209209
| Send request to get serialized chat content in specified format. | `aws/chat/getSerializedChat` | `GetSerializedChatParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) Client to Server | `GetSerializedChatResult` |
210210
| Send request to open file dialog for file selection. | `aws/chat/openFileDialog` | `OpenFileDialogParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) Client to Server | `OpenFileDialogResult` |
211+
| Sent to display subscription information in the chat UI | `aws/chat/subscription/details` | SubscriptionDetailsParams | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) Server to Client | n/a |
212+
| Sent to begin a subscription upgrade | `aws/chat/subscription/upgrade` | SubscriptionUpgradeParams | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) Client to Server | n/a |
211213
212214
213215
```ts

runtimes/protocol/chat.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ import {
9191
LIST_AVAILABLE_MODELS_REQUEST_METHOD,
9292
ListAvailableModelsResult,
9393
ListAvailableModelsParams,
94+
SUBSCRIPTION_DETAILS_NOTIFICATION_METHOD,
95+
SubscriptionDetailsParams,
96+
SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD,
97+
SubscriptionUpgradeParams,
9498
} from './lsp'
9599

96100
export const chatRequestType = new AutoParameterStructuresProtocolRequestType<
@@ -279,3 +283,21 @@ export const listAvailableModelsRequestType = new ProtocolRequestType<
279283
void,
280284
void
281285
>(LIST_AVAILABLE_MODELS_REQUEST_METHOD)
286+
287+
// Subscription Tiers
288+
289+
/**
290+
* Subscription Details Notification is sent from server to client, with the expectation that
291+
* the client will display the subscription details in the Chat UI.
292+
*/
293+
export const subscriptionDetailsNotificationType = new ProtocolNotificationType<SubscriptionDetailsParams, void>(
294+
SUBSCRIPTION_DETAILS_NOTIFICATION_METHOD
295+
)
296+
297+
/**
298+
* Subscription Details Notification is sent from Chat UI through client over to server.
299+
* Flare will then ask the client to open a URL in the browser.
300+
*/
301+
export const subscriptionUpgradeNotificationType = new ProtocolNotificationType<SubscriptionUpgradeParams, void>(
302+
SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD
303+
)

runtimes/runtimes/base-runtime.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ import {
6060
onPinnedContextRemoveNotificationType,
6161
openFileDialogRequestType,
6262
listAvailableModelsRequestType,
63+
subscriptionDetailsNotificationType,
64+
subscriptionUpgradeNotificationType,
6365
} from '../protocol'
6466
import { createConnection } from 'vscode-languageserver/browser'
6567
import {
@@ -200,6 +202,10 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
200202
onOpenFileDialog: handler => lspConnection.onRequest(openFileDialogRequestType.method, handler),
201203
onRuleClick: handler => lspConnection.onRequest(ruleClickRequestType.method, handler),
202204
onListAvailableModels: handler => lspConnection.onRequest(listAvailableModelsRequestType.method, handler),
205+
sendSubscriptionDetails: params =>
206+
lspConnection.sendNotification(subscriptionDetailsNotificationType.method, params),
207+
onSubscriptionUpgrade: handler =>
208+
lspConnection.onNotification(subscriptionUpgradeNotificationType.method, handler),
203209
}
204210

205211
const identityManagement: IdentityManagement = {

runtimes/runtimes/chat/baseChat.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ import {
8888
ListAvailableModelsParams,
8989
ListAvailableModelsResult,
9090
listAvailableModelsRequestType,
91+
SubscriptionDetailsParams,
92+
subscriptionDetailsNotificationType,
93+
subscriptionUpgradeNotificationType,
94+
SubscriptionUpgradeParams,
9195
} from '../../protocol'
9296
import { Chat } from '../../server-interface'
9397

@@ -243,4 +247,12 @@ export class BaseChat implements Chat {
243247
public onListAvailableModels(handler: RequestHandler<ListAvailableModelsParams, ListAvailableModelsResult, void>) {
244248
this.connection.onRequest(listAvailableModelsRequestType.method, handler)
245249
}
250+
251+
public sendSubscriptionDetails(params: SubscriptionDetailsParams) {
252+
this.connection.sendNotification(subscriptionDetailsNotificationType.method, params)
253+
}
254+
255+
public onSubscriptionUpgrade(handler: NotificationHandler<SubscriptionUpgradeParams>) {
256+
this.connection.onNotification(subscriptionUpgradeNotificationType.method, handler)
257+
}
246258
}

runtimes/server-interface/chat.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ import {
5151
ActiveEditorChangedParams,
5252
ListAvailableModelsParams,
5353
ListAvailableModelsResult,
54+
SubscriptionDetailsParams,
55+
SubscriptionUpgradeParams,
5456
} from '../protocol'
5557

5658
/**
@@ -100,4 +102,6 @@ export type Chat = {
100102
onCreatePrompt: (handler: NotificationHandler<CreatePromptParams>) => void
101103
onInlineChatResult: (handler: NotificationHandler<InlineChatResultParams>) => void
102104
onPromptInputOptionChange: (handler: NotificationHandler<PromptInputOptionChangeParams>) => void
105+
sendSubscriptionDetails: (params: SubscriptionDetailsParams) => void
106+
onSubscriptionUpgrade: (handler: NotificationHandler<SubscriptionUpgradeParams>) => void
103107
}

types/chat.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export const LIST_AVAILABLE_MODELS_REQUEST_METHOD = 'aws/chat/listAvailableModel
5656
// button ids
5757
export const OPEN_WORKSPACE_INDEX_SETTINGS_BUTTON_ID = 'open-settings-for-ws-index'
5858

59+
// Subscription Tiers
60+
export const SUBSCRIPTION_DETAILS_NOTIFICATION_METHOD = 'aws/chat/subscription/details'
61+
export const SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD = 'aws/chat/subscription/upgrade'
62+
export const SUBSCRIPTION_SHOW_COMMAND_METHOD = 'aws/chat/subscription/show'
63+
5964
export interface ChatItemAction {
6065
pillText: string
6166
prompt?: string
@@ -277,6 +282,11 @@ export interface ChatOptions {
277282
*/
278283
export?: boolean
279284

285+
/**
286+
* Server signals to Client and Chat Client that it supports subscription tier operations
287+
*/
288+
subscriptionDetails?: boolean
289+
280290
/*
281291
Server signals to Chat Client support of Chat notifications.
282292
Currently used for sending chat notifications for developer profile updates.
@@ -695,3 +705,13 @@ export interface ListAvailableModelsResult {
695705
export interface ExecuteShellCommandParams {
696706
id: string
697707
}
708+
709+
export interface SubscriptionDetailsParams {
710+
subscriptionTier: string
711+
queryUsage: number
712+
queryLimit: number
713+
queryOverage: number
714+
daysRemaining: number
715+
}
716+
717+
export interface SubscriptionUpgradeParams {}

0 commit comments

Comments
 (0)