Skip to main content

Client SDK

@codebolt/client-sdk is a typed TypeScript client for all Codebolt HTTP routes and WebSocket channels. It lives in packages/clientsdk and is the primary entry point for building custom UIs on top of Codebolt.

Backend Setup

  1. Run the CLI in server-only mode.
  2. The CLI hosts the backend from packages/server.
  3. Connect your UI through the SDK.
codebolt --server

Installation

npm install @codebolt/client-sdk

Quick Start

import { CodeBoltClient } from '@codebolt/client-sdk';

// Create a client (connects automatically by default)
const client = new CodeBoltClient({
host: 'localhost',
port: 12345,
});

// HTTP API usage
const threads = await client.chat.getThreadsInfo();
await client.git.commit({ message: 'fix bug' });
const tasks = await client.tasks.search({ status: 'pending' });

// WebSocket usage
client.sockets.shell.on('output', (data) => console.log(data));
client.sockets.shell.send('ls -la');

// Listen to all socket events
const unsub = client.onAllEvents((event) => {
console.log(event);
});

// Cleanup
await client.disconnectAll();

Configuration

Pass a partial CodeBoltConfig to the constructor. Missing fields use defaults.

interface CodeBoltConfig {
host: string; // default: 'localhost'
port: number; // default: 12345 (or SOCKET_PORT env var)
basePath: string; // default: '/'
httpTimeout: number; // default: 30000 (ms)
wsReconnect: boolean; // default: true
wsReconnectInterval: number; // default: 1000 (ms)
wsMaxReconnectAttempts: number; // default: 10
debug: boolean; // default: false
autoConnect?: boolean; // default: true
defaultPreset?: ConnectionPreset; // default: MINIMAL
defaultSockets?: string[];
excludeHighSpeed?: boolean; // default: true
}

Connection Presets

Control which WebSockets connect automatically:

PresetSocketsUse case
MINIMALmain, systemAlertLightweight clients that only need HTTP APIs
STANDARDLow-speed + medium-speed socketsMost custom UIs
FULLAll sockets except high-speedFull-featured applications
import { CodeBoltClient, ConnectionPreset } from '@codebolt/client-sdk';

const client = new CodeBoltClient({
defaultPreset: ConnectionPreset.STANDARD,
});

Architecture

The SDK has two communication layers:

  • HTTP API modules (72 modules) — request/response calls over REST
  • WebSocket modules (34 modules) — real-time bidirectional channels

All modules are lazily initialized on first access, so unused modules don't allocate resources.

HTTP API Modules

Access via client.<module>. Every module is a class with typed methods wrapping Codebolt REST endpoints.

Core Modules

PropertyClassDescription
chatChatApiThread management, messaging, steps, steering
threadsThreadsApiThread CRUD
threadStepsThreadStepsApiThread step management
agentsAgentsApiAgent lifecycle — start, install, configure
tasksTasksApiTask search, create, update, delete, statistics
taskActivityTaskActivityApiTask activity tracking
projectsProjectsApiProject lifecycle, file trees, workspace
gitGitApiGit operations — commit, push, pull, branch, diff, graph
fileFileApiFile CRUD, existence checks, zip
fileReadFileReadApiFile reading
llmLlmApiLLM providers, models, pricing

Agent & Orchestration

PropertyClassDescription
agentFlowAgentFlowApiAgent workflow orchestration
agentExecutionAgentExecutionApiExecution tracking
agentExecutionPhasesAgentExecutionPhasesApiExecution phase management
agentDeliberationAgentDeliberationApiDeliberation processes
agentPortfolioApiAgentPortfolioApiAgent portfolio management
agentDebugApiAgentDebugApiAgent debugging
backgroundAgentsBackgroundAgentsApiBackground agent management
swarmSwarmApiMulti-agent swarm coordination
orchestratorOrchestratorApiOrchestration control
reviewMergeReviewMergeApiCode review and merge

Knowledge & Memory

PropertyClassDescription
knowledgeKnowledgeApiKnowledge collections, documents, retrieval
knowledgeGraphKnowledgeGraphApiKnowledge graph operations
memoryMemoryApiMemory management
memoryIngestionMemoryIngestionApiMemory ingestion
persistentMemoryPersistentMemoryApiPersistent memory storage
vectorDbVectorDbApiVector database operations
kvStoreKvStoreApiKey-value store

Code & Editor

PropertyClassDescription
editorApiEditorApiEditor operations
codebaseIndexCodebaseIndexApiCodebase indexing
codemapCodemapApiCode mapping
languageServerLanguageServerApiLSP integration
shadowGitShadowGitApiShadow git operations
fileUpdateIntentsFileUpdateIntentsApiFile update intent tracking

Context & Planning

PropertyClassDescription
contextAssemblyContextAssemblyApiContext assembly
contextRuleEngineContextRuleEngineApiContext rules
plannerPlannerApiPlanning operations
actionPlansActionPlansApiAction plan management
actionBlocksActionBlocksApiAction block management
requirementPlanRequirementPlanApiRequirement planning
specsSpecsApiSpecification management

Browser & Terminal

PropertyClassDescription
browserBrowserApiBrowser automation — navigate, click, fill, screenshot
terminalProcessesTerminalProcessesApiTerminal process management

