@codebolt/codeboltjs 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/core/messageManager.d.ts +47 -0
  2. package/dist/core/messageManager.js +128 -0
  3. package/dist/{modules → core}/websocket.d.ts +5 -0
  4. package/dist/{modules → core}/websocket.js +13 -9
  5. package/dist/index.d.ts +42 -53
  6. package/dist/index.js +49 -4
  7. package/dist/modules/agent.js +26 -58
  8. package/dist/modules/browser.d.ts +7 -7
  9. package/dist/modules/browser.js +75 -195
  10. package/dist/modules/chat.d.ts +8 -20
  11. package/dist/modules/chat.js +60 -123
  12. package/dist/modules/codeutils.d.ts +1 -1
  13. package/dist/modules/codeutils.js +30 -107
  14. package/dist/modules/crawler.d.ts +1 -16
  15. package/dist/modules/crawler.js +13 -72
  16. package/dist/modules/dbmemory.js +12 -28
  17. package/dist/modules/debug.js +17 -33
  18. package/dist/modules/fs.d.ts +1 -1
  19. package/dist/modules/fs.js +82 -162
  20. package/dist/modules/git.js +60 -148
  21. package/dist/modules/history.js +11 -27
  22. package/dist/modules/llm.js +8 -16
  23. package/dist/modules/project.d.ts +1 -1
  24. package/dist/modules/project.js +16 -40
  25. package/dist/modules/state.js +29 -69
  26. package/dist/modules/task.js +19 -43
  27. package/dist/modules/terminal.d.ts +3 -2
  28. package/dist/modules/terminal.js +36 -47
  29. package/dist/modules/tokenizer.js +15 -31
  30. package/dist/modules/tools.d.ts +0 -6
  31. package/dist/modules/tools.js +41 -179
  32. package/dist/modules/utils.js +22 -0
  33. package/dist/modules/vectordb.js +30 -62
  34. package/dist/utils.d.ts +1 -1
  35. package/dist/utils.js +1 -1
  36. package/package.json +1 -1
  37. package/dist/utils/editFile.js +0 -30
  38. /package/dist/{utils/editFile.d.ts → modules/utils.d.ts} +0 -0
  39. /package/dist/{modules → utils}/toolBox.d.ts +0 -0
  40. /package/dist/{modules → utils}/toolBox.js +0 -0
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const websocket_1 = __importDefault(require("./websocket"));
6
+ const websocket_1 = __importDefault(require("../core/websocket"));
7
7
  /**
8
8
  * A service for interacting with Git operations via WebSocket messages.
9
9
  */
@@ -14,19 +14,11 @@ const gitService = {
14
14
  * @returns {Promise<any>} A promise that resolves with the response from the init event.
15
15
  */
16
16
  init: async (path) => {
17
- return new Promise((resolve, reject) => {
18
- websocket_1.default.getWebsocket.send(JSON.stringify({
19
- "type": "gitEvent",
20
- "action": "Init",
21
- "path": path
22
- }));
23
- websocket_1.default.getWebsocket.on('message', (data) => {
24
- const response = JSON.parse(data);
25
- if (response.type === "InitResponse") {
26
- resolve(response);
27
- }
28
- });
29
- });
17
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
18
+ "type": "gitEvent",
19
+ "action": "Init",
20
+ "path": path
21
+ }, "InitResponse");
30
22
  },
31
23
  /**
32
24
  * Clones a Git repository from the given URL to the specified path.
@@ -35,20 +27,12 @@ const gitService = {
35
27
  * @returns {Promise<any>} A promise that resolves with the response from the clone event.
36
28
  */
37
29
  clone: async (url, path) => {
38
- return new Promise((resolve, reject) => {
39
- websocket_1.default.getWebsocket.send(JSON.stringify({
40
- "type": "gitEvent",
41
- "action": "Clone",
42
- "url": url,
43
- "path": path
44
- }));
45
- websocket_1.default.getWebsocket.on('message', (data) => {
46
- const response = JSON.parse(data);
47
- if (response.type === "CloneResponse") {
48
- resolve(response);
49
- }
50
- });
51
- });
30
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
31
+ "type": "gitEvent",
32
+ "action": "Clone",
33
+ "url": url,
34
+ "path": path
35
+ }, "CloneResponse");
52
36
  },
