@codebolt/codeboltjs 2.0.11 → 2.0.13
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/Readme.md +138 -4
- package/dist/core/Codebolt.d.ts +310 -0
- package/dist/core/Codebolt.js +159 -0
- package/dist/index.d.ts +4 -300
- package/dist/index.js +11 -137
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.js +15 -0
- package/dist/types/libFunctionTypes.d.ts +30 -1
- package/package.json +2 -2
package/Readme.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# Codebolt Agent Library
|
|
2
2
|
|
|
3
|
-
This library provides a set of tools and utilities for creating Codebolt agents, enabling seamless integration with the Codebolt platform.
|
|
3
|
+
This library provides a set of tools and utilities for creating Codebolt agents, enabling seamless integration with the Codebolt platform with full TypeScript support.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
- Create and manage Codebolt agents
|
|
7
7
|
- Interact with the Codebolt platform
|
|
8
8
|
- Utilize Codebolt's powerful API
|
|
9
|
+
- **Full TypeScript support with comprehensive type definitions**
|
|
10
|
+
- Type-safe API interactions
|
|
11
|
+
- IntelliSense support in TypeScript/JavaScript IDEs
|
|
9
12
|
|
|
10
13
|
## Installation
|
|
11
14
|
|
|
@@ -13,12 +16,137 @@ This library provides a set of tools and utilities for creating Codebolt agents,
|
|
|
13
16
|
npm install @codebolt/codeboltjs
|
|
14
17
|
```
|
|
15
18
|
|
|
16
|
-
##
|
|
19
|
+
## Quick Start
|
|
17
20
|
|
|
21
|
+
### JavaScript
|
|
18
22
|
```javascript
|
|
19
23
|
const codebolt = require('@codebolt/codeboltjs');
|
|
20
24
|
|
|
21
|
-
//
|
|
25
|
+
// Set up message handling
|
|
26
|
+
codebolt.onMessage(async (userMessage) => {
|
|
27
|
+
console.log('User said:', userMessage.userMessage);
|
|
28
|
+
|
|
29
|
+
// Read a file
|
|
30
|
+
const content = await codebolt.fs.readFile({ path: './example.txt' });
|
|
31
|
+
console.log('File content:', content);
|
|
32
|
+
|
|
33
|
+
return { status: 'completed' };
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### TypeScript
|
|
38
|
+
```typescript
|
|
39
|
+
import codebolt from 'codeboltjs';
|
|
40
|
+
import type {
|
|
41
|
+
ChatMessageFromUser,
|
|
42
|
+
ReadFileOptions,
|
|
43
|
+
BrowserScreenshotOptions
|
|
44
|
+
} from 'codeboltjs';
|
|
45
|
+
|
|
46
|
+
// Type-safe message handling
|
|
47
|
+
codebolt.onMessage(async (userMessage: ChatMessageFromUser) => {
|
|
48
|
+
console.log('User said:', userMessage.userMessage);
|
|
49
|
+
console.log('Mentioned files:', userMessage.mentionedFiles);
|
|
50
|
+
|
|
51
|
+
// Type-safe file operations
|
|
52
|
+
const readOptions: ReadFileOptions = {
|
|
53
|
+
path: './config.json',
|
|
54
|
+
encoding: 'utf8',
|
|
55
|
+
askForPermission: true
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const content = await codebolt.fs.readFile(readOptions);
|
|
59
|
+
|
|
60
|
+
// Type-safe browser operations
|
|
61
|
+
const screenshotOptions: BrowserScreenshotOptions = {
|
|
62
|
+
fullPage: true,
|
|
63
|
+
quality: 90,
|
|
64
|
+
format: 'png'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const screenshot = await codebolt.browser.takeScreenshot(screenshotOptions);
|
|
68
|
+
|
|
69
|
+
return { status: 'completed', data: content };
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## TypeScript Support
|
|
74
|
+
|
|
75
|
+
This library provides comprehensive TypeScript support with over 200+ type definitions covering:
|
|
76
|
+
|
|
77
|
+
### Core Types
|
|
78
|
+
- **Message & Tool Types**: `Message`, `ToolCall`, `Tool`, `LLMInferenceParams`
|
|
79
|
+
- **API Response Types**: `APIResponse`, `SuccessResponse`, `FailureResponse`
|
|
80
|
+
- **Configuration Types**: `CodeboltConfig`, `AgentConfiguration`
|
|
81
|
+
|
|
82
|
+
### Module-Specific Types
|
|
83
|
+
- **File System**: `ReadFileOptions`, `WriteFileOptions`, `SearchFilesOptions`
|
|
84
|
+
- **Browser**: `BrowserNavigationOptions`, `BrowserScreenshotOptions`
|
|
85
|
+
- **Terminal**: `TerminalExecuteOptions`
|
|
86
|
+
- **Git**: `GitCommitOptions`, `GitLogOptions`
|
|
87
|
+
- **LLM**: `LLMChatOptions`, `OpenAIMessage`
|
|
88
|
+
- **Vector DB**: `VectorAddOptions`, `VectorQueryOptions`
|
|
89
|
+
|
|
90
|
+
### Import Strategies
|
|
91
|
+
|
|
92
|
+
#### From Main Package
|
|
93
|
+
```typescript
|
|
94
|
+
import codebolt, { type Message, type ToolCall } from 'codeboltjs';
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### From Types Barrel (Recommended)
|
|
98
|
+
```typescript
|
|
99
|
+
import codebolt from 'codeboltjs';
|
|
100
|
+
import type { Message, ToolCall, LLMChatOptions } from 'codeboltjs/types';
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Namespace Import
|
|
104
|
+
```typescript
|
|
105
|
+
import codebolt from 'codeboltjs';
|
|
106
|
+
import type * as CodeboltTypes from 'codeboltjs/types';
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
For detailed type usage examples, see [TYPES.md](./TYPES.md).
|
|
110
|
+
|
|
111
|
+
## API Overview
|
|
112
|
+
|
|
113
|
+
### Core Modules
|
|
114
|
+
|
|
115
|
+
- `codebolt.fs` - File system operations
|
|
116
|
+
- `codebolt.git` - Git operations
|
|
117
|
+
- `codebolt.browser` - Browser automation
|
|
118
|
+
- `codebolt.terminal` - Terminal/shell operations
|
|
119
|
+
- `codebolt.llm` - LLM interactions
|
|
120
|
+
- `codebolt.chat` - Chat management
|
|
121
|
+
- `codebolt.agent` - Agent operations
|
|
122
|
+
- `codebolt.vectordb` - Vector database operations
|
|
123
|
+
- `codebolt.mcp` - MCP (Model Context Protocol) tools
|
|
124
|
+
|
|
125
|
+
### Example Usage
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
// Wait for connection
|
|
129
|
+
await codebolt.waitForReady();
|
|
130
|
+
|
|
131
|
+
// File operations
|
|
132
|
+
const files = await codebolt.fs.listFiles({ path: './src', recursive: true });
|
|
133
|
+
const content = await codebolt.fs.readFile({ path: './package.json' });
|
|
134
|
+
|
|
135
|
+
// Browser operations
|
|
136
|
+
await codebolt.browser.navigateTo({ url: 'https://example.com' });
|
|
137
|
+
const screenshot = await codebolt.browser.takeScreenshot({ fullPage: true });
|
|
138
|
+
|
|
139
|
+
// Terminal operations
|
|
140
|
+
const result = await codebolt.terminal.execute({
|
|
141
|
+
command: 'npm install',
|
|
142
|
+
cwd: './my-project'
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// LLM operations
|
|
146
|
+
const response = await codebolt.llm.chat({
|
|
147
|
+
messages: [{ role: 'user', content: 'Explain TypeScript' }],
|
|
148
|
+
temperature: 0.7
|
|
149
|
+
});
|
|
22
150
|
```
|
|
23
151
|
|
|
24
152
|
## Development
|
|
@@ -64,11 +192,17 @@ The project supports two build methods:
|
|
|
64
192
|
### Project Structure
|
|
65
193
|
|
|
66
194
|
- `src/` - TypeScript source code
|
|
195
|
+
- `core/` - Core library classes (Codebolt class, WebSocket management)
|
|
196
|
+
- `modules/` - Feature modules (fs, git, browser, etc.)
|
|
197
|
+
- `types/` - TypeScript type definitions
|
|
198
|
+
- `utils/` - Utility functions
|
|
67
199
|
- `dist/` - Compiled JavaScript and type definitions (generated by TypeScript)
|
|
68
200
|
- `build/` - Webpack bundle (generated by webpack)
|
|
69
201
|
- `docs/` - Generated documentation
|
|
70
202
|
|
|
71
203
|
## Documentation
|
|
72
204
|
|
|
73
|
-
|
|
205
|
+
- **[Type Definitions Guide](./TYPES.md)** - Comprehensive TypeScript usage guide
|
|
206
|
+
- **[Codebolt Documentation](https://docs.codebolt.ai)** - Platform documentation
|
|
207
|
+
- **API Reference** - Generated from source code (coming soon)
|
|
74
208
|
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import WebSocket from 'ws';
|
|
3
|
+
import type { UserMessage } from '../types/libFunctionTypes';
|
|
4
|
+
/**
|
|
5
|
+
* @class Codebolt
|
|
6
|
+
* @description This class provides a unified interface to interact with various modules.
|
|
7
|
+
*/
|
|
8
|
+
declare class Codebolt {
|
|
9
|
+
websocket: WebSocket | null;
|
|
10
|
+
private isReady;
|
|
11
|
+
private readyPromise;
|
|
12
|
+
/**
|
|
13
|
+
* @constructor
|
|
14
|
+
* @description Initializes the websocket connection.
|
|
15
|
+
*/
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* @method initializeConnection
|
|
19
|
+
* @description Initializes the WebSocket connection asynchronously.
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
private initializeConnection;
|
|
23
|
+
/**
|
|
24
|
+
* @method waitForReady
|
|
25
|
+
* @description Waits for the Codebolt instance to be fully initialized.
|
|
26
|
+
* @returns {Promise<void>} A promise that resolves when the instance is ready.
|
|
27
|
+
*/
|
|
28
|
+
waitForReady(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* @method isReady
|
|
31
|
+
* @description Checks if the Codebolt instance is ready for use.
|
|
32
|
+
* @returns {boolean} True if the instance is ready, false otherwise.
|
|
33
|
+
*/
|
|
34
|
+
get ready(): boolean;
|
|
35
|
+
fs: {
|
|
36
|
+
createFile: (fileName: string, source: string, filePath: string) => Promise<import("../types/socketMessageTypes").CreateFileResponse>;
|
|
37
|
+
createFolder: (folderName: string, folderPath: string) => Promise<import("../types/socketMessageTypes").CreateFolderResponse>;
|
|
38
|
+
readFile: (filePath: string) => Promise<import("../types/socketMessageTypes").ReadFileResponse>;
|
|
39
|
+
updateFile: (filename: string, filePath: string, newContent: string) => Promise<import("../types/socketMessageTypes").UpdateFileResponse>;
|
|
40
|
+
deleteFile: (filename: string, filePath: string) => Promise<import("../types/socketMessageTypes").DeleteFileResponse>;
|
|
41
|
+
deleteFolder: (foldername: string, folderpath: string) => Promise<import("../types/socketMessageTypes").DeleteFolderResponse>;
|
|
42
|
+
listFile: (folderPath: string, isRecursive?: boolean) => Promise<any>;
|
|
43
|
+
listCodeDefinitionNames: (path: string) => Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
result: any;
|
|
46
|
+
}>;
|
|
47
|
+
searchFiles: (path: string, regex: string, filePattern: string) => Promise<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
result: any;
|
|
50
|
+
}>;
|
|
51
|
+
writeToFile: (relPath: string, newContent: string) => Promise<any>;
|
|
52
|
+
grepSearch: (path: string, query: string, includePattern?: string | undefined, excludePattern?: string | undefined, caseSensitive?: boolean) => Promise<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
result: any;
|
|
55
|
+
}>;
|
|
56
|
+
fileSearch: (query: string) => Promise<{
|
|
57
|
+
success: boolean;
|
|
58
|
+
result: any;
|
|
59
|
+
}>;
|
|
60
|
+
editFileWithDiff: (targetFile: string, codeEdit: string, diffIdentifier: string, prompt: string, applyModel?: string | undefined) => Promise<{
|
|
61
|
+
success: boolean;
|
|
62
|
+
result: any;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
git: {
|
|
66
|
+
init: (path: string) => Promise<import("../types/socketMessageTypes").GitInitResponse>;
|
|
67
|
+
pull: () => Promise<import("../types/socketMessageTypes").GitPullResponse>;
|
|
68
|
+
push: () => Promise<import("../types/socketMessageTypes").GitPushResponse>;
|
|
69
|
+
status: () => Promise<import("../types/socketMessageTypes").GitStatusResponse>;
|
|
70
|
+
addAll: () => Promise<import("../types/socketMessageTypes").AddResponse>;
|
|
71
|
+
commit: (message: string) => Promise<import("../types/socketMessageTypes").GitCommitResponse>;
|
|
72
|
+
checkout: (branch: string) => Promise<import("../types/socketMessageTypes").GitCheckoutResponse>;
|
|
73
|
+
branch: (branch: string) => Promise<import("../types/socketMessageTypes").GitBranchResponse>;
|
|
74
|
+
logs: (path: string) => Promise<import("../types/socketMessageTypes").GitLogsResponse>;
|
|
75
|
+
diff: (commitHash: string) => Promise<import("../types/socketMessageTypes").GitDiffResponse>;
|
|
76
|
+
};
|
|
77
|
+
llm: {
|
|
78
|
+
inference: (message: string, llmrole: string) => Promise<import("../types/socketMessageTypes").LLMResponse>;
|
|
79
|
+
};
|
|
80
|
+
browser: {
|
|
81
|
+
newPage: () => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
|
|
82
|
+
getUrl: () => Promise<import("../types/socketMessageTypes").UrlResponse>;
|
|
83
|
+
goToPage: (url: string) => Promise<import("../types/socketMessageTypes").GoToPageResponse>;
|
|
84
|
+
screenshot: () => Promise<import("../types/socketMessageTypes").BrowserScreenshotResponse>;
|
|
85
|
+
getHTML: () => Promise<import("../types/socketMessageTypes").HtmlReceived>;
|
|
86
|
+
getMarkdown: () => Promise<import("../types/socketMessageTypes").GetMarkdownResponse>;
|
|
87
|
+
getPDF: () => void;
|
|
88
|
+
pdfToText: () => void;
|
|
89
|
+
getContent: () => Promise<import("../types/socketMessageTypes").GetContentResponse>;
|
|
90
|
+
getSnapShot: () => Promise<import("../types/socketMessageTypes").BrowserSnapshotResponse>;
|
|
91
|
+
getBrowserInfo: () => Promise<import("../types/socketMessageTypes").BrowserInfoResponse>;
|
|
92
|
+
extractText: () => Promise<import("../types/socketMessageTypes").ExtractTextResponse>;
|
|
93
|
+
close: () => void;
|
|
94
|
+
scroll: (direction: string, pixels: string) => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
|
|
95
|
+
type: (elementid: string, text: string) => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
|
|
96
|
+
click: (elementid: string) => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
|
|
97
|
+
enter: () => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
|
|
98
|
+
search: (elementid: string, query: string) => Promise<import("../types/socketMessageTypes").BrowserActionResponseData>;
|
|
99
|
+
};
|
|
100
|
+
chat: {
|
|
101
|
+
getChatHistory: () => Promise<import("../types/socketMessageTypes").ChatMessage[]>;
|
|
102
|
+
setRequestHandler: (handler: (request: any, response: (data: any) => void) => void | Promise<void>) => void;
|
|
103
|
+
sendMessage: (message: string, payload: any) => void;
|
|
104
|
+
waitforReply: (message: string) => Promise<import("../types/socketMessageTypes").UserMessage>;
|
|
105
|
+
processStarted: (onStopClicked?: ((message: any) => void) | undefined) => {
|
|
106
|
+
stopProcess: () => void;
|
|
107
|
+
cleanup: () => void;
|
|
108
|
+
} | {
|
|
109
|
+
stopProcess: () => void;
|
|
110
|
+
cleanup?: undefined;
|
|
111
|
+
};
|
|
112
|
+
stopProcess: () => void;
|
|
113
|
+
processFinished: () => void;
|
|
114
|
+
sendConfirmationRequest: (confirmationMessage: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
|
|
115
|
+
askQuestion: (question: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
|
|
116
|
+
sendNotificationEvent: (notificationMessage: string, type: "browser" | "terminal" | "git" | "debug" | "planner" | "editor" | "preview") => void;
|
|
117
|
+
};
|
|
118
|
+
terminal: {
|
|
119
|
+
eventEmitter: {
|
|
120
|
+
cleanup?: (() => void) | undefined;
|
|
121
|
+
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
|
|
122
|
+
addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
123
|
+
on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
124
|
+
once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
125
|
+
removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
126
|
+
off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
127
|
+
removeAllListeners(eventName?: string | symbol | undefined): any;
|
|
128
|
+
setMaxListeners(n: number): any;
|
|
129
|
+
getMaxListeners(): number;
|
|
130
|
+
listeners<K_6>(eventName: string | symbol): Function[];
|
|
131
|
+
rawListeners<K_7>(eventName: string | symbol): Function[];
|
|
132
|
+
emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
|
|
133
|
+
listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
|
|
134
|
+
prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
135
|
+
prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
136
|
+
eventNames(): (string | symbol)[];
|
|
137
|
+
};
|
|
138
|
+
executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<any>;
|
|
139
|
+
executeCommandRunUntilError: (command: string, executeInMain?: boolean) => Promise<import("../types/socketMessageTypes").CommandError>;
|
|
140
|
+
sendManualInterrupt(): Promise<import("../types/socketMessageTypes").TerminalInterruptResponse>;
|
|
141
|
+
executeCommandWithStream(command: string, executeInMain?: boolean): {
|
|
142
|
+
cleanup?: (() => void) | undefined;
|
|
143
|
+
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
|
|
144
|
+
addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
145
|
+
on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
146
|
+
once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
147
|
+
removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
148
|
+
off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
149
|
+
removeAllListeners(eventName?: string | symbol | undefined): any;
|
|
150
|
+
setMaxListeners(n: number): any;
|
|
151
|
+
getMaxListeners(): number;
|
|
152
|
+
listeners<K_6>(eventName: string | symbol): Function[];
|
|
153
|
+
rawListeners<K_7>(eventName: string | symbol): Function[];
|
|
154
|
+
emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
|
|
155
|
+
listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
|
|
156
|
+
prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
157
|
+
prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
158
|
+
eventNames(): (string | symbol)[];
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
codeutils: {
|
|
162
|
+
getJsTree: (filePath?: string | undefined) => Promise<import("../types/InternalTypes").JSTreeResponse>;
|
|
163
|
+
getAllFilesAsMarkDown: () => Promise<string>;
|
|
164
|
+
performMatch: (matcherDefinition: object, problemPatterns: any[], problems?: any[]) => Promise<import("../types/socketMessageTypes").MatchProblemResponse>;
|
|
165
|
+
getMatcherList: () => Promise<import("../types/socketMessageTypes").GetMatcherListTreeResponse>;
|
|
166
|
+
matchDetail: (matcher: string) => Promise<import("../types/socketMessageTypes").getMatchDetail>;
|
|
167
|
+
};
|
|
168
|
+
crawler: {
|
|
169
|
+
start: () => void;
|
|
170
|
+
screenshot: () => void;
|
|
171
|
+
goToPage: (url: string) => void;
|
|
172
|
+
scroll: (direction: string) => void;
|
|
173
|
+
click: (id: string) => Promise<any>;
|
|
174
|
+
};
|
|
175
|
+
search: {
|
|
176
|
+
init: (engine?: string) => void;
|
|
177
|
+
search: (query: string) => Promise<string>;
|
|
178
|
+
get_first_link: (query: string) => Promise<string>;
|
|
179
|
+
};
|
|
180
|
+
knowledge: {};
|
|
181
|
+
rag: {
|
|
182
|
+
init: () => void;
|
|
183
|
+
add_file: (filename: string, file_path: string) => void;
|
|
184
|
+
retrieve_related_knowledge: (query: string, filename: string) => void;
|
|
185
|
+
};
|
|
186
|
+
codeparsers: {
|
|
187
|
+
getClassesInFile: (file: string) => Promise<{
|
|
188
|
+
error: string;
|
|
189
|
+
} | {
|
|
190
|
+
name: any;
|
|
191
|
+
location: string;
|
|
192
|
+
}[]>;
|
|
193
|
+
getFunctionsinClass: (file: string, className: string) => Promise<{
|
|
194
|
+
error: string;
|
|
195
|
+
} | {
|
|
196
|
+
name: string;
|
|
197
|
+
class: string;
|
|
198
|
+
location: string;
|
|
199
|
+
}[]>;
|
|
200
|
+
getAstTreeInFile: (file: string, className?: string | undefined) => Promise<import("..").ASTNode | {
|
|
201
|
+
error: string;
|
|
202
|
+
}>;
|
|
203
|
+
};
|
|
204
|
+
outputparsers: {
|
|
205
|
+
parseJSON: (jsonString: string) => {
|
|
206
|
+
success: boolean;
|
|
207
|
+
parsed?: any;
|
|
208
|
+
error?: Error | undefined;
|
|
209
|
+
};
|
|
210
|
+
parseXML: (xmlString: string) => {
|
|
211
|
+
success: boolean;
|
|
212
|
+
parsed?: any;
|
|
213
|
+
};
|
|
214
|
+
parseCSV: (csvString: string) => {
|
|
215
|
+
success: boolean;
|
|
216
|
+
parsed?: any[] | undefined;
|
|
217
|
+
error?: Error | undefined;
|
|
218
|
+
};
|
|
219
|
+
parseText: (text: string) => {
|
|
220
|
+
success: boolean;
|
|
221
|
+
parsed: string[]; /**
|
|
222
|
+
* @method isReady
|
|
223
|
+
* @description Checks if the Codebolt instance is ready for use.
|
|
224
|
+
* @returns {boolean} True if the instance is ready, false otherwise.
|
|
225
|
+
*/
|
|
226
|
+
};
|
|
227
|
+
parseErrors: (output: any) => string[];
|
|
228
|
+
parseWarnings: (output: any) => string[];
|
|
229
|
+
};
|
|
230
|
+
project: {
|
|
231
|
+
getProjectSettings: () => Promise<any>;
|
|
232
|
+
getProjectPath: () => Promise<import("../types/socketMessageTypes").GetProjectPathResponse>;
|
|
233
|
+
getRepoMap: (message: any) => Promise<import("../types/socketMessageTypes").GetProjectPathResponse>;
|
|
234
|
+
runProject: () => void;
|
|
235
|
+
getEditorFileStatus: () => Promise<any>;
|
|
236
|
+
};
|
|
237
|
+
dbmemory: {
|
|
238
|
+
addKnowledge: (key: string, value: any) => Promise<import("../types/socketMessageTypes").MemorySetResponse>;
|
|
239
|
+
getKnowledge: (key: string) => Promise<import("../types/socketMessageTypes").MemoryGetResponse>; /**
|
|
240
|
+
* @constructor
|
|
241
|
+
* @description Initializes the websocket connection.
|
|
242
|
+
*/
|
|
243
|
+
};
|
|
244
|
+
cbstate: {
|
|
245
|
+
getApplicationState: () => Promise<import("../types/commonTypes").ApplicationState>;
|
|
246
|
+
addToAgentState: (key: string, value: string) => Promise<import("../types/socketMessageTypes").AddToAgentStateResponse>;
|
|
247
|
+
getAgentState: () => Promise<import("../types/socketMessageTypes").GetAgentStateResponse>;
|
|
248
|
+
getProjectState: () => Promise<any>;
|
|
249
|
+
updateProjectState: (key: string, value: any) => Promise<any>;
|
|
250
|
+
};
|
|
251
|
+
taskplaner: {
|
|
252
|
+
addTask: (task: string) => Promise<any>;
|
|
253
|
+
getTasks: () => Promise<any>;
|
|
254
|
+
updateTask: (task: string) => Promise<any>;
|
|
255
|
+
};
|
|
256
|
+
vectordb: {
|
|
257
|
+
getVector: (key: string) => Promise<import("../types/socketMessageTypes").GetVectorResponse>;
|
|
258
|
+
addVectorItem: (item: any) => Promise<import("../types/socketMessageTypes").AddVectorItemResponse>;
|
|
259
|
+
queryVectorItem: (key: string) => Promise<import("../types/socketMessageTypes").QueryVectorItemResponse>;
|
|
260
|
+
queryVectorItems: (items: [], dbPath: string) => Promise<import("../types/socketMessageTypes").QueryVectorItemResponse>;
|
|
261
|
+
};
|
|
262
|
+
debug: {
|
|
263
|
+
debug: (log: string, type: import("../modules/debug").logType) => Promise<import("../types/socketMessageTypes").DebugAddLogResponse>;
|
|
264
|
+
openDebugBrowser: (url: string, port: number) => Promise<import("../types/socketMessageTypes").OpenDebugBrowserResponse>;
|
|
265
|
+
};
|
|
266
|
+
tokenizer: {
|
|
267
|
+
addToken: (key: string) => Promise<import("../types/socketMessageTypes").AddTokenResponse>;
|
|
268
|
+
getToken: (key: string) => Promise<import("../types/socketMessageTypes").GetTokenResponse>;
|
|
269
|
+
};
|
|
270
|
+
chatSummary: {
|
|
271
|
+
summarizeAll: () => Promise<import("../types/socketMessageTypes").GetSummarizeAllResponse>;
|
|
272
|
+
summarize: (messages: {
|
|
273
|
+
role: string;
|
|
274
|
+
content: string;
|
|
275
|
+
}[], depth: number) => Promise<import("../types/socketMessageTypes").GetSummarizeResponse>;
|
|
276
|
+
};
|
|
277
|
+
mcp: {
|
|
278
|
+
getEnabledMCPServers: () => Promise<import("../types/socketMessageTypes").GetEnabledToolBoxesResponse>;
|
|
279
|
+
getLocalMCPServers: () => Promise<import("../types/socketMessageTypes").GetLocalToolBoxesResponse>;
|
|
280
|
+
getMentionedMCPServers: (userMessage: import("../utils").UserMessage) => Promise<import("../types/socketMessageTypes").GetAvailableToolBoxesResponse>;
|
|
281
|
+
searchAvailableMCPServers: (query: string) => Promise<import("../types/socketMessageTypes").SearchAvailableToolBoxesResponse>;
|
|
282
|
+
listMcpFromServers: (toolBoxes: string[]) => Promise<import("../types/socketMessageTypes").ListToolsFromToolBoxesResponse>;
|
|
283
|
+
configureMCPServer: (name: string, config: any) => Promise<import("../types/socketMessageTypes").ConfigureToolBoxResponse>;
|
|
284
|
+
getTools: (tools: {
|
|
285
|
+
toolbox: string;
|
|
286
|
+
toolName: string;
|
|
287
|
+
}[]) => Promise<import("../types/socketMessageTypes").GetToolsResponse>;
|
|
288
|
+
executeTool: (toolbox: string, toolName: string, params: any) => Promise<import("../types/socketMessageTypes").ExecuteToolResponse>;
|
|
289
|
+
};
|
|
290
|
+
agent: {
|
|
291
|
+
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>;
|
|
292
|
+
/**
|
|
293
|
+
* @constructor
|
|
294
|
+
* @description Initializes the websocket connection.
|
|
295
|
+
*/
|
|
296
|
+
startAgent: (agentId: string, task: string) => Promise<import("../types/socketMessageTypes").TaskCompletionResponse>;
|
|
297
|
+
getAgentsList: (type?: import("../modules/agent").Agents) => Promise<import("../types/socketMessageTypes").ListAgentsResponse>;
|
|
298
|
+
getAgentsDetail: (agentList?: never[]) => Promise<import("../types/socketMessageTypes").AgentsDetailResponse>;
|
|
299
|
+
};
|
|
300
|
+
utils: {
|
|
301
|
+
editFileAndApplyDiff: (filePath: string, diff: string, diffIdentifier: string, prompt: string, applyModel?: string | undefined) => Promise<import("../types/socketMessageTypes").FsEditFileAndApplyDiffResponse>;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Sets up a listener for incoming messages with a direct handler function.
|
|
305
|
+
* @param {Function} handler - The handler function to call when a message is received.
|
|
306
|
+
* @returns {void}
|
|
307
|
+
*/
|
|
308
|
+
onMessage(handler: (userMessage: UserMessage) => void | Promise<void> | any | Promise<any>): void;
|
|
309
|
+
}
|
|
310
|
+
export default Codebolt;
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
/**
|
|
32
|
+
* @class Codebolt
|
|
33
|
+
* @description This class provides a unified interface to interact with various modules.
|
|
34
|
+
*/
|
|
35
|
+
class Codebolt {
|
|
36
|
+
/**
|
|
37
|
+
* @constructor
|
|
38
|
+
* @description Initializes the websocket connection.
|
|
39
|
+
*/
|
|
40
|
+
constructor() {
|
|
41
|
+
this.websocket = null;
|
|
42
|
+
this.isReady = false;
|
|
43
|
+
this.fs = fs_1.default;
|
|
44
|
+
this.git = git_1.default;
|
|
45
|
+
this.llm = llm_1.default;
|
|
46
|
+
this.browser = browser_1.default;
|
|
47
|
+
this.chat = chat_1.default;
|
|
48
|
+
this.terminal = terminal_1.default;
|
|
49
|
+
this.codeutils = codeutils_1.default;
|
|
50
|
+
this.crawler = crawler_1.default;
|
|
51
|
+
this.search = search_1.default;
|
|
52
|
+
this.knowledge = knowledge_1.default;
|
|
53
|
+
this.rag = rag_1.default;
|
|
54
|
+
this.codeparsers = codeparsers_1.default;
|
|
55
|
+
this.outputparsers = outputparsers_1.default;
|
|
56
|
+
this.project = project_1.default;
|
|
57
|
+
this.dbmemory = dbmemory_1.default;
|
|
58
|
+
this.cbstate = state_1.default;
|
|
59
|
+
this.taskplaner = task_1.default;
|
|
60
|
+
this.vectordb = vectordb_1.default;
|
|
61
|
+
this.debug = debug_1.default;
|
|
62
|
+
this.tokenizer = tokenizer_1.default;
|
|
63
|
+
this.chatSummary = history_1.chatSummary;
|
|
64
|
+
this.mcp = mcp_1.default;
|
|
65
|
+
this.agent = agent_1.default;
|
|
66
|
+
this.utils = utils_1.default;
|
|
67
|
+
console.log("Codebolt Agent initialized");
|
|
68
|
+
this.readyPromise = this.initializeConnection();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @method initializeConnection
|
|
72
|
+
* @description Initializes the WebSocket connection asynchronously.
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
async initializeConnection() {
|
|
76
|
+
try {
|
|
77
|
+
await websocket_1.default.initializeWebSocket();
|
|
78
|
+
this.websocket = websocket_1.default.getWebsocket;
|
|
79
|
+
this.isReady = true;
|
|
80
|
+
console.log("Codebolt WebSocket connection established");
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error('Failed to initialize WebSocket connection:', error);
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @method waitForReady
|
|
89
|
+
* @description Waits for the Codebolt instance to be fully initialized.
|
|
90
|
+
* @returns {Promise<void>} A promise that resolves when the instance is ready.
|
|
91
|
+
*/
|
|
92
|
+
async waitForReady() {
|
|
93
|
+
return this.readyPromise;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @method isReady
|
|
97
|
+
* @description Checks if the Codebolt instance is ready for use.
|
|
98
|
+
* @returns {boolean} True if the instance is ready, false otherwise.
|
|
99
|
+
*/
|
|
100
|
+
get ready() {
|
|
101
|
+
return this.isReady;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Sets up a listener for incoming messages with a direct handler function.
|
|
105
|
+
* @param {Function} handler - The handler function to call when a message is received.
|
|
106
|
+
* @returns {void}
|
|
107
|
+
*/
|
|
108
|
+
onMessage(handler) {
|
|
109
|
+
// Wait for the WebSocket to be ready before setting up the handler
|
|
110
|
+
this.waitForReady().then(() => {
|
|
111
|
+
const handleUserMessage = async (response) => {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
console.log("Message received By Agent Library Starting Custom Agent Handler Logic");
|
|
114
|
+
if (response.type === "messageResponse") {
|
|
115
|
+
try {
|
|
116
|
+
// Extract user-facing message from internal socket message
|
|
117
|
+
const userMessage = {
|
|
118
|
+
userMessage: response.message.userMessage,
|
|
119
|
+
currentFile: response.message.currentFile,
|
|
120
|
+
mentionedFiles: response.message.mentionedFiles || [],
|
|
121
|
+
mentionedFullPaths: response.message.mentionedFullPaths || [],
|
|
122
|
+
mentionedFolders: response.message.mentionedFolders || [],
|
|
123
|
+
uploadedImages: response.message.uploadedImages || [],
|
|
124
|
+
selectedAgent: {
|
|
125
|
+
id: ((_a = response.message.selectedAgent) === null || _a === void 0 ? void 0 : _a.id) || '',
|
|
126
|
+
name: ((_b = response.message.selectedAgent) === null || _b === void 0 ? void 0 : _b.name) || ''
|
|
127
|
+
},
|
|
128
|
+
messageId: response.message.messageId,
|
|
129
|
+
threadId: response.message.threadId,
|
|
130
|
+
selection: response.message.selection
|
|
131
|
+
};
|
|
132
|
+
const result = await handler(userMessage);
|
|
133
|
+
// Send processStoped with optional message
|
|
134
|
+
const message = {
|
|
135
|
+
"type": "processStoped"
|
|
136
|
+
};
|
|
137
|
+
// If handler returned data, include it as message
|
|
138
|
+
if (result !== undefined && result !== null) {
|
|
139
|
+
message.message = result;
|
|
140
|
+
}
|
|
141
|
+
websocket_1.default.messageManager.send(message);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
console.error('Error in user message handler:', error);
|
|
145
|
+
// Send processStoped even if there's an error
|
|
146
|
+
websocket_1.default.messageManager.send({
|
|
147
|
+
"type": "processStoped",
|
|
148
|
+
"error": error instanceof Error ? error.message : "Unknown error occurred"
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
websocket_1.default.messageManager.on('message', handleUserMessage);
|
|
154
|
+
}).catch(error => {
|
|
155
|
+
console.error('Failed to set up message handler:', error);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.default = Codebolt;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,302 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { ChatMessageFromUser, LLMResponse, UserMessage } from './types/socketMessageTypes';
|
|
5
|
-
export type { Message, ToolCall, Tool, LLMInferenceParams, APIResponse, CodeboltConfig, ProgressCallback, ErrorCallback, SuccessCallback, CompletionCallback } from './types/libFunctionTypes';
|
|
6
|
-
/**
|
|
7
|
-
* @class Codebolt
|
|
8
|
-
* @description This class provides a unified interface to interact with various modules.
|
|
9
|
-
*/
|
|
10
|
-
declare class Codebolt {
|
|
11
|
-
websocket: WebSocket | null;
|
|
12
|
-
private isReady;
|
|
13
|
-
private readyPromise;
|
|
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: (message: string, llmrole: string) => Promise<LLMResponse>;
|
|
81
|
-
};
|
|
82
|
-
browser: {
|
|
83
|
-
newPage: () => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
|
|
84
|
-
getUrl: () => Promise<import("./types/socketMessageTypes").UrlResponse>;
|
|
85
|
-
goToPage: (url: string) => Promise<import("./types/socketMessageTypes").GoToPageResponse>;
|
|
86
|
-
screenshot: () => Promise<import("./types/socketMessageTypes").BrowserScreenshotResponse>;
|
|
87
|
-
getHTML: () => Promise<import("./types/socketMessageTypes").HtmlReceived>;
|
|
88
|
-
getMarkdown: () => Promise<import("./types/socketMessageTypes").GetMarkdownResponse>;
|
|
89
|
-
getPDF: () => void;
|
|
90
|
-
pdfToText: () => void;
|
|
91
|
-
getContent: () => Promise<import("./types/socketMessageTypes").GetContentResponse>;
|
|
92
|
-
getSnapShot: () => Promise<import("./types/socketMessageTypes").BrowserSnapshotResponse>;
|
|
93
|
-
getBrowserInfo: () => Promise<import("./types/socketMessageTypes").BrowserInfoResponse>;
|
|
94
|
-
extractText: () => Promise<import("./types/socketMessageTypes").ExtractTextResponse>;
|
|
95
|
-
close: () => void;
|
|
96
|
-
scroll: (direction: string, pixels: string) => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
|
|
97
|
-
type: (elementid: string, text: string) => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
|
|
98
|
-
click: (elementid: string) => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
|
|
99
|
-
enter: () => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
|
|
100
|
-
search: (elementid: string, query: string) => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
|
|
101
|
-
};
|
|
102
|
-
chat: {
|
|
103
|
-
getChatHistory: () => Promise<import("./types/socketMessageTypes").ChatMessage[]>;
|
|
104
|
-
setRequestHandler: (handler: (request: any, response: (data: any) => void) => void | Promise<void>) => void;
|
|
105
|
-
sendMessage: (message: string, payload: any) => void;
|
|
106
|
-
waitforReply: (message: string) => Promise<UserMessage>;
|
|
107
|
-
processStarted: (onStopClicked?: ((message: any) => void) | undefined) => {
|
|
108
|
-
stopProcess: () => void;
|
|
109
|
-
cleanup: () => void;
|
|
110
|
-
} | {
|
|
111
|
-
stopProcess: () => void;
|
|
112
|
-
cleanup?: undefined;
|
|
113
|
-
};
|
|
114
|
-
stopProcess: () => void;
|
|
115
|
-
processFinished: () => void;
|
|
116
|
-
sendConfirmationRequest: (confirmationMessage: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
|
|
117
|
-
askQuestion: (question: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
|
|
118
|
-
sendNotificationEvent: (notificationMessage: string, type: "browser" | "terminal" | "git" | "debug" | "planner" | "editor" | "preview") => void;
|
|
119
|
-
};
|
|
120
|
-
terminal: {
|
|
121
|
-
eventEmitter: {
|
|
122
|
-
cleanup?: (() => void) | undefined;
|
|
123
|
-
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
|
|
124
|
-
addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
125
|
-
on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
126
|
-
once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
127
|
-
removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
128
|
-
off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
129
|
-
removeAllListeners(eventName?: string | symbol | undefined): any;
|
|
130
|
-
setMaxListeners(n: number): any;
|
|
131
|
-
getMaxListeners(): number;
|
|
132
|
-
listeners<K_6>(eventName: string | symbol): Function[];
|
|
133
|
-
rawListeners<K_7>(eventName: string | symbol): Function[];
|
|
134
|
-
emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
|
|
135
|
-
listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
|
|
136
|
-
prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
137
|
-
prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
138
|
-
eventNames(): (string | symbol)[];
|
|
139
|
-
};
|
|
140
|
-
executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<any>;
|
|
141
|
-
executeCommandRunUntilError: (command: string, executeInMain?: boolean) => Promise<import("./types/socketMessageTypes").CommandError>;
|
|
142
|
-
sendManualInterrupt(): Promise<import("./types/socketMessageTypes").TerminalInterruptResponse>;
|
|
143
|
-
executeCommandWithStream(command: string, executeInMain?: boolean): {
|
|
144
|
-
cleanup?: (() => void) | undefined;
|
|
145
|
-
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
|
|
146
|
-
addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
147
|
-
on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
148
|
-
once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
149
|
-
removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
150
|
-
off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
151
|
-
removeAllListeners(eventName?: string | symbol | undefined): any;
|
|
152
|
-
setMaxListeners(n: number): any;
|
|
153
|
-
getMaxListeners(): number;
|
|
154
|
-
listeners<K_6>(eventName: string | symbol): Function[];
|
|
155
|
-
rawListeners<K_7>(eventName: string | symbol): Function[];
|
|
156
|
-
emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
|
|
157
|
-
listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
|
|
158
|
-
prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
159
|
-
prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
160
|
-
eventNames(): (string | symbol)[];
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
codeutils: {
|
|
164
|
-
getJsTree: (filePath?: string | undefined) => Promise<import("./types/InternalTypes").JSTreeResponse>;
|
|
165
|
-
getAllFilesAsMarkDown: () => Promise<string>;
|
|
166
|
-
performMatch: (matcherDefinition: object, problemPatterns: any[], problems?: any[]) => Promise<import("./types/socketMessageTypes").MatchProblemResponse>;
|
|
167
|
-
getMatcherList: () => Promise<import("./types/socketMessageTypes").GetMatcherListTreeResponse>;
|
|
168
|
-
matchDetail: (matcher: string) => Promise<import("./types/socketMessageTypes").getMatchDetail>;
|
|
169
|
-
};
|
|
170
|
-
crawler: {
|
|
171
|
-
start: () => void;
|
|
172
|
-
screenshot: () => void;
|
|
173
|
-
goToPage: (url: string) => void;
|
|
174
|
-
scroll: (direction: string) => void;
|
|
175
|
-
click: (id: string) => Promise<any>;
|
|
176
|
-
};
|
|
177
|
-
search: {
|
|
178
|
-
init: (engine?: string) => void;
|
|
179
|
-
search: (query: string) => Promise<string>;
|
|
180
|
-
get_first_link: (query: string) => Promise<string>;
|
|
181
|
-
};
|
|
182
|
-
knowledge: {};
|
|
183
|
-
rag: {
|
|
184
|
-
init: () => void;
|
|
185
|
-
add_file: (filename: string, file_path: string) => void;
|
|
186
|
-
retrieve_related_knowledge: (query: string, filename: string) => void;
|
|
187
|
-
};
|
|
188
|
-
codeparsers: {
|
|
189
|
-
getClassesInFile: (file: string) => Promise<{
|
|
190
|
-
error: string;
|
|
191
|
-
} | {
|
|
192
|
-
name: any;
|
|
193
|
-
location: string;
|
|
194
|
-
}[]>;
|
|
195
|
-
getFunctionsinClass: (file: string, className: string) => Promise<{
|
|
196
|
-
error: string;
|
|
197
|
-
} | {
|
|
198
|
-
name: string;
|
|
199
|
-
class: string;
|
|
200
|
-
location: string;
|
|
201
|
-
}[]>;
|
|
202
|
-
getAstTreeInFile: (file: string, className?: string | undefined) => Promise<import("./types/commonTypes").ASTNode | {
|
|
203
|
-
error: string;
|
|
204
|
-
}>;
|
|
205
|
-
};
|
|
206
|
-
outputparsers: {
|
|
207
|
-
parseJSON: (jsonString: string) => {
|
|
208
|
-
success: boolean;
|
|
209
|
-
parsed?: any;
|
|
210
|
-
error?: Error | undefined;
|
|
211
|
-
};
|
|
212
|
-
parseXML: (xmlString: string) => {
|
|
213
|
-
success: boolean;
|
|
214
|
-
parsed?: any;
|
|
215
|
-
};
|
|
216
|
-
parseCSV: (csvString: string) => {
|
|
217
|
-
success: boolean;
|
|
218
|
-
parsed?: any[] | undefined;
|
|
219
|
-
error?: Error | undefined;
|
|
220
|
-
};
|
|
221
|
-
parseText: (text: string) => {
|
|
222
|
-
success: boolean;
|
|
223
|
-
parsed: string[];
|
|
224
|
-
};
|
|
225
|
-
parseErrors: (output: any) => string[];
|
|
226
|
-
parseWarnings: (output: any) => string[];
|
|
227
|
-
};
|
|
228
|
-
project: {
|
|
229
|
-
getProjectSettings: () => Promise<any>;
|
|
230
|
-
getProjectPath: () => Promise<import("./types/socketMessageTypes").GetProjectPathResponse>;
|
|
231
|
-
getRepoMap: (message: any) => Promise<import("./types/socketMessageTypes").GetProjectPathResponse>;
|
|
232
|
-
runProject: () => void;
|
|
233
|
-
getEditorFileStatus: () => Promise<any>;
|
|
234
|
-
};
|
|
235
|
-
dbmemory: {
|
|
236
|
-
addKnowledge: (key: string, value: any) => Promise<import("./types/socketMessageTypes").MemorySetResponse>;
|
|
237
|
-
getKnowledge: (key: string) => Promise<import("./types/socketMessageTypes").MemoryGetResponse>;
|
|
238
|
-
};
|
|
239
|
-
cbstate: {
|
|
240
|
-
getApplicationState: () => Promise<import("./types/commonTypes").ApplicationState>;
|
|
241
|
-
addToAgentState: (key: string, value: string) => Promise<import("./types/socketMessageTypes").AddToAgentStateResponse>;
|
|
242
|
-
getAgentState: () => Promise<import("./types/socketMessageTypes").GetAgentStateResponse>;
|
|
243
|
-
getProjectState: () => Promise<any>;
|
|
244
|
-
updateProjectState: (key: string, value: any) => Promise<any>;
|
|
245
|
-
};
|
|
246
|
-
taskplaner: {
|
|
247
|
-
addTask: (task: string) => Promise<any>;
|
|
248
|
-
getTasks: () => Promise<any>;
|
|
249
|
-
updateTask: (task: string) => Promise<any>;
|
|
250
|
-
};
|
|
251
|
-
vectordb: {
|
|
252
|
-
getVector: (key: string) => Promise<import("./types/socketMessageTypes").GetVectorResponse>;
|
|
253
|
-
addVectorItem: (item: any) => Promise<import("./types/socketMessageTypes").AddVectorItemResponse>;
|
|
254
|
-
queryVectorItem: (key: string) => Promise<import("./types/socketMessageTypes").QueryVectorItemResponse>;
|
|
255
|
-
queryVectorItems: (items: [], dbPath: string) => Promise<import("./types/socketMessageTypes").QueryVectorItemResponse>;
|
|
256
|
-
};
|
|
257
|
-
debug: {
|
|
258
|
-
debug: (log: string, type: import("./modules/debug").logType) => Promise<import("./types/socketMessageTypes").DebugAddLogResponse>;
|
|
259
|
-
openDebugBrowser: (url: string, port: number) => Promise<import("./types/socketMessageTypes").OpenDebugBrowserResponse>;
|
|
260
|
-
};
|
|
261
|
-
tokenizer: {
|
|
262
|
-
addToken: (key: string) => Promise<import("./types/socketMessageTypes").AddTokenResponse>;
|
|
263
|
-
getToken: (key: string) => Promise<import("./types/socketMessageTypes").GetTokenResponse>;
|
|
264
|
-
};
|
|
265
|
-
chatSummary: {
|
|
266
|
-
summarizeAll: () => Promise<import("./types/socketMessageTypes").GetSummarizeAllResponse>;
|
|
267
|
-
summarize: (messages: {
|
|
268
|
-
role: string;
|
|
269
|
-
content: string;
|
|
270
|
-
}[], depth: number) => Promise<import("./types/socketMessageTypes").GetSummarizeResponse>;
|
|
271
|
-
};
|
|
272
|
-
mcp: {
|
|
273
|
-
getEnabledMCPServers: () => Promise<import("./types/socketMessageTypes").GetEnabledToolBoxesResponse>;
|
|
274
|
-
getLocalMCPServers: () => Promise<import("./types/socketMessageTypes").GetLocalToolBoxesResponse>;
|
|
275
|
-
getMentionedMCPServers: (userMessage: import("./utils").UserMessage) => Promise<import("./types/socketMessageTypes").GetAvailableToolBoxesResponse>;
|
|
276
|
-
searchAvailableMCPServers: (query: string) => Promise<import("./types/socketMessageTypes").SearchAvailableToolBoxesResponse>;
|
|
277
|
-
listMcpFromServers: (toolBoxes: string[]) => Promise<import("./types/socketMessageTypes").ListToolsFromToolBoxesResponse>;
|
|
278
|
-
configureMCPServer: (name: string, config: any) => Promise<import("./types/socketMessageTypes").ConfigureToolBoxResponse>;
|
|
279
|
-
getTools: (tools: {
|
|
280
|
-
toolbox: string;
|
|
281
|
-
toolName: string;
|
|
282
|
-
}[]) => Promise<import("./types/socketMessageTypes").GetToolsResponse>;
|
|
283
|
-
executeTool: (toolbox: string, toolName: string, params: any) => Promise<import("./types/socketMessageTypes").ExecuteToolResponse>;
|
|
284
|
-
};
|
|
285
|
-
agent: {
|
|
286
|
-
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>;
|
|
287
|
-
startAgent: (agentId: string, task: string) => Promise<import("./types/socketMessageTypes").TaskCompletionResponse>;
|
|
288
|
-
getAgentsList: (type?: import("./modules/agent").Agents) => Promise<import("./types/socketMessageTypes").ListAgentsResponse>;
|
|
289
|
-
getAgentsDetail: (agentList?: never[]) => Promise<import("./types/socketMessageTypes").AgentsDetailResponse>;
|
|
290
|
-
};
|
|
291
|
-
utils: {
|
|
292
|
-
editFileAndApplyDiff: (filePath: string, diff: string, diffIdentifier: string, prompt: string, applyModel?: string | undefined) => Promise<import("./types/socketMessageTypes").FsEditFileAndApplyDiffResponse>;
|
|
293
|
-
};
|
|
294
|
-
/**
|
|
295
|
-
* Sets up a listener for incoming messages with a direct handler function.
|
|
296
|
-
* @param {Function} handler - The handler function to call when a message is received.
|
|
297
|
-
* @returns {void}
|
|
298
|
-
*/
|
|
299
|
-
onMessage(handler: (userMessage: ChatMessageFromUser) => void | Promise<void> | any | Promise<any>): void;
|
|
300
|
-
}
|
|
1
|
+
import Codebolt from './core/Codebolt';
|
|
2
|
+
export type { Message, ToolCall, Tool, UserMessage, LLMInferenceParams, APIResponse, CodeboltConfig, ProgressCallback, ErrorCallback, SuccessCallback, CompletionCallback, OpenAIMessage, OpenAITool, ConversationEntry, ToolResult, ToolDetails, UserMessageContent, CodeboltAPI, ReadFileOptions, WriteFileOptions, ListFilesOptions, SearchFilesOptions, GrepSearchOptions, BrowserNavigationOptions, BrowserScreenshotOptions, BrowserElementSelector, TerminalExecuteOptions, GitCommitOptions, GitLogOptions, LLMChatOptions, VectorAddOptions, VectorQueryOptions, AgentMessageHandler, AgentConfiguration, MemorySetOptions, MemoryGetOptions, TaskCreateOptions, TaskUpdateOptions, CodeAnalysisOptions, CodeParseOptions, DebugLogOptions, ProjectInfo, CrawlerOptions, MCPExecuteOptions, MCPConfigureOptions, StateUpdateOptions, ChatSendOptions, ChatHistoryOptions, NotificationOptions, PaginationOptions, FilterOptions, AsyncOperationOptions, APIEventMap } from './types/libFunctionTypes';
|
|
3
|
+
export type { GitFileStatus, StatusResult, CommitSummary, DiffResult, AgentFunction, AgentDetail, Agent, Task, VectorItem, VectorQueryResult, FileEntry, SearchMatch, SearchResult, BrowserElement, CodeIssue, CodeAnalysis, CodeMatcher, MCPTool, MCPServer, ASTNode, Notification, DeepPartial, DeepRequired, Optional, Required } from './types/commonTypes';
|
|
301
4
|
declare const codebolt: Codebolt;
|
|
302
5
|
export default codebolt;
|
|
6
|
+
export { Codebolt };
|
package/dist/index.js
CHANGED
|
@@ -3,145 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
/**
|
|
32
|
-
* @class Codebolt
|
|
33
|
-
* @description This class provides a unified interface to interact with various modules.
|
|
34
|
-
*/
|
|
35
|
-
class Codebolt {
|
|
36
|
-
/**
|
|
37
|
-
* @constructor
|
|
38
|
-
* @description Initializes the websocket connection.
|
|
39
|
-
*/
|
|
40
|
-
constructor() {
|
|
41
|
-
this.websocket = null;
|
|
42
|
-
this.isReady = false;
|
|
43
|
-
this.fs = fs_1.default;
|
|
44
|
-
this.git = git_1.default;
|
|
45
|
-
this.llm = llm_1.default;
|
|
46
|
-
this.browser = browser_1.default;
|
|
47
|
-
this.chat = chat_1.default;
|
|
48
|
-
this.terminal = terminal_1.default;
|
|
49
|
-
this.codeutils = codeutils_1.default;
|
|
50
|
-
this.crawler = crawler_1.default;
|
|
51
|
-
this.search = search_1.default;
|
|
52
|
-
this.knowledge = knowledge_1.default;
|
|
53
|
-
this.rag = rag_1.default;
|
|
54
|
-
this.codeparsers = codeparsers_1.default;
|
|
55
|
-
this.outputparsers = outputparsers_1.default;
|
|
56
|
-
this.project = project_1.default;
|
|
57
|
-
this.dbmemory = dbmemory_1.default;
|
|
58
|
-
this.cbstate = state_1.default;
|
|
59
|
-
this.taskplaner = task_1.default;
|
|
60
|
-
this.vectordb = vectordb_1.default;
|
|
61
|
-
this.debug = debug_1.default;
|
|
62
|
-
this.tokenizer = tokenizer_1.default;
|
|
63
|
-
this.chatSummary = history_1.chatSummary;
|
|
64
|
-
this.mcp = mcp_1.default;
|
|
65
|
-
this.agent = agent_1.default;
|
|
66
|
-
this.utils = utils_1.default;
|
|
67
|
-
console.log("Codebolt Agent initialized");
|
|
68
|
-
this.readyPromise = this.initializeConnection();
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* @method initializeConnection
|
|
72
|
-
* @description Initializes the WebSocket connection asynchronously.
|
|
73
|
-
* @private
|
|
74
|
-
*/
|
|
75
|
-
async initializeConnection() {
|
|
76
|
-
try {
|
|
77
|
-
await websocket_1.default.initializeWebSocket();
|
|
78
|
-
this.websocket = websocket_1.default.getWebsocket;
|
|
79
|
-
this.isReady = true;
|
|
80
|
-
console.log("Codebolt WebSocket connection established");
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error('Failed to initialize WebSocket connection:', error);
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @method waitForReady
|
|
89
|
-
* @description Waits for the Codebolt instance to be fully initialized.
|
|
90
|
-
* @returns {Promise<void>} A promise that resolves when the instance is ready.
|
|
91
|
-
*/
|
|
92
|
-
async waitForReady() {
|
|
93
|
-
return this.readyPromise;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* @method isReady
|
|
97
|
-
* @description Checks if the Codebolt instance is ready for use.
|
|
98
|
-
* @returns {boolean} True if the instance is ready, false otherwise.
|
|
99
|
-
*/
|
|
100
|
-
get ready() {
|
|
101
|
-
return this.isReady;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Sets up a listener for incoming messages with a direct handler function.
|
|
105
|
-
* @param {Function} handler - The handler function to call when a message is received.
|
|
106
|
-
* @returns {void}
|
|
107
|
-
*/
|
|
108
|
-
onMessage(handler) {
|
|
109
|
-
// Wait for the WebSocket to be ready before setting up the handler
|
|
110
|
-
this.waitForReady().then(() => {
|
|
111
|
-
const handleUserMessage = async (response) => {
|
|
112
|
-
console.log("Message received By Agent Library Starting Custom Agent Handler Logic");
|
|
113
|
-
if (response.type === "messageResponse") {
|
|
114
|
-
try {
|
|
115
|
-
const result = await handler(response.message);
|
|
116
|
-
// Send processStoped with optional message
|
|
117
|
-
const message = {
|
|
118
|
-
"type": "processStoped"
|
|
119
|
-
};
|
|
120
|
-
// If handler returned data, include it as message
|
|
121
|
-
if (result !== undefined && result !== null) {
|
|
122
|
-
message.message = result;
|
|
123
|
-
}
|
|
124
|
-
websocket_1.default.messageManager.send(message);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
console.error('Error in user message handler:', error);
|
|
128
|
-
// Send processStoped even if there's an error
|
|
129
|
-
websocket_1.default.messageManager.send({
|
|
130
|
-
"type": "processStoped",
|
|
131
|
-
"error": error instanceof Error ? error.message : "Unknown error occurred"
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
websocket_1.default.messageManager.on('message', handleUserMessage);
|
|
137
|
-
}).catch(error => {
|
|
138
|
-
console.error('Failed to set up message handler:', error);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const codebolt = new Codebolt();
|
|
6
|
+
exports.Codebolt = void 0;
|
|
7
|
+
const Codebolt_1 = __importDefault(require("./core/Codebolt"));
|
|
8
|
+
exports.Codebolt = Codebolt_1.default;
|
|
9
|
+
// ================================
|
|
10
|
+
// Main Library Instance
|
|
11
|
+
// ================================
|
|
12
|
+
const codebolt = new Codebolt_1.default();
|
|
13
|
+
// ================================
|
|
14
|
+
// Export the Main Instance and Class
|
|
15
|
+
// ================================
|
|
143
16
|
// For ES6 modules (import)
|
|
144
17
|
exports.default = codebolt;
|
|
145
18
|
// For CommonJS compatibility (require)
|
|
146
19
|
module.exports = codebolt;
|
|
147
20
|
module.exports.default = codebolt;
|
|
21
|
+
module.exports.Codebolt = Codebolt_1.default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codebolt Types - Essential type exports for the codeboltjs library
|
|
3
|
+
*
|
|
4
|
+
* This file provides easy access to all user-facing types exported by the library.
|
|
5
|
+
* Users can import types from here for better organization.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import type { Message, ToolCall, APIResponse } from 'codeboltjs/types';
|
|
10
|
+
* // or
|
|
11
|
+
* import type { LLMChatOptions, BrowserScreenshotOptions } from 'codeboltjs/types';
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export type { Message, ToolCall, Tool, UserMessage, LLMInferenceParams, APIResponse, CodeboltConfig, ProgressCallback, ErrorCallback, SuccessCallback, CompletionCallback, OpenAIMessage, OpenAITool, ConversationEntry, ToolResult, ToolDetails, UserMessageContent, CodeboltAPI, ReadFileOptions, WriteFileOptions, ListFilesOptions, SearchFilesOptions, GrepSearchOptions, BrowserNavigationOptions, BrowserScreenshotOptions, BrowserElementSelector, TerminalExecuteOptions, GitCommitOptions, GitLogOptions, LLMChatOptions, VectorAddOptions, VectorQueryOptions, AgentMessageHandler, AgentConfiguration, MemorySetOptions, MemoryGetOptions, TaskCreateOptions, TaskUpdateOptions, CodeAnalysisOptions, CodeParseOptions, DebugLogOptions, ProjectInfo, CrawlerOptions, MCPExecuteOptions, MCPConfigureOptions, StateUpdateOptions, ChatSendOptions, ChatHistoryOptions, NotificationOptions, PaginationOptions, FilterOptions, AsyncOperationOptions, APIEventMap } from './libFunctionTypes';
|
|
15
|
+
export type { GitFileStatus, StatusResult, CommitSummary, DiffResult, AgentFunction, AgentDetail, Agent, Task, VectorItem, VectorQueryResult, FileEntry, SearchMatch, SearchResult, BrowserElement, CodeIssue, CodeAnalysis, CodeMatcher, MCPTool, MCPServer, ASTNode, Notification, DeepPartial, DeepRequired, Optional, Required } from './commonTypes';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Codebolt Types - Essential type exports for the codeboltjs library
|
|
4
|
+
*
|
|
5
|
+
* This file provides easy access to all user-facing types exported by the library.
|
|
6
|
+
* Users can import types from here for better organization.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import type { Message, ToolCall, APIResponse } from 'codeboltjs/types';
|
|
11
|
+
* // or
|
|
12
|
+
* import type { LLMChatOptions, BrowserScreenshotOptions } from 'codeboltjs/types';
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -166,6 +166,35 @@ export interface UserMessageContent {
|
|
|
166
166
|
/** The text content */
|
|
167
167
|
text: string;
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* User message received from the Codebolt platform
|
|
171
|
+
* This is a simplified, user-friendly version of the internal message format
|
|
172
|
+
*/
|
|
173
|
+
export interface UserMessage {
|
|
174
|
+
/** The user's message content */
|
|
175
|
+
userMessage: string;
|
|
176
|
+
/** Current file being worked on */
|
|
177
|
+
currentFile: string;
|
|
178
|
+
/** Files mentioned in the message */
|
|
179
|
+
mentionedFiles: string[];
|
|
180
|
+
/** Full file paths mentioned */
|
|
181
|
+
mentionedFullPaths: string[];
|
|
182
|
+
/** Folders mentioned */
|
|
183
|
+
mentionedFolders: string[];
|
|
184
|
+
/** Images uploaded with the message */
|
|
185
|
+
uploadedImages: string[];
|
|
186
|
+
/** Selected agent information */
|
|
187
|
+
selectedAgent: {
|
|
188
|
+
id: string;
|
|
189
|
+
name: string;
|
|
190
|
+
};
|
|
191
|
+
/** Unique message identifier */
|
|
192
|
+
messageId: string;
|
|
193
|
+
/** Thread identifier */
|
|
194
|
+
threadId: string;
|
|
195
|
+
/** Any text selection in the editor */
|
|
196
|
+
selection?: any;
|
|
197
|
+
}
|
|
169
198
|
/**
|
|
170
199
|
* Interface for codebolt API functionality
|
|
171
200
|
*/
|
|
@@ -330,7 +359,7 @@ export interface VectorQueryOptions {
|
|
|
330
359
|
minScore?: number;
|
|
331
360
|
}
|
|
332
361
|
export interface AgentMessageHandler {
|
|
333
|
-
(userMessage:
|
|
362
|
+
(userMessage: UserMessage): void | Promise<void> | any | Promise<any>;
|
|
334
363
|
}
|
|
335
364
|
export interface AgentConfiguration {
|
|
336
365
|
/** Agent name */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebolt/codeboltjs",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
|
-
"url": "https://github.com/codeboltai/codeboltjs"
|
|
26
|
+
"url": "git+https://github.com/codeboltai/codeboltjs.git"
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"homepage": "https://codeboltai.github.io",
|