# AgentsKit Chat 0.4.0

`0.4.0` adds an externally controlled session seam for hosts that already own
their transport and lifecycle state. The host supplies a validated serializable
snapshot and lifecycle callbacks; AgentsKit Chat supplies the shared application
presentation without creating another controller or session store.

## What changed

- `createControlledChatDriver` and `parseControlledChatSnapshot` expose the
  framework-neutral controlled contract from `@agentskit/chat`.
- React `AgentChat` and Ink `AgentChat` accept a controlled source while keeping
  their existing definition-owned mode compatible.
- The controlled lifecycle covers input, send, cancel, retry, edit, regenerate,
  approval, denial, and semantic component interaction.
- Runtime validation rejects unknown or malformed external state before it can
  reach a renderer.
- Synthetic fixtures exercise idle, streaming, error, cancellation-ready,
  confirmation, and semantic-component states across the shared driver.

## Ownership boundary

Controlled mode does not move transport, authentication, authorization,
persistence, business actions, or host session state into AgentsKit Chat. It is
an application projection over host-owned state. Definition-owned applications
may continue using `defineChat`, `createChatSession`, and the existing renderer
props without changes.

## Upgrade

Update both fixed-group packages together:

```bash
npm install @agentskit/chat@0.4.0
npm install --save-dev @agentskit/chat-cli@0.4.0
```

No migration is required for existing definition-owned sessions. Adopt the
controlled source only when the host must retain ownership of its controller
and persisted session contract.

## Evidence

The stable workflow builds and clean-installs both public tarballs, verifies all
seven renderer exports, runs browser, Expo, and real-PTY gates, checks the
controlled synthetic conformance suite, and publishes through npm Trusted
Publishing with provenance and immutable SHA-256 checksums.