53
37
  /**
54
38
  * Pulls the latest changes from the remote repository to the local repository at the given path.
@@ -56,19 +40,11 @@ const gitService = {
56
40
  * @returns {Promise<any>} A promise that resolves with the response from the pull event.
57
41
  */
58
42
  pull: async (path) => {
59
- return new Promise((resolve, reject) => {
60
- websocket_1.default.getWebsocket.send(JSON.stringify({
61
- "type": "gitEvent",
62
- "action": "Pull",
63
- "path": path
64
- }));
65
- websocket_1.default.getWebsocket.on('message', (data) => {
66
- const response = JSON.parse(data);
67
- if (response.type === "PullResponse") {
68
- resolve(response);
69
- }
70
- });
71
- });
43
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
44
+ "type": "gitEvent",
45
+ "action": "Pull",
46
+ "path": path
47
+ }, "PullResponse");
72
48
  },
73
49
  /**
74
50
  * Pushes local repository changes to the remote repository at the given path.
@@ -76,19 +52,11 @@ const gitService = {
76
52
  * @returns {Promise<any>} A promise that resolves with the response from the push event.
77
53
  */
78
54
  push: async (path) => {
79
- return new Promise((resolve, reject) => {
80
- websocket_1.default.getWebsocket.send(JSON.stringify({
81
- "type": "gitEvent",
82
- "action": "Push",
83
- "path": path
84
- }));
85
- websocket_1.default.getWebsocket.on('message', (data) => {
86
- const response = JSON.parse(data);
87
- if (response.type === "PushResponse") {
88
- resolve(response);
89
- }
90
- });
91
- });
55
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
56
+ "type": "gitEvent",
57
+ "action": "Push",
58
+ "path": path
59
+ }, "PushResponse");
92
60
  },
93
61
  /**
94
62
  * Retrieves the status of the local repository at the given path.
@@ -96,19 +64,11 @@ const gitService = {
96
64
  * @returns {Promise<any>} A promise that resolves with the response from the status event.
97
65
  */
98
66
  status: async (path) => {
99
- return new Promise((resolve, reject) => {
100
- websocket_1.default.getWebsocket.send(JSON.stringify({
101
- "type": "gitEvent",
102
- "action": "Status",
103
- "path": path
104
- }));
105
- websocket_1.default.getWebsocket.on('message', (data) => {
106
- const response = JSON.parse(data);
107
- if (response.type === "StatusResponse") {
108
- resolve(response);
109
- }
110
- });
111
- });
67
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
68
+ "type": "gitEvent",
69
+ "action": "Status",
70
+ "path": path
71
+ }, "StatusResponse");
112
72
  },
113
73
  /**
114
74
  * Adds changes in the local repository to the staging area at the given path.
@@ -116,19 +76,11 @@ const gitService = {
116
76
  * @returns {Promise<any>} A promise that resolves with the response from the add event.
117
77
  */
118
78
  add: async (path) => {
119
- return new Promise((resolve, reject) => {
120
- websocket_1.default.getWebsocket.send(JSON.stringify({
121
- "type": "gitEvent",
122
- "action": "Add",
123
- "path": path
124
- }));
125
- websocket_1.default.getWebsocket.on('message', (data) => {
126
- const response = JSON.parse(data);
127
- if (response.type === "AddResponse") {
128
- resolve(response);
129
- }
130
- });
131
- });
79
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
80
+ "type": "gitEvent",
81
+ "action": "Add",
82
+ "path": path
83
+ }, "AddResponse");
132
84
  },
133
85
  /**
134
86
  * Commits the staged changes in the local repository with the given commit message.
@@ -136,19 +88,11 @@ const gitService = {
136
88
  * @returns {Promise<any>} A promise that resolves with the response from the commit event.
137
89
  */
