Documentation
Everything you need to build durable workflows.
Define workflows your way
import { Mobius } from '@mobius/sdk'
const mobius = new Mobius({ apiKey: process.env.MOBIUS_KEY })
// Define a workflow
await mobius.run('order-processing', async (ctx) => {
// Step 1: Validate the order
const validation = await ctx.step('validate', async () => {
return await validateOrder(ctx.input.orderId)
})
// Step 2: Check inventory (with retries)
const inventory = await ctx.step('check-inventory',
async () => await checkInventory(validation.items),
{ retry: { maxAttempts: 3, backoff: 'exponential' } }
)
// Step 3: Human approval for high-value orders
if (validation.total > 1000) {
const approval = await ctx.prompt('approve-order', {
type: 'review',
message: `Approve order for $${validation.total}?`,
outcomes: ['approve', 'deny'],
timeout: '24h'
})
if (approval.outcome === 'deny') {
return { status: 'denied', reason: approval.reasoning }
}
}
// Step 4: Process payment
const payment = await ctx.step('charge', async () => {
return await chargeCard(validation.total)
})
return { status: 'completed', paymentId: payment.id }
})Get started in 5 minutes
From zero to a running workflow
Install the SDK
Use npm or pip to install
Define your workflow
Write steps in TypeScript, Python, or YAML
Run it
Execute via API, SDK, or CLI
Monitor & iterate
View execution history, debug failures, respond to prompts
Install
# npm npm install @mobius/sdk # or pip pip install mobius-sdk
Initialize
import { Mobius } from '@mobius/sdk'
const mobius = new Mobius({
apiKey: process.env.MOBIUS_KEY
})Run your first workflow
await mobius.run('hello-world', async (ctx) => {
const result = await ctx.step('greet', () => {
return { message: 'Hello, Mobius!' }
})
console.log(result.message)
})Documentation
Workflows
Define, run, and monitor workflows
Key Concepts
Workflow
A sequence of steps that execute in order. Each step is a checkpoint—if the process crashes, it resumes from the last completed step.
Step
A single unit of work. Steps can call APIs, run code, or wait for input. Each step's output is durably stored.
Prompt
A special step that pauses for external input. Prompts can be reviews, confirmations, choices, or forms.
Signal
An external event that can influence a running workflow. Workflows can wait for signals before continuing.
Execution
A single run of a workflow. Each execution has its own state and can be monitored independently.
State
The data that flows through a workflow. State is persisted after each step and survives crashes.
Human-in-the-Loop
Prompt Types
Four built-in prompt types for common human interaction patterns. Each type has its own UI and response schema.
Review
Present data for human review with multiple outcome options
await ctx.prompt('review-order', {
type: 'review',
message: 'Review this order',
data: orderDetails,
outcomes: ['approve', 'deny', 'escalate']
})Confirm
Simple yes/no confirmation for critical actions
await ctx.prompt('confirm-delete', {
type: 'confirm',
message: 'Delete 150 records?',
consequences: 'This cannot be undone'
})Choice
Select from a list of options
await ctx.prompt('select-action', {
type: 'choice',
message: 'How to proceed?',
options: [
{ value: 'retry', label: 'Retry' },
{ value: 'skip', label: 'Skip' },
{ value: 'manual', label: 'Handle manually' }
]
})Form
Collect structured input with validation
await ctx.prompt('get-details', {
type: 'form',
message: 'Provide shipping details',
fields: [
{ name: 'address', type: 'text', required: true },
{ name: 'priority', type: 'select', options: [...] }
]
})Advanced Patterns
Common patterns for building robust workflows
Parallel Execution
Fan out to multiple steps and collect results
const results = await ctx.parallel([
ctx.step('fetch-a', () => fetchA()),
ctx.step('fetch-b', () => fetchB()),
ctx.step('fetch-c', () => fetchC()),
])
// All three run concurrentlyWait for Signal
Pause until an external event arrives
// Wait up to 7 days for payment
const payment = await ctx.waitForSignal(
'payment_received',
{ timeout: '7d' }
)
// Triggered via webhook or APIScheduled Delays
Pause for a duration, then continue
// Send email, wait 3 days, send reminder
await ctx.step('send-email', sendEmail)
await ctx.sleep('3d')
await ctx.step('send-reminder', sendReminder)Conditional Retry
Custom retry logic based on error type
await ctx.step('call-api', callApi, {
retry: {
maxAttempts: 5,
backoff: 'exponential',
retryIf: (err) => err.code === 429
}
})Examples
Real World Workflows
Complete, production-ready examples you can copy and customize
A support ticket agent that classifies, drafts responses, and escalates when uncertain
await mobius.run('support-agent', async (ctx) => {
const ticket = ctx.input.ticket;
// Step 1: Classify the ticket
const classification = await ctx.step('classify', async () => {
const result = await ai.classify(ticket.content, {
categories: ['billing', 'technical', 'general', 'urgent']
});
return result;
});
// Step 2: Generate a draft response
const draft = await ctx.step('draft-response', async () => {
return await ai.generate({
prompt: `Draft a response to: ${ticket.content}`,
context: classification.category
});
});
// Step 3: If confidence is low, escalate to human
if (draft.confidence < 0.8) {
const review = await ctx.prompt('review-draft', {
type: 'review',
message: 'AI drafted response needs review',
data: {
ticket: ticket.content,
draft: draft.response,
confidence: draft.confidence
},
outcomes: ['approve', 'edit', 'escalate']
});
if (review.outcome === 'escalate') {
return await ctx.step('create-escalation', () =>
createEscalation(ticket.id)
);
}
}
// Step 4: Send the response
await ctx.step('send-response', async () => {
return await sendEmail(ticket.email, draft.response);
});
return { status: 'resolved', ticketId: ticket.id };
})CLI Usage
Test and manage workflows from the command line
Local Development
# Start a local dev server
mobius dev
# Run a workflow locally
mobius run my-workflow --input '{"key": "value"}'
# Tail execution logs
mobius logs exec_abc123 --followDeployment & Management
# Deploy workflows mobius deploy # List executions mobius executions list --status running # Respond to a prompt mobius prompts complete prompt_xyz --outcome approve
Need help? Open an issue on GitHub or email support