@codebolt/codeboltjs 1.1.58 → 1.1.60
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 +14 -1
- package/index.js +2 -0
- package/modules/browser.d.ts +1 -1
- package/modules/browser.js +12 -4
- package/modules/history.d.ts +19 -0
- package/modules/history.js +46 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/modules/browser.ts +8 -0
- package/src/modules/history.ts +61 -0
package/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ declare class Codebolt {
|
|
|
47
47
|
newPage: () => Promise<unknown>;
|
|
48
48
|
getUrl: () => Promise<import("@codebolt/types").UrlResponse>;
|
|
49
49
|
goToPage: (url: string) => Promise<import("@codebolt/types").GoToPageResponse>;
|
|
50
|
-
screenshot: () =>
|
|
50
|
+
screenshot: () => Promise<unknown>;
|
|
51
51
|
getHTML: () => Promise<import("@codebolt/types").HtmlReceived>;
|
|
52
52
|
getMarkdown: () => Promise<import("@codebolt/types").GetMarkdownResponse>;
|
|
53
53
|
getPDF: () => void;
|
|
@@ -210,6 +210,19 @@ declare class Codebolt {
|
|
|
210
210
|
addToken: (key: string) => Promise<import("@codebolt/types").AddTokenResponse>;
|
|
211
211
|
getToken: (key: string) => Promise<import("@codebolt/types").GetTokenResponse>;
|
|
212
212
|
};
|
|
213
|
+
chatSummary: {
|
|
214
|
+
summarizeAll: () => Promise<{
|
|
215
|
+
role: string;
|
|
216
|
+
content: string;
|
|
217
|
+
}[]>;
|
|
218
|
+
summarize: (messages: {
|
|
219
|
+
role: string;
|
|
220
|
+
content: string;
|
|
221
|
+
}[], depth: number) => Promise<{
|
|
222
|
+
role: string;
|
|
223
|
+
content: string;
|
|
224
|
+
}[]>;
|
|
225
|
+
};
|
|
213
226
|
}
|
|
214
227
|
declare const _default: Codebolt;
|
|
215
228
|
export default _default;
|
package/index.js
CHANGED
|
@@ -26,6 +26,7 @@ const vectordb_1 = __importDefault(require("./modules/vectordb"));
|
|
|
26
26
|
const debug_1 = __importDefault(require("./modules/debug"));
|
|
27
27
|
const tokenizer_1 = __importDefault(require("./modules/tokenizer"));
|
|
28
28
|
const ws_1 = __importDefault(require("ws"));
|
|
29
|
+
const history_1 = require("./modules/history");
|
|
29
30
|
/**
|
|
30
31
|
* @class Codebolt
|
|
31
32
|
* @description This class provides a unified interface to interact with various modules.
|
|
@@ -58,6 +59,7 @@ class Codebolt {
|
|
|
58
59
|
this.vectordb = vectordb_1.default;
|
|
59
60
|
this.debug = debug_1.default;
|
|
60
61
|
this.tokenizer = tokenizer_1.default;
|
|
62
|
+
this.chatSummary = history_1.chatSummary;
|
|
61
63
|
this.websocket = websocket_1.default.getWebsocket;
|
|
62
64
|
}
|
|
63
65
|
/**
|
package/modules/browser.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare const cbbrowser: {
|
|
|
21
21
|
/**
|
|
22
22
|
* Takes a screenshot of the current page.
|
|
23
23
|
*/
|
|
24
|
-
screenshot: () =>
|
|
24
|
+
screenshot: () => Promise<unknown>;
|
|
25
25
|
/**
|
|
26
26
|
* Retrieves the HTML content of the current page.
|
|
27
27
|
* @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content.
|
package/modules/browser.js
CHANGED
|
@@ -67,10 +67,18 @@ const cbbrowser = {
|
|
|
67
67
|
* Takes a screenshot of the current page.
|
|
68
68
|
*/
|
|
69
69
|
screenshot: () => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
72
|
+
"type": "browserEvent",
|
|
73
|
+
action: 'screenshot'
|
|
74
|
+
}));
|
|
75
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
76
|
+
const response = JSON.parse(data);
|
|
77
|
+
if (response.event === "screenshotResponse") {
|
|
78
|
+
resolve(response.payload);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
74
82
|
},
|
|
75
83
|
/**
|
|
76
84
|
* Retrieves the HTML content of the current page.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum logType {
|
|
2
|
+
info = "info",
|
|
3
|
+
error = "error",
|
|
4
|
+
warning = "warning"
|
|
5
|
+
}
|
|
6
|
+
export declare const chatSummary: {
|
|
7
|
+
summarizeAll: () => Promise<{
|
|
8
|
+
role: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}[]>;
|
|
11
|
+
summarize: (messages: {
|
|
12
|
+
role: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}[], depth: number) => Promise<{
|
|
15
|
+
role: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}[]>;
|
|
18
|
+
};
|
|
19
|
+
export default chatSummary;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
exports.chatSummary = exports.logType = void 0;
|
|
7
|
+
const websocket_1 = __importDefault(require("./websocket"));
|
|
8
|
+
var logType;
|
|
9
|
+
(function (logType) {
|
|
10
|
+
logType["info"] = "info";
|
|
11
|
+
logType["error"] = "error";
|
|
12
|
+
logType["warning"] = "warning";
|
|
13
|
+
})(logType || (exports.logType = logType = {}));
|
|
14
|
+
exports.chatSummary = {
|
|
15
|
+
summarizeAll: () => {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
18
|
+
"type": "chatSummaryEvent",
|
|
19
|
+
"action": "summarizeAll",
|
|
20
|
+
}));
|
|
21
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
22
|
+
const response = JSON.parse(data);
|
|
23
|
+
if (response.type === "getSummarizeAllResponse") {
|
|
24
|
+
resolve(response.payload); // Resolve the Promise with the response data
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
summarize: (messages, depth) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
32
|
+
"type": "chatSummaryEvent",
|
|
33
|
+
"action": "summarize",
|
|
34
|
+
messages,
|
|
35
|
+
depth
|
|
36
|
+
}));
|
|
37
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
38
|
+
const response = JSON.parse(data);
|
|
39
|
+
if (response.type === "getSummarizeResponse") {
|
|
40
|
+
resolve(response.payload); // Resolve the Promise with the response data
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.default = exports.chatSummary;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import debug from './modules/debug'
|
|
|
22
22
|
import tokenizer from './modules/tokenizer'
|
|
23
23
|
import WebSocket from 'ws';
|
|
24
24
|
import { EventEmitter } from 'events';
|
|
25
|
+
import {chatSummary} from './modules/history'
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -89,6 +90,7 @@ class Codebolt { // Extend EventEmitter
|
|
|
89
90
|
vectordb = vectorDB;
|
|
90
91
|
debug = debug;
|
|
91
92
|
tokenizer = tokenizer;
|
|
93
|
+
chatSummary=chatSummary
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
export default new Codebolt();
|
package/src/modules/browser.ts
CHANGED
|
@@ -68,10 +68,18 @@ const cbbrowser = {
|
|
|
68
68
|
* Takes a screenshot of the current page.
|
|
69
69
|
*/
|
|
70
70
|
screenshot: () => {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
71
72
|
cbws.getWebsocket.send(JSON.stringify({
|
|
72
73
|
"type": "browserEvent",
|
|
73
74
|
action: 'screenshot'
|
|
74
75
|
}));
|
|
76
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
77
|
+
const response = JSON.parse(data);
|
|
78
|
+
if (response.event === "screenshotResponse") {
|
|
79
|
+
resolve(response.payload);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
75
83
|
},
|
|
76
84
|
|
|
77
85
|
/**
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import cbws from './websocket';
|
|
2
|
+
|
|
3
|
+
export enum logType {
|
|
4
|
+
info = "info",
|
|
5
|
+
error = "error",
|
|
6
|
+
warning = "warning"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const chatSummary = {
|
|
11
|
+
|
|
12
|
+
summarizeAll: (): Promise<{
|
|
13
|
+
role: string;
|
|
14
|
+
content: string;
|
|
15
|
+
}[]> => {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
18
|
+
"type": "chatSummaryEvent",
|
|
19
|
+
"action": "summarizeAll",
|
|
20
|
+
|
|
21
|
+
}));
|
|
22
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
23
|
+
const response = JSON.parse(data);
|
|
24
|
+
if (response.type === "getSummarizeAllResponse") {
|
|
25
|
+
resolve(response.payload); // Resolve the Promise with the response data
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
},
|
|
32
|
+
summarize: (messages: {
|
|
33
|
+
role: string;
|
|
34
|
+
content: string;
|
|
35
|
+
}[], depth: number): Promise<{
|
|
36
|
+
role: string;
|
|
37
|
+
content: string;
|
|
38
|
+
}[]> => {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
41
|
+
"type": "chatSummaryEvent",
|
|
42
|
+
"action": "summarize",
|
|
43
|
+
messages,
|
|
44
|
+
depth
|
|
45
|
+
}));
|
|
46
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
47
|
+
const response = JSON.parse(data);
|
|
48
|
+
if (response.type === "getSummarizeResponse") {
|
|
49
|
+
resolve(response.payload); // Resolve the Promise with the response data
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export default chatSummary;
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|