Skip to content

zidane-ui/server/testing

import { … } from 'zidane-ui/server/testing'ui/src/server/testing/index.ts

Functions#

createScriptedProviderFunction#

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.

TypeScript
function createScriptedProvider(options?: ScriptedProviderOptions): Provider
Parameters
NameTypeDefaultDescription
options?ScriptedProviderOptions{}

The script and the streaming pace.

Provider

ui/src/server/scripted-provider.ts:109

defaultScriptFunction#

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

TypeScript
function defaultScript(input: ScriptInput): ScriptedTurn
Parameters
NameTypeDescription
inputScriptInput

The ScriptInput for the model call.

ui/src/server/scripted-provider.ts:50

readScriptInputFunction#

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

TypeScript
function readScriptInput(messages: readonly SessionMessage[]): ScriptInput
Parameters
NameTypeDescription
messagesreadonly SessionMessage[]

The conversation messages sent to the provider.

ui/src/server/scripted-provider.ts:82

Constants#

demoToolsConstant#

The tool set for demos: just lookupTool, keyed by name.

TypeScript
const demoTools: Record<string, ToolDef>

ui/src/server/demo-tools.ts:34

lookupToolConstant#

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

TypeScript
const lookupTool: ToolDef

ui/src/server/demo-tools.ts:14

Interfaces#

ScriptedProviderOptionsInterface#

Options for createScriptedProvider.

TypeScript
interface ScriptedProviderOptions
ScriptedProviderOptions properties
NameTypeDescription
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.

wordsPerChunk?number

Words per streamed chunk (default 2).

ui/src/server/scripted-provider.ts:36

ScriptedTurnInterface#

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

TypeScript
interface ScriptedTurn
ScriptedTurn properties
NameTypeDescription
textstring

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.

ui/src/server/scripted-provider.ts:26

ScriptInputInterface#

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

TypeScript
interface ScriptInput
ScriptInput properties
NameTypeDescription
promptstring

The text of the latest user prompt.

stepnumber

Model calls made since that prompt (0 on the first).

toolResultsreadonly { callId: string; isError: boolean; output: string }[]

Tool results returned since that prompt, oldest first.

ui/src/server/scripted-provider.ts:16