SDK Reference
TypeScript SDK
TypeScript-specific setup, imports, and module structure for the CUP SDK.
Installation
npm install computeruseprotocolFor platform-specific requirements, see Installation.
API
The TypeScript SDK exposes the full Session API. Here are TypeScript-specific usage notes.
Import patterns
import { snapshot, snapshotRaw, overview } from "computeruseprotocol";
// Session class for more control
import { Session } from "computeruseprotocol";
const session = await Session.create();Async factory
Unlike Python's synchronous cup.Session(), the TypeScript SDK uses an async factory:
const session = await Session.create(); // auto-detect
const session = await Session.create({ platform: "web" }); // force web adapterAction parameters
Action parameters are passed as an options object:
await session.action("e5", "type", { value: "hello world" });
await session.action("e9", "scroll", { direction: "down" });Types
All types are exported from the main package:
import type { ActionResult, CupEnvelope, CupNode } from "computeruseprotocol";Module structure
src/
index.ts # Public API
types.ts # Type definitions
cli.ts # CLI entry point
base.ts # Abstract PlatformAdapter
router.ts # Platform detection
format.ts # Envelope builder, compact serializer, pruning
search.ts # Semantic element search
actions/ # Per-platform action executors
platforms/ # Platform adapters
mcp/ # MCP server