@codebolt/codeboltjs 1.1.27 → 1.1.30

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.d.ts CHANGED
@@ -97,7 +97,11 @@ declare class Codebolt {
97
97
  };
98
98
  codeutils: {
99
99
  getCodeTree: () => Promise<any>;
100
+ getJsTree: (filePath: string) => Promise<any>;
100
101
  getAllFilesAsMarkDown: () => Promise<unknown>;
102
+ performMatch: (matcherDefinition: object, problemPatterns: [], problems: []) => Promise<unknown>;
103
+ getMatcherList: () => Promise<unknown>;
104
+ matchDetail: (matcher: string) => Promise<unknown>;
101
105
  };
102
106
  docutils: {
103
107
  pdf_to_text: (pdf_path: any) => Promise<string>;
@@ -143,6 +147,8 @@ declare class Codebolt {
143
147
  };
144
148
  cbstate: {
145
149
  getApplicationState: () => Promise<any>;
150
+ addToAgentState: (key: string, value: string) => Promise<void>;
151
+ getAgentState: () => Promise<any>;
146
152
  };
147
153
  taskplaner: {
148
154
  addTask: (task: string) => Promise<any>;
@@ -2,14 +2,11 @@
2
2
  * A utility module for working with code.
3
3
  */
4
4
  declare const cbcodeutils: {
5
- /**
6
- * Asynchronously generates a code tree from the provided source code.
7
- * @param {any} fileName - The name of the file.
8
- * @param {any} source - The source code to generate the tree from.
9
- * @param {any} filePath - The file path where the source code is located.
10
- * @returns {Promise<any>} A promise that resolves with the code tree.
11
- */
12
5
  getCodeTree: () => Promise<any>;
6
+ getJsTree: (filePath: string) => Promise<any>;
13
7
  getAllFilesAsMarkDown: () => Promise<unknown>;
8
+ performMatch: (matcherDefinition: object, problemPatterns: [], problems: []) => Promise<unknown>;
9
+ getMatcherList: () => Promise<unknown>;
10
+ matchDetail: (matcher: string) => Promise<unknown>;
14
11
  };
15
12
  export default cbcodeutils;
@@ -8,13 +8,6 @@ const websocket_1 = __importDefault(require("./websocket"));
8
8
  * A utility module for working with code.
9
9
  */
10
10
  const cbcodeutils = {
11
- /**
12
- * Asynchronously generates a code tree from the provided source code.
13
- * @param {any} fileName - The name of the file.
14
- * @param {any} source - The source code to generate the tree from.
15
- * @param {any} filePath - The file path where the source code is located.
16
- * @returns {Promise<any>} A promise that resolves with the code tree.
17
- */
18
11
  getCodeTree: () => {
19
12
  return new Promise((resolve, reject) => {
20
13
  websocket_1.default.getWebsocket.send(JSON.stringify({
@@ -29,6 +22,23 @@ const cbcodeutils = {
29
22
  });
30
23
  });
31
24
  },
25
+ getJsTree: (filePath) => {
26
+ return new Promise((resolve, reject) => {
27
+ websocket_1.default.getWebsocket.send(JSON.stringify({
28
+ "type": "codeEvent",
29
+ "action": "getJsTree",
30
+ payload: {
31
+ filePath
32
+ }
33
+ }));
34
+ websocket_1.default.getWebsocket.on('message', (data) => {
35
+ const response = JSON.parse(data);
36
+ if (response.type === "getJsTreeResponse") {
37
+ resolve(resolve); // Resolve the Promise with the response data
38
+ }
39
+ });
40
+ });
41
+ },
32
42
  getAllFilesAsMarkDown: () => {
33
43
  return new Promise((resolve, reject) => {
34
44
  websocket_1.default.getWebsocket.send(JSON.stringify({
@@ -42,6 +52,55 @@ const cbcodeutils = {
42
52
  }
43
53
  });
44
54
  });
55
+ },
56
+ performMatch: (matcherDefinition, problemPatterns, problems) => {
57
+ return new Promise((resolve, reject) => {
58
+ websocket_1.default.getWebsocket.send(JSON.stringify({
59
+ "type": "codeEvent",
60
+ "action": "performMatch",
61
+ payload: {
62
+ matcherDefinition,
63
+ problemPatterns,
64
+ }
65
+ }));
66
+ websocket_1.default.getWebsocket.on('message', (data) => {
67
+ const response = JSON.parse(data);
68
+ if (response.type === "getgetJsTreeResponse") {
69
+ resolve(resolve); // Resolve the Promise with the response data
70
+ }
71
+ });
72
+ });
73
+ },
74
+ getMatcherList: () => {
75
+ return new Promise((resolve, reject) => {
76
+ websocket_1.default.getWebsocket.send(JSON.stringify({
77
+ "type": "codeEvent",
78
+ "action": "getMatcherList",
79
+ }));
80
+ websocket_1.default.getWebsocket.on('message', (data) => {
81
+ const response = JSON.parse(data);
82
+ if (response.type === "getMatcherListTreeResponse") {
83
+ resolve(resolve); // Resolve the Promise with the response data
84
+ }
85
+ });
86
+ });
87
+ },
88
+ matchDetail: (matcher) => {
89
+ return new Promise((resolve, reject) => {
90
+ websocket_1.default.getWebsocket.send(JSON.stringify({
91
+ "type": "codeEvent",
92
+ "action": "getMatchDetail",
93
+ payload: {
94
+ match: matcher
95
+ }
96
+ }));
97
+ websocket_1.default.getWebsocket.on('message', (data) => {
98
+ const response = JSON.parse(data);
99
+ if (response.type === "matchDetailTreeResponse") {
100
+ resolve(resolve); // Resolve the Promise with the response data
101
+ }
102
+ });
103
+ });
45
104
  }
46
105
  };
47
106
  exports.default = cbcodeutils;
@@ -4,5 +4,7 @@
4
4
  */
5
5
  declare const cbstate: {
6
6
  getApplicationState: () => Promise<any>;
7
+ addToAgentState: (key: string, value: string) => Promise<void>;
8
+ getAgentState: () => Promise<any>;
7
9
  };
8
10
  export default cbstate;
package/modules/state.js CHANGED
@@ -21,6 +21,38 @@ const cbstate = {
21
21
  }
22
22
  });
23
23
  });
24
+ },
25
+ addToAgentState: async (key, value) => {
26
+ return new Promise((resolve, reject) => {
27
+ websocket_1.default.getWebsocket.send(JSON.stringify({
28
+ "type": "agentStateEvent",
29
+ "action": "addToAgentState",
30
+ payload: {
31
+ key,
32
+ value
33
+ }
34
+ }));
35
+ websocket_1.default.getWebsocket.on('message', (data) => {
36
+ const response = JSON.parse(data);
37
+ if (response.type === "addToAgentStateResponse") {
38
+ resolve(response); // Resolve the Promise with the response data
39
+ }
40
+ });
41
+ });
42
+ },
43
+ getAgentState: async () => {
44
+ return new Promise((resolve, reject) => {
45
+ websocket_1.default.getWebsocket.send(JSON.stringify({
46
+ "type": "agentStateEvent",
47
+ "action": "getAgentState",
48
+ }));
49
+ websocket_1.default.getWebsocket.on('message', (data) => {
50
+ const response = JSON.parse(data);
51
+ if (response.type === "getAgentStateResponse") {
52
+ resolve(response); // Resolve the Promise with the response data
53
+ }
54
+ });
55
+ });
24
56
  }
