TypeScript SDK

View as Markdown

The official TypeScript SDK provides type-safe access to the Chaser API for session management, workspaces, command execution, file operations, browser CDP, accounts, billing, webhooks, audit, and jobs.

Install

$npm install chaser-sdk

Create a client

1import { ChaserClient } from "chaser-sdk";
2
3const client = new ChaserClient({
4 apiKey: process.env.CHASER_API_KEY,
5 account: "personal" // or an organization name
6});

The account parameter maps to the X-Chaser-Account header, so one client can target a personal or organization context.

Sessions

1// Create a browser session
2const browser = await client.sessions.create({
3 session_type: "browser",
4 ephemeral: true
5});
6
7// Create a sandbox session with a workspace
8const sandbox = await client.sessions.create({
9 session_type: "sandbox",
10 workspace: "my-project"
11});
12
13// Wait for the session to be ready
14await client.sessions.waitUntilReady(sandbox.id);
15
16// Runtime self-test
17const diagnostics = await client.sessions.selfTest(sandbox.id);
18console.log(diagnostics.runtime.tools.node);

Command execution

1// Run in an existing session
2const result = await client.exec.inSession(sandbox.id, {
3 command: "npm ci && npm test",
4 cwd: "/workspace"
5});
6
7// Run with auto-provisioned ephemeral sandbox
8const result = await client.exec.run({
9 ephemeral: true,
10 image: "node:20-bookworm",
11 command: "node -e \"console.log(42)\""
12});
13
14console.log(result.output);

Workspaces

1// Create a workspace
2const workspace = await client.workspaces.create({
3 name: "frontend-app",
4 session_type: "sandbox",
5 image: "ghcr.io/example/dev:latest"
6});
7
8// Create a snapshot
9await client.workspaces.snapshots.create("frontend-app", {
10 name: "before-upgrade"
11});
12
13// Clone from a template
14await client.workspaces.create({
15 clone_from: "frontend-app",
16 name: "frontend-app-feature"
17});

Files

1await client.files.uploadText(session.id, "/workspace/hello.txt", "hello");
2const text = await client.files.downloadText(session.id, "/workspace/hello.txt");

Port forwarding

1const url = client.sessions.forwardUrl(session.id, 3000);
2// => https://<session_id>.chaser.sh/forward/3000/

Browser CDP

1const browser = await client.sessions.create({
2 session_type: "browser",
3 ephemeral: true
4});
5
6const cdp = await client.browser.connect(browser.id);
7await cdp.send("Browser.getVersion");
8cdp.close();

client.browser.connect() waits for readiness, fetches /json/version, and opens a WebSocket CDP connection.

Organizations and service accounts

1const orgClient = client.withAccount("Acme Engineering");
2
3const sa = await orgClient.accounts.serviceAccounts.create("ci-bot");
4const key = await orgClient.accounts.serviceAccounts.keys.create(sa.id, {
5 name: "ci-key",
6 scopes: ["sessions.read", "workspaces.write", "exec.write"]
7});

Scope

The SDK covers the core Chaser API surface. It does not include CHASM assistant management or act as an MCP transport wrapper. For MCP usage, call POST /v1/mcp directly.