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

# View client: @haip/view

> Dependency-free client for producer Views on the HAIP Agent UI wire.

`@haip/view` is the client a producer bundles into its review View for **2.0.0-draft.3**. A View runs inside HAIP's opaque sandbox frame with scripts only. It can present the stored input and result snapshots and propose a response. Trusted HAIP controls handle confirmation and authorisation, while execution remains external.

```js theme={null}
import { connectView } from '@haip/view';

const view = await connectView({
  name: 'Choice review',
  version: '1.0.0',
  onResult: (result) => render(result.structuredContent?.payload),
});
await view.propose({ decision: 'answer', response: { choice: 'accept' } });
```

The client performs the `haip/ui.initialize` -> `haip/ui.initialized` handshake, validates the exact `2.0.0-draft.3` envelope, correlates request IDs, delivers `haip/ui.input` and `haip/ui.result` once and in order, and exposes the recursively frozen host-verified identity as `view.envelope` (request and bundle identity, source, snapshot digests and binding digest). A teardown acknowledgement closes the client, rejects pending proposals and removes its message listener. Every message and the envelope are defined in the protocol schema as `StoredApp` and the `AgentUi*` definitions, with generated TypeScript types in `@haip/protocol`.

The sandbox has no network access, so bundle the client into the self-contained HTML registered through `POST /v2/bundles`. See `examples/http/choice-app.js` for a complete View.
