@codebolt/codeboltjs 2.0.4 → 2.0.6

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 (91) 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 +15 -10
  5. package/dist/index.d.ts +98 -68
  6. package/dist/index.js +51 -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/codeparsers.d.ts +32 -3
  13. package/dist/modules/codeparsers.js +295 -3
  14. package/dist/modules/codeutils.d.ts +24 -7
  15. package/dist/modules/codeutils.js +113 -126
  16. package/dist/modules/crawler.d.ts +1 -16
  17. package/dist/modules/crawler.js +13 -72
  18. package/dist/modules/dbmemory.js +12 -28
  19. package/dist/modules/debug.js +17 -33
  20. package/dist/modules/docutils.d.ts +1 -4
  21. package/dist/modules/docutils.js +52 -2
  22. package/dist/modules/fs.d.ts +47 -1
  23. package/dist/modules/fs.js +151 -162
  24. package/dist/modules/git.d.ts +7 -14
  25. package/dist/modules/git.js +54 -163
  26. package/dist/modules/history.js +11 -27
  27. package/dist/modules/llm.js +8 -16
  28. package/dist/modules/outputparsers.d.ts +36 -4
  29. package/dist/modules/outputparsers.js +56 -5
  30. package/dist/modules/project.d.ts +4 -5
  31. package/dist/modules/project.js +23 -45
  32. package/dist/modules/state.js +29 -69
  33. package/dist/modules/task.js +19 -43
  34. package/dist/modules/terminal.d.ts +3 -2
  35. package/dist/modules/terminal.js +36 -47
  36. package/dist/modules/tokenizer.js +15 -31
  37. package/dist/modules/tools.d.ts +0 -6
  38. package/dist/modules/tools.js +41 -179
  39. package/dist/modules/utils.js +22 -0
  40. package/dist/modules/vectordb.js +30 -62
  41. package/dist/utils/parse-source-code/index.d.ts +9 -0
  42. package/dist/utils/parse-source-code/index.js +233 -0
  43. package/dist/utils/parse-source-code/languageParser.d.ts +8 -0
  44. package/dist/utils/parse-source-code/languageParser.js +137 -0
  45. package/dist/utils/parse-source-code/queries/c-sharp.d.ts +2 -0
  46. package/dist/utils/parse-source-code/queries/c-sharp.js +25 -0
  47. package/dist/utils/parse-source-code/queries/c.d.ts +2 -0
  48. package/dist/utils/parse-source-code/queries/c.js +17 -0
  49. package/dist/utils/parse-source-code/queries/cpp.d.ts +2 -0
  50. package/dist/utils/parse-source-code/queries/cpp.js +25 -0
  51. package/dist/utils/parse-source-code/queries/go.d.ts +2 -0
  52. package/dist/utils/parse-source-code/queries/go.js +29 -0
  53. package/dist/utils/parse-source-code/queries/index.d.ts +12 -0
  54. package/dist/utils/parse-source-code/queries/index.js +30 -0
  55. package/dist/utils/parse-source-code/queries/java.d.ts +2 -0
  56. package/dist/utils/parse-source-code/queries/java.js +17 -0
  57. package/dist/utils/parse-source-code/queries/javascript.d.ts +2 -0
  58. package/dist/utils/parse-source-code/queries/javascript.js +67 -0
  59. package/dist/utils/parse-source-code/queries/php.d.ts +2 -0
  60. package/dist/utils/parse-source-code/queries/php.js +17 -0
  61. package/dist/utils/parse-source-code/queries/python.d.ts +2 -0
  62. package/dist/utils/parse-source-code/queries/python.js +13 -0
  63. package/dist/utils/parse-source-code/queries/ruby.d.ts +2 -0
  64. package/dist/utils/parse-source-code/queries/ruby.js +54 -0
  65. package/dist/utils/parse-source-code/queries/rust.d.ts +2 -0
  66. package/dist/utils/parse-source-code/queries/rust.js +18 -0
  67. package/dist/utils/parse-source-code/queries/swift.d.ts +2 -0
  68. package/dist/utils/parse-source-code/queries/swift.js +47 -0
  69. package/dist/utils/parse-source-code/queries/typescript.d.ts +2 -0
  70. package/dist/utils/parse-source-code/queries/typescript.js +34 -0
  71. package/dist/utils/parse-source-code/tree-sitter-c.wasm +0 -0
  72. package/dist/utils/parse-source-code/tree-sitter-c_sharp.wasm +0 -0
  73. package/dist/utils/parse-source-code/tree-sitter-cpp.wasm +0 -0
  74. package/dist/utils/parse-source-code/tree-sitter-go.wasm +0 -0
  75. package/dist/utils/parse-source-code/tree-sitter-java.wasm +0 -0
  76. package/dist/utils/parse-source-code/tree-sitter-javascript.wasm +0 -0
  77. package/dist/utils/parse-source-code/tree-sitter-php.wasm +0 -0
  78. package/dist/utils/parse-source-code/tree-sitter-python.wasm +0 -0
  79. package/dist/utils/parse-source-code/tree-sitter-ruby.wasm +0 -0
  80. package/dist/utils/parse-source-code/tree-sitter-rust.wasm +0 -0
  81. package/dist/utils/parse-source-code/tree-sitter-swift.wasm +0 -0
  82. package/dist/utils/parse-source-code/tree-sitter-tsx.wasm +0 -0
  83. package/dist/utils/parse-source-code/tree-sitter-typescript.wasm +0 -0
  84. package/dist/utils/parse-source-code/tree-sitter.wasm +0 -0
  85. package/dist/utils.d.ts +1 -1
  86. package/dist/utils.js +1 -1
  87. package/package.json +6 -2
  88. package/dist/utils/editFile.js +0 -30
  89. /package/dist/{utils/editFile.d.ts → modules/utils.d.ts} +0 -0
  90. /package/dist/{modules → utils}/toolBox.d.ts +0 -0
  91. /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,121 +14,55 @@ 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
