> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# Interface: UseOpenUIStateOptions

用于解析 OpenUI 文本并构建渲染器状态的输入。

## Properties

### initialQueryResults?

> `optional` **initialQueryResults?**: `Readonly`\<`Record`\<`string`, `unknown`>>

预取的 Query 结果，以 Query 赋值名称（statement ID）为键。它们在首次渲染时即可使用，并在可选的 tool provider 于 commit 后重新校验期间作为兜底值。

***

### initialState?

> `optional` **initialState?**: `Record`\<`string`, `unknown`>

***

### isStreaming

> **isStreaming**: `boolean`

***

### library

> **library**: [`Library`](/next/zh/api/genui/openui/core/type-aliases/Library.md)

***

### onAction?

> `optional` **onAction?**: (`event`: [`ActionEvent`](/next/zh/api/genui/openui/core/interfaces/ActionEvent.md)) => `void`

#### Parameters

| Parameter | Type                                                                      |
| --------- | ------------------------------------------------------------------------- |
| `event`   | [`ActionEvent`](/next/zh/api/genui/openui/core/interfaces/ActionEvent.md) |

#### Returns

`void`

***

### onError?

> `optional` **onError?**: (`errors`: [`OpenUIError`](/next/zh/api/genui/openui/core/interfaces/OpenUIError.md)\[]) => `void`

结构化、便于 LLM 理解的错误回调。参见 OpenUIError 类型。

#### Parameters

| Parameter | Type                                                                         |
| --------- | ---------------------------------------------------------------------------- |
| `errors`  | [`OpenUIError`](/next/zh/api/genui/openui/core/interfaces/OpenUIError.md)\[] |

#### Returns

`void`

***

### onStateUpdate?

> `optional` **onStateUpdate?**: (`state`: `Record`\<`string`, `unknown`>) => `void`

#### Parameters

| Parameter | Type                           |
| --------- | ------------------------------ |
| `state`   | `Record`\<`string`, `unknown`> |

#### Returns

`void`

***

### response

> **response**: `string` | `null`

***

### toolProvider?

> `optional` **toolProvider?**: [`ToolProvider`](/next/zh/api/genui/openui/core/interfaces/ToolProvider.md) | `null`

用于 Query 数据获取的 ToolProvider——MCP、REST、GraphQL 或任意后端。
