Skip to content

Commit d30dcc2

Browse files
typing added
1 parent 7b2ce9b commit d30dcc2

21 files changed

+2003
-80
lines changed

package-lock.json

Lines changed: 350 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/agentlib/usermessage.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ class UserMessage {
124124

125125
if (bAttachEnvironment) {
126126
let { projectPath } = await project.getProjectPath();
127-
const environmentDetail = await this.getEnvironmentDetail(projectPath);
128-
this.userMessages.push({ type: "text", text: environmentDetail });
127+
if (projectPath) {
128+
const environmentDetail = await this.getEnvironmentDetail(projectPath);
129+
this.userMessages.push({ type: "text", text: environmentDetail });
130+
}
129131
}
130132

131133
return this.userMessages;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {chatSummary} from './modules/history'
2525
import codeboltTools from './modules/tools';
2626
import cbagent from './modules/agent';
2727
import cbutils from './modules/utils';
28-
import type { LLMResponse } from '@codebolt/types';
28+
import type { LLMResponse } from './types/cliWebSocketInterfaces';
2929

3030
/**
3131
* Represents a message in the conversation with roles and content.

src/modules/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GetAgentStateResponse } from '@codebolt/types';
1+
import { GetAgentStateResponse } from '../types/cliWebSocketInterfaces';
22
import cbws from '../core/websocket';
33

44

src/modules/browser.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cbws from '../core/websocket';
2-
import {GoToPageResponse,UrlResponse,GetMarkdownResponse,HtmlReceived,ExtractTextResponse,GetContentResponse} from '@codebolt/types'
2+
import { GoToPageResponse, UrlResponse, GetMarkdownResponse, HtmlReceived, ExtractTextResponse, GetContentResponse, BrowserActionResponseData, BrowserScreenshotResponse, BrowserInfoResponse, BrowserSnapshotResponse } from '../types/cliWebSocketInterfaces';
33
/**
44
* A module for interacting with a browser through WebSockets.
55
*/
@@ -8,7 +8,7 @@ const cbbrowser = {
88
/**
99
* Opens a new page in the browser.
1010
*/
11-
newPage: () => {
11+
newPage: (): Promise<BrowserActionResponseData> => {
1212

1313
return cbws.messageManager.sendAndWaitForResponse(
1414
{
@@ -23,7 +23,7 @@ const cbbrowser = {
2323
* Retrieves the current URL of the browser's active page.
2424
* @returns {Promise<UrlResponse>} A promise that resolves with the URL.
2525
*/
26-
getUrl: ():Promise<UrlResponse> => {
26+
getUrl: (): Promise<UrlResponse> => {
2727
return cbws.messageManager.sendAndWaitForResponse(
2828
{
2929
"type": "browserEvent",
@@ -38,7 +38,7 @@ const cbbrowser = {
3838
* @param {string} url - The URL to navigate to.
3939
* @returns {Promise<GoToPageResponse>} A promise that resolves when navigation is complete.
4040
*/
41-
goToPage: (url: string):Promise<GoToPageResponse> => {
41+
goToPage: (url: string): Promise<GoToPageResponse> => {
4242
return cbws.messageManager.sendAndWaitForResponse(
4343
{
4444
"type": "browserEvent",
@@ -52,7 +52,7 @@ const cbbrowser = {
5252
/**
5353
* Takes a screenshot of the current page.
5454
*/
55-
screenshot: () => {
55+
screenshot: (): Promise<BrowserScreenshotResponse> => {
5656
return cbws.messageManager.sendAndWaitForResponse(
5757
{
5858
"type": "browserEvent",
@@ -66,7 +66,7 @@ const cbbrowser = {
6666
* Retrieves the HTML content of the current page.
6767
* @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content.
6868
*/
69-
getHTML: ():Promise<HtmlReceived> => {
69+
getHTML: (): Promise<HtmlReceived> => {
7070
return cbws.messageManager.sendAndWaitForResponse(
7171
{
7272
"type": "browserEvent",
@@ -80,7 +80,7 @@ const cbbrowser = {
8080
* Retrieves the Markdown content of the current page.
8181
* @returns {Promise<GetMarkdownResponse>} A promise that resolves with the Markdown content.
8282
*/
83-
getMarkdown: ():Promise<GetMarkdownResponse> => {
83+
getMarkdown: (): Promise<GetMarkdownResponse> => {
8484
return cbws.messageManager.sendAndWaitForResponse(
8585
{
8686
"type": "browserEvent",
@@ -94,7 +94,7 @@ const cbbrowser = {
9494
* Retrieves the PDF content of the current page.
9595
*
9696
*/
97-
getPDF: () => {
97+
getPDF: (): void => {
9898
cbws.messageManager.send({
9999
"type": "browserEvent",
100100
action: 'getPDF'
@@ -104,7 +104,7 @@ const cbbrowser = {
104104
/**
105105
* Converts the PDF content of the current page to text.
106106
*/
107-
pdfToText: () => {
107+
pdfToText: (): void => {
108108
cbws.messageManager.send({
109109
"type": "browserEvent",
110110
action: 'pdfToText'
@@ -115,7 +115,7 @@ const cbbrowser = {
115115
* Retrieves the content of the current page.
116116
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
117117
*/
118-
getContent: ():Promise<GetContentResponse> => {
118+
getContent: (): Promise<GetContentResponse> => {
119119

120120
return cbws.messageManager.sendAndWaitForResponse(
121121
{
@@ -127,9 +127,9 @@ const cbbrowser = {
127127
},
128128
/**
129129
* Retrieves the snapshot of the current page.
130-
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
130+
* @returns {Promise<BrowserSnapshotResponse>} A promise that resolves with the snapshot.
131131
*/
132-
getSnapShot: ():Promise<any> => {
132+
getSnapShot: (): Promise<BrowserSnapshotResponse> => {
133133

134134
return cbws.messageManager.sendAndWaitForResponse(
135135
{
@@ -141,9 +141,9 @@ const cbbrowser = {
141141
},
142142
/**
143143
* Retrieves browser info like height width scrollx scrolly of the current page.
144-
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
144+
* @returns {Promise<BrowserInfoResponse>} A promise that resolves with the browser info.
145145
*/
146-
getBrowserInfo: ():Promise<any> => {
146+
getBrowserInfo: (): Promise<BrowserInfoResponse> => {
147147

148148
return cbws.messageManager.sendAndWaitForResponse(
149149
{
@@ -159,7 +159,7 @@ const cbbrowser = {
159159
* @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
160160
*
161161
*/
162-
extractText: ():Promise<ExtractTextResponse> => {
162+
extractText: (): Promise<ExtractTextResponse> => {
163163

164164
return cbws.messageManager.sendAndWaitForResponse(
165165
{
@@ -173,7 +173,7 @@ const cbbrowser = {
173173
/**
174174
* Closes the current page.
175175
*/
176-
close: () => {
176+
close: (): void => {
177177
cbws.messageManager.send({
178178
"type": "browserEvent",
179179
action: 'close'
@@ -184,9 +184,9 @@ const cbbrowser = {
184184
* Scrolls the current page in a specified direction by a specified number of pixels.
185185
* @param {string} direction - The direction to scroll.
186186
* @param {string} pixels - The number of pixels to scroll.
187-
* @returns {Promise<any>} A promise that resolves when the scroll action is complete.
187+
* @returns {Promise<BrowserActionResponseData>} A promise that resolves when the scroll action is complete.
188188
*/
189-
scroll: (direction: string, pixels: string) => {
189+
scroll: (direction: string, pixels: string): Promise<BrowserActionResponseData> => {
190190
return cbws.messageManager.sendAndWaitForResponse(
191191
{
192192
"type": "browserEvent",
@@ -202,9 +202,9 @@ const cbbrowser = {
202202
* Types text into a specified element on the page.
203203
* @param {string} elementid - The ID of the element to type into.
204204
* @param {string} text - The text to type.
205-
* @returns {Promise<any>} A promise that resolves when the typing action is complete.
205+
* @returns {Promise<BrowserActionResponseData>} A promise that resolves when the typing action is complete.
206206
*/
207-
type: (elementid: string, text: string) => {
207+
type: (elementid: string, text: string): Promise<BrowserActionResponseData> => {
208208
return cbws.messageManager.sendAndWaitForResponse(
209209
{
210210
"type": "browserEvent",
@@ -219,9 +219,9 @@ const cbbrowser = {
219219
/**
220220
* Clicks on a specified element on the page.
221221
* @param {string} elementid - The ID of the element to click.
222-
* @returns {Promise<any>} A promise that resolves when the click action is complete.
222+
* @returns {Promise<BrowserActionResponseData>} A promise that resolves when the click action is complete.
223223
*/
224-
click: (elementid: string) => {
224+
click: (elementid: string): Promise<BrowserActionResponseData> => {
225225
return cbws.messageManager.sendAndWaitForResponse(
226226
{
227227
"type": "browserEvent",
@@ -234,9 +234,9 @@ const cbbrowser = {
234234

235235
/**
236236
* Simulates the Enter key press on the current page.
237-
* @returns {Promise<any>} A promise that resolves when the Enter action is complete.
237+
* @returns {Promise<BrowserActionResponseData>} A promise that resolves when the Enter action is complete.
238238
*/
239-
enter: () => {
239+
enter: (): Promise<BrowserActionResponseData> => {
240240
return cbws.messageManager.sendAndWaitForResponse(
241241
{
242242
"type": "browserEvent",
@@ -250,9 +250,9 @@ const cbbrowser = {
250250
* Performs a search on the current page using a specified query.
251251
* @param {string} elementid - The ID of the element to perform the search in.
252252
* @param {string} query - The search query.
253-
* @returns {Promise<any>} A promise that resolves with the search results.
253+
* @returns {Promise<BrowserActionResponseData>} A promise that resolves with the search results.
254254
*/
255-
search: (elementid: string, query: string) => {
255+
search: (elementid: string, query: string): Promise<BrowserActionResponseData> => {
256256
return cbws.messageManager.sendAndWaitForResponse(
257257
{
258258
"type": "browserEvent",

src/modules/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// chat.ts
22
import cbws from '../core/websocket';
3-
import { ChatMessage, UserMessage } from '@codebolt/types'
3+
import { ChatMessage, UserMessage } from '../types/cliWebSocketInterfaces';
44

55
type RequestHandler = (request: any, response: (data: any) => void) => Promise<void> | void;
66
/**

src/modules/codeutils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'path';
55
// import JavaScript from 'tree-sitter-javascript';
66
// import typescript from "tree-sitter-typescript"; // TypeScript and TSX grammar
77

8-
import { MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '@codebolt/types';
8+
import { MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '../types/cliWebSocketInterfaces';
99
import { loadRequiredLanguageParsers } from '../utils/parse-source-code/languageParser';
1010

1111
// Define our own interface for the JS tree response

src/modules/dbmemory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cbws from '../core/websocket';
2-
import {MemorySetResponse,MemoryGetResponse } from '@codebolt/types';
2+
import { MemorySetResponse, MemoryGetResponse } from '../types/cliWebSocketInterfaces';
33

44
/**
55
* A module for handling in-memory database operations via WebSocket.

src/modules/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cbws from '../core/websocket';
2-
import {DebugAddLogResponse,OpenDebugBrowserResponse } from '@codebolt/types';
2+
import { DebugAddLogResponse, OpenDebugBrowserResponse } from '../types/cliWebSocketInterfaces';
33
export enum logType{
44
info="info",
55
error="error",

src/modules/fs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cbws from '../core/websocket';
2-
import {CreateFileResponse,CreateFolderResponse,ReadFileResponse,UpdateFileResponse,DeleteFileResponse,DeleteFolderResponse} from '@codebolt/types'
2+
import { CreateFileResponse, CreateFolderResponse, ReadFileResponse, UpdateFileResponse, DeleteFileResponse, DeleteFolderResponse } from '../types/cliWebSocketInterfaces';
33
/**
44
* @module cbfs
55
* @description This module provides functionality to interact with the filesystem.

0 commit comments

Comments
 (0)