- });
30
- },
31
- /**
32
- * Clones a Git repository from the given URL to the specified path.
33
- * @param {string} url - The URL of the Git repository to clone.
34
- * @param {string} path - The file system path where the repository should be cloned to.
35
- * @returns {Promise<any>} A promise that resolves with the response from the clone event.
36
- */
37
- 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
- });
17
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
18
+ "type": "gitEvent",
19
+ "action": "Init",
20
+ "path": path
21
+ }, "gitInitResponse");
52
22
  },
53
23
  /**
54
24
  * Pulls the latest changes from the remote repository to the local repository at the given path.
55
25
  * @param {string} path - The file system path of the local Git repository.
56
26
  * @returns {Promise<any>} A promise that resolves with the response from the pull event.
57
27
  */
58
- 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
- });
28
+ pull: async () => {
29
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
30
+ "type": "gitEvent",
31
+ "action": "Pull"
32
+ }, "PullResponse");
72
33
  },
73
34
  /**
74
35
  * Pushes local repository changes to the remote repository at the given path.
75
36
  * @param {string} path - The file system path of the local Git repository.
76
37
  * @returns {Promise<any>} A promise that resolves with the response from the push event.
77
38
  */
78
- 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
- });
39
+ push: async () => {
40
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
41
+ "type": "gitEvent",
42
+ "action": "Push",
43
+ }, "PushResponse");
92
44
  },
93
45
  /**
94
46
  * Retrieves the status of the local repository at the given path.
95
47
  * @param {string} path - The file system path of the local Git repository.
96
48
  * @returns {Promise<any>} A promise that resolves with the response from the status event.
97
49
  */
98
- 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
- });
50
+ status: async () => {
51
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
52
+ "type": "gitEvent",
53
+ "action": "Status",
54
+ }, "gitStatusResponse");
112
55
  },
113
56
  /**
114
57
  * Adds changes in the local repository to the staging area at the given path.
115
58
  * @param {string} path - The file system path of the local Git repository.
116
59
  * @returns {Promise<any>} A promise that resolves with the response from the add event.
117
60
  */
118
- 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
- });
61
+ addAll: async () => {
62
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
63
+ "type": "gitEvent",
64
+ "action": "Add",
65
+ }, "AddResponse");
132
66
  },
133
67
  /**
134
68
  * Commits the staged changes in the local repository with the given commit message.
@@ -136,19 +70,11 @@ const gitService = {
136
70
  * @returns {Promise<any>} A promise that resolves with the response from the commit event.
137
71
  */
138
72
  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
- });
73
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
74
+ "type": "gitEvent",
75
+ "action": "Commit",
76
+ "message": message
77
+ }, "gitCommitResponse");
152
78
  },
153
79
  /**
154
80
  * Checks out a branch or commit in the local repository at the given path.
@@ -156,21 +82,12 @@ const gitService = {
156
82
  * @param {string} branch - The name of the branch or commit to check out.
157
83
  * @returns {Promise<any>} A promise that resolves with the response from the checkout event.
158
84
  */
