Skip to content

Commit bf3f95b

Browse files
committed
feat: added protocol for create prompt
1 parent e5dc9f3 commit bf3f95b

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
@@ -43,6 +43,8 @@ import {
4343
InlineChatParams,
4444
CONTEXT_COMMAND_NOTIFICATION_METHOD,
4545
ContextCommandParams,
46+
CREATE_PROMPT_NOTIFICATION_METHOD,
47+
CreatePromptParams,
4648
} from './lsp'
4749

4850
export const chatRequestType = new AutoParameterStructuresProtocolRequestType<
@@ -105,3 +107,6 @@ export const fileClickNotificationType = new ProtocolNotificationType<FileClickP
105107
export const contextCommandsNotificationType = new ProtocolNotificationType<ContextCommandParams, void>(
106108
CONTEXT_COMMAND_NOTIFICATION_METHOD
107109
)
110+
export const createPromptNotificationType = new ProtocolNotificationType<CreatePromptParams, void>(
111+
CREATE_PROMPT_NOTIFICATION_METHOD
112+
)

runtimes/runtimes/base-runtime.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
fileClickNotificationType,
4141
inlineChatRequestType,
4242
contextCommandsNotificationType,
43+
createPromptNotificationType,
4344
} from '../protocol'
4445
import { createConnection } from 'vscode-languageserver/browser'
4546
import {
@@ -145,7 +146,8 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
145146
openTab: params => lspConnection.sendRequest(openTabRequestType.method, params),
146147
sendChatUpdate: params => lspConnection.sendNotification(chatUpdateNotificationType.method, params),
147148
onFileClicked: handler => lspConnection.onNotification(fileClickNotificationType.method, handler),
148-
sendContextCommands: params => lspConnection.sendNotification(contextCommandsNotificationType.method),
149+
sendContextCommands: params => lspConnection.sendNotification(contextCommandsNotificationType.method, params),
150+
onCreatePrompt: handler => lspConnection.onNotification(createPromptNotificationType.method, handler),
149151
}
150152

151153
const identityManagement: IdentityManagement = {

runtimes/runtimes/chat/baseChat.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import {
4040
InlineChatParams,
4141
ContextCommandParams,
4242
contextCommandsNotificationType,
43+
CreatePromptParams,
44+
createPromptNotificationType,
4345
} from '../../protocol'
4446
import { Chat } from '../../server-interface'
4547

@@ -117,4 +119,8 @@ export class BaseChat implements Chat {
117119
public sendContextCommands(params: ContextCommandParams) {
118120
this.connection.sendNotification(contextCommandsNotificationType.method, params)
119121
}
122+
123+
public onCreatePrompt(handler: NotificationHandler<CreatePromptParams>) {
124+
this.connection.onNotification(createPromptNotificationType.method, handler)
125+
}
120126
}

runtimes/server-interface/chat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
FileClickParams,
2323
InlineChatParams,
2424
ContextCommandParams,
25+
CreatePromptParams,
2526
} from '../protocol'
2627

2728
/**
@@ -48,4 +49,5 @@ export type Chat = {
4849
sendChatUpdate: (params: ChatUpdateParams) => void
4950
onFileClicked: (handler: NotificationHandler<FileClickParams>) => void
5051
sendContextCommands: (params: ContextCommandParams) => void
52+
onCreatePrompt: (handler: NotificationHandler<CreatePromptParams>) => void
5153
}

types/chat.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const CHAT_UPDATE_NOTIFICATION_METHOD = 'aws/chat/sendChatUpdate'
1919
export const FILE_CLICK_NOTIFICATION_METHOD = 'aws/chat/fileClick'
2020
export const INLINE_CHAT_REQUEST_METHOD = 'aws/chat/sendInlineChatPrompt'
2121
export const CONTEXT_COMMAND_NOTIFICATION_METHOD = 'aws/chat/sendContextCommands'
22+
export const CREATE_PROMPT_NOTIFICATION_METHOD = 'aws/chat/createPrompt'
2223

2324
export interface ChatItemAction {
2425
pillText: string
@@ -130,6 +131,8 @@ export interface QuickActionCommand {
130131
icon?: IconType
131132
}
132133

134+
export type IconType = 'file' | 'folder' | 'code-block' | 'list-add' | 'magic' | 'help' | 'trash'
135+
133136
/**
134137
* Configuration object for registering chat quick actions groups.
135138
*/
@@ -264,8 +267,6 @@ export interface ContextCommandGroup {
264267
commands: ContextCommand[]
265268
}
266269

267-
export type IconType = 'file' | 'folder' | 'code-block' | 'list-add' | 'magic' | 'help' | 'trash'
268-
269270
export interface ContextCommand extends QuickActionCommand {
270271
id?: string
271272
route?: string[]
@@ -276,3 +277,7 @@ export interface ContextCommand extends QuickActionCommand {
276277
export interface ContextCommandParams {
277278
contextCommandGroups: ContextCommandGroup[]
278279
}
280+
281+
export interface CreatePromptParams {
282+
promptName: string
283+
}

0 commit comments

Comments
 (0)