# FakeAgentScript

Package: `@threadplane/ag-ui` · 0.3.4

Reference: /docs/api/ag-ui/FakeAgentScript

```typescript
import type { FakeAgentScript } from '@threadplane/ag-ui';
```

## FakeAgentScript

Deterministic event branches for [FakeAgent](/docs/api/ag-ui/FakeAgent), reachable through the
constructor and through `provideFakeAgent({ script })`.

Each branch supplies a raw AG-UI event sequence — tool calls, state
snapshots, custom events, anything the protocol defines. `when: 'initial'`
matches a turn whose history carries no tool result; `{ toolMessageFor: id }`
matches the follow-up turn whose history carries a tool result for that tool
call id. The first matching branch wins, and its `events` are wrapped in
`RUN_STARTED` / `RUN_FINISHED`. When no branch matches, the canned token
reply is streamed instead.

```typescript
export type FakeAgentScript = readonly {
    when: 'initial' | {
        toolMessageFor: string;
    };
    events: readonly BaseEvent[];
}[];
```