Skip to content

Commit 8d83287

Browse files
committed
moved the codeboltjs class outside
1 parent 2ae1d69 commit 8d83287

File tree

6 files changed

+1007
-156
lines changed

6 files changed

+1007
-156
lines changed

Readme.md

Lines changed: 138 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,152 @@
11
# Codebolt Agent Library
22

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.
44

55
## Features
66
- Create and manage Codebolt agents
77
- Interact with the Codebolt platform
88
- 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
912

1013
## Installation
1114

1215
```bash
1316
npm install @codebolt/codeboltjs
1417
```
1518

16-
## Usage
19+
## Quick Start
1720

21+
### JavaScript
1822
```javascript
1923
const codebolt = require('@codebolt/codeboltjs');
2024

21-
// Your code here
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+
});
22150
```
23151

24152
## Development
@@ -64,11 +192,17 @@ The project supports two build methods:
64192
### Project Structure
65193

66194
- `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
67199
- `dist/` - Compiled JavaScript and type definitions (generated by TypeScript)
68200
- `build/` - Webpack bundle (generated by webpack)
69201
- `docs/` - Generated documentation
70202

71203
## Documentation
72204

73-
For More Documentation visit [Codebolt's Documentation](https://docs.codebolt.ai)
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)
74208

0 commit comments

Comments
 (0)