TypeScript quickstart
Before you start
The TypeScript SDK exposes the same Rust execution engine as Python with Promise-based APIs and Node.js idioms. If you want the smallest example first, see First workflow in five minutes (Python) or jump to the example below.
Requires Node.js 18+. For install issues, see Install and build.
Concept
Behavior matches Python for the same workflow definition; only the surface syntax differs. Omitting a provider in run() uses the default in-process agent backend. The runtime executes steps in order and returns camelCase fields on the result object (runId, stepCount, traceEvents).
For browser production embeds, prefer @arcflow/static over bundling the full SDK. See Static site chatbot.
Install
From npm (consumer projects)
The package ships a prebuilt native .node binary and has no production npm dependencies.
From this repository (local development)
Verify:
Example: agent and workflow
Save as quickstart.ts:
Run with Node 18+ (top-level await) or wrap in async function main():
Or use tsx:
The fluent step() pattern returns this, so you can chain:
Reading the result
| Field | Meaning |
|---|---|
output | Final step text |
runId | Run UUID (camelCase in TypeScript) |
stepCount | Steps executed |
status | Terminal status |
traceEvents | Raw metadata events from the runtime |
Cross-language runs produce equivalent trace shapes; integration tests in sdk-python/tests/integration/test_cross_language_equivalence.py compare normalized trace status and step counts.
Structured trace via workflow.trace()
trace() before run() throws TraceNotFoundError.
Optional: real LLM with OpenAI
Set OPENAI_API_KEY in the environment before running. Anthropic and Gemini providers follow the same run() options pattern with ANTHROPIC_API_KEY and GEMINI_API_KEY.
Async patterns
All execution entry points return Promises. Use async/await in scripts:
For streaming in Node, see runStream() on Workflow. See SDK streaming.
Common errors
| Error | Typical cause |
|---|---|
WorkflowConfigurationError | Invalid workflow name, graph/step mismatch, bad agent type |
WorkflowExecutionError | Runtime step failure |
TraceNotFoundError | No completed run on this workflow instance |
Equivalence with Python
| Python | TypeScript |
|---|---|
Workflow("name") | new Workflow({ name: "name" }) |
workflow.step(agent) | workflow.step(agent) |
workflow.run("input") | await workflow.run("input") |
result.run_id | result.runId |
OpenAI(model="gpt-4o") | new OpenAI({ model: "gpt-4o" }) |
Verify
| Check | Expected |
|---|---|
| Import succeeds | import ok |
| Default run (no API key) | stepCount === 2, non-empty output |
workflow.trace() after run | Summary prints without exception |
Next
| Topic | Link |
|---|---|
| Python twin | Python quickstart |
| Track A with verification steps | Track A: First workflow |
| Provider guide | Provider configuration |
| Browser static client | Static site chatbot |
| VS Code extension | VS Code overview |