138
90
  commit: async (message) => {
139
- return new Promise((resolve, reject) => {
140
- websocket_1.default.getWebsocket.send(JSON.stringify({
141
- "type": "gitEvent",
142
- "action": "Commit",
143
- "message": message
144
- }));
145
- websocket_1.default.getWebsocket.on('message', (data) => {
146
- const response = JSON.parse(data);
147
- if (response.type === "gitCommitResponse") {
148
- resolve(response);
149
- }
150
- });
151
- });
91
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
92
+ "type": "gitEvent",
93
+ "action": "Commit",
94
+ "message": message
95
+ }, "gitCommitResponse");
152
96
  },
153
97
  /**
154
98
  * Checks out a branch or commit in the local repository at the given path.
@@ -157,20 +101,12 @@ const gitService = {
157
101
  * @returns {Promise<any>} A promise that resolves with the response from the checkout event.
158
102
  */
159
103
  checkout: async (path, branch) => {
160
- return new Promise((resolve, reject) => {
161
- websocket_1.default.getWebsocket.send(JSON.stringify({
162
- "type": "gitEvent",
163
- "action": "Checkout",
164
- "path": path,
165
- "branch": branch
166
- }));
167
- websocket_1.default.getWebsocket.on('message', (data) => {
168
- const response = JSON.parse(data);
169
- if (response.type === "CheckoutResponse") {
170
- resolve(response);
171
- }
172
- });
173
- });
104
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
105
+ "type": "gitEvent",
106
+ "action": "Checkout",
107
+ "path": path,
108
+ "branch": branch
109
+ }, "CheckoutResponse");
174
110
  },
175
111
  /**
176
112
  * Creates a new branch in the local repository at the given path.
@@ -179,20 +115,12 @@ const gitService = {
179
115
  * @returns {Promise<any>} A promise that resolves with the response from the branch event.
180
116
  */
181
117
  branch: async (path, branch) => {
182
- return new Promise((resolve, reject) => {
183
- websocket_1.default.getWebsocket.send(JSON.stringify({
184
- "type": "gitEvent",
185
- "action": "Branch",
186
- "path": path,
187
- "branch": branch
188
- }));
189
- websocket_1.default.getWebsocket.on('message', (data) => {
190
- const response = JSON.parse(data);
191
- if (response.type === "BranchResponse") {
192
- resolve(response);
193
- }
194
- });
195
- });
118
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
119
+ "type": "gitEvent",
120
+ "action": "Branch",
121
+ "path": path,
122
+ "branch": branch
123
+ }, "BranchResponse");
196
124
  },
197
125
  /**
198
126
  * Retrieves the commit logs for the local repository at the given path.
@@ -200,19 +128,11 @@ const gitService = {
200
128
  * @returns {Promise<any>} A promise that resolves with the response from the logs event.
201
129
  */
202
130
  logs: async (path) => {
203
- return new Promise((resolve, reject) => {
204
- websocket_1.default.getWebsocket.send(JSON.stringify({
205
- "type": "gitEvent",
206
- "action": "Logs",
207
- "path": path
208
- }));
209
- websocket_1.default.getWebsocket.on('message', (data) => {
210
- const response = JSON.parse(data);
211
- if (response.type === "LogsResponse") {
212
- resolve(response);
213
- }
214
- });
215
- });
131
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
132
+ "type": "gitEvent",
133
+ "action": "Logs",
134
+ "path": path
135
+ }, "LogsResponse");
216
136
  },
217
137
  /**
218
138
  * Retrieves the diff of changes for a specific commit in the local repository.
@@ -221,20 +141,12 @@ const gitService = {
221
141
  * @returns {Promise<any>} A promise that resolves with the response from the diff event.
222
142
  */
