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