Package Exports
- @codebolt/codeboltjs
- @codebolt/codeboltjs/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@codebolt/codeboltjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Codebolt Agent Library
This library provides a set of tools and utilities for creating Codebolt agents, enabling seamless integration with the Codebolt platform with full TypeScript support.
Features
- Create and manage Codebolt agents
- Interact with the Codebolt platform
- Utilize Codebolt's powerful API
- Full TypeScript support with comprehensive type definitions
- Type-safe API interactions
- IntelliSense support in TypeScript/JavaScript IDEs
Installation
npm install @codebolt/codeboltjsQuick Start
JavaScript
const codebolt = require('@codebolt/codeboltjs');
// Set up message handling
codebolt.onMessage(async (userMessage) => {
console.log('User said:', userMessage.userMessage);
// Read a file
const content = await codebolt.fs.readFile({ path: './example.txt' });
console.log('File content:', content);
return { status: 'completed' };
});TypeScript
import codebolt from 'codeboltjs';
import type {
ChatMessageFromUser,
ReadFileOptions,
BrowserScreenshotOptions
} from 'codeboltjs';
// Type-safe message handling
codebolt.onMessage(async (userMessage: ChatMessageFromUser) => {
console.log('User said:', userMessage.userMessage);
console.log('Mentioned files:', userMessage.mentionedFiles);
// Type-safe file operations
const readOptions: ReadFileOptions = {
path: './config.json',
encoding: 'utf8',
askForPermission: true
};
const content = await codebolt.fs.readFile(readOptions);
// Type-safe browser operations
const screenshotOptions: BrowserScreenshotOptions = {
fullPage: true,
quality: 90,
format: 'png'
};
const screenshot = await codebolt.browser.takeScreenshot(screenshotOptions);
return { status: 'completed', data: content };
});TypeScript Support
This library provides comprehensive TypeScript support with over 200+ type definitions covering:
Core Types
- Message & Tool Types:
Message,ToolCall,Tool,LLMInferenceParams - API Response Types:
APIResponse,SuccessResponse,FailureResponse - Configuration Types:
CodeboltConfig,AgentConfiguration
Module-Specific Types
- File System:
ReadFileOptions,WriteFileOptions,SearchFilesOptions - Browser:
BrowserNavigationOptions,BrowserScreenshotOptions - Terminal:
TerminalExecuteOptions - Git:
GitCommitOptions,GitLogOptions - LLM:
LLMChatOptions,OpenAIMessage - Vector DB:
VectorAddOptions,VectorQueryOptions
Import Strategies
From Main Package
import codebolt, { type Message, type ToolCall } from 'codeboltjs';From Types Barrel (Recommended)
import codebolt from 'codeboltjs';
import type { Message, ToolCall, LLMChatOptions } from 'codeboltjs/types';Namespace Import
import codebolt from 'codeboltjs';
import type * as CodeboltTypes from 'codeboltjs/types';For detailed type usage examples, see TYPES.md.
API Overview
Core Modules
codebolt.fs- File system operationscodebolt.git- Git operationscodebolt.browser- Browser automationcodebolt.terminal- Terminal/shell operationscodebolt.llm- LLM interactionscodebolt.chat- Chat managementcodebolt.agent- Agent operationscodebolt.vectordb- Vector database operationscodebolt.mcp- MCP (Model Context Protocol) toolscodebolt.codeparsers- Code parsing and AST generation (migrated from internal module)
Note: The
codeparsersfunctions have been migrated to the@codebolt/codeparserpackage for better modularity. You can still access them throughcodebolt.codeparsersor import directly from@codebolt/codeparser. See CODEPARSERS_MIGRATION.md for details.
Example Usage
// Wait for connection
await codebolt.waitForReady();
// File operations
const files = await codebolt.fs.listFiles({ path: './src', recursive: true });
const content = await codebolt.fs.readFile({ path: './package.json' });
// Browser operations
await codebolt.browser.navigateTo({ url: 'https://example.com' });
const screenshot = await codebolt.browser.takeScreenshot({ fullPage: true });
// Terminal operations
const result = await codebolt.terminal.execute({
command: 'npm install',
cwd: './my-project'
});
// LLM operations
const response = await codebolt.llm.chat({
messages: [{ role: 'user', content: 'Explain TypeScript' }],
temperature: 0.7
});Development
Building the Project
# Install dependencies
npm install
# Build TypeScript to dist/ (recommended for development)
npm run build
# Build webpack bundle to build/bundle.js (single file for distribution)
npm run build:webpack
# Build both TypeScript and webpack versions
npm run build:all
# Clean all build artifacts
npm run clean
# Build documentation
npm run build:docsBuild Outputs
The project supports two build methods:
TypeScript Build (
npm run build)- Outputs to
dist/directory - Preserves module structure
- Includes separate
.jsand.d.tsfiles - Recommended for npm publishing and development
- Outputs to
Webpack Build (
npm run build:webpack)- Outputs to
build/bundle.js - Single bundled file
- Optimized for production deployment
- Works in Node.js environments
- Outputs to
Project Structure
src/- TypeScript source codecore/- Core library classes (Codebolt class, WebSocket management)modules/- Feature modules (fs, git, browser, etc.)types/- TypeScript type definitionsutils/- Utility functions
dist/- Compiled JavaScript and type definitions (generated by TypeScript)build/- Webpack bundle (generated by webpack)docs/- Generated documentation
Documentation
- Type Definitions Guide - Comprehensive TypeScript usage guide
- Codebolt Documentation - Platform documentation
- API Reference - Generated from source code (coming soon)