@codebolt/codeboltjs 2.0.12 → 2.0.15

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.
Files changed (129) hide show
  1. package/Readme.md +138 -4
  2. package/dist/agentlib/agent.js +3 -7
  3. package/dist/agentlib/followupquestionbuilder.d.ts +75 -0
  4. package/dist/agentlib/followupquestionbuilder.js +193 -0
  5. package/dist/agentlib/llmoutputhandler.d.ts +102 -0
  6. package/dist/agentlib/llmoutputhandler.js +451 -0
  7. package/dist/agentlib/promptbuilder.d.ts +171 -17
  8. package/dist/agentlib/promptbuilder.js +367 -49
  9. package/dist/agentlib/systemprompt.js +3 -3
  10. package/dist/agentlib/usermessage.d.ts +1 -1
  11. package/dist/agentlib/usermessage.js +5 -1
  12. package/dist/core/Codebolt.d.ts +342 -0
  13. package/dist/core/Codebolt.js +201 -0
  14. package/dist/core/websocket.js +2 -1
  15. package/dist/index.d.ts +4 -300
  16. package/dist/index.js +11 -137
  17. package/dist/modules/llm.d.ts +23 -3
  18. package/dist/modules/llm.js +20 -3
  19. package/dist/modules/project.d.ts +3 -3
  20. package/dist/modules/project.js +1 -1
  21. package/dist/modules/state.d.ts +5 -3
  22. package/dist/modules/state.js +2 -0
  23. package/dist/modules/task.d.ts +126 -11
  24. package/dist/modules/task.js +262 -20
  25. package/dist/notificationfunctions/agent.d.ts +48 -0
  26. package/dist/notificationfunctions/agent.js +115 -0
  27. package/dist/notificationfunctions/browser.d.ts +60 -0
  28. package/dist/notificationfunctions/browser.js +145 -0
  29. package/dist/notificationfunctions/chat.d.ts +53 -0
  30. package/dist/notificationfunctions/chat.js +125 -0
  31. package/dist/notificationfunctions/codeutils.d.ts +60 -0
  32. package/dist/notificationfunctions/codeutils.js +145 -0
  33. package/dist/notificationfunctions/crawler.d.ts +59 -0
  34. package/dist/notificationfunctions/crawler.js +159 -0
  35. package/dist/notificationfunctions/dbmemory.d.ts +50 -0
  36. package/dist/notificationfunctions/dbmemory.js +132 -0
  37. package/dist/notificationfunctions/fs.d.ts +125 -0
  38. package/dist/notificationfunctions/fs.js +472 -0
  39. package/dist/notificationfunctions/git.d.ts +174 -0
  40. package/dist/notificationfunctions/git.js +521 -0
  41. package/dist/notificationfunctions/history.d.ts +38 -0
  42. package/dist/notificationfunctions/history.js +97 -0
  43. package/dist/notificationfunctions/index.d.ts +79 -0
  44. package/dist/notificationfunctions/index.js +102 -0
  45. package/dist/notificationfunctions/llm.d.ts +39 -0
  46. package/dist/notificationfunctions/llm.js +99 -0
  47. package/dist/notificationfunctions/mcp.d.ts +67 -0
  48. package/dist/notificationfunctions/mcp.js +192 -0
  49. package/dist/notificationfunctions/search.d.ts +50 -0
  50. package/dist/notificationfunctions/search.js +146 -0
  51. package/dist/notificationfunctions/system.d.ts +25 -0
  52. package/dist/notificationfunctions/system.js +59 -0
  53. package/dist/notificationfunctions/terminal.d.ts +26 -0
  54. package/dist/notificationfunctions/terminal.js +64 -0
  55. package/dist/notificationfunctions/todo.d.ts +63 -0
  56. package/dist/notificationfunctions/todo.js +164 -0
  57. package/dist/notificationfunctions/utils.d.ts +81 -0
  58. package/dist/notificationfunctions/utils.js +177 -0
  59. package/dist/types/InternalTypes.d.ts +1 -0
  60. package/dist/types/commonTypes.d.ts +26 -3
  61. package/dist/types/index.d.ts +15 -0
  62. package/dist/types/index.js +15 -0
  63. package/dist/types/libFunctionTypes.d.ts +110 -4
  64. package/dist/types/notificationFunctions/agent.d.ts +8 -0
  65. package/dist/types/notificationFunctions/agent.js +2 -0
  66. package/dist/types/notificationFunctions/browser.d.ts +10 -0
  67. package/dist/types/notificationFunctions/browser.js +2 -0
  68. package/dist/types/notificationFunctions/chat.d.ts +10 -0
  69. package/dist/types/notificationFunctions/chat.js +2 -0
  70. package/dist/types/notificationFunctions/codeutils.d.ts +10 -0
  71. package/dist/types/notificationFunctions/codeutils.js +2 -0
  72. package/dist/types/notificationFunctions/crawler.d.ts +10 -0
  73. package/dist/types/notificationFunctions/crawler.js +2 -0
  74. package/dist/types/notificationFunctions/dbmemory.d.ts +9 -0
  75. package/dist/types/notificationFunctions/dbmemory.js +2 -0
  76. package/dist/types/notificationFunctions/fs.d.ts +27 -0
  77. package/dist/types/notificationFunctions/fs.js +2 -0
  78. package/dist/types/notificationFunctions/git.d.ts +29 -0
  79. package/dist/types/notificationFunctions/git.js +2 -0
  80. package/dist/types/notificationFunctions/history.d.ts +10 -0
  81. package/dist/types/notificationFunctions/history.js +2 -0
  82. package/dist/types/notificationFunctions/index.d.ts +0 -0
  83. package/dist/types/notificationFunctions/index.js +1 -0
  84. package/dist/types/notificationFunctions/llm.d.ts +10 -0
  85. package/dist/types/notificationFunctions/llm.js +2 -0
  86. package/dist/types/notificationFunctions/mcp.d.ts +16 -0
  87. package/dist/types/notificationFunctions/mcp.js +2 -0
  88. package/dist/types/notificationFunctions/search.d.ts +11 -0
  89. package/dist/types/notificationFunctions/search.js +2 -0
  90. package/dist/types/notificationFunctions/system.d.ts +7 -0
  91. package/dist/types/notificationFunctions/system.js +2 -0
  92. package/dist/types/notificationFunctions/terminal.d.ts +7 -0
  93. package/dist/types/notificationFunctions/terminal.js +2 -0
  94. package/dist/types/notificationFunctions/todo.d.ts +11 -0
  95. package/dist/types/notificationFunctions/todo.js +2 -0
  96. package/dist/types/notifications/agent.d.ts +31 -0
  97. package/dist/types/notifications/agent.js +3 -0
  98. package/dist/types/notifications/browser.d.ts +53 -0
  99. package/dist/types/notifications/browser.js +3 -0
  100. package/dist/types/notifications/chat.d.ts +37 -0
  101. package/dist/types/notifications/chat.js +3 -0
  102. package/dist/types/notifications/codeutils.d.ts +55 -0
  103. package/dist/types/notifications/codeutils.js +3 -0
  104. package/dist/types/notifications/crawler.d.ts +55 -0
  105. package/dist/types/notifications/crawler.js +3 -0
  106. package/dist/types/notifications/dbmemory.d.ts +31 -0
  107. package/dist/types/notifications/dbmemory.js +3 -0
  108. package/dist/types/notifications/fs.d.ts +180 -0
  109. package/dist/types/notifications/fs.js +3 -0
  110. package/dist/types/notifications/git.d.ts +205 -0
  111. package/dist/types/notifications/git.js +3 -0
  112. package/dist/types/notifications/history.d.ts +32 -0
  113. package/dist/types/notifications/history.js +3 -0
  114. package/dist/types/notifications/llm.d.ts +45 -0
  115. package/dist/types/notifications/llm.js +2 -0
  116. package/dist/types/notifications/mcp.d.ts +63 -0
  117. package/dist/types/notifications/mcp.js +3 -0
  118. package/dist/types/notifications/search.d.ts +47 -0
  119. package/dist/types/notifications/search.js +3 -0
  120. package/dist/types/notifications/system.d.ts +20 -0
  121. package/dist/types/notifications/system.js +2 -0
  122. package/dist/types/notifications/terminal.d.ts +17 -0
  123. package/dist/types/notifications/terminal.js +2 -0
  124. package/dist/types/notifications/todo.d.ts +60 -0
  125. package/dist/types/notifications/todo.js +3 -0
  126. package/dist/types/socketMessageTypes.d.ts +3 -0
  127. package/dist/utils.d.ts +3 -0
  128. package/dist/utils.js +7 -1
  129. package/package.json +1 -1