25
57
  };
26
58
  exports.default = cbstate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.27",
3
+ "version": "1.1.30",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -4,13 +4,8 @@ import cbws from './websocket';
4
4
  * A utility module for working with code.
5
5
  */
6
6
  const cbcodeutils = {
7
- /**
8
- * Asynchronously generates a code tree from the provided source code.
9
- * @param {any} fileName - The name of the file.
10
- * @param {any} source - The source code to generate the tree from.
11
- * @param {any} filePath - The file path where the source code is located.
12
- * @returns {Promise<any>} A promise that resolves with the code tree.
13
- */
7
+
8
+
14
9
  getCodeTree: (): Promise<any> => {
15
10
  return new Promise((resolve, reject) => {
16
11
  cbws.getWebsocket.send(JSON.stringify({
@@ -25,6 +20,23 @@ const cbcodeutils = {
25
20
  });
26
21
  });
27
22
  },
23
+ getJsTree: (filePath:string): Promise<any> => {
24
+ return new Promise((resolve, reject) => {
25
+ cbws.getWebsocket.send(JSON.stringify({
26
+ "type": "codeEvent",
27
+ "action":"getJsTree",
28
+ payload:{
29
+ filePath
30
+ }
31
+ }));
32
+ cbws.getWebsocket.on('message', (data: string) => {
33
+ const response = JSON.parse(data);
34
+ if (response.type === "getJsTreeResponse") {
35
+ resolve(resolve); // Resolve the Promise with the response data
36
+ }
37
+ });
38
+ });
39
+ },
28
40
  getAllFilesAsMarkDown:()=>{
29
41
  return new Promise((resolve, reject) => {
30
42
  cbws.getWebsocket.send(JSON.stringify({
@@ -38,7 +50,59 @@ const cbcodeutils = {
38
50
  }
39
51
  });
40
52
  });
53
+ },
54
+ performMatch:(matcherDefinition:object, problemPatterns:[], problems:[])=>{
55
+ return new Promise((resolve, reject) => {
56
+ cbws.getWebsocket.send(JSON.stringify({
57
+ "type": "codeEvent",
58
+ "action":"performMatch",
59
+ payload:{
60
+ matcherDefinition,
61
+ problemPatterns,
62
+ }
63
+ }));
64
+ cbws.getWebsocket.on('message', (data: string) => {
65
+ const response = JSON.parse(data);
66
+ if (response.type === "getgetJsTreeResponse") {
67
+ resolve(resolve); // Resolve the Promise with the response data
68
+ }
69
+ });
70
+ });
71
+ },
72
+ getMatcherList:()=>{
73
+ return new Promise((resolve, reject) => {
74
+ cbws.getWebsocket.send(JSON.stringify({
75
+ "type": "codeEvent",
76
+ "action":"getMatcherList",
77
+
78
+ }));
79
+ cbws.getWebsocket.on('message', (data: string) => {
80
+ const response = JSON.parse(data);
81
+ if (response.type === "getMatcherListTreeResponse") {
82
+ resolve(resolve); // Resolve the Promise with the response data
83
+ }
84
+ });
85
+ });
86
+ },
87
+ matchDetail:(matcher:string)=>{
88
+ return new Promise((resolve, reject) => {
89
+ cbws.getWebsocket.send(JSON.stringify({
90
+ "type": "codeEvent",
91
+ "action":"getMatchDetail",
92
+ payload:{
93
+ match:matcher
94
+ }
95
+
96
+ }));
97
+ cbws.getWebsocket.on('message', (data: string) => {
98
+ const response = JSON.parse(data);
99
+ if (response.type === "matchDetailTreeResponse") {
100
+ resolve(resolve); // Resolve the Promise with the response data
101
+ }
102
+ });
103
+ });
41
104
  }
105
+
42
106
  };
43
107
 
44
108
  export default cbcodeutils;
@@ -18,6 +18,40 @@ const cbstate = {
18
18
  }
19
19
  });
20
20
  });
21
+ },
22
+ addToAgentState: async (key: string, value: string): Promise<void> => {
23
+ return new Promise((resolve, reject) => {
24
+ cbws.getWebsocket.send(JSON.stringify({
25
+ "type": "agentStateEvent",
26
+ "action":"addToAgentState",
27
+ payload:{
28
+ key,
29
+ value
30
+ }
31
+
32
+ }));
33
+ cbws.getWebsocket.on('message', (data: string) => {
34
+ const response = JSON.parse(data);
35
+ if (response.type === "addToAgentStateResponse") {
36
+ resolve(response); // Resolve the Promise with the response data
37
+ }
38
+ });
39
+ });
40
+ },
41
+ getAgentState: async (): Promise<any> => {
42
+ return new Promise((resolve, reject) => {
43
+ cbws.getWebsocket.send(JSON.stringify({
44
+ "type": "agentStateEvent",
45
+ "action":"getAgentState",
46
+
47
+ }));
48
+ cbws.getWebsocket.on('message', (data: string) => {
49
+ const response = JSON.parse(data);
50
+ if (response.type === "getAgentStateResponse") {
51
+ resolve(response); // Resolve the Promise with the response data
52
+ }
53
+ });
54
+ });
21
55
  }
22
56
  };
23
57