223
143
  diff: async (commitHash, path) => {
224
- return new Promise((resolve, reject) => {
225
- websocket_1.default.getWebsocket.send(JSON.stringify({
226
- "type": "gitEvent",
227
- "action": "Diff",
228
- "path": path,
229
- "commitHash": commitHash
230
- }));
231
- websocket_1.default.getWebsocket.on('message', (data) => {
232
- const response = JSON.parse(data);
233
- if (response.type === "DiffResponse") {
234
- resolve(response);
235
- }
236
- });
237
- });
144
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
145
+ "type": "gitEvent",
146
+ "action": "Diff",
147
+ "path": path,
148
+ "commitHash": commitHash
149
+ }, "DiffResponse");
238
150
  }
239
151
  };
240
152
  exports.default = gitService;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.chatSummary = exports.logType = void 0;
7
- const websocket_1 = __importDefault(require("./websocket"));
7
+ const websocket_1 = __importDefault(require("../core/websocket"));
8
8
  /**
9
9
  * Enum representing different types of log messages.
10
10
  */
@@ -28,18 +28,10 @@ exports.chatSummary = {
28
28
  * @returns Promise with an array of message objects containing role and content
29
29
  */
30
30
  summarizeAll: () => {
31
- return new Promise((resolve, reject) => {
32
- websocket_1.default.getWebsocket.send(JSON.stringify({
33
- "type": "chatSummaryEvent",
34
- "action": "summarizeAll",
35
- }));
36
- websocket_1.default.getWebsocket.on('message', (data) => {
37
- const response = JSON.parse(data);
38
- if (response.type === "getSummarizeAllResponse") {
39
- resolve(response.payload); // Resolve the Promise with the response data
40
- }
41
- });
42
- });
31
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
32
+ "type": "chatSummaryEvent",
33
+ "action": "summarizeAll",
34
+ }, "getSummarizeAllResponse");
43
35
  },
44
36
  /**
45
37
  * Summarizes a specific part of the chat history.
@@ -49,20 +41,12 @@ exports.chatSummary = {
49
41
  * @returns Promise with an array of summarized message objects
50
42
  */
51
43
  summarize: (messages, depth) => {
52
- return new Promise((resolve, reject) => {
53
- websocket_1.default.getWebsocket.send(JSON.stringify({
54
- "type": "chatSummaryEvent",
55
- "action": "summarize",
56
- messages,
57
- depth
58
- }));
59
- websocket_1.default.getWebsocket.on('message', (data) => {
60
- const response = JSON.parse(data);
61
- if (response.type === "getSummarizeResponse") {
62
- resolve(response.payload); // Resolve the Promise with the response data
63
- }
64
- });
65
- });
44
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
45
+ "type": "chatSummaryEvent",
46
+ "action": "summarize",
47
+ messages,
48
+ depth
49
+ }, "getSummarizeResponse");
66
50
  }
67
51
  };
68
52
  exports.default = exports.chatSummary;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const websocket_1 = __importDefault(require("./websocket"));
6
+ const websocket_1 = __importDefault(require("../core/websocket"));
7
7
  /**
8
8
  * A module for interacting with language learning models (LLMs) via WebSocket.
9
9
  */
@@ -19,21 +19,13 @@ const cbllm = {
19
19
  * @returns {Promise<LLMResponse>} A promise that resolves with the LLM's response.
20
20
  */
21
21
  inference: async (message, llmrole) => {
22
- return new Promise((resolve, reject) => {
23
- websocket_1.default.getWebsocket.send(JSON.stringify({
24
- "type": "inference",
25
- "message": {
26
- prompt: message,
27
- llmrole
28
- },
29
- }));
30
- websocket_1.default.getWebsocket.on('message', (data) => {
31
- const response = JSON.parse(data);
32
- if (response.type === "llmResponse") {
33
- resolve(response); // Resolve the Promise with the response data
34
- }
35
- });
36
- });
22
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
23
+ "type": "inference",
24
+ "message": {
25
+ prompt: message,
26
+ llmrole
27
+ },
28
+ }, "llmResponse");
37
29
  }
38
30
  };
39
31
  exports.default = cbllm;
