Installation & Setup

View as Markdown

Install

$npm install @bctrl/sdk

Create a client

1import { Bctrl } from "@bctrl/sdk";
2
3const bctrl = new Bctrl({
4 apiKey: process.env.BCTRL_API_KEY!,
5});

Create an API key in the BCTRL dashboard.

Create a space

A space is the boundary for runtime work. It controls which resources the runtime can access.

1const space = await bctrl.spaces.create({
2 name: "invoice-agent",
3 mounts: {
4 storage: { space: "acme-invoices" },
5 vault: { allow: ["clients/acme/"] },
6 ai: { allowConnections: ["anthropic-prod"] },
7 },
8});

Launch a browser runtime

1const runtime = await space.runtimes.browser.launch({
2 name: "quickbooks",
3});

Connect to it

Browser runtimes expose CDP connections. Use the endpoint with Playwright, Puppeteer, or another CDP-compatible tool.

1const connection = await runtime.connections.create({
2 protocol: "cdp",
3});

Inspect the active run

The run is where BCTRL records evidence.

1const run = await runtime.currentRun();
2
3const live = await run.live({
4 control: "none",
5});
6
7console.log(live.iframeUrl);

Next