# zidane-ui/server/testing

Import: `import { … } from 'zidane-ui/server/testing'`. Source: [ui/src/server/testing/index.ts](https://github.com/Tahul/zidane/blob/main/ui/src/server/testing/index.ts).

## Functions

### `createScriptedProvider`

Function.

Creates a deterministic, offline zidane `Provider` for demos and tests. Each model call asks `script` what to say and streams the answer in word chunks.

```ts
function createScriptedProvider(options?: ScriptedProviderOptions): Provider
```

**Parameters**

- `options?` (`ScriptedProviderOptions`, default `{}`): The `script` and the streaming pace.

**Returns** `Provider`

Source: [ui/src/server/scripted-provider.ts:109](https://github.com/Tahul/zidane/blob/main/ui/src/server/scripted-provider.ts#L109)

### `defaultScript`

Function.

Calls `lookup` with the prompt, then replies with its result.

```ts
function defaultScript(input: ScriptInput): ScriptedTurn
```

**Parameters**

- `input` (`ScriptInput`): The [`ScriptInput`](https://zidane.si/docs/reference/ui-server-testing.md#ScriptInput) for the model call.

**Returns** `ScriptedTurn`

Source: [ui/src/server/scripted-provider.ts:50](https://github.com/Tahul/zidane/blob/main/ui/src/server/scripted-provider.ts#L50)

### `readScriptInput`

Function.

The latest prompt and what the run did since, read off the wire messages.

```ts
function readScriptInput(messages: readonly SessionMessage[]): ScriptInput
```

**Parameters**

- `messages` (`readonly SessionMessage[]`): The conversation messages sent to the provider.

**Returns** `ScriptInput`

Source: [ui/src/server/scripted-provider.ts:82](https://github.com/Tahul/zidane/blob/main/ui/src/server/scripted-provider.ts#L82)

## Constants

### `demoTools`

Constant.

The tool set for demos: just [`lookupTool`](https://zidane.si/docs/reference/ui-server-testing.md#lookupTool), keyed by name.

```ts
const demoTools: Record<string, ToolDef>
```

Source: [ui/src/server/demo-tools.ts:34](https://github.com/Tahul/zidane/blob/main/ui/src/server/demo-tools.ts#L34)

### `lookupTool`

Constant.

The `lookup` tool: answers a topic from a small fixed table (`zidane`, `sse`). It touches neither the disk nor the network.

```ts
const lookupTool: ToolDef
```

Source: [ui/src/server/demo-tools.ts:14](https://github.com/Tahul/zidane/blob/main/ui/src/server/demo-tools.ts#L14)

## Interfaces

### `ScriptedProviderOptions`

Interface.

Options for [`createScriptedProvider`](https://zidane.si/docs/reference/ui-server-testing.md#createScriptedProvider).

```ts
interface ScriptedProviderOptions
```

**Properties**

- `delayMs?` (`number`): Milliseconds between streamed chunks (default 15; 0 streams synchronously).
- `script?` (`(input: ScriptInput) => ScriptedTurn`): Decides what the provider says for each model call. Default: [`defaultScript`](https://zidane.si/docs/reference/ui-server-testing.md#defaultScript).
- `wordsPerChunk?` (`number`): Words per streamed chunk (default 2).

Source: [ui/src/server/scripted-provider.ts:36](https://github.com/Tahul/zidane/blob/main/ui/src/server/scripted-provider.ts#L36)

### `ScriptedTurn`

Interface.

What a script answers for one model call: text, optional thinking, and optional tool calls.

```ts
interface ScriptedTurn
```

**Properties**

- `text` (`string`): The reply text, streamed to the client in word chunks.
- `thinking?` (`string`): Reasoning text streamed before the reply.
- `toolCalls?` (`readonly { id: string; input: Record<string, unknown>; name: string }[]`): Tool calls the turn makes. With none, the run ends after this turn.

Source: [ui/src/server/scripted-provider.ts:26](https://github.com/Tahul/zidane/blob/main/ui/src/server/scripted-provider.ts#L26)

### `ScriptInput`

Interface.

What a script sees for one model call: the latest prompt and what the run did since.

```ts
interface ScriptInput
```

**Properties**

- `prompt` (`string`): The text of the latest user prompt.
- `step` (`number`): Model calls made since that prompt (0 on the first).
- `toolResults` (`readonly { callId: string; isError: boolean; output: string }[]`): Tool results returned since that prompt, oldest first.

Source: [ui/src/server/scripted-provider.ts:16](https://github.com/Tahul/zidane/blob/main/ui/src/server/scripted-provider.ts#L16)