@@ -16,6 +16,6 @@ declare const cbproject: {
16
16
  getProjectPath: () => Promise<GetProjectPathResponse>;
17
17
  getRepoMap: (message: any) => Promise<GetProjectPathResponse>;
18
18
  runProject: () => void;
19
- getEditorFileStatus: () => Promise<unknown>;
19
+ getEditorFileStatus: () => Promise<any>;
20
20
  };
21
21
  export default cbproject;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const websocket_1 = __importDefault(require("./websocket"));
6
+ const websocket_1 = __importDefault(require("../core/websocket"));
7
7
  /**
8
8
  * A module for interacting with project settings and paths.
9
9
  */
@@ -21,52 +21,28 @@ const cbproject = {
21
21
  * @returns {Promise<GetProjectPathResponse>} A promise that resolves with the project path response.
22
22
  */
23
23
  getProjectPath: () => {
24
- return new Promise((resolve, reject) => {
25
- websocket_1.default.getWebsocket.send(JSON.stringify({
26
- "type": "settingEvent",
27
- "action": "getProjectPath"
28
- }));
29
- websocket_1.default.getWebsocket.on('message', (data) => {
30
- const response = JSON.parse(data);
31
- if (response.type === "getProjectPathResponse") {
32
- resolve(response);
33
- }
34
- });
35
- });
24
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
25
+ "type": "settingEvent",
26
+ "action": "getProjectPath"
27
+ }, "getProjectPathResponse");
36
28
  },
37
29
  getRepoMap: (message) => {
38
- return new Promise((resolve, reject) => {
39
- websocket_1.default.getWebsocket.send(JSON.stringify({
40
- "type": "settingEvent",
41
- "action": "getRepoMap",
42
- message
43
- }));
44
- websocket_1.default.getWebsocket.on('message', (data) => {
45
- const response = JSON.parse(data);
46
- if (response.type === "getRepoMapResponse") {
47
- resolve(response);
48
- }
49
- });
50
- });
30
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
31
+ "type": "settingEvent",
32
+ "action": "getRepoMap",
33
+ message
34
+ }, "getRepoMapResponse");
51
35
  },
52
36
  runProject: () => {
53
- websocket_1.default.getWebsocket.send(JSON.stringify({
37
+ websocket_1.default.messageManager.send({
54
38
  "type": "runProject"
55
- }));
39
+ });
56
40
  },
57
41
  getEditorFileStatus: () => {
58
- return new Promise((resolve, reject) => {
59
- websocket_1.default.getWebsocket.send(JSON.stringify({
60
- "type": "settingEvent",
61
- "action": "getEditorFileStatus",
62
- }));
63
- websocket_1.default.getWebsocket.on('message', (data) => {
64
- const response = JSON.parse(data);
65
- if (response.type === "getEditorFileStatusResponse") {
66
- resolve(response);
67
- }
68
- });
69
- });
42
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
43
+ "type": "settingEvent",
44
+ "action": "getEditorFileStatus",
45
+ }, "getEditorFileStatusResponse");
70
46
  }
71
47
  };
72
48
  exports.default = cbproject;
@@ -3,25 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const websocket_1 = __importDefault(require("./websocket"));
6
+ const websocket_1 = __importDefault(require("../core/websocket"));
7
7
  const cbstate = {
8
8
  /**
9
9
  * Retrieves the current application state from the server via WebSocket.
10
10
  * @returns {Promise<ApplicationState>} A promise that resolves with the application state.
11
11
  */
12
12
  getApplicationState: async () => {
13
- return new Promise((resolve, reject) => {
14
- websocket_1.default.getWebsocket.send(JSON.stringify({
15
- "type": "projectStateEvent",
16
- "action": "getAppState",
17
- }));
18
- websocket_1.default.getWebsocket.on('message', (data) => {
19
- const response = JSON.parse(data);
20
- if (response.type === "getAppStateResponse") {
21
- resolve(response); // Resolve the Promise with the response data
22
- }
23
- });
24
- });
13
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
14
+ "type": "projectStateEvent",
15
+ "action": "getAppState",
16
+ }, "getAppStateResponse");
25
17
  },
