Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/website/content/AGENTS.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ChatComponent as NgafChatComponent } from '@ngaf/chat';
`,
})
export class ChatComponent {
chat = agent({ assistantId: 'chat_agent' });
chat = agent({ apiUrl: 'http://localhost:2024', assistantId: 'chat_agent' });
}
```

Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/CLAUDE.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ChatComponent as NgafChatComponent } from '@ngaf/chat';
`,
})
export class ChatComponent {
chat = agent({ assistantId: 'chat_agent' });
chat = agent({ apiUrl: 'http://localhost:2024', assistantId: 'chat_agent' });
}
```

Expand Down
4 changes: 2 additions & 2 deletions apps/website/content/docs/agent/api/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@
{
"name": "apiUrl",
"type": "string",
"description": "Base URL of the LangGraph Platform API.",
"optional": false
"description": "Base URL of the LangGraph Platform API. Defaults to `provideAgent({ apiUrl })` when omitted.",
"optional": true
},
{
"name": "assistantId",
Expand Down
6 changes: 3 additions & 3 deletions apps/website/content/docs/chat/api/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5543,13 +5543,13 @@
{
"name": "assistantName",
"type": "string",
"description": "Override the default assistant display name (default: \"Assistant\").",
"description": "Shared assistant display name for consumers that read CHAT_CONFIG (default: \"Assistant\").",
"optional": true
},
{
"name": "avatarLabel",
"type": "string",
"description": "Override the default AI avatar label (default: \"A\").",
"description": "Shared AI avatar label for consumers that read CHAT_CONFIG (default: \"A\").",
"optional": true
},
{
Expand All @@ -5561,7 +5561,7 @@
{
"name": "renderRegistry",
"type": "AngularRegistry",
"description": "Default render registry for generative UI components.",
"description": "Shared render registry for consumers that read CHAT_CONFIG.",
"optional": true
}
],
Expand Down
29 changes: 19 additions & 10 deletions apps/website/content/docs/chat/api/chat-config.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ChatConfig

`ChatConfig` is the configuration interface accepted by `provideChat()`. It defines global settings for chat composition components including the generative UI registry, assistant labels, and license token.
`ChatConfig` is the configuration interface accepted by `provideChat()`. The object is stored under `CHAT_CONFIG` for application code that wants shared chat defaults, and `provideChat()` uses the license token to start the package license check.

**Import:**

Expand All @@ -13,11 +13,11 @@ import type { AngularRegistry } from '@ngaf/render';

```typescript
interface ChatConfig {
/** Default render registry for generative UI components. */
/** Shared render registry for consumers that read CHAT_CONFIG. */
renderRegistry?: AngularRegistry;
/** Override the default AI avatar label (default: "A"). */
/** Shared AI avatar label for consumers that read CHAT_CONFIG (default: "A"). */
avatarLabel?: string;
/** Override the default assistant display name (default: "Assistant"). */
/** Shared assistant display name for consumers that read CHAT_CONFIG (default: "Assistant"). */
assistantName?: string;
/** Signed license token from cacheplane.dev. Optional; omitted in dev. */
license?: string;
Expand All @@ -32,7 +32,7 @@ interface ChatConfig {
avatarLabel?: string
```

A short string (typically one or two characters) displayed in the AI avatar badge that appears next to assistant messages in composition components.
A short string (typically one or two characters) for wrappers or components that choose to read `CHAT_CONFIG`.

**Default:** `"A"`

Expand All @@ -42,15 +42,15 @@ A short string (typically one or two characters) displayed in the AI avatar badg
provideChat({ avatarLabel: 'AI' });
```

There is no avatar-specific CSS token. Use `avatarLabel` for the badge text, and use the shared `--ngaf-chat-*` tokens such as `--ngaf-chat-surface`, `--ngaf-chat-text`, and `--ngaf-chat-text-muted` to align surrounding chat surfaces with your app theme.
There is no avatar-specific CSS token. Use the shared `--ngaf-chat-*` tokens such as `--ngaf-chat-surface`, `--ngaf-chat-text`, and `--ngaf-chat-text-muted` to align chat surfaces with your app theme.

### assistantName

```typescript
assistantName?: string
```

The display name for the AI assistant. Used in labels, ARIA attributes, and any place where the assistant needs a human-readable name.
The display name for wrappers or components that choose to read `CHAT_CONFIG`.

**Default:** `"Assistant"`

Expand All @@ -66,7 +66,7 @@ provideChat({ assistantName: 'Code Copilot' });
renderRegistry?: AngularRegistry
```

The default render registry for generative UI components.
A shared render registry value for consumers that inject `CHAT_CONFIG`. `ChatComponent` does not read this value directly; pass a `ViewRegistry` to the `<chat [views]="...">` input for built-in generative UI rendering.

**Example:**

Expand Down Expand Up @@ -112,12 +112,21 @@ export class ChatHeaderComponent {
}
```

## Gotcha: Inputs Still Win

`provideChat()` is not a replacement for component inputs. For generative UI, configure the chat surface directly:

```html
<chat [agent]="agentRef" [views]="views" [store]="store" [handlers]="handlers" />
```

Use `CHAT_CONFIG` when you are building your own wrappers or want route-level defaults that your code reads explicitly.

## Type Location

The `ChatConfig` interface is defined in two files within the library:
The canonical `ChatConfig` interface is defined alongside `provideChat()`:

- `libs/chat/src/lib/provide-chat.ts` -- The canonical definition with JSDoc comments, alongside the `provideChat()` function and `CHAT_CONFIG` token
- `libs/chat/src/lib/chat.types.ts` -- A separate internal type used by lower-level chat types

The public API exports `ChatConfig` as a type-only export:

Expand Down
15 changes: 9 additions & 6 deletions apps/website/content/docs/chat/api/provide-chat.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# provideChat()

`provideChat` is the provider factory that registers `@ngaf/chat` configuration in Angular's dependency injection system. Call it once in your `ApplicationConfig` (or at the route level) to set global defaults used by chat composition components.
`provideChat` is the provider factory that registers `@ngaf/chat` configuration in Angular's dependency injection system and starts the package license check. Call it in your `ApplicationConfig` or at the route level when you need a shared `CHAT_CONFIG` value.

```typescript
import { provideChat } from '@ngaf/chat';
Expand All @@ -23,7 +23,7 @@ function provideChat(config: ChatConfig): EnvironmentProviders

| Parameter | Type | Description |
|-----------|------|-------------|
| `config` | `ChatConfig` | Configuration object with optional render registry, avatar label, and assistant name |
| `config` | `ChatConfig` | Configuration object with optional render registry, avatar label, assistant name, and license token |

**Returns:** `EnvironmentProviders` -- created via `makeEnvironmentProviders()`, compatible with `bootstrapApplication`, `ApplicationConfig`, and route-level `providers`.

Expand All @@ -35,7 +35,7 @@ function provideChat(config: ChatConfig): EnvironmentProviders
{ provide: CHAT_CONFIG, useValue: config }
```

This makes the `ChatConfig` object available throughout the application via the `CHAT_CONFIG` injection token.
This makes the `ChatConfig` object available throughout the application via the `CHAT_CONFIG` injection token. `provideChat()` does not automatically wire generative UI into `<chat>`; pass `[views]`, `[store]`, and `[handlers]` directly to `ChatComponent`.

## CHAT_CONFIG Injection Token

Expand Down Expand Up @@ -67,8 +67,10 @@ See the [ChatConfig API reference](/docs/chat/api/chat-config) for the full inte

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `avatarLabel` | `string` | `"A"` | AI avatar badge text |
| `assistantName` | `string` | `"Assistant"` | AI assistant display name |
| `renderRegistry` | `AngularRegistry` | `undefined` | Stored on `CHAT_CONFIG` for consumers that want a shared render registry. `<chat>` uses the `[views]` input directly. |
| `avatarLabel` | `string` | `"A"` | Shared avatar label for consumers that inject `CHAT_CONFIG` |
| `assistantName` | `string` | `"Assistant"` | Shared assistant display name for consumers that inject `CHAT_CONFIG` |
| `license` | `string` | `undefined` | Signed license token used by the package license check |

## Usage Patterns

Expand Down Expand Up @@ -126,7 +128,7 @@ All chat components work without `provideChat()`. They use defaults:

- Avatar label: `"A"`
- Assistant name: `"Assistant"`
- Generative UI requires `[views]` input on `ChatComponent`
- Generative UI still requires the `[views]` input on `ChatComponent`

```typescript
// This works fine without provideChat()
Expand All @@ -136,6 +138,7 @@ All chat components work without `provideChat()`. They use defaults:
})
export class SimpleChatComponent {
chatRef = agent({
apiUrl: 'http://localhost:2024',
assistantId: 'chat_agent',
threadId: signal(null),
});
Expand Down
16 changes: 15 additions & 1 deletion apps/website/content/docs/chat/components/chat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { ChatComponent } from '@ngaf/chat';
})
export class ChatPageComponent {
chatRef = agent({
apiUrl: 'http://localhost:2024',
assistantId: 'chat_agent',
threadId: signal(null),
});
Expand Down Expand Up @@ -100,6 +101,7 @@ When you pass a non-empty `threads` array, a sidebar appears on the left (hidden
})
export class ChatWithThreadsComponent {
chatRef = agent({
apiUrl: 'http://localhost:2024',
assistantId: 'chat_agent',
threadId: signal(null),
});
Expand Down Expand Up @@ -151,7 +153,19 @@ AI messages containing JSON are parsed character-by-character as tokens stream.

## A2UI Rendering

When AI messages contain A2UI content (prefixed with `---a2ui_JSON---`), the component auto-detects and renders surfaces using the built-in `a2uiBasicCatalog()`. This includes 12 components from the A2UI v0.9 basic catalog: Text, Image, Icon, Divider, Row, Column, Card, List, Button, TextField, CheckBox, and ChoicePicker.
When AI messages contain A2UI content (prefixed with `---a2ui_JSON---`), the component auto-detects A2UI mode. Pass `a2uiBasicCatalog()` to `[views]` to render the built-in catalog:

```typescript
import { ChatComponent, a2uiBasicCatalog } from '@ngaf/chat';

views = a2uiBasicCatalog();
```

```html
<chat [agent]="chatRef" [views]="views" />
```

The catalog currently maps 18 component types: Text, Image, Icon, Divider, Row, Column, Card, List, Button, TextField, CheckBox, MultipleChoice, DateTimeInput, Slider, Tabs, Modal, Video, and AudioPlayer.

A2UI surfaces support two-way data binding, button actions, template expansion over collections, and validation. See the [A2UI guide](/docs/render/a2ui/overview) for details.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ LangGraph Platform

- **`@ngaf/langgraph`** provides the `agent()` function and returns a `LangGraphAgent`, which satisfies the `Agent` contract consumed by `@ngaf/chat`. It exposes reactive Signals for `messages()`, `isLoading()`, `error()`, `interrupt()`, `toolCalls()`, `history()`, and more.

- **`@ngaf/render`** provides `RenderSpecComponent` and view registries for rendering JSON UI specs as Angular components. The `ChatComponent` auto-detects JSON specs in AI messages and renders them through `@ngaf/render` - pass a view registry via the `[views]` input. The `ChatComponent` also auto-detects A2UI v0.9 payloads and renders them using a built-in 12-component catalog.
- **`@ngaf/render`** provides `RenderSpecComponent` and view registries for rendering JSON UI specs as Angular components. The `ChatComponent` auto-detects JSON specs in AI messages and renders them through `@ngaf/render` - pass a view registry via the `[views]` input. The same `[views]` input enables A2UI rendering with `a2uiBasicCatalog()`, which currently maps 18 component types.

## When to Use `ChatComponent` vs. Custom Assembly

Expand Down
22 changes: 16 additions & 6 deletions apps/website/content/docs/chat/guides/configuration.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Configuration

`@ngaf/chat` uses Angular's dependency injection system for global configuration. The `provideChat()` function registers a `ChatConfig` object under the `CHAT_CONFIG` injection token.
`@ngaf/chat` uses Angular's dependency injection system for shared configuration. The `provideChat()` function registers a `ChatConfig` object under the `CHAT_CONFIG` injection token and starts the package license check.

## provideChat()

Call `provideChat()` in your application's provider array to set global configuration for chat components.
Call `provideChat()` in your application's provider array when your application or wrappers need to inject shared chat configuration.

```typescript
// app.config.ts
Expand Down Expand Up @@ -32,21 +32,31 @@ function provideChat(config: ChatConfig): EnvironmentProviders
## ChatConfig Interface

```typescript
import type { AngularRegistry } from '@ngaf/render';

interface ChatConfig {
/** Default render registry for consumers that read CHAT_CONFIG. */
renderRegistry?: AngularRegistry;

/** Override the default AI avatar label (default: "A"). */
avatarLabel?: string;

/** Override the default assistant display name (default: "Assistant"). */
assistantName?: string;

/** Signed license token from cacheplane.dev. Optional in development. */
license?: string;
}
```

### Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `avatarLabel` | `string` | `"A"` | Single character or short string displayed in the AI avatar badge next to assistant messages. |
| `assistantName` | `string` | `"Assistant"` | Display name for the AI assistant, used in labels and ARIA attributes. |
| `renderRegistry` | `AngularRegistry` | `undefined` | Stored on `CHAT_CONFIG` for consumers that want a shared render registry. Pass `[views]` directly to `ChatComponent` for built-in generative UI rendering. |
| `avatarLabel` | `string` | `"A"` | Single character or short string for consumers that inject `CHAT_CONFIG`. |
| `assistantName` | `string` | `"Assistant"` | Display name for consumers that inject `CHAT_CONFIG`. |
| `license` | `string` | `undefined` | Signed license token used by the package license check. |

## CHAT_CONFIG Injection Token

Expand Down Expand Up @@ -110,6 +120,6 @@ All composition components use sensible defaults. If you do not call `provideCha

- Use `"A"` as the avatar label
- Use `"Assistant"` as the assistant name
- Have no render registry (generative UI will not render)
- Have no injected `CHAT_CONFIG`

This means you can use `ChatComponent`, `ChatInputComponent`, and all other components without any global configuration for basic chat functionality.
This means you can use `ChatComponent`, `ChatInputComponent`, and all other components without global configuration for basic chat functionality. Generative UI is controlled by the `ChatComponent` `[views]`, `[store]`, and `[handlers]` inputs.
5 changes: 3 additions & 2 deletions apps/website/content/docs/chat/guides/generative-ui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const myViews = views({
})
export class ChatPageComponent {
chatRef = agent({
apiUrl: 'http://localhost:2024',
assistantId: 'gen_ui_agent',
threadId: signal(null),
});
Expand Down Expand Up @@ -132,7 +133,7 @@ The store enables two-way data binding between generative UI components and your

## A2UI Protocol

For agents that implement Google's A2UI v0.9 protocol, `ChatComponent` auto-detects A2UI payloads (prefixed with `---a2ui_JSON---`) and renders them using the built-in A2UI catalog. See the [A2UI guide](/docs/render/a2ui/overview) for details.
For agents that emit A2UI JSONL payloads, `ChatComponent` auto-detects content prefixed with `---a2ui_JSON---`. Pass `a2uiBasicCatalog()` to `[views]` when you want those surfaces rendered with the built-in components. See the [A2UI guide](/docs/render/a2ui/overview) for details.

## What's Next

Expand All @@ -152,6 +153,6 @@ For agents that implement Google's A2UI v0.9 protocol, `ChatComponent` auto-dete
Full reference for the JSON spec format, prop expressions, and element types.
</Card>
<Card title="A2UI Protocol" icon="layers" href="/docs/render/a2ui/overview">
Render A2UI v0.9 surfaces with the built-in 12-component catalog.
Render A2UI surfaces with the built-in 18-component catalog.
</Card>
</CardGroup>
16 changes: 8 additions & 8 deletions apps/website/content/docs/render/a2ui/catalog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,20 @@ A labeled checkbox with two-way binding for its checked state.
| `_bindings` | `Record<string, string>` | Auto-populated by `surfaceToSpec()` from path references |
| `emit` | injected | Event emitter provided by the render engine |

### ChoicePicker
### MultipleChoice

A dropdown select control with a list of string options.
A single-select dropdown or multi-select checkbox list. Set `maxAllowedSelections` to `1` or less for a dropdown; set it above `1` for a checkbox list.

| A2UI type | Angular component | Selector |
|-----------|-------------------|----------|
| `ChoicePicker` | `A2uiChoicePickerComponent` | `a2ui-choice-picker` |
| `MultipleChoice` | `A2uiMultipleChoiceComponent` | `a2ui-multiple-choice` |

| Prop | Type | Description |
|------|------|-------------|
| `label` | `string` | Select label |
| `options` | `string[]` | List of available options |
| `selected` | `string` | Currently selected value (resolved from path reference) |
| `validationResult` | `A2uiValidationResult` | Validation state — shows errors below dropdown when invalid |
| `label` | `string` | Field label |
| `options` | `{ label: string; value: string }[]` | Resolved option labels and values |
| `selections` | `string \| string[]` | Current selected value or values (resolved from path reference) |
| `maxAllowedSelections` | `number` | `1` or less renders a dropdown; higher values render checkboxes |
| `_bindings` | `Record<string, string>` | Auto-populated by `surfaceToSpec()` from path references |
| `emit` | injected | Event emitter provided by the render engine |

Expand Down Expand Up @@ -432,7 +432,7 @@ Props that use `A2uiFunctionCall` can reference these built-in functions:
| `Button` | `A2uiButtonComponent` | Interactive |
| `TextField` | `A2uiTextFieldComponent` | Interactive |
| `CheckBox` | `A2uiCheckBoxComponent` | Interactive |
| `ChoicePicker` | `A2uiChoicePickerComponent` | Interactive |
| `MultipleChoice` | `A2uiMultipleChoiceComponent` | Interactive |
| `Tabs` | `A2uiTabsComponent` | Layout |
| `Modal` | `A2uiModalComponent` | Layout |
| `Video` | `A2uiVideoComponent` | Media |
Expand Down
4 changes: 2 additions & 2 deletions apps/website/public/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Agent UI for Angular v0.0.37
# Agent UI for Angular v0.0.40

Agent UI primitives and LangGraph streaming adapters for Angular.

Expand Down Expand Up @@ -29,7 +29,7 @@ import { ChatComponent as NgafChatComponent } from '@ngaf/chat';
`,
})
export class ChatComponent {
chat = agent({ assistantId: 'chat_agent' });
chat = agent({ apiUrl: 'http://localhost:2024', assistantId: 'chat_agent' });
}
```

Expand Down
4 changes: 2 additions & 2 deletions apps/website/public/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Agent UI for Angular v0.0.37
# Agent UI for Angular v0.0.40

Agent UI primitives and LangGraph streaming adapters for Angular.

Expand Down Expand Up @@ -29,7 +29,7 @@ import { ChatComponent as NgafChatComponent } from '@ngaf/chat';
`,
})
export class ChatComponent {
chat = agent({ assistantId: 'chat_agent' });
chat = agent({ apiUrl: 'http://localhost:2024', assistantId: 'chat_agent' });
}
```

Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default async function ChatPage() {
{ title: 'tool primitives', description: 'Tool-call lifecycle.' },
{ title: 'interrupt primitive', description: 'Approval gate.' },
]}
cta={{ label: 'Headless API', href: '/docs/chat/api' }}
cta={{ label: 'Headless API', href: '/docs/chat/api/provide-chat' }}
visualLeft
visual={<ChatLandingCodeShowcase />}
/>
Expand Down
Loading
Loading