159
- 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
- });
85
+ checkout: async (branch) => {
86
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
87
+ "type": "gitEvent",
88
+ "action": "Checkout",
89
+ "branch": branch
90
+ }, "gitCheckoutResponse");
174
91
  },
175
92
  /**
176
93
  * Creates a new branch in the local repository at the given path.
@@ -178,21 +95,12 @@ const gitService = {
178
95
  * @param {string} branch - The name of the new branch to create.
179
96
  * @returns {Promise<any>} A promise that resolves with the response from the branch event.
180
97
  */
181
- 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
- });
98
+ branch: async (branch) => {
99
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
100
+ "type": "gitEvent",
101
+ "action": "gitBranch",
102
+ "branch": branch,
103
+ }, "gitBranchResponse");
196
104
  },
197
105
  /**
198
106
  * Retrieves the commit logs for the local repository at the given path.
@@ -200,19 +108,11 @@ const gitService = {
200
108
  * @returns {Promise<any>} A promise that resolves with the response from the logs event.
201
109
  */
202
110
  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
- });
111
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
112
+ "type": "gitEvent",
113
+ "action": "gitLogs",
114
+ "path": path
115
+ }, "gitLogsResponse");
216
116
  },
217
117
  /**
218
118
  * Retrieves the diff of changes for a specific commit in the local repository.
@@ -220,21 +120,12 @@ const gitService = {
220
120
  * @param {string} path - The file system path of the local Git repository.
221
121
  * @returns {Promise<any>} A promise that resolves with the response from the diff event.
222
122
  */
223
- 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
- });
123
+ diff: async (commitHash) => {
124
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
125
+ "type": "gitEvent",
126
+ "action": "Diff",
127
+ "commitHash": commitHash
128
+ }, "DiffResponse");
238
129
  }
239
130
  };
240
131
  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;
@@ -3,11 +3,43 @@
3
3
  */
