Skip to main content

Chat API

The chat module of the @codebolt/plugin-sdk.

import plugin from '@codebolt/plugin-sdk';

Quick Reference

MethodDescription
askQuestion
checkForSteeringMessageChecks if any steering message has been received.
getChatHistoryRetrieves the chat history from the server.
onSteeringMessageReceivedWaits for a steering message.
processFinishedStops the ongoing process.
processStartedNotifies the server that a process has started and sets up a listener for stopProcessClicked events.
sendConfirmationRequestSends a confirmation request to the server with two options: Yes or No.
sendMessageSends a message through the WebSocket connection.
sendNotificationEventSends a notification event to the server.
setRequestHandlerSets a global request handler for all incoming messages
stopProcessStops the ongoing process.
waitforReplyWaits for a reply to a sent message.

Methods


askQuestion

plugin.chat.askQuestion(question: string, buttons: string[], withFeedback: boolean): Promise<string>
ParameterTypeRequiredDescription
questionstringYes
buttonsstring[]Yes(default: [])
withFeedbackbooleanYes(default: false)

Returns: Promise<string>

Full reference →


checkForSteeringMessage

plugin.chat.checkForSteeringMessage(): SteeringMessage | null

Checks if any steering message has been received.

No parameters.

Returns: SteeringMessage | null — The message data if available, or null

Full reference →


getChatHistory

plugin.chat.getChatHistory(threadId: string): Promise<ChatMessage>

Retrieves the chat history from the server.

ParameterTypeRequiredDescription
threadIdstringYes

Returns: Promise<ChatMessage> — A promise that resolves with an array of ChatMessage objects representing the chat history.

Full reference →


onSteeringMessageReceived

plugin.chat.onSteeringMessageReceived(): Promise<SteeringMessage | null>

Waits for a steering message.

No parameters.

Returns: Promise<SteeringMessage | null> — A promise that resolves with the message data

Full reference →


processFinished

plugin.chat.processFinished(): void

Stops the ongoing process. Sends a specific message to the server to stop the process.

No parameters.

Returns: void

Full reference →


processStarted

plugin.chat.processStarted(onStopClicked?: Function): ProcessControl | ProcessControlWithCleanup

Notifies the server that a process has started and sets up a listener for stopProcessClicked events.

ParameterTypeRequiredDescription
onStopClickedFunctionNoCallback function to handle stop process events.

Returns: ProcessControl | ProcessControlWithCleanup — An object containing a stopProcess method.

Full reference →


sendConfirmationRequest

plugin.chat.sendConfirmationRequest(confirmationMessage: string, buttons: string[], withFeedback: boolean): Promise<string>

Sends a confirmation request to the server with two options: Yes or No.

ParameterTypeRequiredDescription
confirmationMessagestringYes
buttonsstring[]Yes(default: [])
withFeedbackbooleanYes(default: false)

Returns: Promise<string> — A promise that resolves with the server's response.

Full reference →


sendMessage

plugin.chat.sendMessage(message: string, payload?: object): void

Sends a message through the WebSocket connection.

ParameterTypeRequiredDescription
messagestringYesThe message to be sent.
payloadobjectNoOptional additional payload data.

Returns: void

Full reference →


sendNotificationEvent

plugin.chat.sendNotificationEvent(notificationMessage: string, type: "editor" | "browser" | "terminal" | "git" | "debug" | "planner" | "preview"): void

Sends a notification event to the server.

ParameterTypeRequiredDescription
notificationMessagestringYesThe message to be sent in the notification.
type`"editor""browser""terminal"

Returns: void

Full reference →


setRequestHandler

plugin.chat.setRequestHandler(handler: RequestHandler): void

Sets a global request handler for all incoming messages

ParameterTypeRequiredDescription
handlerRequestHandlerYesThe async handler function

Returns: void

Full reference →


stopProcess

plugin.chat.stopProcess(): void

Stops the ongoing process. Sends a specific message to the server to stop the process.

No parameters.

Returns: void

Full reference →


waitforReply

plugin.chat.waitforReply(message: string): Promise<UserMessage>

Waits for a reply to a sent message.

ParameterTypeRequiredDescription
messagestringYesThe message for which a reply is expected.

Returns: Promise<UserMessage> — A promise that resolves with the reply.

Full reference →