> ## Documentation Index
> Fetch the complete documentation index at: https://docs.duraton.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> Write durable agents in TypeScript: @duraton/sdk authors workflows, runs a runner, and calls Duraton from app code, all from one package.

`@duraton/sdk` is how you author workflows, run them on a runner, and talk to Duraton from app code.
Install it and import from the package root:

<CodeGroup>
  ```sh npm theme={null}
  npm install @duraton/sdk
  ```

  ```sh pnpm theme={null}
  pnpm add @duraton/sdk
  ```

  ```sh yarn theme={null}
  yarn add @duraton/sdk
  ```

  ```sh bun theme={null}
  bun add @duraton/sdk
  ```
</CodeGroup>

```ts theme={null}
import {
  workflow,
  connect,
  createClient,
  NonRetriableError,
  RetryAfterError,
  PollTimeoutError,
} from "@duraton/sdk";
```

## Entry points

Every export is reachable from the package root. The scoped entries are subsets, for code that should
not pull in the rest.

```ts theme={null}
import { createClient } from "@duraton/sdk/client";   // no workflow authoring, no runner
import { createMemoryCache } from "@duraton/sdk/ai";  // the AI ports and their adapters
```

| Entry                 | Contains                                                                         | Use it when                                                             |
| --------------------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `@duraton/sdk`        | Everything below, plus `workflow`, `connect`, `hashStepId`, and the error types. | Authoring workflows and running a runner.                               |
| `@duraton/sdk/client` | `createClient`, `DuratonApiError`, and the REST DTOs.                            | App code that only calls Duraton - an admin tool, a frontend, a script. |
| `@duraton/sdk/ai`     | The `AIProvider` and `AICache` ports, their adapters, and the AI journal types.  | Supplying your own model provider or cache store.                       |

## The surface

<CardGroup cols={2}>
  <Card title="Defining workflows" href="/reference/sdk/defining-workflows">
    workflow: name, triggers, retry, flow control.
  </Card>

  <Card title="Steps" href="/reference/sdk/steps">
    The handler context and the durable step API.
  </Card>

  <Card title="connect" href="/reference/sdk/connect">
    Run a runner over an outbound WebSocket - no inbound URL.
  </Card>

  <Card title="REST client" href="/reference/sdk/client">
    createClient: trigger events, read and control runs.
  </Card>

  <Card title="AI steps" href="/reference/sdk/ai-steps">
    step.ai: durable model calls, agent loops, providers, cache.
  </Card>
</CardGroup>
