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

# Hooks

> Composer state, MCP auth, runtime hooks, and re-exports.

## Composer state

| Hook | Returns |
| - | - |
| `useComposerBusyState()` | Whether the composer is busy. Requires `ComposerBusyProvider`. Type: `ComposerBusyState`. |
| `useComposerPauseView()` | `{ kind: "mcp" \| "ask-user" \| "compose" }` — why input is paused. Types: `ComposerPauseView`, `ThreadPauseState`. |

`threadHasPendingMcpAuth(state)` is the standalone predicate behind the `"mcp"` case.

## Server capabilities

```ts theme={null}
import { useServerCapabilities } from "@truefoundry/trueforge-ui";

const capabilities = useServerCapabilities();
// { sandbox: { enabled }, skill: { enabled, reason? }, settings?: { enabled } } | null
```

Returns the resolved value from your server's `getCapabilities()`, or `null` while it is still
loading or if the call failed. Use it to gate your own chrome the same way the SDK gates its
sandbox, skill, and settings affordances. See
[Server contract](/ui-sdk/setup-custom-servers/server-contract#capabilities).

## MCP auth

```ts theme={null}
const auth = useMCPAuth({ callbackPath: "/mcp-callback" });
```

`MCP_AUTH_POPUP_CHANNEL` is `"truefoundry-mcp-auth-popup"` — the `BroadcastChannel` name used
to signal completion back to the opener. Types: `McpAuthCallback`, `McpAuthPopupMessage`,
`UseMCPAuthOptions`. See [MCP OAuth](/ui-sdk/setup-custom-ui/mcp-oauth).

## assistant-ui state

`useAui`, `useAuiState`, and the `AssistantState` type come from `@assistant-ui/react`, which
the SDK bundles as a dependency and also declares as an optional peer. They are re-exported from
the package root and from a dedicated subpath:

```ts theme={null}
import { useAui, useAuiState } from "@truefoundry/trueforge-ui/assistant-ui";
```

## Runtime hooks

Import these from `@truefoundry/trueforge-ui` like everything else:

| Export | Purpose |
| - | - |
| `useTrueForgeAgentRuntime` | The underlying runtime hook. |
| `useTrueForgeAgentSpec` | Read the active agent spec. |
| `useTrueForgeUpdateAgentSpec` | Mutate the draft spec. |
| `useTrueForgeCancel` | Cancel the in-flight turn. |
| `useTrueForgeTurnId` | The id of the current turn. |
| `useTrueForgeHistoryPagination` | Page backwards through history. |
| `useTrueForgeMcpAuth` | Low-level MCP auth state. |
| `useTrueForgeRespondToToolApproval` | Approve or reject a tool call. |
| `useTrueForgeToolResponses` | Read tool responses. |
| `useTrueForgeDownloadSandboxFile` | Download a sandbox artifact. |
| `mergeAgentSpec` | Merge partial specs. |
| `trueForgeAttachmentAdapter` | Default attachment adapter. |

Types: `DraftAgentConfig`, `NamedAgentConfig`, `TrueForgeAgentConfig`,
`UseTrueForgeAgentRuntimeOptions`.

## Utilities

```ts theme={null}
computeAgentStepsSplit(parts: AgentStepPart[], isRunning: boolean): AgentStepsSplitResult;
```

Splits message parts into the steps shown inline versus those collapsed into the steps card.
Both `AgentStepPart` and `AgentStepsSplitResult` are exported.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.