| 
 | 1 | +import WebSocket from 'ws';  | 
 | 2 | +import { EventEmitter } from 'events';  | 
1 | 3 | /**  | 
2 | 4 |  * @class Codebolt  | 
3 | 5 |  * @description This class provides a unified interface to interact with various modules.  | 
4 | 6 |  */  | 
5 | 7 | declare class Codebolt {  | 
6 |  | -    private static instance;  | 
7 |  | -    private wsManager;  | 
8 |  | -    private chat;  | 
9 | 8 |     /**  | 
10 | 9 |      * @constructor  | 
11 | 10 |      * @description Initializes the websocket connection.  | 
12 | 11 |      */  | 
13 | 12 |     constructor();  | 
14 |  | -    static getInstance(): Codebolt;  | 
15 | 13 |     /**  | 
16 | 14 |      * @method waitForConnection  | 
17 | 15 |      * @description Waits for the WebSocket connection to open.  | 
18 | 16 |      * @returns {Promise<void>} A promise that resolves when the WebSocket connection is open.  | 
19 | 17 |      */  | 
20 |  | -    connect(): Promise<void>;  | 
21 |  | -    disconnect(): Promise<void>;  | 
 | 18 | +    waitForConnection(): Promise<void>;  | 
 | 19 | +    websocket: WebSocket | null;  | 
 | 20 | +    fs: {  | 
 | 21 | +        createFile: (fileName: string, source: string, filePath: string) => Promise<import("@codebolt/types").CreateFileResponse>;  | 
 | 22 | +        createFolder: (folderName: string, folderPath: string) => Promise<import("@codebolt/types").CreateFolderResponse>;  | 
 | 23 | +        readFile: (filename: string, filePath: string) => Promise<import("@codebolt/types").ReadFileResponse>;  | 
 | 24 | +        updateFile: (filename: string, filePath: string, newContent: string) => Promise<import("@codebolt/types").UpdateFileResponse>;  | 
 | 25 | +        deleteFile: (filename: string, filePath: string) => Promise<import("@codebolt/types").DeleteFileResponse>;  | 
 | 26 | +        deleteFolder: (foldername: string, folderpath: string) => Promise<import("@codebolt/types").DeleteFolderResponse>;  | 
 | 27 | +        listFile: (folderPath: string, isRecursive?: boolean) => Promise<unknown>;  | 
 | 28 | +    };  | 
 | 29 | +    git: {  | 
 | 30 | +        init: (path: string) => Promise<any>;  | 
 | 31 | +        clone: (url: string, path: string) => Promise<any>;  | 
 | 32 | +        pull: (path: string) => Promise<any>;  | 
 | 33 | +        push: (path: string) => Promise<any>;  | 
 | 34 | +        status: (path: string) => Promise<any>;  | 
 | 35 | +        add: (path: string) => Promise<any>;  | 
 | 36 | +        commit: (message: string) => Promise<any>;  | 
 | 37 | +        checkout: (path: string, branch: string) => Promise<any>;  | 
 | 38 | +        branch: (path: string, branch: string) => Promise<any>;  | 
 | 39 | +        logs: (path: string) => Promise<any>;  | 
 | 40 | +        diff: (commitHash: string, path: string) => Promise<any>;  | 
 | 41 | +    };  | 
 | 42 | +    llm: {  | 
 | 43 | +        inference: (message: string, llmrole: string) => Promise<import("@codebolt/types").LLMResponse>;  | 
 | 44 | +    };  | 
 | 45 | +    browser: {  | 
 | 46 | +        newPage: () => Promise<unknown>;  | 
 | 47 | +        getUrl: () => Promise<import("@codebolt/types").UrlResponse>;  | 
 | 48 | +        goToPage: (url: string) => Promise<import("@codebolt/types").GoToPageResponse>;  | 
 | 49 | +        screenshot: () => Promise<unknown>;  | 
 | 50 | +        getHTML: () => Promise<import("@codebolt/types").HtmlReceived>;  | 
 | 51 | +        getMarkdown: () => Promise<import("@codebolt/types").GetMarkdownResponse>;  | 
 | 52 | +        getPDF: () => void;  | 
 | 53 | +        pdfToText: () => void;  | 
 | 54 | +        getContent: () => Promise<import("@codebolt/types").GetContentResponse>;  | 
 | 55 | +        getSnapShot: () => Promise<any>;  | 
 | 56 | +        getBrowserInfo: () => Promise<any>;  | 
 | 57 | +        extractText: () => Promise<import("@codebolt/types").ExtractTextResponse>;  | 
 | 58 | +        close: () => void;  | 
 | 59 | +        scroll: (direction: string, pixels: string) => Promise<unknown>;  | 
 | 60 | +        type: (elementid: string, text: string) => Promise<unknown>;  | 
 | 61 | +        click: (elementid: string) => Promise<unknown>;  | 
 | 62 | +        enter: () => Promise<unknown>;  | 
 | 63 | +        search: (elementid: string, query: string) => Promise<unknown>;  | 
 | 64 | +    };  | 
 | 65 | +    chat: {  | 
 | 66 | +        getChatHistory: () => Promise<import("@codebolt/types").ChatMessage[]>;  | 
 | 67 | +        onActionMessage: () => {  | 
 | 68 | +            [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;  | 
 | 69 | +            addListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 70 | +            on<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 71 | +            once<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 72 | +            removeListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 73 | +            off<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 74 | +            removeAllListeners(eventName?: string | symbol | undefined): any;  | 
 | 75 | +            setMaxListeners(n: number): any;  | 
 | 76 | +            getMaxListeners(): number;  | 
 | 77 | +            listeners<K>(eventName: string | symbol): Function[];  | 
 | 78 | +            rawListeners<K>(eventName: string | symbol): Function[];  | 
 | 79 | +            emit<K>(eventName: string | symbol, ...args: any[]): boolean;  | 
 | 80 | +            listenerCount<K>(eventName: string | symbol, listener?: Function | undefined): number;  | 
 | 81 | +            prependListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 82 | +            prependOnceListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 83 | +            eventNames(): (string | symbol)[];  | 
 | 84 | +        } | undefined;  | 
 | 85 | +        sendMessage: (message: string, payload: any) => void;  | 
 | 86 | +        waitforReply: (message: string) => Promise<import("@codebolt/types").UserMessage>;  | 
 | 87 | +        processStarted: () => {  | 
 | 88 | +            event: {  | 
 | 89 | +                [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;  | 
 | 90 | +                addListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 91 | +                on<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 92 | +                once<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 93 | +                removeListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 94 | +                off<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 95 | +                removeAllListeners(eventName?: string | symbol | undefined): any;  | 
 | 96 | +                setMaxListeners(n: number): any;  | 
 | 97 | +                getMaxListeners(): number;  | 
 | 98 | +                listeners<K>(eventName: string | symbol): Function[];  | 
 | 99 | +                rawListeners<K>(eventName: string | symbol): Function[];  | 
 | 100 | +                emit<K>(eventName: string | symbol, ...args: any[]): boolean;  | 
 | 101 | +                listenerCount<K>(eventName: string | symbol, listener?: Function | undefined): number;  | 
 | 102 | +                prependListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 103 | +                prependOnceListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 104 | +                eventNames(): (string | symbol)[];  | 
 | 105 | +            };  | 
 | 106 | +            stopProcess: () => void;  | 
 | 107 | +        };  | 
 | 108 | +        stopProcess: () => void;  | 
 | 109 | +        processFinished: () => void;  | 
 | 110 | +        sendConfirmationRequest: (confirmationMessage: string, buttons?: string[]) => Promise<string>;  | 
 | 111 | +        sendNotificationEvent: (notificationMessage: string, type: "debug" | "git" | "planner" | "browser" | "editor" | "terminal" | "preview") => void;  | 
 | 112 | +    };  | 
 | 113 | +    terminal: {  | 
 | 114 | +        eventEmitter: {  | 
 | 115 | +            [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;  | 
 | 116 | +            addListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 117 | +            on<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 118 | +            once<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 119 | +            removeListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 120 | +            off<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 121 | +            removeAllListeners(eventName?: string | symbol | undefined): any;  | 
 | 122 | +            setMaxListeners(n: number): any;  | 
 | 123 | +            getMaxListeners(): number;  | 
 | 124 | +            listeners<K>(eventName: string | symbol): Function[];  | 
 | 125 | +            rawListeners<K>(eventName: string | symbol): Function[];  | 
 | 126 | +            emit<K>(eventName: string | symbol, ...args: any[]): boolean;  | 
 | 127 | +            listenerCount<K>(eventName: string | symbol, listener?: Function | undefined): number;  | 
 | 128 | +            prependListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 129 | +            prependOnceListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;  | 
 | 130 | +            eventNames(): (string | symbol)[];  | 
 | 131 | +        };  | 
 | 132 | +        executeCommand: (command: string, executeInMain?: boolean) => Promise<import("@codebolt/types").CommandOutput | import("@codebolt/types").CommandError>;  | 
 | 133 | +        executeCommandRunUntilError: (command: string, executeInMain?: boolean) => Promise<import("@codebolt/types").CommandError>;  | 
 | 134 | +        sendManualInterrupt(): Promise<import("@codebolt/types").TerminalInterruptResponse>;  | 
 | 135 | +        executeCommandWithStream(command: string, executeInMain?: boolean): EventEmitter;  | 
 | 136 | +    };  | 
 | 137 | +    codeutils: {  | 
 | 138 | +        getJsTree: (filePath?: string) => Promise<any>;  | 
 | 139 | +        getAllFilesAsMarkDown: () => Promise<string>;  | 
 | 140 | +        performMatch: (matcherDefinition: object, problemPatterns: any[], problems: any[]) => Promise<import("@codebolt/types").MatchProblemResponse>;  | 
 | 141 | +        getMatcherList: () => Promise<import("@codebolt/types").GetMatcherListTreeResponse>;  | 
 | 142 | +        matchDetail: (matcher: string) => Promise<import("@codebolt/types").getMatchDetail>;  | 
 | 143 | +    };  | 
 | 144 | +    docutils: {  | 
 | 145 | +        pdf_to_text: (pdf_path: any) => Promise<string>;  | 
 | 146 | +    };  | 
 | 147 | +    crawler: {  | 
 | 148 | +        start: () => void;  | 
 | 149 | +        screenshot: () => void;  | 
 | 150 | +        goToPage: (url: string) => void;  | 
 | 151 | +        scroll: (direction: string) => void;  | 
 | 152 | +        click: (id: string) => Promise<unknown>;  | 
 | 153 | +        type: (id: string, text: string) => Promise<unknown>;  | 
 | 154 | +        enter: () => void;  | 
 | 155 | +        crawl: (query: string) => Promise<unknown>;  | 
 | 156 | +    };  | 
 | 157 | +    search: {  | 
 | 158 | +        init: (engine?: string) => void;  | 
 | 159 | +        search: (query: string) => Promise<string>;  | 
 | 160 | +        get_first_link: (query: string) => Promise<string>;  | 
 | 161 | +    };  | 
 | 162 | +    knowledge: {};  | 
 | 163 | +    rag: {  | 
 | 164 | +        init: () => void;  | 
 | 165 | +        add_file: (filename: string, file_path: string) => void;  | 
 | 166 | +        retrieve_related_knowledge: (query: string, filename: string) => void;  | 
 | 167 | +    };  | 
 | 168 | +    codeparsers: {  | 
 | 169 | +        getClassesInFile: (file: any) => void;  | 
 | 170 | +        getFunctionsinClass: (file: any, className: any) => void;  | 
 | 171 | +        getAstTreeInFile: (file: any, className: any) => void;  | 
 | 172 | +    };  | 
 | 173 | +    outputparsers: {  | 
 | 174 | +        init: (output: any) => void;  | 
 | 175 | +        parseErrors: (output: any) => string[];  | 
 | 176 | +        parseWarnings: (output: any) => string[];  | 
 | 177 | +    };  | 
 | 178 | +    project: {  | 
 | 179 | +        getProjectSettings: (output: any) => void;  | 
 | 180 | +        getProjectPath: () => Promise<import("@codebolt/types").GetProjectPathResponse>;  | 
 | 181 | +        getRepoMap: (message: any) => Promise<import("@codebolt/types").GetProjectPathResponse>;  | 
 | 182 | +        runProject: () => void;  | 
 | 183 | +    };  | 
 | 184 | +    dbmemory: {  | 
 | 185 | +        addKnowledge: (key: string, value: any) => Promise<import("@codebolt/types").MemorySetResponse>;  | 
 | 186 | +        getKnowledge: (key: string) => Promise<import("@codebolt/types").MemoryGetResponse>;  | 
 | 187 | +    };  | 
 | 188 | +    cbstate: {  | 
 | 189 | +        getApplicationState: () => Promise<import("@codebolt/types").ApplicationState>;  | 
 | 190 | +        addToAgentState: (key: string, value: string) => Promise<import("@codebolt/types").AddToAgentStateResponse>;  | 
 | 191 | +        getAgentState: () => Promise<import("@codebolt/types").GetAgentStateResponse>;  | 
 | 192 | +    };  | 
 | 193 | +    taskplaner: {  | 
 | 194 | +        addTask: (task: string) => Promise<any>;  | 
 | 195 | +        getTasks: () => Promise<any>;  | 
 | 196 | +        updateTask: (task: string) => Promise<any>;  | 
 | 197 | +    };  | 
 | 198 | +    vectordb: {  | 
 | 199 | +        getVector: (key: string) => Promise<import("@codebolt/types").GetVectorResponse>;  | 
 | 200 | +        addVectorItem: (item: any) => Promise<import("@codebolt/types").AddVectorItemResponse>;  | 
 | 201 | +        queryVectorItem: (key: string) => Promise<import("@codebolt/types").QueryVectorItemResponse>;  | 
 | 202 | +        queryVectorItems: (items: [], dbPath: string) => Promise<import("@codebolt/types").QueryVectorItemResponse>;  | 
 | 203 | +    };  | 
 | 204 | +    debug: {  | 
 | 205 | +        debug: (log: string, type: import("./modules/debug").logType) => Promise<import("@codebolt/types").DebugAddLogResponse>;  | 
 | 206 | +        openDebugBrowser: (url: string, port: number) => Promise<import("@codebolt/types").OpenDebugBrowserResponse>;  | 
 | 207 | +    };  | 
 | 208 | +    tokenizer: {  | 
 | 209 | +        addToken: (key: string) => Promise<import("@codebolt/types").AddTokenResponse>;  | 
 | 210 | +        getToken: (key: string) => Promise<import("@codebolt/types").GetTokenResponse>;  | 
 | 211 | +    };  | 
 | 212 | +    chatSummary: {  | 
 | 213 | +        summarizeAll: () => Promise<{  | 
 | 214 | +            role: string;  | 
 | 215 | +            content: string;  | 
 | 216 | +        }[]>;  | 
 | 217 | +        summarize: (messages: {  | 
 | 218 | +            role: string;  | 
 | 219 | +            content: string;  | 
 | 220 | +        }[], depth: number) => Promise<{  | 
 | 221 | +            role: string;  | 
 | 222 | +            content: string;  | 
 | 223 | +        }[]>;  | 
 | 224 | +    };  | 
22 | 225 | }  | 
23 | 226 | declare const _default: Codebolt;  | 
24 | 227 | export default _default;  | 
0 commit comments