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

# TypeScript

> Define the same Roark resources in TypeScript with define* builders, then apply them with the Node SDK, a typed alternative to YAML

Config as Code has two front doors to the **same** system. Write your resources as [YAML](https://docs.roark.ai/documentation/config-as-code/overview.md) files, or build them in **TypeScript** with the `define*` helpers in the [Node SDK](https://docs.roark.ai/documentation/sdks/node-sdk.md) (at the subpath `@roarkanalytics/sdk/lib/config`). Both produce the identical bundle and go through the identical `diff` / `apply`, so you can pick whichever fits your codebase, or mix them.

TypeScript buys you type-checked fields, editor autocomplete on every resource, typed cross-references (reference an agent by its construct, not a string), loops and shared constants, and prompts as plain strings, with no YAML `file://` sentinel. The [Quickstart](https://docs.roark.ai/documentation/config-as-code/overview.md#quickstart) walks the full author-preview-apply loop in both languages, and every resource page below carries a TypeScript example beside its YAML.

***

## Builders

One `define*` helper per resource kind. Each injects the resource's `kind` (and any fixed discriminator) and returns the exact object `config.apply` expects:

| Helper | Resource |
| :- | :- |
| `defineAgent` | Voice agents and their endpoints |
| `defineTool` | Agent tools (takes a typed `agent` reference) |
| `definePersona` | The simulated caller for a flow |
| `defineImprovFlow` / `defineScriptedFlow` | Simulation flows |
| `defineMetric` | Custom LLM-judged metrics |
| `defineCollector` | Which metrics run on which conversations |
| `defineSimulationPlan` / `defineQaSimulationPlan` | Saved, repeatable runs |
| `defineSimulationGroup` | Several plans run together |
| `defineAlert` | Threshold / event / simulation alerts |
| `defineDashboard` | Dashboards and widgets |
| `defineHTTPRequestDefinition` | Outbound-dial HTTP requests |
| `defineProject` | Projects (organization key, see [Organizations](https://docs.roark.ai/documentation/config-as-code/organizations.md)) |

`defineConfig({ resources, prune })` assembles the bundle. `resources` accepts both builder outputs and raw resource objects, so a kind without a dedicated helper still fits:

```ts theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
defineConfig({
  resources: [frontDesk, { kind: 'persona', name: 'frustrated-caller', accent: 'US' /* ... */ }],
});
```

***

## Apply semantics

Identical to the YAML path, because the output is the same bundle: identity by `name`, cross-references resolved by name, `prune` deletes config-managed resources you drop (set `prune: false` for additive-only), and applies are idempotent. See [Apply semantics](https://docs.roark.ai/documentation/config-as-code/overview.md#apply-semantics) for the full rules, and [Config-managed resources in the UI](https://docs.roark.ai/documentation/config-as-code/overview.md#config-managed-resources-in-the-ui) for how managed resources behave in the dashboard.

> [!TIP]
>
> YAML and TypeScript are interchangeable, not exclusive. A resource authored in TypeScript and one authored in YAML are the same resource to Roark (both keyed by `<kind>/<name>`), so you can migrate one kind at a time, or keep prompts as `.md` files and the rest in code.

> **[Node SDK](https://docs.roark.ai/documentation/sdks/node-sdk.md)**
>
> Full setup for `@roarkanalytics/sdk`: install, authentication, and the rest of the API surface the same client exposes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.