@stevora/sdk
v0.1.0
Published
TypeScript SDK for Stevora — durable execution for AI agent workflows
Downloads
59
Maintainers
Readme
@stevora/sdk
TypeScript SDK for Stevora — durable execution for AI agent workflows.
Install
npm install @stevora/sdkQuick Start
import { AgentRuntime } from '@stevora/sdk';
const runtime = new AgentRuntime({
apiKey: 'stv_your_api_key',
baseUrl: 'http://localhost:3000', // or your deployed URL
});
// Create a workflow run
const run = await runtime.workflows.create({
definitionId: 'your-definition-id',
input: {
prospectName: 'Sarah Chen',
company: 'TechFlow AI',
email: '[email protected]',
},
});
console.log(`Run started: ${run.id} — status: ${run.status}`);
// Wait for completion (polls every 2s)
const completed = await runtime.workflows.waitForCompletion(run.id);
console.log(`Done! Status: ${completed.status}`);
// Check cost
const cost = await runtime.workflows.getCost(run.id);
console.log(`Total cost: ${cost.totalCostDollars}`);Resources
runtime.workflows
| Method | Description |
|--------|-------------|
| create(input) | Start a new workflow run |
| get(id) | Get run by ID with step details |
| list(params?) | List runs with pagination and filters |
| cancel(id) | Cancel a running workflow |
| resume(id, input) | Resume with external signal |
| retry(id) | Retry a failed workflow |
| getEvents(id) | Get event timeline |
| getCost(id) | Get cost breakdown |
| getTraces(id) | Get LLM call + tool traces |
| waitForCompletion(id, opts?) | Poll until terminal state |
runtime.definitions
| Method | Description |
|--------|-------------|
| create(input) | Create workflow definition |
| get(id) | Get definition by ID |
| list() | List all active definitions |
runtime.approvals
| Method | Description |
|--------|-------------|
| list(opts?) | List approvals (filter by pending) |
| decide(id, input) | Submit a decision |
| approve(id, by?) | Shorthand for approve |
| reject(id, by?) | Shorthand for reject |
runtime.costs
| Method | Description |
|--------|-------------|
| summary(opts?) | Workspace cost aggregation |
Error Handling
import { AgentRuntimeError } from '@stevora/sdk';
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"
}
}