loading
loading
@trickest/sdk wraps the platform in a TypeScript client built on native fetch. Construct it once, reach every surface through 21 lazy service namespaces, then expose the same workflows to Claude Code, Cursor, Codex, and your own agents through CLI, MCP, and skills.
install & quick start
Install with your package manager of choice. The client reads its token from a { token } option or the TRICKEST_TOKEN environment variable; with neither set, the constructor throws immediately rather than failing on first call.
import { TrickestClient } from "@trickest/sdk"
const client = new TrickestClient() // reads TRICKEST_TOKEN
// List spaces — async iteration paginates for you.
for await (const space of client.spaces.list()) {
console.log(space.name, space.id)
}
// Create then execute a workflow.
const workflow = await client.workflows.create(spaceId, {
name: "My Workflow",
})
const run = await client.runs.execute(workflow.id, {
inputs: { domain: "example.com" },
})npm install @trickest/sdk · bun add @trickest/sdk · Node.js ≥ 22
authenticate
The client authenticates via the Authorization header and picks the scheme automatically: a personal API token goes out as Token <token>, while a JWT (it contains a .) goes out as Bearer <token>. Point at a different deployment with baseUrl or TRICKEST_BASE_URL.
// 1 — pass a token directly
const client = new TrickestClient({ token: "your-token" })
// 2 — read TRICKEST_TOKEN from the environment
const client = new TrickestClient()
// 3 — target a custom deployment
const client = new TrickestClient({
token: "your-token",
baseUrl: "https://trickest.io", // the default
})the surfaces you reach for
Execute a workflow, drive an agent turn over a SessionHandle, or filter the tables a run produces with TQL. Every snippet here compiles against the shipping 3.0 client.
Pass { node } and the SDK reads the workflow graph, finds the last completed run whose upstream subjobs succeeded, and memoizes from it. Only the target node re-runs. Fleet and vault resolve from the workflow when you leave them out.
import { TrickestClient } from "@trickest/sdk"const client = new TrickestClient() // reads TRICKEST_TOKEN// Full run. Fleet + vault auto-resolve from the workflow.const run = await client.runs.execute(workflowId, {inputs: { domain: "example.com" },})// Single node. Upstream outputs memoized from a recent run.const partial = await client.runs.execute(workflowId, {node: "httpx",})
service namespaces
The client instantiates each service the first time you touch its getter; every service extends BaseService, which provides auto-pagination, single-page fetching, and CRUD helpers. Authentication stays internal, so there is no auth namespace to call.
pagination
Every list method returns an AsyncGenerator that transparently fetches pages with page and page_size (default 500). Drop to listPage when you need a single page with cursor and count.
// Auto-paginate every workflow in a space.
for await (const workflow of client.workflows.list(spaceId)) {
console.log(workflow.name)
}
// Control the page size.
for await (const run of client.runs.list(workflowId, { pageSize: 50 })) {
// ...
}
// Low-level: one page with { results, next, count }.
import { listPage } from "@trickest/sdk"
const page = await listPage(client.http, "/v1/spaces/", { pageSize: 10 })agent chat · sdk 3.0
Agent turns do not stream over HTTP. sessions.handle() opens a long-lived handle bound to one session: it fetches the canonical projection, then (with realtime: true) subscribes over WebSocket so invalidation frames trigger coalesced refetches and per-character deltas. For headless callers, runTurn dispatches a turn and resolves once the projection seals.
import { TrickestClient, runTurn } from "@trickest/sdk"
const client = new TrickestClient()
const session = await client.sessions.create(vaultId, "Recon Session")
const handle = await client.sessions.handle(session.id, vaultId, {
realtime: true,
})
try {
const turn = await runTurn(handle, {
prompt: "Build a recon workflow for example.com",
autoApprove: true,
})
console.log(turn.answer) // concatenated text blocks
console.log(turn.toolCalls.length) // [{ name, args, status, result? }]
console.log(turn.phase) // completed | failed | aborted
} finally {
handle.close()
}UI consumers subscribe() for canonical state and subscribeStreaming() for live deltas · dispatch() is the fire-and-forget escape hatch
error handling
Every failure throws a class that extends TrickestError and carries status, code, and requestId (aliased traceId). Branch on the instanceof class first, then narrow on the server code for sub-types of the same status.
The SDK retries with exponential backoff (3 attempts, 1s base): 429 always honors Retry-After (capped at 60s); 5xx, network, and timeout failures retry on idempotent methods, or on POST/PATCH carrying an idempotencyKey. Other 4xx throw immediately.
per-request options
Every service method takes a trailing RequestOptions object, so timeouts, cancellation, retry policy, headers, idempotency, auth, and response validation are all controllable at the call site.
const space = await client.spaces.get(id, {
timeout: 5000,
signal: controller.signal,
retry: false,
})
// Idempotency-key-aware POST — retried on 5xx / network / timeout.
await client.database.insertRow(
tableId,
{ host: "example.com", port: 443 },
{ idempotencyKey: `scan:${runId}:${rowHash}` },
)coding-agent toolchain
The SDK is the typed surface. The CLI gives it a terminal shape, MCP exposes it as tools to coding agents, and skills package the repeatable playbooks. Configure it once and use the same Trickest workflows from your editor, your terminal, or an agent runtime.
Install, authenticate, and call typed service namespaces from TypeScript.
Read more →Use the terminal surface for shell automation, CI, and sandbox agents.
Read more →Expose Trickest workflow and run tools to Claude Code, Cursor, Codex, or another MCP client.
Read more →Package repeatable playbooks that tell agents when to use Trickest.
Read more →Get a personalized demo
A 30-minute walkthrough. We map the platform to your stack and answer pricing and deployment questions for your environment.