@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.
- package/dist/core/messageManager.d.ts +47 -0
- package/dist/core/messageManager.js +128 -0
- package/dist/{modules → core}/websocket.d.ts +5 -0
- package/dist/{modules → core}/websocket.js +13 -9
- package/dist/index.d.ts +42 -53
- package/dist/index.js +49 -4
- package/dist/modules/agent.js +26 -58
- package/dist/modules/browser.d.ts +7 -7
- package/dist/modules/browser.js +75 -195
- package/dist/modules/chat.d.ts +8 -20
- package/dist/modules/chat.js +60 -123
- package/dist/modules/codeutils.d.ts +1 -1
- package/dist/modules/codeutils.js +30 -107
- package/dist/modules/crawler.d.ts +1 -16
- package/dist/modules/crawler.js +13 -72
- package/dist/modules/dbmemory.js +12 -28
- package/dist/modules/debug.js +17 -33
- package/dist/modules/fs.d.ts +1 -1
- package/dist/modules/fs.js +82 -162
- package/dist/modules/git.js +60 -148
- package/dist/modules/history.js +11 -27
- package/dist/modules/llm.js +8 -16
- package/dist/modules/project.d.ts +1 -1
- package/dist/modules/project.js +16 -40
- package/dist/modules/state.js +29 -69
- package/dist/modules/task.js +19 -43
- package/dist/modules/terminal.d.ts +3 -2
- package/dist/modules/terminal.js +36 -47
- package/dist/modules/tokenizer.js +15 -31
- package/dist/modules/tools.d.ts +0 -6
- package/dist/modules/tools.js +41 -179
- package/dist/modules/utils.js +22 -0
- package/dist/modules/vectordb.js +30 -62
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/utils/editFile.js +0 -30
- /package/dist/{utils/editFile.d.ts → modules/utils.d.ts} +0 -0
- /package/dist/{modules → utils}/toolBox.d.ts +0 -0
- /package/dist/{modules → utils}/toolBox.js +0 -0
package/dist/modules/git.js
CHANGED
|
@@ -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("
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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;
|
package/dist/modules/history.js
CHANGED
|
@@ -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("
|
|
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
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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;
|
package/dist/modules/llm.js
CHANGED
|
@@ -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("
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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<
|
|
19
|
+
getEditorFileStatus: () => Promise<any>;
|
|
20
20
|
};
|
|
21
21
|
export default cbproject;
|
package/dist/modules/project.js
CHANGED
|
@@ -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("
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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.
|
|
37
|
+
websocket_1.default.messageManager.send({
|
|
54
38
|
"type": "runProject"
|
|
55
|
-
})
|
|
39
|
+
});
|
|
56
40
|
},
|
|
57
41
|
getEditorFileStatus: () => {
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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;
|
package/dist/modules/state.js
CHANGED
|
@@ -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("
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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;
|