4
4
  declare const cboutputparsers: {
5
5
  /**
6
- * Initializes the output parser module.
7
- * Currently, this function does not perform any operations.
8
- * @param {any} output - The output to be initialized.
6
+ * Parses JSON string and returns a result object.
7
+ * @param {string} jsonString - The JSON string to parse.
8
+ * @returns {Object} An object with success flag and parsed data or error.
9
9
  */
10
- init: (output: any) => void;
10
+ parseJSON: (jsonString: string) => {
11
+ success: boolean;
12
+ parsed?: any;
13
+ error?: Error;
14
+ };
15
+ /**
16
+ * Parses XML string and returns a result object.
17
+ * @param {string} xmlString - The XML string to parse.
18
+ * @returns {Object} An object with success flag and parsed data.
19
+ */
20
+ parseXML: (xmlString: string) => {
21
+ success: boolean;
22
+ parsed?: any;
23
+ };
24
+ /**
25
+ * Parses CSV string and returns a result object.
26
+ * @param {string} csvString - The CSV string to parse.
27
+ * @returns {Object} An object with success flag and parsed data or error.
28
+ */
29
+ parseCSV: (csvString: string) => {
30
+ success: boolean;
31
+ parsed?: any[];
32
+ error?: Error;
33
+ };
34
+ /**
35
+ * Parses text string and returns a result object with lines.
36
+ * @param {string} text - The text to parse.
37
+ * @returns {Object} An object with success flag and parsed lines.
38
+ */
39
+ parseText: (text: string) => {
40
+ success: boolean;
41
+ parsed: string[];
42
+ };
11
43
  /**
12
44
  * Parses the given output and returns all the error messages.
13
45
  * @param {any} output - The output to parse for error messages.
@@ -5,12 +5,63 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  */
6
6
  const cboutputparsers = {
7
7
  /**
8
- * Initializes the output parser module.
9
- * Currently, this function does not perform any operations.
10
- * @param {any} output - The output to be initialized.
8
+ * Parses JSON string and returns a result object.
9
+ * @param {string} jsonString - The JSON string to parse.
10
+ * @returns {Object} An object with success flag and parsed data or error.
11
11
  */
12
- init: (output) => {
13
- // Initialization code can be added here if necessary
12
+ parseJSON: (jsonString) => {
13
+ try {
14
+ const parsed = JSON.parse(jsonString);
15
+ return { success: true, parsed };
16
+ }
17
+ catch (error) {
18
+ return { success: false, error: error };
19
+ }
20
+ },
21
+ /**
22
+ * Parses XML string and returns a result object.
23
+ * @param {string} xmlString - The XML string to parse.
24
+ * @returns {Object} An object with success flag and parsed data.
25
+ */
26
+ parseXML: (xmlString) => {
27
+ // Simple XML parsing - in a real implementation, would use a proper XML parser
28
+ const hasValidRoot = xmlString.trim().startsWith('<') && xmlString.trim().endsWith('>');
29
+ return {
30
+ success: hasValidRoot,
31
+ parsed: hasValidRoot ? { rootElement: xmlString } : undefined
32
+ };
33
+ },
34
+ /**
35
+ * Parses CSV string and returns a result object.
36
+ * @param {string} csvString - The CSV string to parse.
37
+ * @returns {Object} An object with success flag and parsed data or error.
38
+ */
39
+ parseCSV: (csvString) => {
40
+ try {
41
+ const lines = csvString.split('\n');
42
+ const headers = lines[0].split(',');
43
+ const results = lines.slice(1).map(line => {
44
+ const values = line.split(',');
45
+ const obj = {};
46
+ headers.forEach((header, index) => {
47
+ obj[header] = values[index];
48
+ });
49
+ return obj;
50
+ });
51
+ return { success: true, parsed: results };
52
+ }
53
+ catch (error) {
54
+ return { success: false, error: error };
55
+ }
56
+ },
57
+ /**
58
+ * Parses text string and returns a result object with lines.
59
+ * @param {string} text - The text to parse.
60
+ * @returns {Object} An object with success flag and parsed lines.
61
+ */
62
+ parseText: (text) => {
63
+ const lines = text ? text.split('\n') : [];
64
+ return { success: true, parsed: lines };
14
65
  },
15
66
  /**
16
67
  * Parses the given output and returns all the error messages.
@@ -4,11 +4,10 @@ import { GetProjectPathResponse } from '@codebolt/types';
4
4
  */
5
5
  declare const cbproject: {
6
6
  /**
7
- * Placeholder for a method to get project settings.
8
- * Currently, this method does not perform any operations.
9
- * @param {any} output - The output where project settings would be stored.
7
+ * Retrieves the project settings from the server.
8
+ * @returns {Promise<any>} A promise that resolves with the project settings response.
10
9
  */
11
- getProjectSettings: (output: any) => void;
10
+ getProjectSettings: () => Promise<any>;
12
11
  /**
13
12
  * Retrieves the path of the current project.
14
13
  * @returns {Promise<GetProjectPathResponse>} A promise that resolves with the project path response.
@@ -16,6 +15,6 @@ declare const cbproject: {
16
15
  getProjectPath: () => Promise<GetProjectPathResponse>;
17
16
  getRepoMap: (message: any) => Promise<GetProjectPathResponse>;
18
17
  runProject: () => void;
19
- getEditorFileStatus: () => Promise<unknown>;
18
+ getEditorFileStatus: () => Promise<any>;
20
19
  };
21
20
  export default cbproject;
@@ -3,70 +3,48 @@ 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
  */
10
10
  const cbproject = {
11
11
  /**
12
- * Placeholder for a method to get project settings.
13
- * Currently, this method does not perform any operations.
14
- * @param {any} output - The output where project settings would be stored.
12
+ * Retrieves the project settings from the server.
13
+ * @returns {Promise<any>} A promise that resolves with the project settings response.
15
14
  */
16
- getProjectSettings: (output) => {
17
- // Implementation for getting project settings will be added here
15
+ getProjectSettings: () => {
16
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
17
+ "type": "settingEvent",
18
+ "action": "getProjectSettings"
19
+ }, "getProjectSettingsResponse");
18
20
  },
19
21
  /**
20
22
  * Retrieves the path of the current project.
21
23
  * @returns {Promise<GetProjectPathResponse>} A promise that resolves with the project path response.
22
24
  */
23
25
  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
- });
26
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
27
+ "type": "settingEvent",
28
+ "action": "getProjectPath"
29
+ }, "getProjectPathResponse");
36
30
  },
37
31
  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
- });
32
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
33
+ "type": "settingEvent",
34
+ "action": "getRepoMap",
35
+ message
36
+ }, "getRepoMapResponse");
51
37
  },
52
38
  runProject: () => {
53
- websocket_1.default.getWebsocket.send(JSON.stringify({
39
+ websocket_1.default.messageManager.send({
54
40
  "type": "runProject"
55
- }));
41
+ });
56
42
  },
57
43
  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
- });
44
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
45
+ "type": "settingEvent",
46
+ "action": "getEditorFileStatus",
47
+ }, "getEditorFileStatusResponse");
70
48
  }
71
49
  };
72
50
  exports.default = cbproject;