@codebolt/codeboltjs 2.0.7 → 2.0.12
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/dist/agentlib/agent.js +12 -4
- package/dist/agentlib/promptbuilder.d.ts +228 -0
- package/dist/agentlib/promptbuilder.js +487 -0
- package/dist/agentlib/taskInstruction.d.ts +3 -25
- package/dist/agentlib/usermessage.d.ts +13 -43
- package/dist/agentlib/usermessage.js +8 -8
- package/dist/core/messageManager.d.ts +4 -6
- package/dist/core/messageManager.js +24 -17
- package/dist/core/websocket.d.ts +10 -0
- package/dist/core/websocket.js +92 -8
- package/dist/index.d.ts +97 -95
- package/dist/index.js +63 -57
- package/dist/modules/agent.d.ts +9 -8
- package/dist/modules/agent.js +4 -4
- package/dist/modules/browser.d.ts +17 -17
- package/dist/modules/browser.js +7 -7
- package/dist/modules/chat.d.ts +1 -1
- package/dist/modules/codeparsers.d.ts +1 -16
- package/dist/modules/codeutils.d.ts +3 -18
- package/dist/modules/dbmemory.d.ts +1 -1
- package/dist/modules/debug.d.ts +1 -1
- package/dist/modules/fs.d.ts +1 -1
- package/dist/modules/git.d.ts +21 -20
- package/dist/modules/git.js +10 -10
- package/dist/modules/history.d.ts +6 -8
- package/dist/modules/history.js +4 -1
- package/dist/modules/llm.d.ts +13 -5
- package/dist/modules/llm.js +29 -4
- package/dist/modules/{tools.d.ts → mcp.d.ts} +9 -8
- package/dist/modules/{tools.js → mcp.js} +6 -6
- package/dist/modules/project.d.ts +1 -1
- package/dist/modules/state.d.ts +2 -1
- package/dist/modules/task.js +0 -1
- package/dist/modules/terminal.d.ts +1 -1
- package/dist/modules/tokenizer.d.ts +1 -1
- package/dist/modules/utils.d.ts +11 -1
- package/dist/modules/utils.js +9 -0
- package/dist/modules/vectordb.d.ts +1 -1
- package/dist/types/InternalTypes.d.ts +501 -0
- package/dist/types/InternalTypes.js +30 -0
- package/dist/types/commonTypes.d.ts +346 -0
- package/dist/types/commonTypes.js +37 -0
- package/dist/types/libFunctionTypes.d.ts +589 -0
- package/dist/types/libFunctionTypes.js +11 -0
- package/dist/types/socketMessageTypes.d.ts +951 -0
- package/dist/types/socketMessageTypes.js +51 -0
- package/dist/utils/{toolBox.d.ts → mcpServer.d.ts} +1 -1
- package/dist/utils/{toolBox.js → mcpServer.js} +36 -36
- package/dist/utils/parse-source-code/languageParser.d.ts +1 -7
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +3 -3
- package/package.json +7 -2
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common TypeScript types and interfaces shared across the codeboltjs library
|
|
3
|
+
*
|
|
4
|
+
* This file contains:
|
|
5
|
+
* - Shared data structures
|
|
6
|
+
* - Common enums
|
|
7
|
+
* - Utility types
|
|
8
|
+
* - Application state types
|
|
9
|
+
* - Git-related types
|
|
10
|
+
* - Vector database types
|
|
11
|
+
* - General purpose interfaces
|
|
12
|
+
*/
|
|
13
|
+
export interface ApplicationState {
|
|
14
|
+
currentProject?: string;
|
|
15
|
+
workingDirectory?: string;
|
|
16
|
+
openFiles?: string[];
|
|
17
|
+
recentProjects?: string[];
|
|
18
|
+
userPreferences?: Record<string, any>;
|
|
19
|
+
sessionData?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
export interface GitFileStatus {
|
|
22
|
+
path: string;
|
|
23
|
+
index: string;
|
|
24
|
+
working_dir: string;
|
|
25
|
+
}
|
|
26
|
+
export interface StatusResult {
|
|
27
|
+
not_added: string[];
|
|
28
|
+
conflicted: string[];
|
|
29
|
+
created: string[];
|
|
30
|
+
deleted: string[];
|
|
31
|
+
modified: string[];
|
|
32
|
+
renamed: string[];
|
|
33
|
+
files: GitFileStatus[];
|
|
34
|
+
staged: string[];
|
|
35
|
+
ahead: number;
|
|
36
|
+
behind: number;
|
|
37
|
+
current: string | null;
|
|
38
|
+
tracking: string | null;
|
|
39
|
+
detached: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface CommitSummary {
|
|
42
|
+
hash: string;
|
|
43
|
+
date: string;
|
|
44
|
+
message: string;
|
|
45
|
+
refs: string;
|
|
46
|
+
body: string;
|
|
47
|
+
author_name: string;
|
|
48
|
+
author_email: string;
|
|
49
|
+
}
|
|
50
|
+
export interface DiffResult {
|
|
51
|
+
files: Array<{
|
|
52
|
+
file: string;
|
|
53
|
+
changes: number;
|
|
54
|
+
insertions: number;
|
|
55
|
+
deletions: number;
|
|
56
|
+
binary: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
insertions: number;
|
|
59
|
+
deletions: number;
|
|
60
|
+
changed: number;
|
|
61
|
+
}
|
|
62
|
+
export interface AgentFunction {
|
|
63
|
+
type: 'function';
|
|
64
|
+
function: {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
parameters: {
|
|
68
|
+
type: 'object';
|
|
69
|
+
properties: Record<string, {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
}>;
|
|
73
|
+
required?: string[];
|
|
74
|
+
additionalProperties?: boolean;
|
|
75
|
+
};
|
|
76
|
+
strict?: boolean;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface AgentDetail {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
description: string;
|
|
83
|
+
capabilities?: string[];
|
|
84
|
+
isLocal: boolean;
|
|
85
|
+
version: string;
|
|
86
|
+
status: string;
|
|
87
|
+
unique_id: string;
|
|
88
|
+
}
|
|
89
|
+
export interface Task {
|
|
90
|
+
id?: string;
|
|
91
|
+
title?: string;
|
|
92
|
+
description?: string;
|
|
93
|
+
completed?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface VectorItem {
|
|
96
|
+
id: string;
|
|
97
|
+
vector: number[];
|
|
98
|
+
metadata: Record<string, any>;
|
|
99
|
+
content?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface VectorQueryResult {
|
|
102
|
+
items: VectorItem[];
|
|
103
|
+
scores?: number[];
|
|
104
|
+
distances?: number[];
|
|
105
|
+
}
|
|
106
|
+
export interface FileStateInfo {
|
|
107
|
+
type: 'file' | 'folder' | 'search' | 'fileSearch' | 'mcp';
|
|
108
|
+
path?: string;
|
|
109
|
+
content?: string | string[];
|
|
110
|
+
query?: string;
|
|
111
|
+
stateEvent: 'ASK_FOR_CONFIRMATION' | 'FILE_READ' | 'FILE_READ_ERROR' | 'REJECTED' | 'SEARCHING' | 'ASK_FOR_CONFIRMATION' | 'APPLYING_EDIT' | 'EDIT_STARTING' | 'FILE_WRITE' | 'FILE_WRITE_ERROR';
|
|
112
|
+
originalContent?: string;
|
|
113
|
+
results?: any[];
|
|
114
|
+
includePattern?: string;
|
|
115
|
+
excludePattern?: string;
|
|
116
|
+
caseSensitive?: boolean;
|
|
117
|
+
toolName?: string;
|
|
118
|
+
serverName?: string;
|
|
119
|
+
params?: any;
|
|
120
|
+
}
|
|
121
|
+
export declare enum LogType {
|
|
122
|
+
/** Informational messages */
|
|
123
|
+
info = "info",
|
|
124
|
+
/** Error messages */
|
|
125
|
+
error = "error",
|
|
126
|
+
/** Warning messages */
|
|
127
|
+
warning = "warning"
|
|
128
|
+
}
|
|
129
|
+
export interface PendingRequest {
|
|
130
|
+
resolve: (value: any) => void;
|
|
131
|
+
reject: (reason?: any) => void;
|
|
132
|
+
messageTypes: string[];
|
|
133
|
+
requestId?: string;
|
|
134
|
+
}
|
|
135
|
+
export interface ServiceResponseTypeMap {
|
|
136
|
+
filesystem: any;
|
|
137
|
+
fsService: any;
|
|
138
|
+
browser: any;
|
|
139
|
+
terminal: any;
|
|
140
|
+
git: any;
|
|
141
|
+
memory: any;
|
|
142
|
+
tasks: any;
|
|
143
|
+
vectordb: any;
|
|
144
|
+
debug: any;
|
|
145
|
+
codeutils: any;
|
|
146
|
+
agents: any;
|
|
147
|
+
state: any;
|
|
148
|
+
chat: any;
|
|
149
|
+
crawler: any;
|
|
150
|
+
mcp: any;
|
|
151
|
+
project: any;
|
|
152
|
+
notification: any;
|
|
153
|
+
problemMatcher: any;
|
|
154
|
+
jsTreeParser: any;
|
|
155
|
+
}
|
|
156
|
+
export type SuccessResponse<T = any> = {
|
|
157
|
+
success: true;
|
|
158
|
+
data?: T;
|
|
159
|
+
};
|
|
160
|
+
export type FailureResponse = {
|
|
161
|
+
success: false;
|
|
162
|
+
error: string;
|
|
163
|
+
};
|
|
164
|
+
export type WebSocketMessageHandler<T = any> = (response: T) => void | Promise<void>;
|
|
165
|
+
export type ServiceWebSocketHandler<K extends keyof ServiceResponseTypeMap> = WebSocketMessageHandler<ServiceResponseTypeMap[K]>;
|
|
166
|
+
/**
|
|
167
|
+
* Makes all properties of T optional recursively
|
|
168
|
+
*/
|
|
169
|
+
export type DeepPartial<T> = {
|
|
170
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Makes all properties of T required recursively
|
|
174
|
+
*/
|
|
175
|
+
export type DeepRequired<T> = {
|
|
176
|
+
[P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Extract keys from T that have values assignable to U
|
|
180
|
+
*/
|
|
181
|
+
export type KeysOfType<T, U> = {
|
|
182
|
+
[K in keyof T]: T[K] extends U ? K : never;
|
|
183
|
+
}[keyof T];
|
|
184
|
+
/**
|
|
185
|
+
* Make specific properties optional
|
|
186
|
+
*/
|
|
187
|
+
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
188
|
+
/**
|
|
189
|
+
* Make specific properties required
|
|
190
|
+
*/
|
|
191
|
+
export type Required<T, K extends keyof T> = T & {
|
|
192
|
+
[P in K]-?: T[P];
|
|
193
|
+
};
|
|
194
|
+
export interface EventMap {
|
|
195
|
+
[key: string]: (...args: any[]) => void;
|
|
196
|
+
}
|
|
197
|
+
export interface TypedEventEmitter<T extends EventMap> {
|
|
198
|
+
on<K extends keyof T>(event: K, listener: T[K]): this;
|
|
199
|
+
off<K extends keyof T>(event: K, listener: T[K]): this;
|
|
200
|
+
emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): boolean;
|
|
201
|
+
removeAllListeners<K extends keyof T>(event?: K): this;
|
|
202
|
+
}
|
|
203
|
+
export interface Config {
|
|
204
|
+
websocket?: {
|
|
205
|
+
url?: string;
|
|
206
|
+
timeout?: number;
|
|
207
|
+
reconnectInterval?: number;
|
|
208
|
+
maxReconnectAttempts?: number;
|
|
209
|
+
};
|
|
210
|
+
logging?: {
|
|
211
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
212
|
+
enabled?: boolean;
|
|
213
|
+
};
|
|
214
|
+
[key: string]: any;
|
|
215
|
+
}
|
|
216
|
+
export interface CodeboltError extends Error {
|
|
217
|
+
code?: string;
|
|
218
|
+
details?: any;
|
|
219
|
+
timestamp?: string;
|
|
220
|
+
}
|
|
221
|
+
export declare class CodeboltError extends Error {
|
|
222
|
+
code?: string | undefined;
|
|
223
|
+
details?: any;
|
|
224
|
+
constructor(message: string, code?: string | undefined, details?: any);
|
|
225
|
+
}
|
|
226
|
+
export interface FileEntry {
|
|
227
|
+
name: string;
|
|
228
|
+
isDirectory: boolean;
|
|
229
|
+
size?: number;
|
|
230
|
+
modified?: string;
|
|
231
|
+
created?: string;
|
|
232
|
+
permissions?: string;
|
|
233
|
+
}
|
|
234
|
+
export interface SearchMatch {
|
|
235
|
+
line: number;
|
|
236
|
+
content: string;
|
|
237
|
+
lineNumber: number;
|
|
238
|
+
}
|
|
239
|
+
export interface SearchResult {
|
|
240
|
+
path: string;
|
|
241
|
+
matches: SearchMatch[];
|
|
242
|
+
}
|
|
243
|
+
export interface BrowserElement {
|
|
244
|
+
id: string;
|
|
245
|
+
tag: string;
|
|
246
|
+
text: string;
|
|
247
|
+
attributes: Record<string, string>;
|
|
248
|
+
}
|
|
249
|
+
export interface CodeIssue {
|
|
250
|
+
type: string;
|
|
251
|
+
severity: 'error' | 'warning' | 'info';
|
|
252
|
+
message: string;
|
|
253
|
+
file: string;
|
|
254
|
+
line: number;
|
|
255
|
+
column?: number;
|
|
256
|
+
}
|
|
257
|
+
export interface CodeAnalysis {
|
|
258
|
+
complexity: number;
|
|
259
|
+
maintainability: number;
|
|
260
|
+
issues: CodeIssue[];
|
|
261
|
+
}
|
|
262
|
+
export interface CodeMatcher {
|
|
263
|
+
name: string;
|
|
264
|
+
description: string;
|
|
265
|
+
language: string;
|
|
266
|
+
pattern: string;
|
|
267
|
+
examples?: string[];
|
|
268
|
+
}
|
|
269
|
+
export interface MCPTool {
|
|
270
|
+
/** Name of the MCP */
|
|
271
|
+
name?: string;
|
|
272
|
+
/** Toolbox name */
|
|
273
|
+
toolbox?: string;
|
|
274
|
+
/** Tool name */
|
|
275
|
+
toolName?: string;
|
|
276
|
+
/** Available tools */
|
|
277
|
+
tools?: any[];
|
|
278
|
+
/** Description */
|
|
279
|
+
description?: string;
|
|
280
|
+
/** Parameters */
|
|
281
|
+
parameters?: Record<string, any>;
|
|
282
|
+
}
|
|
283
|
+
export interface MCPServer {
|
|
284
|
+
name: string;
|
|
285
|
+
enabled: boolean;
|
|
286
|
+
tools: MCPTool[];
|
|
287
|
+
configuration?: Record<string, any>;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Interface for Agent structure
|
|
291
|
+
*/
|
|
292
|
+
export interface Agent {
|
|
293
|
+
/** Agent name */
|
|
294
|
+
name?: string;
|
|
295
|
+
/** Agent ID */
|
|
296
|
+
id?: string | number;
|
|
297
|
+
/** Agent description */
|
|
298
|
+
description?: string;
|
|
299
|
+
/** Agent title */
|
|
300
|
+
title?: string;
|
|
301
|
+
/** Agent identifier string */
|
|
302
|
+
agent_id?: string;
|
|
303
|
+
/** Unique identifier for the agent */
|
|
304
|
+
unique_id?: string;
|
|
305
|
+
/** Detailed description of the agent and its capabilities */
|
|
306
|
+
longDescription?: string;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Interface for initial user message structure
|
|
310
|
+
*/
|
|
311
|
+
export interface InitialUserMessage {
|
|
312
|
+
/** The message text */
|
|
313
|
+
messageText?: string;
|
|
314
|
+
/** The actual text content of the user message */
|
|
315
|
+
userMessage?: string;
|
|
316
|
+
/** List of mentioned files */
|
|
317
|
+
mentionedFiles?: string[];
|
|
318
|
+
/** List of mentioned MCPs */
|
|
319
|
+
mentionedMCPs?: MCPTool[];
|
|
320
|
+
/** List of mentioned agents */
|
|
321
|
+
mentionedAgents?: Agent[];
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Type definition for an AST node.
|
|
325
|
+
*/
|
|
326
|
+
export interface ASTNode {
|
|
327
|
+
type: string;
|
|
328
|
+
text: string;
|
|
329
|
+
startPosition: {
|
|
330
|
+
row: number;
|
|
331
|
+
column: number;
|
|
332
|
+
};
|
|
333
|
+
endPosition: {
|
|
334
|
+
row: number;
|
|
335
|
+
column: number;
|
|
336
|
+
};
|
|
337
|
+
children: ASTNode[];
|
|
338
|
+
}
|
|
339
|
+
export interface Notification {
|
|
340
|
+
id?: string;
|
|
341
|
+
type: 'info' | 'warning' | 'error' | 'success';
|
|
342
|
+
title?: string;
|
|
343
|
+
message: string;
|
|
344
|
+
timestamp?: string;
|
|
345
|
+
duration?: number;
|
|
346
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Common TypeScript types and interfaces shared across the codeboltjs library
|
|
4
|
+
*
|
|
5
|
+
* This file contains:
|
|
6
|
+
* - Shared data structures
|
|
7
|
+
* - Common enums
|
|
8
|
+
* - Utility types
|
|
9
|
+
* - Application state types
|
|
10
|
+
* - Git-related types
|
|
11
|
+
* - Vector database types
|
|
12
|
+
* - General purpose interfaces
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CodeboltError = exports.LogType = void 0;
|
|
16
|
+
// ================================
|
|
17
|
+
// Log Types
|
|
18
|
+
// ================================
|
|
19
|
+
var LogType;
|
|
20
|
+
(function (LogType) {
|
|
21
|
+
/** Informational messages */
|
|
22
|
+
LogType["info"] = "info";
|
|
23
|
+
/** Error messages */
|
|
24
|
+
LogType["error"] = "error";
|
|
25
|
+
/** Warning messages */
|
|
26
|
+
LogType["warning"] = "warning";
|
|
27
|
+
})(LogType || (exports.LogType = LogType = {}));
|
|
28
|
+
class CodeboltError extends Error {
|
|
29
|
+
constructor(message, code, details) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.code = code;
|
|
32
|
+
this.details = details;
|
|
33
|
+
this.name = 'CodeboltError';
|
|
34
|
+
this.timestamp = new Date().toISOString();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.CodeboltError = CodeboltError;
|