26
18
  /**
27
19
  * Adds a key-value pair to the agent's state on the server via WebSocket.
@@ -30,80 +22,48 @@ const cbstate = {
30
22
  * @returns {Promise<AddToAgentStateResponse>} A promise that resolves with the response to the addition request.
31
23
  */
32
24
  addToAgentState: async (key, value) => {
33
- return new Promise((resolve, reject) => {
34
- websocket_1.default.getWebsocket.send(JSON.stringify({
35
- "type": "agentStateEvent",
36
- "action": "addToAgentState",
37
- payload: {
38
- key,
39
- value
40
- }
41
- }));
42
- websocket_1.default.getWebsocket.on('message', (data) => {
43
- const response = JSON.parse(data);
44
- if (response.type === "addToAgentStateResponse") {
45
- resolve(response); // Resolve the Promise with the response data
46
- }
47
- });
48
- });
25
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
26
+ "type": "agentStateEvent",
27
+ "action": "addToAgentState",
28
+ payload: {
29
+ key,
30
+ value
31
+ }
32
+ }, "addToAgentStateResponse");
49
33
  },
50
34
  /**
51
35
  * Retrieves the current state of the agent from the server via WebSocket.
52
36
  * @returns {Promise<GetAgentStateResponse>} A promise that resolves with the agent's state.
53
37
  */
54
38
  getAgentState: async () => {
55
- return new Promise((resolve, reject) => {
56
- websocket_1.default.getWebsocket.send(JSON.stringify({
57
- "type": "agentStateEvent",
58
- "action": "getAgentState",
59
- }));
60
- websocket_1.default.getWebsocket.on('message', (data) => {
61
- const response = JSON.parse(data);
62
- if (response.type === "getAgentStateResponse") {
63
- resolve(response); // Resolve the Promise with the response data
64
- }
65
- });
66
- });
39
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
40
+ "type": "agentStateEvent",
41
+ "action": "getAgentState",
42
+ }, "getAgentStateResponse");
67
43
  },
68
44
  /**
69
45
  * Retrieves the current project state from the server via WebSocket.
70
46
  * @returns {Promise<GetProjectStateResponse>} A promise that resolves with the project's state.
71
47
  */
72
48
  getProjectState: async () => {
73
- return new Promise((resolve, reject) => {
74
- websocket_1.default.getWebsocket.send(JSON.stringify({
75
- "type": "projectStateEvent",
76
- "action": "getProjectState",
77
- }));
78
- websocket_1.default.getWebsocket.on('message', (data) => {
79
- const response = JSON.parse(data);
80
- if (response.type === "getProjectStateResponse") {
81
- resolve(response); // Resolve the Promise with the response data
82
- }
83
- });
84
- });
49
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
50
+ "type": "projectStateEvent",
51
+ "action": "getProjectState",
52
+ }, "getProjectStateResponse");
85
53
  },
86
54
  /**
87
55
  * Updates the project state on the server via WebSocket.
88
56
  * @returns {Promise<UpdateProjectStateResponse>} A promise that resolves with the response to the update request.
89
57
  */
90
58
  updateProjectState: async (key, value) => {
91
- return new Promise((resolve, reject) => {
92
- websocket_1.default.getWebsocket.send(JSON.stringify({
93
- "type": "projectStateEvent",
94
- "action": "updateProjectState",
95
- payload: {
96
- key,
97
- value
98
- }
99
- }));
100
- websocket_1.default.getWebsocket.on('message', (data) => {
101
- const response = JSON.parse(data);
102
- if (response.type === "updateProjectStateResponse") {
103
- resolve(response); // Resolve the Promise with the response data
104
- }
105
- });
106
- });
59
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
60
+ "type": "projectStateEvent",
61
+ "action": "updateProjectState",
62
+ payload: {
63
+ key,
64
+ value
65
+ }
66
+ }, "updateProjectStateResponse");
107
67
  }
108
68
  };
109
69
  exports.default = cbstate;