@codebolt/codeboltjs 1.1.17 → 1.1.19
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/index.js +2 -0
- package/modules/terminal.d.ts +1 -11
- package/modules/terminal.js +1 -24
- package/modules/vectordb.d.ts +25 -0
- package/modules/vectordb.js +76 -0
- package/package.json +1 -1
- package/src/index.ts +4 -1
- package/src/modules/terminal.ts +3 -24
- package/src/modules/vectordb.ts +75 -0
package/index.js
CHANGED
|
@@ -22,6 +22,7 @@ const git_1 = __importDefault(require("./modules/git"));
|
|
|
22
22
|
const dbmemory_1 = __importDefault(require("./modules/dbmemory"));
|
|
23
23
|
const state_1 = __importDefault(require("./modules/state"));
|
|
24
24
|
const task_1 = __importDefault(require("./modules/task"));
|
|
25
|
+
const vectordb_1 = __importDefault(require("./modules/vectordb"));
|
|
25
26
|
const ws_1 = __importDefault(require("ws"));
|
|
26
27
|
/**
|
|
27
28
|
* @class Codebolt
|
|
@@ -52,6 +53,7 @@ class Codebolt {
|
|
|
52
53
|
this.dbmemory = dbmemory_1.default;
|
|
53
54
|
this.cbstate = state_1.default;
|
|
54
55
|
this.taskplaner = task_1.default;
|
|
56
|
+
this.vectordb = vectordb_1.default;
|
|
55
57
|
this.websocket = websocket_1.default.getWebsocket;
|
|
56
58
|
}
|
|
57
59
|
/**
|
package/modules/terminal.d.ts
CHANGED
|
@@ -27,14 +27,6 @@ declare const cbterminal: {
|
|
|
27
27
|
* @returns {Promise<any>} A promise that resolves when an error occurs during command execution.
|
|
28
28
|
*/
|
|
29
29
|
executeCommandRunUntilError: (command: string) => Promise<any>;
|
|
30
|
-
/**
|
|
31
|
-
* Executes a given command and keeps running until interrupted.
|
|
32
|
-
* Listens for messages from the WebSocket and resolves the promise when an interruption signal is received.
|
|
33
|
-
*
|
|
34
|
-
* @param {string} command - The command to be executed.
|
|
35
|
-
* @returns {Promise<any>} A promise that resolves when an interruption signal is received during command execution.
|
|
36
|
-
*/
|
|
37
|
-
executeCommandRunUnitlInterrupt: (command: string) => Promise<any>;
|
|
38
30
|
/**
|
|
39
31
|
* Sends a manual interrupt signal to the terminal.
|
|
40
32
|
*
|
|
@@ -48,8 +40,6 @@ declare const cbterminal: {
|
|
|
48
40
|
* @param {string} command - The command to be executed.
|
|
49
41
|
* @returns {Promise<any>} A promise that streams the output data during command execution.
|
|
50
42
|
*/
|
|
51
|
-
executeCommandWithStream(command: string):
|
|
52
|
-
event: CustomEventEmitter;
|
|
53
|
-
};
|
|
43
|
+
executeCommandWithStream(command: string): CustomEventEmitter;
|
|
54
44
|
};
|
|
55
45
|
export default cbterminal;
|
package/modules/terminal.js
CHANGED
|
@@ -58,27 +58,6 @@ const cbterminal = {
|
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
},
|
|
61
|
-
/**
|
|
62
|
-
* Executes a given command and keeps running until interrupted.
|
|
63
|
-
* Listens for messages from the WebSocket and resolves the promise when an interruption signal is received.
|
|
64
|
-
*
|
|
65
|
-
* @param {string} command - The command to be executed.
|
|
66
|
-
* @returns {Promise<any>} A promise that resolves when an interruption signal is received during command execution.
|
|
67
|
-
*/
|
|
68
|
-
executeCommandRunUnitlInterrupt: async (command) => {
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
71
|
-
"type": "executeCommandRunUnitlInterrupt",
|
|
72
|
-
"message": command,
|
|
73
|
-
}));
|
|
74
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
75
|
-
const response = JSON.parse(data);
|
|
76
|
-
if (response.type === "terminalInterruptResponse") {
|
|
77
|
-
resolve(response);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
61
|
/**
|
|
83
62
|
* Sends a manual interrupt signal to the terminal.
|
|
84
63
|
*
|
|
@@ -119,9 +98,7 @@ const cbterminal = {
|
|
|
119
98
|
this.eventEmitter.emit("serverEvents", response.response);
|
|
120
99
|
});
|
|
121
100
|
// Return an object that includes the event emitter and the stopProcess method
|
|
122
|
-
return
|
|
123
|
-
event: this.eventEmitter
|
|
124
|
-
};
|
|
101
|
+
return this.eventEmitter;
|
|
125
102
|
}
|
|
126
103
|
};
|
|
127
104
|
exports.default = cbterminal;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const VectorDB: {
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves a vector from the vector database based on the provided key.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} key - The key of the vector to retrieve.
|
|
6
|
+
* @returns {Promise<any>} A promise that resolves with the retrieved vector.
|
|
7
|
+
*/
|
|
8
|
+
getVector: (key: string) => Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Adds a new vector item to the vector database.
|
|
11
|
+
*
|
|
12
|
+
|
|
13
|
+
* @param {any} item - The item to add to the vector.
|
|
14
|
+
* @returns {Promise<any>} A promise that resolves when the item is successfully added.
|
|
15
|
+
*/
|
|
16
|
+
addVectorItem: (item: any) => Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Queries a vector item from the vector database based on the provided key.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} key - The key of the vector to query the item from.
|
|
21
|
+
* @returns {Promise<any>} A promise that resolves with the queried vector item.
|
|
22
|
+
*/
|
|
23
|
+
queryVectorItem: (key: string) => Promise<any>;
|
|
24
|
+
};
|
|
25
|
+
export default VectorDB;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
+
const VectorDB = {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves a vector from the vector database based on the provided key.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} key - The key of the vector to retrieve.
|
|
12
|
+
* @returns {Promise<any>} A promise that resolves with the retrieved vector.
|
|
13
|
+
*/
|
|
14
|
+
getVector: async (key) => {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
17
|
+
"type": "getVector",
|
|
18
|
+
"message": {
|
|
19
|
+
item: key
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
23
|
+
const response = JSON.parse(data);
|
|
24
|
+
if (response.type === "getVectorResponse") {
|
|
25
|
+
resolve(response);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Adds a new vector item to the vector database.
|
|
32
|
+
*
|
|
33
|
+
|
|
34
|
+
* @param {any} item - The item to add to the vector.
|
|
35
|
+
* @returns {Promise<any>} A promise that resolves when the item is successfully added.
|
|
36
|
+
*/
|
|
37
|
+
addVectorItem: async (item) => {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
40
|
+
"type": "addVectorItem",
|
|
41
|
+
"message": {
|
|
42
|
+
item: item
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
46
|
+
const response = JSON.parse(data);
|
|
47
|
+
if (response.type === "addVectorItemResponse") {
|
|
48
|
+
resolve(response);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Queries a vector item from the vector database based on the provided key.
|
|
55
|
+
*
|
|
56
|
+
* @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.
|
|
58
|
+
*/
|
|
59
|
+
queryVectorItem: async (key) => {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
62
|
+
"type": "queryVectorItem",
|
|
63
|
+
"message": {
|
|
64
|
+
item: key
|
|
65
|
+
},
|
|
66
|
+
}));
|
|
67
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
68
|
+
const response = JSON.parse(data);
|
|
69
|
+
if (response.type === "qeryVectorItemResponse") {
|
|
70
|
+
resolve(response);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
exports.default = VectorDB;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -17,6 +17,8 @@ import git from './modules/git';
|
|
|
17
17
|
import dbmemory from './modules/dbmemory';
|
|
18
18
|
import cbstate from './modules/state';
|
|
19
19
|
import task from './modules/task';
|
|
20
|
+
|
|
21
|
+
import vectorDB from './modules/vectordb';
|
|
20
22
|
import WebSocket from 'ws';
|
|
21
23
|
|
|
22
24
|
|
|
@@ -90,7 +92,8 @@ class Codebolt {
|
|
|
90
92
|
project = cbproject;
|
|
91
93
|
dbmemory = dbmemory;
|
|
92
94
|
cbstate=cbstate;
|
|
93
|
-
taskplaner=task
|
|
95
|
+
taskplaner=task;
|
|
96
|
+
vectordb=vectorDB;
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
// export default new Codebolt();
|
package/src/modules/terminal.ts
CHANGED
|
@@ -56,27 +56,7 @@ const cbterminal = {
|
|
|
56
56
|
});
|
|
57
57
|
},
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
* Executes a given command and keeps running until interrupted.
|
|
61
|
-
* Listens for messages from the WebSocket and resolves the promise when an interruption signal is received.
|
|
62
|
-
*
|
|
63
|
-
* @param {string} command - The command to be executed.
|
|
64
|
-
* @returns {Promise<any>} A promise that resolves when an interruption signal is received during command execution.
|
|
65
|
-
*/
|
|
66
|
-
executeCommandRunUnitlInterrupt: async (command: string): Promise<any> => {
|
|
67
|
-
return new Promise((resolve, reject) => {
|
|
68
|
-
cbws.getWebsocket.send(JSON.stringify({
|
|
69
|
-
"type": "executeCommandRunUnitlInterrupt",
|
|
70
|
-
"message": command,
|
|
71
|
-
}));
|
|
72
|
-
cbws.getWebsocket.on('message', (data: string) => {
|
|
73
|
-
const response = JSON.parse(data);
|
|
74
|
-
if (response.type === "terminalInterruptResponse") {
|
|
75
|
-
resolve(response);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
},
|
|
59
|
+
|
|
80
60
|
/**
|
|
81
61
|
* Sends a manual interrupt signal to the terminal.
|
|
82
62
|
*
|
|
@@ -120,9 +100,8 @@ const cbterminal = {
|
|
|
120
100
|
});
|
|
121
101
|
|
|
122
102
|
// Return an object that includes the event emitter and the stopProcess method
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
};
|
|
103
|
+
return this.eventEmitter
|
|
104
|
+
|
|
126
105
|
}
|
|
127
106
|
|
|
128
107
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import cbws from './websocket';
|
|
2
|
+
|
|
3
|
+
const VectorDB = {
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves a vector from the vector database based on the provided key.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} key - The key of the vector to retrieve.
|
|
8
|
+
* @returns {Promise<any>} A promise that resolves with the retrieved vector.
|
|
9
|
+
*/
|
|
10
|
+
getVector: async (key: string): Promise<any> => {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
13
|
+
"type": "getVector",
|
|
14
|
+
"message": {
|
|
15
|
+
item: key
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
19
|
+
const response = JSON.parse(data);
|
|
20
|
+
if (response.type === "getVectorResponse") {
|
|
21
|
+
resolve(response);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Adds a new vector item to the vector database.
|
|
29
|
+
*
|
|
30
|
+
|
|
31
|
+
* @param {any} item - The item to add to the vector.
|
|
32
|
+
* @returns {Promise<any>} A promise that resolves when the item is successfully added.
|
|
33
|
+
*/
|
|
34
|
+
addVectorItem: async ( item: any): Promise<any> => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
37
|
+
"type": "addVectorItem",
|
|
38
|
+
"message": {
|
|
39
|
+
item: item
|
|
40
|
+
},
|
|
41
|
+
}));
|
|
42
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
43
|
+
const response = JSON.parse(data);
|
|
44
|
+
if (response.type === "addVectorItemResponse") {
|
|
45
|
+
resolve(response);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Queries a vector item from the vector database based on the provided key.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} key - The key of the vector to query the item from.
|
|
55
|
+
* @returns {Promise<any>} A promise that resolves with the queried vector item.
|
|
56
|
+
*/
|
|
57
|
+
queryVectorItem: async (key: string): Promise<any> => {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
60
|
+
"type": "queryVectorItem",
|
|
61
|
+
"message": {
|
|
62
|
+
item: key
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
66
|
+
const response = JSON.parse(data);
|
|
67
|
+
if (response.type === "qeryVectorItemResponse") {
|
|
68
|
+
resolve(response);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default VectorDB;
|