Stevora

Installation

Install and configure the Stevora TypeScript SDK

Installation

The Stevora TypeScript SDK (@stevora/sdk) provides a typed client for the Stevora REST API. It works in any Node.js or edge runtime environment that supports the fetch API.

Install the package

npm install @stevora/sdk

Initialize the client

Import the AgentRuntime class and create an instance with your API key:

import { AgentRuntime } from '@stevora/sdk';

const runtime = new AgentRuntime({
  apiKey: 'stv_your_api_key',
});

The constructor throws immediately if apiKey is missing.

Configuration options

The AgentRuntimeConfig object accepts the following fields:

OptionTypeDefaultDescription
apiKeystring(required)Your Stevora API key. Starts with stv_.
baseUrlstringhttp://localhost:3000Base URL of the Stevora API server. Set this to your deployed URL in production.
timeoutnumber30000Request timeout in milliseconds. Applies to every HTTP call made by the SDK.

Full configuration example

import { AgentRuntime } from '@stevora/sdk';

const runtime = new AgentRuntime({
  apiKey: process.env.STEVORA_API_KEY!,
  baseUrl: 'https://api.stevora.example.com',
  timeout: 15000,
});

Resource namespaces

Once initialized, the client exposes four resource namespaces:

NamespaceDescription
runtime.workflowsCreate, list, cancel, resume, and monitor workflow runs
runtime.definitionsManage workflow definitions
runtime.approvalsList and decide on human-in-the-loop approval requests
runtime.costsQuery aggregated cost data across your workspace

There is also a top-level health() method:

const status = await runtime.health();
// { status: 'ok', checks: { database: 'ok', queue: 'ok' } }

Error handling

All SDK methods throw an AgentRuntimeError when the API returns a non-success response. Import it to catch errors with full context:

import { AgentRuntime, AgentRuntimeError } from '@stevora/sdk';

const runtime = new AgentRuntime({ apiKey: 'stv_your_api_key' });

try {
  await runtime.workflows.get('nonexistent');
} catch (err) {
  if (err instanceof AgentRuntimeError) {
    console.log(err.code);       // 'NOT_FOUND'
    console.log(err.statusCode); // 404
    console.log(err.message);    // "WorkflowRun 'nonexistent' not found"
    console.log(err.details);    // additional context, if any
  }
}

The AgentRuntimeError class extends Error and has the following properties:

PropertyTypeDescription
messagestringHuman-readable error description
codestringMachine-readable error code (e.g., NOT_FOUND, VALIDATION_ERROR)
statusCodenumberHTTP status code from the API response
detailsunknownOptional additional error context

ESM only

The SDK is published as an ES module ("type": "module" in its package.json). If your project uses CommonJS, you will need to use dynamic import() or update your project configuration to support ESM imports.