@codebolt/cloud-sdk
v0.1.2
Published
SDK for connecting runtimes, preview providers, and services to CodeBolt Cloud.
Readme
CodeBolt Cloud SDK
Reusable SDK for cloud access and cloud connection management.
This package owns the cloud-facing pieces:
- websocket transport to CodeBolt Cloud
- proxy gateway registration and messaging
- artifact init/upload/complete API calls
- preview provider registration and preview lifecycle messages
- runtime identity helpers used by cloud runtimes
It intentionally does not subscribe to local CodeBolt plugin events. Local application/plugin integration belongs in @codebolt/plugin-sdk or in an adapter such as plugins/cloud-plugin.
Install
npm install @codebolt/cloud-sdkPreview Provider
import { createPreviewProvider } from '@codebolt/cloud-sdk/preview'
const provider = createPreviewProvider({
appToken: process.env.CODEBOLT_APP_TOKEN,
provider: {
providerId: 'my-static-provider',
name: 'My Static Provider',
kind: 'remote',
artifactTypes: ['static_site'],
},
})
provider.onPreviewRequest(async (request) => {
request.ack('Preparing preview...')
const url = request.getDirectUrl()
if (!url) {
request.error('No direct URL was available.')
return
}
request.ready({ kind: 'url', url, label: request.artifact.title || 'Artifact Preview' })
})
await provider.start()Proxy Gateway
import { ProxyGatewayClient } from '@codebolt/cloud-sdk/proxy'
const gateway = new ProxyGatewayClient({
appToken: process.env.CODEBOLT_APP_TOKEN,
userId: process.env.CODEBOLT_USER_ID,
runtime: {
runtimeId: 'runtime-1',
runtimeType: 'local',
projectPath: process.cwd(),
},
})
gateway.onMessage((message) => {
console.log('cloud message', message)
})
await gateway.connect()Artifacts
import { ArtifactCloudClient } from '@codebolt/cloud-sdk/artifacts'
const artifacts = new ArtifactCloudClient({
appToken: process.env.CODEBOLT_APP_TOKEN,
userId: process.env.CODEBOLT_USER_ID,
})
await artifacts.syncArtifact({
artifact,
files,
runtimeId: 'runtime-1',
})