@@ -0,0 +1,342 @@
1
+ /// <reference types="node" />
2
+ import WebSocket from 'ws';
3
+ import { type NotificationFunctions } from '../notificationfunctions';
4
+ import type { UserMessage } from '../types/libFunctionTypes';
5
+ /**
6
+ * @class Codebolt
7
+ * @description This class provides a unified interface to interact with various modules.
8
+ */
9
+ declare class Codebolt {
10
+ websocket: WebSocket | null;
11
+ private isReady;
12
+ private readyPromise;
13
+ private readyHandlers;
14
+ /**
15
+ * @constructor
16
+ * @description Initializes the websocket connection.
17
+ */
18
+ constructor();
19
+ /**
20
+ * @method initializeConnection
21
+ * @description Initializes the WebSocket connection asynchronously.
22
+ * @private
23
+ */
24
+ private initializeConnection;
25
+ /**
26
+ * @method waitForReady
27
+ * @description Waits for the Codebolt instance to be fully initialized.
28
+ * @returns {Promise<void>} A promise that resolves when the instance is ready.
29
+ */
30
+ waitForReady(): Promise<void>;
31
+ /**
32
+ * @method isReady
33
+ * @description Checks if the Codebolt instance is ready for use.
34
+ * @returns {boolean} True if the instance is ready, false otherwise.
35
+ */
36
+ get ready(): boolean;
37
+ fs: {
38
+ createFile: (fileName: string, source: string, filePath: string) => Promise<import("../types/socketMessageTypes").CreateFileResponse>;
39
+ createFolder: (folderName: string, folderPath: string) => Promise<import("../types/socketMessageTypes").CreateFolderResponse>;
40
+ readFile: (filePath: string) => Promise<import("../types/socketMessageTypes").ReadFileResponse>;
41
+ updateFile: (filename: string, filePath: string, newContent: string) => Promise<import("../types/socketMessageTypes").UpdateFileResponse>;
42
+ deleteFile: (filename: string, filePath: string) => Promise<import("../types/socketMessageTypes").DeleteFileResponse>;
43
+ deleteFolder: (foldername: string, folderpath: string) => Promise<import("../types/socketMessageTypes").DeleteFolderResponse>;
44
+ listFile: (folderPath: string, isRecursive?: boolean) => Promise<any>;
45
+ listCodeDefinitionNames: (path: string) => Promise<{
46
+ success: boolean;
47
+ result: any;
48
+ }>;
49
+ searchFiles: (path: string, regex: string, filePattern: string) => Promise<{
50
+ success: boolean;
51
+ result: any;
52
+ }>;
53
+ writeToFile: (relPath: string, newContent: string) => Promise<any>;
54
+ grepSearch: (path: string, query: string, includePattern?: string | undefined, excludePattern?: string | undefined, caseSensitive?: boolean) => Promise<{
55
+ success: boolean;
56
+ result: any;
57
+ }>;
58
+ fileSearch: (query: string) => Promise<{
59
+ success: boolean;
60
+ result: any;
61
+ }>;
62
+ editFileWithDiff: (targetFile: string, codeEdit: string, diffIdentifier: string, prompt: string, applyModel?: string | undefined) => Promise<{
63
+ success: boolean;
64
+ result: any;
65
+ }>;
66
+ };
67
+ git: {
68
+ init: (path: string) => Promise<import("../types/socketMessageTypes").GitInitResponse>;
69
+ pull: () => Promise<import("../types/socketMessageTypes").GitPullResponse>;
70
+ push: () => Promise<import("../types/socketMessageTypes").GitPushResponse>;
71
+ status: () => Promise<import("../types/socketMessageTypes").GitStatusResponse>;
72
+ addAll: () => Promise<import("../types/socketMessageTypes").AddResponse>;
73
+ commit: (message: string) => Promise<import("../types/socketMessageTypes").GitCommitResponse>;
74
+ checkout: (branch: string) => Promise<import("../types/socketMessageTypes").GitCheckoutResponse>;
75
+ branch: (branch: string) => Promise<import("../types/socketMessageTypes").GitBranchResponse>;
76
+ logs: (path: string) => Promise<import("../types/socketMessageTypes").GitLogsResponse>;
77
+ diff: (commitHash: string) => Promise<import("../types/socketMessageTypes").GitDiffResponse>;
78
+ };
79
+ llm: {
80
+ inference: (params: {
81
+ messages: import("../types/libFunctionTypes").Message[];
82
+ tools?: any[] | undefined;
83
+ tool_choice?: string | undefined;
84
+ full?: boolean | undefined;
85
+ llmrole?: string | undefined;
86
+ max_tokens?: number | undefined;
87
+ temperature?: number | undefined;
88
+ stream?: boolean | undefined;
89
+ }, llmrole?: string | undefined) => Promise<{
90
+ /**
91
+ * @constructor
92
+ * @description Initializes the websocket connection.
93
+ */
94
+ completion: any;
95
+ }>;
96
+ legacyInference: (message: string, llmrole: string) => Promise<import("../types/socketMessageTypes").LLMResponse>;
97
+ };
98
+ browser: {
99
+ newPage: () => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
100
+ getUrl: () => Promise<import("../types/socketMessageTypes").UrlResponse>;
101
+ goToPage: (url: string) => Promise<import("../types/socketMessageTypes").GoToPageResponse>;
102
+ screenshot: () => Promise<import("../types/socketMessageTypes").BrowserScreenshotResponse>;
103
+ getHTML: () => Promise<import("../types/socketMessageTypes").HtmlReceived>;
104
+ getMarkdown: () => Promise<import("../types/socketMessageTypes").GetMarkdownResponse>;
105
+ getPDF: () => void;
106
+ pdfToText: () => void;
107
+ getContent: () => Promise<import("../types/socketMessageTypes").GetContentResponse>;
108
+ getSnapShot: () => Promise<import("../types/socketMessageTypes").BrowserSnapshotResponse>;
109
+ getBrowserInfo: () => Promise<import("../types/socketMessageTypes").BrowserInfoResponse>;
110
+ extractText: () => Promise<import("../types/socketMessageTypes").ExtractTextResponse>;
111
+ close: () => void;
112
+ scroll: (direction: string, pixels: string) => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
113
+ type: (elementid: string, text: string) => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
114
+ click: (elementid: string) => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
115
+ enter: () => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
116
+ search: (elementid: string, query: string) => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
117
+ };
118
+ chat: {
119
+ getChatHistory: () => Promise<import("../types/socketMessageTypes").ChatMessage[]>;
120
+ setRequestHandler: (handler: (request: any, response: (data: any) => void) => void | Promise<void>) => void;
121
+ sendMessage: (message: string, payload: any) => void;
122
+ waitforReply: (message: string) => Promise<import("../types/socketMessageTypes").UserMessage>;
123
+ processStarted: (onStopClicked?: ((message: any) => void) | undefined) => {
124
+ stopProcess: () => void;
125
+ cleanup: () => void;
126
+ } | {
127
+ stopProcess: () => void;
128
+ cleanup?: undefined;
129
+ };
130
+ stopProcess: () => void;
131
+ processFinished: () => void;
132
+ sendConfirmationRequest: (confirmationMessage: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
133
+ askQuestion: (question: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
134
+ sendNotificationEvent: (notificationMessage: string, type: "browser" | "terminal" | "git" | "debug" | "planner" | "editor" | "preview") => void;
135
+ };
136
+ terminal: {
137
+ eventEmitter: {
138
+ cleanup?: (() => void) | undefined;
139
+ [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
140
+ addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
141
+ on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
142
+ once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
143
+ removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
144
+ off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
145
+ removeAllListeners(eventName?: string | symbol | undefined): any;
146
+ setMaxListeners(n: number): any;
147
+ getMaxListeners(): number;
148
+ listeners<K_6>(eventName: string | symbol): Function[];
149
+ rawListeners<K_7>(eventName: string | symbol): Function[];
150
+ emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
151
+ listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
152
+ prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
153
+ prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
154
+ eventNames(): (string | symbol)[];
155
+ };
156
+ executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<any>;
157
+ executeCommandRunUntilError: (command: string, executeInMain?: boolean) => Promise<import("../types/socketMessageTypes").CommandError>;
158
+ sendManualInterrupt(): Promise<import("../types/socketMessageTypes").TerminalInterruptResponse>;
159
+ executeCommandWithStream(command: string, executeInMain?: boolean): {
160
+ cleanup?: (() => void) | undefined;
161
+ [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
162
+ addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
163
+ on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
164
+ once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
165
+ removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
166
+ off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
167
+ removeAllListeners(eventName?: string | symbol | undefined): any;
168
+ setMaxListeners(n: number): any;
169
+ getMaxListeners(): number;
170
+ listeners<K_6>(eventName: string | symbol): Function[];
171
+ rawListeners<K_7>(eventName: string | symbol): Function[];
172
+ emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
173
+ listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
174
+ prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
175
+ prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
176
+ eventNames(): (string | symbol)[];
177
+ };
178
+ };
179
+ codeutils: {
180
+ getJsTree: (filePath?: string | undefined) => Promise<import("../types/InternalTypes").JSTreeResponse>;
181
+ getAllFilesAsMarkDown: () => Promise<string>;
182
+ performMatch: (matcherDefinition: object, problemPatterns: any[], problems?: any[]) => Promise<import("../types/socketMessageTypes").MatchProblemResponse>;
183
+ getMatcherList: () => Promise<import("../types/socketMessageTypes").GetMatcherListTreeResponse>;
184
+ matchDetail: (matcher: string) => Promise<import("../types/socketMessageTypes").getMatchDetail>;
185
+ };
186
+ crawler: {
187
+ start: () => void;
188
+ screenshot: () => void;
189
+ goToPage: (url: string) => void;
190
+ scroll: (direction: string) => void;
191
+ click: (id: string) => Promise<any>;
192
+ };
193
+ search: {
194
+ init: (engine?: string) => void;
195
+ search: (query: string) => Promise<string>;
196
+ get_first_link: (query: string) => Promise<string>;
197
+ };
198
+ knowledge: {};
199
+ rag: {
200
+ init: () => void;
201
+ add_file: (filename: string, file_path: string) => void;
202
+ retrieve_related_knowledge: (query: string, filename: string) => void;
203
+ };
204
+ codeparsers: {
205
+ getClassesInFile: (file: string) => Promise<{
206
+ error: string;
207
+ } | {
208
+ name: any;
209
+ location: string;
210
+ }[]>;
211
+ getFunctionsinClass: (file: string, className: string) => Promise<{
212
+ error: string;
213
+ } | {
214
+ name: string;
215
+ class: string;
216
+ location: string;
217
+ }[]>;
218
+ getAstTreeInFile: (file: string, className?: string | undefined) => Promise<import("..").ASTNode | {
219
+ error: string;
220
+ }>;
221
+ };
222
+ outputparsers: {
223
+ parseJSON: (jsonString: string) => {
224
+ success: boolean;
225
+ parsed?: any;
226
+ error?: Error | undefined;
227
+ };
228
+ parseXML: (xmlString: string) => {
229
+ success: boolean;
230
+ parsed?: any;
231
+ };
232
+ parseCSV: (csvString: string) => {
233
+ success: boolean;
234
+ parsed?: any[] | undefined;
235
+ error?: Error | undefined;
236
+ };
237
+ parseText: (text: string) => {
238
+ success: boolean;
239
+ parsed: string[];
240
+ };
241
+ parseErrors: (output: any) => string[];
242
+ parseWarnings: (output: any) => string[];
243
+ };
244
+ project: {
245
+ getProjectSettings: () => Promise<import("../types/socketMessageTypes").GetProjectSettingsResponse>;
246
+ getProjectPath: () => Promise<import("../types/socketMessageTypes").GetProjectPathResponse>;
247
+ getRepoMap: (message: any) => Promise<import("../types/socketMessageTypes").GetProjectPathResponse>;
248
+ runProject: () => void;
249
+ getEditorFileStatus: () => Promise<any>;
250
+ };
251
+ dbmemory: {
252
+ addKnowledge: (key: string, value: any) => Promise<import("../types/socketMessageTypes").MemorySetResponse>;
253
+ getKnowledge: (key: string) => Promise<import("../types/socketMessageTypes").MemoryGetResponse>;
254
+ };
255
+ cbstate: {
256
+ getApplicationState: () => Promise<import("../types/commonTypes").ApplicationState>;
257
+ addToAgentState: (key: string, value: string) => Promise<import("../types/socketMessageTypes").AddToAgentStateResponse>;
258
+ getAgentState: () => Promise<import("../types/socketMessageTypes").GetAgentStateResponse>;
259
+ getProjectState: () => Promise<import("../types/socketMessageTypes").GetProjectStateResponse>;
260
+ updateProjectState: (key: string, value: any) => Promise<import("../types/socketMessageTypes").UpdateProjectStateResponse>;
261
+ };
262
+ taskplaner: {
263
+ addTask: (params: import("../types/libFunctionTypes").TaskCreateOptions) => Promise<import("../types/commonTypes").TaskResponse>;
264
+ addSimpleTask: (task: string, agentId?: string) => Promise<import("../types/commonTypes").TaskResponse>;
265
+ getTasks: (filters?: import("../types/libFunctionTypes").TaskFilterOptions) => Promise<import("../types/commonTypes").TaskResponse>;
266
+ getTasksByAgent: (agentId: string) => Promise<import("../types/commonTypes").TaskResponse>;
267
+ getTasksByCategory: (category: string) => Promise<import("../types/commonTypes").TaskResponse>;
268
+ getAllAgents: () => Promise<import("../types/commonTypes").TaskResponse>;
269
+ updateTask: (params: import("../types/libFunctionTypes").TaskUpdateOptions) => Promise<import("../types/commonTypes").TaskResponse>;
270
+ updateSimpleTask: (taskId: string, task: string) => Promise<import("../types/commonTypes").TaskResponse>;
271
+ deleteTask: (taskId: string) => Promise<import("../types/commonTypes").TaskResponse>;
272
+ addSubTask: (params: import("../types/libFunctionTypes").AddSubTaskOptions) => Promise<import("../types/commonTypes").TaskResponse>;
273
+ updateSubTask: (params: import("../types/libFunctionTypes").UpdateSubTaskOptions) => Promise<import("../types/commonTypes").TaskResponse>;
274
+ deleteSubTask: (taskId: string, subtaskId: string) => Promise<import("../types/commonTypes").TaskResponse>;
275
+ createTasksFromMarkdown: (params: import("../types/libFunctionTypes").TaskMarkdownImportOptions) => Promise<import("../types/commonTypes").TaskResponse>;
276
+ exportTasksToMarkdown: (params?: import("../types/libFunctionTypes").TaskMarkdownExportOptions) => Promise<import("../types/commonTypes").TaskResponse>;
277
+ toggleTaskCompletion: (taskId: string, completed: boolean) => Promise<import("../types/commonTypes").TaskResponse>;
278
+ toggleSubTaskCompletion: (taskId: string, subtaskId: string, completed: boolean) => Promise<import("../types/commonTypes").TaskResponse>;
279
+ moveTaskToAgent: (taskId: string, newAgentId: string) => Promise<import("../types/commonTypes").TaskResponse>;
280
+ setTaskPriority: (taskId: string, priority: "low" | "medium" | "high") => Promise<import("../types/commonTypes").TaskResponse>;
281
+ addTaskTags: (taskId: string, tags: string[]) => Promise<import("../types/commonTypes").TaskResponse>;
282
+ createQuickTask: (title: string, agentId?: string, category?: string | undefined) => Promise<import("../types/commonTypes").TaskResponse>;
283
+ };
284
+ vectordb: {
285
+ getVector: (key: string) => Promise<import("../types/socketMessageTypes").GetVectorResponse>;
286
+ addVectorItem: (item: any) => Promise<import("../types/socketMessageTypes").AddVectorItemResponse>;
287
+ queryVectorItem: (key: string) => Promise<import("../types/socketMessageTypes").QueryVectorItemResponse>;
288
+ queryVectorItems: (items: [], dbPath: string) => Promise<import("../types/socketMessageTypes").QueryVectorItemResponse>;
289
+ };
290
+ debug: {
291
+ debug: (log: string, type: import("../modules/debug").logType) => Promise<import("../types/socketMessageTypes").DebugAddLogResponse>;
292
+ openDebugBrowser: (url: string, port: number) => Promise<import("../types/socketMessageTypes").OpenDebugBrowserResponse>;
293
+ };
294
+ tokenizer: {
295
+ addToken: (key: string) => Promise<import("../types/socketMessageTypes").AddTokenResponse>;
296
+ getToken: (key: string) => Promise<import("../types/socketMessageTypes").GetTokenResponse>;
297
+ };
298
+ chatSummary: {
299
+ summarizeAll: () => Promise<import("../types/socketMessageTypes").GetSummarizeAllResponse>;
300
+ summarize: (messages: {
301
+ role: string;
302
+ content: string;
303
+ }[], depth: number) => Promise<import("../types/socketMessageTypes").GetSummarizeResponse>;
304
+ };
305
+ mcp: {
306
+ getEnabledMCPServers: () => Promise<import("../types/socketMessageTypes").GetEnabledToolBoxesResponse>;
307
+ getLocalMCPServers: () => Promise<import("../types/socketMessageTypes").GetLocalToolBoxesResponse>;
308
+ getMentionedMCPServers: (userMessage: import("../utils").UserMessage) => Promise<import("../types/socketMessageTypes").GetAvailableToolBoxesResponse>;
309
+ searchAvailableMCPServers: (query: string) => Promise<import("../types/socketMessageTypes").SearchAvailableToolBoxesResponse>;
310
+ listMcpFromServers: (toolBoxes: string[]) => Promise<import("../types/socketMessageTypes").ListToolsFromToolBoxesResponse>;
311
+ configureMCPServer: (name: string, config: any) => Promise<import("../types/socketMessageTypes").ConfigureToolBoxResponse>;
312
+ getTools: (tools: {
313
+ toolbox: string;
314
+ toolName: string;
315
+ }[]) => Promise<import("../types/socketMessageTypes").GetToolsResponse>;
316
+ executeTool: (toolbox: string, toolName: string, params: any) => Promise<import("../types/socketMessageTypes").ExecuteToolResponse>;
317
+ };
318
+ agent: {
319
+ findAgent: (task: string, maxResult: number | undefined, agents: never[] | undefined, agentLocaltion: import("../modules/agent").AgentLocation | undefined, getFrom: import("../modules/agent").FilterUsing.USE_VECTOR_DB) => Promise<import("../types/socketMessageTypes").FindAgentByTaskResponse>;
320
+ startAgent: (agentId: string, task: string) => Promise<import("../types/socketMessageTypes").TaskCompletionResponse>;
321
+ getAgentsList: (type?: import("../modules/agent").Agents) => Promise<import("../types/socketMessageTypes").ListAgentsResponse>;
322
+ getAgentsDetail: (agentList?: never[]) => Promise<import("../types/socketMessageTypes").AgentsDetailResponse>;
323
+ };
324
+ utils: {
325
+ editFileAndApplyDiff: (filePath: string, diff: string, diffIdentifier: string, prompt: string, applyModel?: string | undefined) => Promise<import("../types/socketMessageTypes").FsEditFileAndApplyDiffResponse>;
326
+ };
327
+ notify: NotificationFunctions;
328
+ /**
329
+ * Sets up a handler function to be executed when the WebSocket connection is established.
330
+ * If the connection is already established, the handler will be executed immediately.
331
+ * @param {Function} handler - The handler function to call when the connection is ready.
332
+ * @returns {void}
333
+ */
334
+ onReady(handler: () => void | Promise<void>): void;
335
+ /**
336
+ * Sets up a listener for incoming messages with a direct handler function.
337
+ * @param {Function} handler - The handler function to call when a message is received.
338
+ * @returns {void}
339
+ */
340
+ onMessage(handler: (userMessage: UserMessage) => void | Promise<void> | any | Promise<any>): void;
341
+ }
342
+ export default Codebolt;
@@ -0,0 +1,201 @@
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
+ const websocket_1 = __importDefault(require("./websocket"));
7
+ const fs_1 = __importDefault(require("../modules/fs"));
8
+ const llm_1 = __importDefault(require("../modules/llm"));
9
+ const terminal_1 = __importDefault(require("../modules/terminal"));
10
+ const browser_1 = __importDefault(require("../modules/browser"));
11
+ const chat_1 = __importDefault(require("../modules/chat"));
12
+ const codeutils_1 = __importDefault(require("../modules/codeutils"));
13
+ const crawler_1 = __importDefault(require("../modules/crawler"));
14
+ const search_1 = __importDefault(require("../modules/search"));
15
+ const knowledge_1 = __importDefault(require("../modules/knowledge"));
16
+ const rag_1 = __importDefault(require("../modules/rag"));
17
+ const codeparsers_1 = __importDefault(require("../modules/codeparsers"));
18
+ const outputparsers_1 = __importDefault(require("../modules/outputparsers"));
19
+ const project_1 = __importDefault(require("../modules/project"));
20
+ const git_1 = __importDefault(require("../modules/git"));
21
+ const dbmemory_1 = __importDefault(require("../modules/dbmemory"));
22
+ const state_1 = __importDefault(require("../modules/state"));
23
+ const task_1 = __importDefault(require("../modules/task"));
24
+ const vectordb_1 = __importDefault(require("../modules/vectordb"));
25
+ const debug_1 = __importDefault(require("../modules/debug"));
26
+ const tokenizer_1 = __importDefault(require("../modules/tokenizer"));
27
+ const history_1 = require("../modules/history");
28
+ const mcp_1 = __importDefault(require("../modules/mcp"));
29
+ const agent_1 = __importDefault(require("../modules/agent"));
30
+ const utils_1 = __importDefault(require("../modules/utils"));
31
+ const notificationfunctions_1 = require("../notificationfunctions");
32
+ /**
33
+ * @class Codebolt
34
+ * @description This class provides a unified interface to interact with various modules.
35
+ */
36
+ class Codebolt {
37
+ /**
38
+ * @constructor
39
+ * @description Initializes the websocket connection.
40
+ */
41
+ constructor() {
42
+ this.websocket = null;
43
+ this.isReady = false;
44
+ this.readyHandlers = [];
45
+ this.fs = fs_1.default;
46
+ this.git = git_1.default;
47
+ this.llm = llm_1.default;
48
+ this.browser = browser_1.default;
49
+ this.chat = chat_1.default;
50
+ this.terminal = terminal_1.default;
51
+ this.codeutils = codeutils_1.default;
52
+ this.crawler = crawler_1.default;
53
+ this.search = search_1.default;
54
+ this.knowledge = knowledge_1.default;
55
+ this.rag = rag_1.default;
56
+ this.codeparsers = codeparsers_1.default;
57
+ this.outputparsers = outputparsers_1.default;
58
+ this.project = project_1.default;
59
+ this.dbmemory = dbmemory_1.default;
60
+ this.cbstate = state_1.default;
61
+ this.taskplaner = task_1.default;
62
+ this.vectordb = vectordb_1.default;
63
+ this.debug = debug_1.default;
64
+ this.tokenizer = tokenizer_1.default;
65
+ this.chatSummary = history_1.chatSummary;
66
+ this.mcp = mcp_1.default;
67
+ this.agent = agent_1.default;
68
+ this.utils = utils_1.default;
69
+ this.notify = notificationfunctions_1.notificationFunctions;
70
+ console.log("Codebolt Agent initialized");
71
+ this.readyPromise = this.initializeConnection();
72
+ }
73
+ /**
74
+ * @method initializeConnection
75
+ * @description Initializes the WebSocket connection asynchronously.
76
+ * @private
77
+ */
78
+ async initializeConnection() {
79
+ try {
80
+ await websocket_1.default.initializeWebSocket();
81
+ this.websocket = websocket_1.default.getWebsocket;
82
+ this.isReady = true;
83
+ console.log("Codebolt WebSocket connection established");
84
+ // Execute all registered ready handlers
85
+ for (const handler of this.readyHandlers) {
86
+ try {
87
+ await handler();
88
+ }
89
+ catch (error) {
90
+ console.error('Error executing ready handler:', error);
91
+ }
92
+ }
93
+ }
94
+ catch (error) {
95
+ console.error('Failed to initialize WebSocket connection:', error);
96
+ throw error;
97
+ }
98
+ }
99
+ /**
100
+ * @method waitForReady
101
+ * @description Waits for the Codebolt instance to be fully initialized.
102
+ * @returns {Promise<void>} A promise that resolves when the instance is ready.
103
+ */
104
+ async waitForReady() {
105
+ return this.readyPromise;
106
+ }
107
+ /**
108
+ * @method isReady
109
+ * @description Checks if the Codebolt instance is ready for use.
110
+ * @returns {boolean} True if the instance is ready, false otherwise.
111
+ */
112
+ get ready() {
113
+ return this.isReady;
114
+ }
115
+ /**
116
+ * Sets up a handler function to be executed when the WebSocket connection is established.
117
+ * If the connection is already established, the handler will be executed immediately.
118
+ * @param {Function} handler - The handler function to call when the connection is ready.
119
+ * @returns {void}
120
+ */
121
+ onReady(handler) {
122
+ if (this.isReady) {
123
+ // If already ready, execute the handler immediately
124
+ try {
125
+ const result = handler();
126
+ if (result instanceof Promise) {
127
+ result.catch(error => {
128
+ console.error('Error in ready handler:', error);
129
+ });
130
+ }
131
+ }
132
+ catch (error) {
133
+ console.error('Error in ready handler:', error);
134
+ }
135
+ }
136
+ else {
137
+ // If not ready yet, add to the list of handlers to execute when ready
138
+ this.readyHandlers.push(handler);
139
+ }
140
+ }
141
+ /**
142
+ * Sets up a listener for incoming messages with a direct handler function.
143
+ * @param {Function} handler - The handler function to call when a message is received.
144
+ * @returns {void}
145
+ */
146
+ onMessage(handler) {
147
+ // Wait for the WebSocket to be ready before setting up the handler
148
+ this.waitForReady().then(() => {
149
+ const handleUserMessage = async (response) => {
150
+ var _a, _b;
151
+ console.log("Message received By Agent Library Starting Custom Agent Handler Logic");
152
+ if (response.type === "messageResponse") {
153
+ try {
154
+ // Extract user-facing message from internal socket message
155
+ const userMessage = {
156
+ type: response.type,
157
+ userMessage: response.message.userMessage,
158
+ currentFile: response.message.currentFile,
159
+ mentionedFiles: response.message.mentionedFiles || [],
160
+ mentionedFullPaths: response.message.mentionedFullPaths || [],
161
+ mentionedFolders: response.message.mentionedFolders || [],
162
+ uploadedImages: response.message.uploadedImages || [],
163
+ mentionedMCPs: response.message.mentionedMCPs || [],
164
+ selectedAgent: {
165
+ id: ((_a = response.message.selectedAgent) === null || _a === void 0 ? void 0 : _a.id) || '',
166
+ name: ((_b = response.message.selectedAgent) === null || _b === void 0 ? void 0 : _b.name) || ''
167
+ },
168
+ messageId: response.message.messageId,
169
+ threadId: response.message.threadId,
170
+ selection: response.message.selection,
171
+ remixPrompt: response.message.remixPrompt,
172
+ mentionedAgents: response.message.mentionedAgents
173
+ };
174
+ const result = await handler(userMessage);
175
+ // Send processStoped with optional message
176
+ const message = {
177
+ "type": "processStoped"
178
+ };
179
+ // If handler returned data, include it as message
180
+ if (result !== undefined && result !== null) {
181
+ message.message = result;
182
+ }
183
+ websocket_1.default.messageManager.send(message);
184
+ }
185
+ catch (error) {
186
+ console.error('Error in user message handler:', error);
187
+ // Send processStoped even if there's an error
188
+ websocket_1.default.messageManager.send({
189
+ "type": "processStoped",
190
+ "error": error instanceof Error ? error.message : "Unknown error occurred"
191
+ });
192
+ }
193
+ }
194
+ };
195
+ websocket_1.default.messageManager.on('message', handleUserMessage);
196
+ }).catch(error => {
197
+ console.error('Failed to set up message handler:', error);
198
+ });
199
+ }
200
+ }
201
+ exports.default = Codebolt;
@@ -65,7 +65,8 @@ class cbws {
65
65
  const parentAgentInstanceIdParam = process.env.parentAgentInstanceId ? `&parentAgentInstanceId=${process.env.parentAgentInstanceId}` : '';
66
66
  const agentTask = process.env.agentTask ? `&agentTask=${process.env.agentTask}` : '';
67
67
  const socketPort = process.env.SOCKET_PORT || '12345';
68
- const wsUrl = `ws://localhost:${socketPort}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${process.env.Is_Dev ? '&dev=true' : ''}`;
68
+ const serverUrl = process.env.CODEBOLT_SERVER_URL || 'localhost';
69
+ const wsUrl = `ws://${serverUrl}:${socketPort}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${process.env.Is_Dev ? '&dev=true' : ''}`;
69
70
  console.log('[WebSocket] Connecting to:', wsUrl);
70
71
  this.websocket = new ws_1.default(wsUrl);
71
72
  return new Promise((resolve, reject) => {