Skip to content

Commit 42b96c7

Browse files
changes
1 parent e8ab69d commit 42b96c7

File tree

9 files changed

+74
-45
lines changed

9 files changed

+74
-45
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"license": "MIT",
1919
"homepage": "https://codeboltai.github.io",
2020
"dependencies": {
21-
"@codebolt/types": "^1.0.8",
21+
"@codebolt/types": "^1.0.9",
2222
"typedoc-plugin-missing-exports": "^2.2.0",
2323
"ws": "^8.17.0"
2424
},

src/modules/debug.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cbws from './websocket';
2-
2+
import {DebugAddLogResponse,OpenDebugBrowserResponse } from '@codebolt/types';
33
export enum logType{
44
info="info",
55
error="error",
@@ -8,7 +8,13 @@ export enum logType{
88

99

1010
export const debug={
11-
debug(log:string,type:logType) {
11+
/**
12+
* Sends a log message to the debug websocket and waits for a response.
13+
* @param {string} log - The log message to send.
14+
* @param {logType} type - The type of the log message (info, error, warning).
15+
* @returns {Promise<DebugAddLogResponse>} A promise that resolves with the response from the debug event.
16+
*/
17+
debug:(log:string,type:logType):Promise<DebugAddLogResponse>=> {
1218
return new Promise((resolve, reject) => {
1319
cbws.getWebsocket.send(JSON.stringify({
1420
"type": "debugEvent",
@@ -28,7 +34,13 @@ export const debug={
2834

2935

3036
},
31-
openDebugBrowser(url:string,port:number){
37+
/**
38+
* Requests to open a debug browser at the specified URL and port.
39+
* @param {string} url - The URL where the debug browser should be opened.
40+
* @param {number} port - The port on which the debug browser will listen.
41+
* @returns {Promise<OpenDebugBrowserResponse>} A promise that resolves with the response from the open debug browser event.
42+
*/
43+
openDebugBrowser:(url:string,port:number):Promise<OpenDebugBrowserResponse>=>{
3244
return new Promise((resolve, reject) => {
3345
cbws.getWebsocket.send(JSON.stringify({
3446
"type": "debugEvent",

src/modules/llm.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cbws from './websocket';
2-
2+
import {LLMResponse } from '@codebolt/types';
33
/**
44
* A module for interacting with language learning models (LLMs) via WebSocket.
55
*/
@@ -12,9 +12,9 @@ const cbllm = {
1212
*
1313
* @param {string} message - The input message or prompt to be sent to the LLM.
1414
* @param {string} llmrole - The role of the LLM to determine which model to use.
15-
* @returns {Promise<any>} A promise that resolves with the LLM's response.
15+
* @returns {Promise<LLMResponse>} A promise that resolves with the LLM's response.
1616
*/
17-
inference: async (message: string, llmrole: string): Promise<any> => {
17+
inference: async (message: string, llmrole: string): Promise<LLMResponse> => {
1818
return new Promise((resolve, reject) => {
1919
cbws.getWebsocket.send(JSON.stringify({
2020
"type": "inference",

src/modules/project.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cbws from './websocket';
2-
2+
import {GetProjectPathResponse } from '@codebolt/types';
33
/**
44
* A module for interacting with project settings and paths.
55
*/
@@ -14,9 +14,9 @@ const cbproject = {
1414
},
1515
/**
1616
* Retrieves the path of the current project.
17-
* @returns {Promise<any>} A promise that resolves with the project path response.
17+
* @returns {Promise<GetProjectPathResponse>} A promise that resolves with the project path response.
1818
*/
19-
getProjectPath: (): Promise<any> => {
19+
getProjectPath: (): Promise<GetProjectPathResponse> => {
2020
return new Promise((resolve, reject) => {
2121
cbws.getWebsocket.send(JSON.stringify({
2222
"type": "settingEvent",

src/modules/state.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import cbws from './websocket';
2+
import {ApplicationState,AddToAgentStateResponse,GetAgentStateResponse } from '@codebolt/types';
23

3-
/**
4-
* Retrieves the application state asynchronously.
5-
* @returns {Promise<any>} A promise that resolves with the application state.
6-
*/
74
const cbstate = {
8-
getApplicationState: async (): Promise<any> => {
5+
/**
6+
* Retrieves the current application state from the server via WebSocket.
7+
* @returns {Promise<ApplicationState>} A promise that resolves with the application state.
8+
*/
9+
getApplicationState: async (): Promise<ApplicationState> => {
910
return new Promise((resolve, reject) => {
1011
cbws.getWebsocket.send(JSON.stringify({
1112
"type": "getAppState",
@@ -19,7 +20,13 @@ const cbstate = {
1920
});
2021
});
2122
},
22-
addToAgentState: async (key: string, value: string): Promise<void> => {
23+
/**
24+
* Adds a key-value pair to the agent's state on the server via WebSocket.
25+
* @param {string} key - The key to add to the agent's state.
26+
* @param {string} value - The value associated with the key.
27+
* @returns {Promise<AddToAgentStateResponse>} A promise that resolves with the response to the addition request.
28+
*/
29+
addToAgentState: async (key: string, value: string): Promise<AddToAgentStateResponse> => {
2330
return new Promise((resolve, reject) => {
2431
cbws.getWebsocket.send(JSON.stringify({
2532
"type": "agentStateEvent",
@@ -38,7 +45,11 @@ const cbstate = {
3845
});
3946
});
4047
},
41-
getAgentState: async (): Promise<any> => {
48+
/**
49+
* Retrieves the current state of the agent from the server via WebSocket.
50+
* @returns {Promise<GetAgentStateResponse>} A promise that resolves with the agent's state.
51+
*/
52+
getAgentState: async (): Promise<GetAgentStateResponse> => {
4253
return new Promise((resolve, reject) => {
4354
cbws.getWebsocket.send(JSON.stringify({
4455
"type": "agentStateEvent",

src/modules/task.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import cbws from './websocket';
2-
2+
import {AddTaskResponse,GetTasksResponse,UpdateTasksResponse } from '@codebolt/types';
33
/**
44
* Manages task operations via WebSocket communication.
55
*/
66
const taskplaner = {
77
/**
88
* Adds a task using a WebSocket message.
99
* @param {string} task - The task to be added.
10-
* @returns {Promise<any>} A promise that resolves with the response from the add task event.
10+
* @returns {Promise<AddTaskResponse>} A promise that resolves with the response from the add task event.
1111
*/
12-
addTask: async (task: string): Promise<any> => {
12+
addTask: async (task: string): Promise<AddTaskResponse> => {
1313
return new Promise((resolve, reject) => {
1414
cbws.getWebsocket.send(JSON.stringify({
1515
"type": "taskEvent",
@@ -29,9 +29,9 @@ const taskplaner = {
2929
},
3030
/**
3131
* Retrieves all tasks using a WebSocket message.
32-
* @returns {Promise<any>} A promise that resolves with the response from the get tasks event.
32+
* @returns {Promise<GetTasksResponse>} A promise that resolves with the response from the get tasks event.
3333
*/
34-
getTasks: async (): Promise<any> => {
34+
getTasks: async (): Promise<GetTasksResponse> => {
3535
return new Promise((resolve, reject) => {
3636
cbws.getWebsocket.send(JSON.stringify({
3737
"type":"taskEvent",
@@ -49,9 +49,9 @@ const taskplaner = {
4949
/**
5050
* Updates an existing task using a WebSocket message.
5151
* @param {string} task - The updated task information.
52-
* @returns {Promise<any>} A promise that resolves with the response from the update task event.
52+
* @returns {Promise<UpdateTasksResponse>} A promise that resolves with the response from the update task event.
5353
*/
54-
updateTask: async ( task: string): Promise<any> => {
54+
updateTask: async ( task: string): Promise<UpdateTasksResponse> => {
5555
return new Promise((resolve, reject) => {
5656
cbws.getWebsocket.send(JSON.stringify({
5757
"type": "taskEvent",

src/modules/terminal.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import cbws from './websocket';
22
import { EventEmitter } from 'events';
3-
3+
import {CommandError,CommandFinish,CommandOutput,TerminalInterruptResponse,TerminalInterrupted } from '@codebolt/types';
44
/**
55
* CustomEventEmitter class that extends the Node.js EventEmitter class.
66
*/
@@ -17,9 +17,9 @@ const cbterminal = {
1717
* of the executed command and resolves the promise accordingly.
1818
*
1919
* @param {string} command - The command to be executed.
20-
* @returns {Promise<any>} A promise that resolves with the command's output, error, or finish signal.
20+
* @returns {Promise<CommandOutput|CommandError>} A promise that resolves with the command's output, error, or finish signal.
2121
*/
22-
executeCommand: async (command: string): Promise<any> => {
22+
executeCommand: async (command: string): Promise<CommandOutput|CommandError> => {
2323
return new Promise((resolve, reject) => {
2424
cbws.getWebsocket.send(JSON.stringify({
2525
"type": "executeCommand",
@@ -39,9 +39,9 @@ const cbterminal = {
3939
* Listens for messages from the WebSocket and resolves the promise when an error is encountered.
4040
*
4141
* @param {string} command - The command to be executed.
42-
* @returns {Promise<any>} A promise that resolves when an error occurs during command execution.
42+
* @returns {Promise<CommandError>} A promise that resolves when an error occurs during command execution.
4343
*/
44-
executeCommandRunUntilError: async (command: string): Promise<any> => {
44+
executeCommandRunUntilError: async (command: string): Promise<CommandError> => {
4545
return new Promise((resolve, reject) => {
4646
cbws.getWebsocket.send(JSON.stringify({
4747
"type": "executeCommandRunUntilError",
@@ -60,9 +60,9 @@ const cbterminal = {
6060
/**
6161
* Sends a manual interrupt signal to the terminal.
6262
*
63-
* @returns {void}
63+
* @returns {Promise<TerminalInterruptResponse>}
6464
*/
65-
sendManualInterrupt(): Promise<any> {
65+
sendManualInterrupt(): Promise<TerminalInterruptResponse> {
6666

6767
return new Promise((resolve, reject) => {
6868
cbws.getWebsocket.send(JSON.stringify({
@@ -82,9 +82,9 @@ const cbterminal = {
8282
* Listens for messages from the WebSocket and streams the output data.
8383
*
8484
* @param {string} command - The command to be executed.
85-
* @returns {Promise<any>} A promise that streams the output data during command execution.
85+
* @returns {EventEmitter} A promise that streams the output data during command execution.
8686
*/
87-
executeCommandWithStream(command: string) {
87+
executeCommandWithStream(command: string):EventEmitter {
8888
// Send the process started message
8989
cbws.getWebsocket.send(JSON.stringify({
9090
"type": "executeCommandWithStream",

src/modules/tokenizer.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AddTokenResponse, GetTokenResponse } from '@codebolt/types';
12
import cbws from './websocket';
23

34
/**
@@ -6,11 +7,11 @@ import cbws from './websocket';
67
const tokenizer = {
78

89
/**
9-
* Adds a token asynchronously.
10-
* @param {string} key - The key of the token to add.
11-
* @returns {Promise<any>} A promise that resolves with the response.
10+
* Adds a token to the system via WebSocket.
11+
* @param {string} key - The key associated with the token to be added.
12+
* @returns {Promise<AddTokenResponse>} A promise that resolves with the response from the add token event.
1213
*/
13-
addToken: async (key: string): Promise<any> => {
14+
addToken: async (key: string): Promise<AddTokenResponse> => {
1415
return new Promise((resolve, reject) => {
1516
cbws.getWebsocket.send(JSON.stringify({
1617
"type":"tokenizerEvent",
@@ -28,7 +29,12 @@ const tokenizer = {
2829
});
2930
},
3031

31-
getToken: async (key: string): Promise<any> => {
32+
/**
33+
* Retrieves a token from the system via WebSocket.
34+
* @param {string} key - The key associated with the token to be retrieved.
35+
* @returns {Promise<GetTokenResponse>} A promise that resolves with the response from the get token event.
36+
*/
37+
getToken: async (key: string): Promise<GetTokenResponse> => {
3238
return new Promise((resolve, reject) => {
3339
cbws.getWebsocket.send(JSON.stringify({
3440
"type":"tokenizerEvent",

src/modules/vectordb.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import cbws from './websocket';
2-
2+
import { AddVectorItemResponse,GetVectorResponse,QueryVectorItemResponse } from '@codebolt/types';
33
const VectorDB = {
44
/**
55
* Retrieves a vector from the vector database based on the provided key.
66
*
77
* @param {string} key - The key of the vector to retrieve.
8-
* @returns {Promise<any>} A promise that resolves with the retrieved vector.
8+
* @returns {Promise<GetVectorResponse>} A promise that resolves with the retrieved vector.
99
*/
10-
getVector: async (key: string): Promise<any> => {
10+
getVector: async (key: string): Promise<GetVectorResponse> => {
1111
return new Promise((resolve, reject) => {
1212
cbws.getWebsocket.send(JSON.stringify({
1313
"type":"vectordbEvent",
@@ -30,9 +30,9 @@ const VectorDB = {
3030
*
3131
3232
* @param {any} item - The item to add to the vector.
33-
* @returns {Promise<any>} A promise that resolves when the item is successfully added.
33+
* @returns {Promise<AddVectorItemResponse>} A promise that resolves when the item is successfully added.
3434
*/
35-
addVectorItem: async ( item: any): Promise<any> => {
35+
addVectorItem: async ( item: any): Promise<AddVectorItemResponse> => {
3636
return new Promise((resolve, reject) => {
3737
cbws.getWebsocket.send(JSON.stringify({
3838
"type":"vectordbEvent",
@@ -54,9 +54,9 @@ const VectorDB = {
5454
* Queries a vector item from the vector database based on the provided key.
5555
*
5656
* @param {string} key - The key of the vector to query the item from.
57-
* @returns {Promise<any>} A promise that resolves with the queried vector item.
57+
* @returns {Promise<QueryVectorItemResponse>} A promise that resolves with the queried vector item.
5858
*/
59-
queryVectorItem: async (key: string): Promise<any> => {
59+
queryVectorItem: async (key: string): Promise<QueryVectorItemResponse> => {
6060
return new Promise((resolve, reject) => {
6161
cbws.getWebsocket.send(JSON.stringify({
6262
"type":"vectordbEvent",

0 commit comments

Comments
 (0)