Infrastructure & System

PropertyClassDescription
systemSystemApiSystem operations
applicationApplicationApiApplication management
appsAppsApiApps management
environmentsEnvironmentsApiEnvironment management
environmentDebugApiEnvironmentDebugApiEnvironment debugging
mcpMcpApiMCP server management
codeboltToolsCodeboltToolsApiCodebolt tools
hooksHooksApiHooks management
localModelsLocalModelsApiLocal model management
autoTestingAutoTestingApiAutomated testing

Productivity

PropertyClassDescription
calendarCalendarApiCalendar and scheduling
mailMailApiEmail operations
inboxInboxApiInbox operations
todosTodosApiTodo management
roadmapRoadmapApiRoadmap management
jobsJobsApiJob management

UI & Misc

PropertyClassDescription
canvasCanvasApiCanvas operations
capabilityCapabilityApiCapability management
controllkControllkApiCtrl+K command palette
eventLogEventLogApiEvent logging
historyHistoryApiHistory tracking
iconViewIconViewApiIcon view
profileProfileApiUser profile
projectStructureProjectStructureApiProject structure
templatesTemplatesApiTemplate management
themesThemesApiTheme management
updateRequestsUpdateRequestsApiUpdate request tracking
usersUsersApiUser management
workspaceWorkspaceApiWorkspace management

WebSocket Modules

Access via client.sockets.<module>. Each socket extends TypedEventEmitter and manages its own connection through the SocketConnectionManager.

PropertyClassDescription
shellShellSocketPTY terminal — send commands, resize, receive output
chatChatSocketChat message streaming
debugDebugSocketDebug session events
codeboltCodeboltSocketCodebolt core events
browserBrowserSocketBrowser automation events
tasksTasksSocketTask update events
jobsJobsSocketJob monitoring events
aiTerminalAiTerminalSocketAI terminal interaction
editorEditorSocketEditor synchronization
mainMainSocketMain connection events
lspLspSocketLanguage Server Protocol
capabilityCapabilitySocketCapability updates
swarmSwarmSocketSwarm coordination events
reviewMergeReviewMergeSocketCode review/merge events
agentPortfolioAgentPortfolioSocketAgent portfolio updates
calendarCalendarSocketCalendar events
episodicMemoryEpisodicMemorySocketMemory events
roadmapRoadmapSocketRoadmap updates
projectStructureProjectStructureSocketProject structure changes
updateRequestUpdateRequestSocketUpdate notifications
backgroundAgentBackgroundAgentSocketBackground agent events
knowledgeKnowledgeSocketKnowledge base events
fileUpdateIntentFileUpdateIntentSocketFile update events
persistentMemoryPersistentMemorySocketPersistent memory events
contextAssemblyContextAssemblySocketContext assembly events
kvStoreKvStoreSocketKey-value store events
eventLogEventLogSocketEvent log entries
iconViewIconViewSocketIcon view updates
localModelLocalModelSocketLocal model events
systemAlertSystemAlertSocketSystem alerts
orchestratorOrchestratorSocketOrchestration events
agentDebugAgentDebugSocketAgent debug events
environmentDebugEnvironmentDebugSocketEnvironment debug events

Connection Management

// Add specific socket connections at runtime
await client.addConnections(['shell', 'chat']);

// Check active connections
const active = client.getActiveConnections();

// Remove connections
await client.removeConnections(['shell']);

// Subscribe to filtered events
const unsub = client.onEvents(
{ socketName: 'chat', eventType: 'message' },
(event) => console.log(event),
);

// Unsubscribe
unsub();

// Disconnect everything
await client.disconnectAll();

Error Handling

The SDK provides typed error classes:

ErrorCodeDescription
CodeBoltErrorCODEBOLT_ERRORBase error
CodeBoltApiErrorAPI_ERRORHTTP errors with status, statusText, data
CodeBoltSocketErrorSOCKET_ERRORWebSocket errors with socketUrl
CodeBoltConnectionErrorCONNECTION_ERRORConnection failures with url
CodeBoltTimeoutErrorTIMEOUT_ERRORTimeout errors with timeout value
import { CodeBoltApiError } from '@codebolt/client-sdk';

try {
await client.tasks.search();
} catch (err) {
if (err instanceof CodeBoltApiError) {
console.error(`API error ${err.status}: ${err.message}`);
}
}

Exports

The package re-exports everything from a single entry point:

import {
// Primary client
CodeBoltClient,
CodeBoltSockets,

// Configuration
CodeBoltConfig,
DEFAULT_CONFIG,
mergeConfig,

// Core utilities
HttpClient,
SocketConnectionManager,
ConnectionPreset,
EventFilter,

// Errors
CodeBoltError,
CodeBoltApiError,
CodeBoltSocketError,
CodeBoltConnectionError,
CodeBoltTimeoutError,

// All type definitions
// All API module classes
// All Socket module classes
} from '@codebolt/client-sdk';

Getting Started

For a step-by-step tutorial that walks through scaffolding a project, making API calls, and subscribing to real-time WebSocket events, see Build your first custom UI.

When to Use

  • You want to own the whole application shell
  • Your UI runs outside the built-in app
  • You need custom branding, routing, layout, or device-specific UX
  • You're building a "Codebolt for X" vertical product

See Also