Skip to content

Commit faa5d37

Browse files
committed
feat: added protocol for create prompt
1 parent 76bca76 commit faa5d37

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

runtimes/protocol/chat.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import {
4141
FileClickParams,
4242
CONTEXT_COMMAND_NOTIFICATION_METHOD,
4343
ContextCommandParams,
44+
CREATE_PROMPT_NOTIFICATION_METHOD,
45+
CreatePromptParams,
4446
} from './lsp'
4547

4648
export const chatRequestType = new AutoParameterStructuresProtocolRequestType<
@@ -96,3 +98,6 @@ export const fileClickNotificationType = new ProtocolNotificationType<FileClickP
9698
export const contextCommandsNotificationType = new ProtocolNotificationType<ContextCommandParams, void>(
9799
CONTEXT_COMMAND_NOTIFICATION_METHOD
98100
)
101+
export const createPromptNotificationType = new ProtocolNotificationType<CreatePromptParams, void>(
102+
CREATE_PROMPT_NOTIFICATION_METHOD
103+
)

runtimes/runtimes/base-runtime.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
chatUpdateNotificationType,
4040
fileClickNotificationType,
4141
contextCommandsNotificationType,
42+
createPromptNotificationType,
4243
} from '../protocol'
4344
import { createConnection } from 'vscode-languageserver/browser'
4445
import {
@@ -142,7 +143,8 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
142143
openTab: params => lspConnection.sendRequest(openTabRequestType.method, params),
143144
sendChatUpdate: params => lspConnection.sendNotification(chatUpdateNotificationType.method, params),
144145
onFileClicked: handler => lspConnection.onNotification(fileClickNotificationType.method, handler),
145-
sendContextCommands: params => lspConnection.sendNotification(contextCommandsNotificationType.method),
146+
sendContextCommands: params => lspConnection.sendNotification(contextCommandsNotificationType.method, params),
147+
onCreatePrompt: handler => lspConnection.onNotification(createPromptNotificationType.method, handler),
146148
}
147149

148150
const identityManagement: IdentityManagement = {

runtimes/runtimes/chat/baseChat.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import {
3838
fileClickNotificationType,
3939
ContextCommandParams,
4040
contextCommandsNotificationType,
41+
CreatePromptParams,
42+
createPromptNotificationType,
4143
} from '../../protocol'
4244
import { Chat } from '../../server-interface'
4345

@@ -111,4 +113,8 @@ export class BaseChat implements Chat {
111113
public sendContextCommands(params: ContextCommandParams) {
112114
this.connection.sendNotification(contextCommandsNotificationType.method, params)
113115
}
116+
117+
public onCreatePrompt(handler: NotificationHandler<CreatePromptParams>) {
118+
this.connection.onNotification(createPromptNotificationType.method, handler)
119+
}
114120
}

runtimes/server-interface/chat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
ChatUpdateParams,
2222
FileClickParams,
2323
ContextCommandParams,
24+
CreatePromptParams,
2425
} from '../protocol'
2526

2627
/**
@@ -46,4 +47,5 @@ export type Chat = {
4647
sendChatUpdate: (params: ChatUpdateParams) => void
4748
onFileClicked: (handler: NotificationHandler<FileClickParams>) => void
4849
sendContextCommands: (params: ContextCommandParams) => void
50+
onCreatePrompt: (handler: NotificationHandler<CreatePromptParams>) => void
4951
}

types/chat.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const OPEN_TAB_REQUEST_METHOD = 'aws/chat/openTab'
1818
export const CHAT_UPDATE_NOTIFICATION_METHOD = 'aws/chat/sendChatUpdate'
1919
export const FILE_CLICK_NOTIFICATION_METHOD = 'aws/chat/fileClick'
2020
export const CONTEXT_COMMAND_NOTIFICATION_METHOD = 'aws/chat/sendContextCommands'
21+
export const CREATE_PROMPT_NOTIFICATION_METHOD = 'aws/chat/createPrompt'
2122

2223
export interface ChatItemAction {
2324
pillText: string
@@ -116,6 +117,8 @@ export interface QuickActionCommand {
116117
icon?: IconType
117118
}
118119

120+
export type IconType = 'file' | 'folder' | 'code-block' | 'list-add' | 'magic' | 'help' | 'trash'
121+
119122
/**
120123
* Configuration object for registering chat quick actions groups.
121124
*/
@@ -250,8 +253,6 @@ export interface ContextCommandGroup {
250253
commands: ContextCommand[]
251254
}
252255

253-
export type IconType = 'file' | 'folder' | 'code-block' | 'list-add' | 'magic' | 'help' | 'trash'
254-
255256
export interface ContextCommand extends QuickActionCommand {
256257
id?: string
257258
route?: string[]
@@ -262,3 +263,7 @@ export interface ContextCommand extends QuickActionCommand {
262263
export interface ContextCommandParams {
263264
contextCommandGroups: ContextCommandGroup[]
264265
}
266+
267+
export interface CreatePromptParams {
268+
promptName: string
269+
}

0 commit comments

Comments
 (0)