@codebolt/codeboltjs 1.1.76 → 1.1.78
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/docs/modules/_internal_.EventEmitter.html +6 -0
- package/docs/modules/_internal_.WebSocket.html +21 -0
- package/docs/modules/_internal_._node_stream_consumers_.html +6 -0
- package/docs/modules/_internal_._node_stream_promises_.html +3 -0
- package/docs/modules/_internal_.html +228 -0
- package/docs/modules/_internal_.internal.finished.html +2 -0
- package/docs/modules/_internal_.internal.html +36 -0
- package/docs/modules/_internal_.internal.pipeline.html +2 -0
- package/index.d.ts +254 -0
- package/modules/browser.d.ts +108 -0
- package/modules/browser.js +331 -0
- package/modules/chat.d.ts +64 -0
- package/modules/chat.js +190 -0
- package/modules/codeparsers.d.ts +23 -0
- package/modules/codeparsers.js +30 -0
- package/modules/codeutils.d.ts +37 -0
- package/modules/codeutils.js +117 -0
- package/modules/crawler.d.ts +45 -0
- package/modules/crawler.js +123 -0
- package/modules/dbmemory.d.ts +20 -0
- package/modules/dbmemory.js +54 -0
- package/modules/debug.d.ts +23 -0
- package/modules/debug.js +64 -0
- package/modules/docutils.d.ts +12 -0
- package/modules/docutils.js +19 -0
- package/modules/fs.d.ts +94 -0
- package/modules/fs.js +264 -0
- package/modules/git.d.ts +76 -0
- package/modules/git.js +240 -0
- package/modules/history.d.ts +19 -0
- package/modules/history.js +46 -0
- package/modules/knowledge.d.ts +2 -0
- package/modules/knowledge.js +6 -0
- package/modules/llm.d.ts +18 -0
- package/modules/llm.js +39 -0
- package/modules/mcp.d.ts +8 -0
- package/modules/mcp.js +139 -0
- package/modules/outputparsers.d.ts +24 -0
- package/modules/outputparsers.js +32 -0
- package/modules/project.d.ts +21 -0
- package/modules/project.js +72 -0
- package/modules/rag.d.ts +22 -0
- package/modules/rag.js +30 -0
- package/modules/search.d.ts +23 -0
- package/modules/search.js +37 -0
- package/modules/state.d.ts +21 -0
- package/modules/state.js +68 -0
- package/modules/task.d.ts +23 -0
- package/modules/task.js +75 -0
- package/modules/terminal.d.ts +46 -0
- package/modules/terminal.js +108 -0
- package/modules/tokenizer.d.ts +19 -0
- package/modules/tokenizer.js +56 -0
- package/modules/vectordb.d.ts +33 -0
- package/modules/vectordb.js +103 -0
- package/modules/websocket.d.ts +27 -0
- package/modules/websocket.js +88 -0
- package/package.json +1 -1
- package/src/modules/browser.ts +352 -0
- package/src/modules/chat.ts +193 -0
- package/src/modules/codeparsers.ts +30 -0
- package/src/modules/codeutils.ts +126 -0
- package/src/modules/crawler.ts +121 -0
- package/src/modules/dbmemory.ts +52 -0
- package/src/modules/debug.ts +68 -0
- package/src/modules/docutils.ts +18 -0
- package/src/modules/fs.ts +263 -0
- package/src/modules/git.ts +237 -0
- package/src/modules/history.ts +61 -0
- package/src/modules/knowledge.ts +5 -0
- package/src/modules/llm.ts +36 -0
- package/src/modules/mcp.ts +127 -0
- package/src/modules/outputparsers.ts +30 -0
- package/src/modules/project.ts +68 -0
- package/src/modules/rag.ts +28 -0
- package/src/modules/search.ts +35 -0
- package/src/modules/state.ts +69 -0
- package/src/modules/task.ts +73 -0
- package/src/modules/terminal.ts +114 -0
- package/src/modules/tokenizer.ts +56 -0
- package/src/modules/vectordb.ts +102 -0
- package/src/modules/websocket.ts +89 -0
package/modules/llm.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* A module for interacting with language learning models (LLMs) via WebSocket.
|
|
9
|
+
*/
|
|
10
|
+
const cbllm = {
|
|
11
|
+
/**
|
|
12
|
+
* Sends an inference request to the LLM and returns the model's response.
|
|
13
|
+
* The model is selected based on the provided `llmrole`. If the specific model
|
|
14
|
+
* for the role is not found, it falls back to the default model for the current agent,
|
|
15
|
+
* and ultimately to the default application-wide LLM if necessary.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} message - The input message or prompt to be sent to the LLM.
|
|
18
|
+
* @param {string} llmrole - The role of the LLM to determine which model to use.
|
|
19
|
+
* @returns {Promise<LLMResponse>} A promise that resolves with the LLM's response.
|
|
20
|
+
*/
|
|
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
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.default = cbllm;
|
package/modules/mcp.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const codeboltMCP: {
|
|
2
|
+
executeTool: (toolName: string, params: any, mcpServer?: string) => Promise<any>;
|
|
3
|
+
getMcpTools: (tools: string[]) => Promise<any>;
|
|
4
|
+
getAllMCPTools: (mpcName: string) => Promise<any>;
|
|
5
|
+
getMCPTool: (name: string) => Promise<any>;
|
|
6
|
+
getEnabledMCPS: () => Promise<any>;
|
|
7
|
+
};
|
|
8
|
+
export default codeboltMCP;
|
package/modules/mcp.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
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 codeboltMCP = {
|
|
8
|
+
executeTool: (toolName, params, mcpServer) => {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
11
|
+
"type": "mcpEvent",
|
|
12
|
+
"action": "executeTool",
|
|
13
|
+
"toolName": toolName,
|
|
14
|
+
"params": params
|
|
15
|
+
}));
|
|
16
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
17
|
+
try {
|
|
18
|
+
const response = JSON.parse(data);
|
|
19
|
+
if (response.type === "executeToolResponse") {
|
|
20
|
+
resolve(response.data);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
reject(new Error("Unexpected response type"));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
reject(new Error("Failed to parse response"));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
31
|
+
reject(error);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
getMcpTools: (tools) => {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
38
|
+
"type": "mcpEvent",
|
|
39
|
+
"action": "getMcpTools",
|
|
40
|
+
"tools": tools
|
|
41
|
+
}));
|
|
42
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
43
|
+
try {
|
|
44
|
+
const response = JSON.parse(data);
|
|
45
|
+
if (response.type === "getMcpToolsResponse") {
|
|
46
|
+
resolve(response.data);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
reject(new Error("Unexpected response type"));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
reject(new Error("Failed to parse response"));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
57
|
+
reject(error);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
getAllMCPTools: (mpcName) => {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
64
|
+
"type": "mcpEvent",
|
|
65
|
+
"action": "getAllMCPTools",
|
|
66
|
+
"mpcName": mpcName
|
|
67
|
+
}));
|
|
68
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
69
|
+
try {
|
|
70
|
+
const response = JSON.parse(data);
|
|
71
|
+
if (response.type === "getAllMCPToolsResponse") {
|
|
72
|
+
resolve(response.data);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
reject(new Error("Unexpected response type"));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
reject(new Error("Failed to parse response"));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
83
|
+
reject(error);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
getMCPTool: (name) => {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
90
|
+
"type": "mcpEvent",
|
|
91
|
+
"action": "getMCPTool",
|
|
92
|
+
"mcpName": name
|
|
93
|
+
}));
|
|
94
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
95
|
+
try {
|
|
96
|
+
const response = JSON.parse(data);
|
|
97
|
+
if (response.type === "getMCPToolResponse") {
|
|
98
|
+
resolve(response.data);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
reject(new Error("Unexpected response type"));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
reject(new Error("Failed to parse response"));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
109
|
+
reject(error);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
getEnabledMCPS: () => {
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
116
|
+
"type": "mcpEvent",
|
|
117
|
+
"action": "getEnabledMCPS"
|
|
118
|
+
}));
|
|
119
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
120
|
+
try {
|
|
121
|
+
const response = JSON.parse(data);
|
|
122
|
+
if (response.type === "getEnabledMCPSResponse") {
|
|
123
|
+
resolve(response.data);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
reject(new Error("Unexpected response type"));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
reject(new Error("Failed to parse response"));
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
134
|
+
reject(error);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
exports.default = codeboltMCP;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A module for parsing output messages to identify errors and warnings.
|
|
3
|
+
*/
|
|
4
|
+
declare const cboutputparsers: {
|
|
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.
|
|
9
|
+
*/
|
|
10
|
+
init: (output: any) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Parses the given output and returns all the error messages.
|
|
13
|
+
* @param {any} output - The output to parse for error messages.
|
|
14
|
+
* @returns {string[]} An array of error messages.
|
|
15
|
+
*/
|
|
16
|
+
parseErrors: (output: any) => string[];
|
|
17
|
+
/**
|
|
18
|
+
* Parses the given output and returns all the warning messages.
|
|
19
|
+
* @param {any} output - The output to parse for warning messages.
|
|
20
|
+
* @returns {string[]} An array of warning messages.
|
|
21
|
+
*/
|
|
22
|
+
parseWarnings: (output: any) => string[];
|
|
23
|
+
};
|
|
24
|
+
export default cboutputparsers;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* A module for parsing output messages to identify errors and warnings.
|
|
5
|
+
*/
|
|
6
|
+
const cboutputparsers = {
|
|
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.
|
|
11
|
+
*/
|
|
12
|
+
init: (output) => {
|
|
13
|
+
// Initialization code can be added here if necessary
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* Parses the given output and returns all the error messages.
|
|
17
|
+
* @param {any} output - The output to parse for error messages.
|
|
18
|
+
* @returns {string[]} An array of error messages.
|
|
19
|
+
*/
|
|
20
|
+
parseErrors: (output) => {
|
|
21
|
+
return output.split('\n').filter((line) => line.includes('Error:'));
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Parses the given output and returns all the warning messages.
|
|
25
|
+
* @param {any} output - The output to parse for warning messages.
|
|
26
|
+
* @returns {string[]} An array of warning messages.
|
|
27
|
+
*/
|
|
28
|
+
parseWarnings: (output) => {
|
|
29
|
+
return output.split('\n').filter((line) => line.includes('Warning:'));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.default = cboutputparsers;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GetProjectPathResponse } from '@codebolt/types';
|
|
2
|
+
/**
|
|
3
|
+
* A module for interacting with project settings and paths.
|
|
4
|
+
*/
|
|
5
|
+
declare const cbproject: {
|
|
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.
|
|
10
|
+
*/
|
|
11
|
+
getProjectSettings: (output: any) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the path of the current project.
|
|
14
|
+
* @returns {Promise<GetProjectPathResponse>} A promise that resolves with the project path response.
|
|
15
|
+
*/
|
|
16
|
+
getProjectPath: () => Promise<GetProjectPathResponse>;
|
|
17
|
+
getRepoMap: (message: any) => Promise<GetProjectPathResponse>;
|
|
18
|
+
runProject: () => void;
|
|
19
|
+
getEditorFileStatus: () => Promise<unknown>;
|
|
20
|
+
};
|
|
21
|
+
export default cbproject;
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* A module for interacting with project settings and paths.
|
|
9
|
+
*/
|
|
10
|
+
const cbproject = {
|
|
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.
|
|
15
|
+
*/
|
|
16
|
+
getProjectSettings: (output) => {
|
|
17
|
+
// Implementation for getting project settings will be added here
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the path of the current project.
|
|
21
|
+
* @returns {Promise<GetProjectPathResponse>} A promise that resolves with the project path response.
|
|
22
|
+
*/
|
|
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
|
+
});
|
|
36
|
+
},
|
|
37
|
+
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
|
+
});
|
|
51
|
+
},
|
|
52
|
+
runProject: () => {
|
|
53
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
54
|
+
"type": "runProject"
|
|
55
|
+
}));
|
|
56
|
+
},
|
|
57
|
+
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
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.default = cbproject;
|
package/modules/rag.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A module for managing files within the CodeBolt File System.
|
|
3
|
+
*/
|
|
4
|
+
declare const cbrag: {
|
|
5
|
+
/**
|
|
6
|
+
* Initializes the CodeBolt File System Module.
|
|
7
|
+
*/
|
|
8
|
+
init: () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Adds a file to the CodeBolt File System.
|
|
11
|
+
* @param {string} filename - The name of the file to add.
|
|
12
|
+
* @param {string} file_path - The path where the file should be added.
|
|
13
|
+
*/
|
|
14
|
+
add_file: (filename: string, file_path: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves related knowledge for a given query and filename.
|
|
17
|
+
* @param {string} query - The query to retrieve related knowledge for.
|
|
18
|
+
* @param {string} filename - The name of the file associated with the query.
|
|
19
|
+
*/
|
|
20
|
+
retrieve_related_knowledge: (query: string, filename: string) => void;
|
|
21
|
+
};
|
|
22
|
+
export default cbrag;
|
package/modules/rag.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* A module for managing files within the CodeBolt File System.
|
|
5
|
+
*/
|
|
6
|
+
const cbrag = {
|
|
7
|
+
/**
|
|
8
|
+
* Initializes the CodeBolt File System Module.
|
|
9
|
+
*/
|
|
10
|
+
init: () => {
|
|
11
|
+
console.log("Initializing CodeBolt File System Module");
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Adds a file to the CodeBolt File System.
|
|
15
|
+
* @param {string} filename - The name of the file to add.
|
|
16
|
+
* @param {string} file_path - The path where the file should be added.
|
|
17
|
+
*/
|
|
18
|
+
add_file: (filename, file_path) => {
|
|
19
|
+
// Implementation for adding a file will be added here
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves related knowledge for a given query and filename.
|
|
23
|
+
* @param {string} query - The query to retrieve related knowledge for.
|
|
24
|
+
* @param {string} filename - The name of the file associated with the query.
|
|
25
|
+
*/
|
|
26
|
+
retrieve_related_knowledge: (query, filename) => {
|
|
27
|
+
// Implementation for retrieving related knowledge will be added here
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
exports.default = cbrag;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A module for handling search operations.
|
|
3
|
+
*/
|
|
4
|
+
declare const cbsearch: {
|
|
5
|
+
/**
|
|
6
|
+
* Initializes the search module with the specified search engine.
|
|
7
|
+
* @param {string} [engine="bing"] - The search engine to use for initializing the module.
|
|
8
|
+
*/
|
|
9
|
+
init: (engine?: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Performs a search operation for the given query.
|
|
12
|
+
* @param {string} query - The search query.
|
|
13
|
+
* @returns {Promise<string>} A promise that resolves with the search results.
|
|
14
|
+
*/
|
|
15
|
+
search: (query: string) => Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the first link from the search results for the given query.
|
|
18
|
+
* @param {string} query - The search query.
|
|
19
|
+
* @returns {Promise<string>} A promise that resolves with the first link of the search results.
|
|
20
|
+
*/
|
|
21
|
+
get_first_link: (query: string) => Promise<string>;
|
|
22
|
+
};
|
|
23
|
+
export default cbsearch;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* A module for handling search operations.
|
|
5
|
+
*/
|
|
6
|
+
const cbsearch = {
|
|
7
|
+
/**
|
|
8
|
+
* Initializes the search module with the specified search engine.
|
|
9
|
+
* @param {string} [engine="bing"] - The search engine to use for initializing the module.
|
|
10
|
+
*/
|
|
11
|
+
init: (engine = "bing") => {
|
|
12
|
+
console.log("Initializing Search Module with engine: " + engine);
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* Performs a search operation for the given query.
|
|
16
|
+
* @param {string} query - The search query.
|
|
17
|
+
* @returns {Promise<string>} A promise that resolves with the search results.
|
|
18
|
+
*/
|
|
19
|
+
search: async (query) => {
|
|
20
|
+
console.log("Searching for " + query);
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
resolve("Search Results for " + query);
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves the first link from the search results for the given query.
|
|
27
|
+
* @param {string} query - The search query.
|
|
28
|
+
* @returns {Promise<string>} A promise that resolves with the first link of the search results.
|
|
29
|
+
*/
|
|
30
|
+
get_first_link: async (query) => {
|
|
31
|
+
console.log("Getting first link for " + query);
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
resolve("First Link for " + query);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.default = cbsearch;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ApplicationState, AddToAgentStateResponse, GetAgentStateResponse } from '@codebolt/types';
|
|
2
|
+
declare const cbstate: {
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the current application state from the server via WebSocket.
|
|
5
|
+
* @returns {Promise<ApplicationState>} A promise that resolves with the application state.
|
|
6
|
+
*/
|
|
7
|
+
getApplicationState: () => Promise<ApplicationState>;
|
|
8
|
+
/**
|
|
9
|
+
* Adds a key-value pair to the agent's state on the server via WebSocket.
|
|
10
|
+
* @param {string} key - The key to add to the agent's state.
|
|
11
|
+
* @param {string} value - The value associated with the key.
|
|
12
|
+
* @returns {Promise<AddToAgentStateResponse>} A promise that resolves with the response to the addition request.
|
|
13
|
+
*/
|
|
14
|
+
addToAgentState: (key: string, value: string) => Promise<AddToAgentStateResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the current state of the agent from the server via WebSocket.
|
|
17
|
+
* @returns {Promise<GetAgentStateResponse>} A promise that resolves with the agent's state.
|
|
18
|
+
*/
|
|
19
|
+
getAgentState: () => Promise<GetAgentStateResponse>;
|
|
20
|
+
};
|
|
21
|
+
export default cbstate;
|
package/modules/state.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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 cbstate = {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the current application state from the server via WebSocket.
|
|
10
|
+
* @returns {Promise<ApplicationState>} A promise that resolves with the application state.
|
|
11
|
+
*/
|
|
12
|
+
getApplicationState: async () => {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
15
|
+
"type": "getAppState",
|
|
16
|
+
}));
|
|
17
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
18
|
+
const response = JSON.parse(data);
|
|
19
|
+
if (response.type === "getAppStateResponse") {
|
|
20
|
+
resolve(response); // Resolve the Promise with the response data
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Adds a key-value pair to the agent's state on the server via WebSocket.
|
|
27
|
+
* @param {string} key - The key to add to the agent's state.
|
|
28
|
+
* @param {string} value - The value associated with the key.
|
|
29
|
+
* @returns {Promise<AddToAgentStateResponse>} A promise that resolves with the response to the addition request.
|
|
30
|
+
*/
|
|
31
|
+
addToAgentState: async (key, value) => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
34
|
+
"type": "agentStateEvent",
|
|
35
|
+
"action": "addToAgentState",
|
|
36
|
+
payload: {
|
|
37
|
+
key,
|
|
38
|
+
value
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
42
|
+
const response = JSON.parse(data);
|
|
43
|
+
if (response.type === "addToAgentStateResponse") {
|
|
44
|
+
resolve(response); // Resolve the Promise with the response data
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the current state of the agent from the server via WebSocket.
|
|
51
|
+
* @returns {Promise<GetAgentStateResponse>} A promise that resolves with the agent's state.
|
|
52
|
+
*/
|
|
53
|
+
getAgentState: async () => {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
56
|
+
"type": "agentStateEvent",
|
|
57
|
+
"action": "getAgentState",
|
|
58
|
+
}));
|
|
59
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
60
|
+
const response = JSON.parse(data);
|
|
61
|
+
if (response.type === "getAgentStateResponse") {
|
|
62
|
+
resolve(response); // Resolve the Promise with the response data
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.default = cbstate;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages task operations via WebSocket communication.
|
|
3
|
+
*/
|
|
4
|
+
declare const taskplaner: {
|
|
5
|
+
/**
|
|
6
|
+
* Adds a task using a WebSocket message.
|
|
7
|
+
* @param {string} task - The task to be added.
|
|
8
|
+
* @returns {Promise<AddTaskResponse>} A promise that resolves with the response from the add task event.
|
|
9
|
+
*/
|
|
10
|
+
addTask: (task: string) => Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves all tasks using a WebSocket message.
|
|
13
|
+
* @returns {Promise<GetTasksResponse>} A promise that resolves with the response from the get tasks event.
|
|
14
|
+
*/
|
|
15
|
+
getTasks: () => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Updates an existing task using a WebSocket message.
|
|
18
|
+
* @param {string} task - The updated task information.
|
|
19
|
+
* @returns {Promise<UpdateTasksResponse>} A promise that resolves with the response from the update task event.
|
|
20
|
+
*/
|
|
21
|
+
updateTask: (task: string) => Promise<any>;
|
|
22
|
+
};
|
|
23
|
+
export default taskplaner;
|
package/modules/task.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
// import {AddTaskResponse,GetTasksResponse,UpdateTasksResponse } from '@codebolt/types';
|
|
8
|
+
/**
|
|
9
|
+
* Manages task operations via WebSocket communication.
|
|
10
|
+
*/
|
|
11
|
+
const taskplaner = {
|
|
12
|
+
/**
|
|
13
|
+
* Adds a task using a WebSocket message.
|
|
14
|
+
* @param {string} task - The task to be added.
|
|
15
|
+
* @returns {Promise<AddTaskResponse>} A promise that resolves with the response from the add task event.
|
|
16
|
+
*/
|
|
17
|
+
addTask: async (task) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
20
|
+
"type": "taskEvent",
|
|
21
|
+
"action": "addTask",
|
|
22
|
+
message: {
|
|
23
|
+
"task": task
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
27
|
+
const response = JSON.parse(data);
|
|
28
|
+
if (response.type === "addTaskResponse") {
|
|
29
|
+
resolve(response); // Resolve the promise with the response data from adding the task
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves all tasks using a WebSocket message.
|
|
36
|
+
* @returns {Promise<GetTasksResponse>} A promise that resolves with the response from the get tasks event.
|
|
37
|
+
*/
|
|
38
|
+
getTasks: async () => {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
41
|
+
"type": "taskEvent",
|
|
42
|
+
"action": "getTasks"
|
|
43
|
+
}));
|
|
44
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
45
|
+
const response = JSON.parse(data);
|
|
46
|
+
if (response.type === "getTasksResponse") {
|
|
47
|
+
resolve(response); // Resolve the promise with the response data from retrieving tasks
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Updates an existing task using a WebSocket message.
|
|
54
|
+
* @param {string} task - The updated task information.
|
|
55
|
+
* @returns {Promise<UpdateTasksResponse>} A promise that resolves with the response from the update task event.
|
|
56
|
+
*/
|
|
57
|
+
updateTask: async (task) => {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
60
|
+
"type": "taskEvent",
|
|
61
|
+
"action": "updateTask",
|
|
62
|
+
message: {
|
|
63
|
+
"task": task
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
67
|
+
const response = JSON.parse(data);
|
|
68
|
+
if (response.type === "updateTaskResponse") {
|
|
69
|
+
resolve(response); // Resolve the promise with the response data from updating the task
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.default = taskplaner;
|