@colletdev/docs 0.2.18 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.md +142 -8
- package/messages.md +89 -75
- package/package.json +1 -1
package/components.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
## Overview
|
|
7
7
|
|
|
8
|
-
Collet ships
|
|
8
|
+
Collet ships 54 components as Custom Elements (`<cx-*>`) with
|
|
9
9
|
framework wrappers for React, Vue, Svelte, and Angular.
|
|
10
10
|
|
|
11
11
|
**npm packages:**
|
|
@@ -95,7 +95,7 @@ Grouped activity feed with expandable entries and status indicators.
|
|
|
95
95
|
| summary | `string` | — | |
|
|
96
96
|
| action | `string` | — | |
|
|
97
97
|
| expanded | `boolean` | `false` | |
|
|
98
|
-
| parts | `string` | — | |
|
|
98
|
+
| parts | `string[] \| string` | — | |
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
@@ -497,11 +497,86 @@ Import from `@colletdev/core/types`:
|
|
|
497
497
|
|
|
498
498
|
---
|
|
499
499
|
|
|
500
|
+
### Chat
|
|
501
|
+
|
|
502
|
+
Chat component.
|
|
503
|
+
|
|
504
|
+
**Tag:** `<cx-chat>` | **Form:** no | **Slots:** header, footer | **Ref methods:** addMessage, scrollToBottom, clear, focus, addFiles, clearAttachments
|
|
505
|
+
|
|
506
|
+
#### Import
|
|
507
|
+
|
|
508
|
+
| Framework | Import |
|
|
509
|
+
|-----------|--------|
|
|
510
|
+
| React | `import { Chat } from '@colletdev/react'` |
|
|
511
|
+
| Vue | `import { Chat } from '@colletdev/vue'` |
|
|
512
|
+
| Svelte | `import Chat from '@colletdev/svelte/chat.svelte'` |
|
|
513
|
+
| Angular | `import { CxChat } from '@colletdev/angular'` |
|
|
514
|
+
|
|
515
|
+
#### Props
|
|
516
|
+
|
|
517
|
+
| Prop | Type | Default | Description |
|
|
518
|
+
|------|------|---------|-------------|
|
|
519
|
+
| id | `string` | — | |
|
|
520
|
+
| shape | `'sharp' \| 'rounded'` | — | |
|
|
521
|
+
| layout | `'standard' \| 'compact' \| 'fullscreen'` | — | |
|
|
522
|
+
| size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | — | |
|
|
523
|
+
| height | `string` | — | |
|
|
524
|
+
| scrollbarShape | `string` | — | |
|
|
525
|
+
| scrollbarTrack | `string` | — | |
|
|
526
|
+
| turns | `ChatTurn[] \| string` | — | |
|
|
527
|
+
| typing | `'' \| 'typing'` | — | |
|
|
528
|
+
| typingSender | `string` | — | |
|
|
529
|
+
| inputShape | `string` | — | |
|
|
530
|
+
| inputPlaceholder | `string` | — | |
|
|
531
|
+
| inputDisabled | `boolean` | `false` | |
|
|
532
|
+
| inputMaxLength | `number` | `0` | |
|
|
533
|
+
| showActionButton | `boolean` | `false` | |
|
|
534
|
+
| label | `string` | — | |
|
|
535
|
+
| inputLabel | `string` | — | |
|
|
536
|
+
| submitLabel | `string` | — | |
|
|
537
|
+
| emptyState | `string` | — | |
|
|
538
|
+
| acceptFiles | `boolean` | `false` | |
|
|
539
|
+
| accept | `string` | — | |
|
|
540
|
+
| maxFileSize | `number` | `0` | |
|
|
541
|
+
| multipleFiles | `boolean` | `false` | |
|
|
542
|
+
|
|
543
|
+
#### Events
|
|
544
|
+
|
|
545
|
+
| Event | React | Vue | Detail |
|
|
546
|
+
|-------|-------|-----|--------|
|
|
547
|
+
| `cx-submit` | `onSubmit` | `@cx-submit` | `ChatSubmitDetail` |
|
|
548
|
+
| `cx-file-add` | `onFileAdd` | `@cx-file-add` | `FileAddDetail` |
|
|
549
|
+
| `cx-file-remove` | `onFileRemove` | `@cx-file-remove` | `FileRemoveDetail` |
|
|
550
|
+
| `cx-file-reject` | `onFileReject` | `@cx-file-reject` | `FileRejectDetail` |
|
|
551
|
+
|
|
552
|
+
#### Ref Methods
|
|
553
|
+
|
|
554
|
+
| Method | Description |
|
|
555
|
+
|--------|-------------|
|
|
556
|
+
| `addMessage(html: string): void` | Adds a pre-rendered message turn to the chat. |
|
|
557
|
+
| `scrollToBottom()` | Scrolls the message area to the bottom. |
|
|
558
|
+
| `clear()` | Clears all messages from the chat. |
|
|
559
|
+
| `focus()` | Focuses the chat input textarea. |
|
|
560
|
+
| `addFiles(files: FileList): void` | Adds files programmatically to the chat input. |
|
|
561
|
+
| `clearAttachments()` | Removes all file attachments from the chat input. |
|
|
562
|
+
|
|
563
|
+
#### Structured Types
|
|
564
|
+
|
|
565
|
+
Import from `@colletdev/core/types`:
|
|
566
|
+
|
|
567
|
+
- `ChatSubmitDetail`
|
|
568
|
+
- `ChatTurn`
|
|
569
|
+
- `FileAddDetail`
|
|
570
|
+
- `FileRejectDetail`
|
|
571
|
+
- `FileRemoveDetail`
|
|
572
|
+
|
|
573
|
+
---
|
|
574
|
+
|
|
500
575
|
### ChatInput
|
|
501
576
|
|
|
502
577
|
Multi-line text area optimized for chat message composition.
|
|
503
578
|
|
|
504
|
-
**Tag:** `<cx-chat-input>` | **Form:** yes | **Ref methods:** focus
|
|
579
|
+
**Tag:** `<cx-chat-input>` | **Form:** yes | **Ref methods:** focus, addFiles, getAttachments, clearAttachments
|
|
505
580
|
|
|
506
581
|
#### Import
|
|
507
582
|
|
|
@@ -529,6 +604,10 @@ Multi-line text area optimized for chat message composition.
|
|
|
529
604
|
| label | `string` | — | |
|
|
530
605
|
| maxLength | `number` | `0` | |
|
|
531
606
|
| slotted | `boolean` | `false` | |
|
|
607
|
+
| acceptFiles | `boolean` | `false` | |
|
|
608
|
+
| accept | `string` | — | |
|
|
609
|
+
| maxFileSize | `number` | `0` | |
|
|
610
|
+
| multipleFiles | `boolean` | `false` | |
|
|
532
611
|
|
|
533
612
|
#### Events
|
|
534
613
|
|
|
@@ -540,18 +619,28 @@ Multi-line text area optimized for chat message composition.
|
|
|
540
619
|
| `cx-keyup` | `onKeyup` | `@cx-keyup` | `KeyboardDetail` |
|
|
541
620
|
| `cx-submit` | `onSubmit` | `@cx-submit` | `ChatSubmitDetail` |
|
|
542
621
|
| `cx-input` | `onInput` | `@cx-input` | `InputDetail` |
|
|
622
|
+
| `cx-file-add` | `onFileAdd` | `@cx-file-add` | `FileAddDetail` |
|
|
623
|
+
| `cx-file-remove` | `onFileRemove` | `@cx-file-remove` | `FileRemoveDetail` |
|
|
624
|
+
| `cx-file-reject` | `onFileReject` | `@cx-file-reject` | `FileRejectDetail` |
|
|
543
625
|
|
|
544
626
|
#### Ref Methods
|
|
545
627
|
|
|
546
628
|
| Method | Description |
|
|
547
629
|
|--------|-------------|
|
|
548
630
|
| `focus()` | Focuses the textarea. |
|
|
631
|
+
| `addFiles(files: FileList): void` | Adds files programmatically to the attachment tray. |
|
|
632
|
+
| `getAttachments(): FileInfo[]` | Returns current attachments as FileInfo[]. |
|
|
633
|
+
| `clearAttachments()` | Removes all file attachments. |
|
|
549
634
|
|
|
550
635
|
#### Structured Types
|
|
551
636
|
|
|
552
637
|
Import from `@colletdev/core/types`:
|
|
553
638
|
|
|
554
639
|
- `ChatSubmitDetail`
|
|
640
|
+
- `FileAddDetail`
|
|
641
|
+
- `FileInfo`
|
|
642
|
+
- `FileRejectDetail`
|
|
643
|
+
- `FileRemoveDetail`
|
|
555
644
|
- `FocusDetail`
|
|
556
645
|
- `InputDetail`
|
|
557
646
|
- `KeyboardDetail`
|
|
@@ -1120,7 +1209,7 @@ Chat message container with sender alignment and avatar.
|
|
|
1120
1209
|
| Prop | Type | Default | Description |
|
|
1121
1210
|
|------|------|---------|-------------|
|
|
1122
1211
|
| id | `string` | — | |
|
|
1123
|
-
|
|
|
1212
|
+
| messageRole | `string` | — | |
|
|
1124
1213
|
| variant | `'filled' \| 'ghost'` | — | |
|
|
1125
1214
|
| shape | `'sharp' \| 'rounded'` | — | |
|
|
1126
1215
|
| alignment | `'auto' \| 'start' \| 'end'` | — | |
|
|
@@ -1153,7 +1242,7 @@ Grouped sequence of message parts (text, code, tool calls, thinking).
|
|
|
1153
1242
|
| Prop | Type | Default | Description |
|
|
1154
1243
|
|------|------|---------|-------------|
|
|
1155
1244
|
| id | `string` | — | |
|
|
1156
|
-
|
|
|
1245
|
+
| messageRole | `string` | — | |
|
|
1157
1246
|
| alignment | `'auto' \| 'start' \| 'end'` | — | |
|
|
1158
1247
|
| size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | — | |
|
|
1159
1248
|
| senderName | `string` | — | |
|
|
@@ -1205,11 +1294,17 @@ MessageTimeline component.
|
|
|
1205
1294
|
| Prop | Type | Default | Description |
|
|
1206
1295
|
|------|------|---------|-------------|
|
|
1207
1296
|
| id | `string` | — | |
|
|
1208
|
-
|
|
|
1209
|
-
| alignment | `
|
|
1297
|
+
| messageRole | `string` | — | |
|
|
1298
|
+
| alignment | `'auto' \| 'start' \| 'end'` | — | |
|
|
1210
1299
|
| size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | — | |
|
|
1211
1300
|
| senderName | `string` | — | |
|
|
1212
|
-
| events | `string` | — | |
|
|
1301
|
+
| events | `TimelineEvent[] \| string` | — | |
|
|
1302
|
+
|
|
1303
|
+
#### Structured Types
|
|
1304
|
+
|
|
1305
|
+
Import from `@colletdev/core/types`:
|
|
1306
|
+
|
|
1307
|
+
- `TimelineEvent`
|
|
1213
1308
|
|
|
1214
1309
|
---
|
|
1215
1310
|
|
|
@@ -1426,6 +1521,45 @@ Import from `@colletdev/core/types`:
|
|
|
1426
1521
|
|
|
1427
1522
|
---
|
|
1428
1523
|
|
|
1524
|
+
### ScrollArea
|
|
1525
|
+
|
|
1526
|
+
ScrollArea component.
|
|
1527
|
+
|
|
1528
|
+
**Tag:** `<cx-scroll-area>` | **Form:** no | **Slots:** default | **Ref methods:** scrollToBottom, scrollToTop
|
|
1529
|
+
|
|
1530
|
+
#### Import
|
|
1531
|
+
|
|
1532
|
+
| Framework | Import |
|
|
1533
|
+
|-----------|--------|
|
|
1534
|
+
| React | `import { ScrollArea } from '@colletdev/react'` |
|
|
1535
|
+
| Vue | `import { ScrollArea } from '@colletdev/vue'` |
|
|
1536
|
+
| Svelte | `import ScrollArea from '@colletdev/svelte/scroll-area.svelte'` |
|
|
1537
|
+
| Angular | `import { CxScrollArea } from '@colletdev/angular'` |
|
|
1538
|
+
|
|
1539
|
+
#### Props
|
|
1540
|
+
|
|
1541
|
+
| Prop | Type | Default | Description |
|
|
1542
|
+
|------|------|---------|-------------|
|
|
1543
|
+
| id | `string` | — | |
|
|
1544
|
+
| shape | `'sharp' \| 'rounded' \| 'pill'` | — | |
|
|
1545
|
+
| track | `'with-track' \| 'floating'` | — | |
|
|
1546
|
+
| axis | `'vertical' \| 'horizontal' \| 'both'` | — | |
|
|
1547
|
+
| size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | — | |
|
|
1548
|
+
| height | `string` | — | |
|
|
1549
|
+
| label | `string` | — | |
|
|
1550
|
+
| autoScroll | `string` | — | |
|
|
1551
|
+
| newContentLabel | `string` | — | |
|
|
1552
|
+
| logRole | `boolean` | `false` | |
|
|
1553
|
+
|
|
1554
|
+
#### Ref Methods
|
|
1555
|
+
|
|
1556
|
+
| Method | Description |
|
|
1557
|
+
|--------|-------------|
|
|
1558
|
+
| `scrollToBottom()` | Scrolls content to the bottom. |
|
|
1559
|
+
| `scrollToTop()` | Scrolls content to the top. |
|
|
1560
|
+
|
|
1561
|
+
---
|
|
1562
|
+
|
|
1429
1563
|
### Scrollbar
|
|
1430
1564
|
|
|
1431
1565
|
Custom-styled scrollbar container for overflow content.
|
package/messages.md
CHANGED
|
@@ -32,25 +32,24 @@ The outer container. Controls sender alignment, avatar, name, and timestamp.
|
|
|
32
32
|
```tsx
|
|
33
33
|
import { MessageBubble } from '@colletdev/react';
|
|
34
34
|
|
|
35
|
-
<MessageBubble
|
|
35
|
+
<MessageBubble messageRole="assistant" senderName="Collet">
|
|
36
36
|
{/* MessageGroup(s) go here */}
|
|
37
37
|
</MessageBubble>
|
|
38
38
|
|
|
39
|
-
<MessageBubble
|
|
39
|
+
<MessageBubble messageRole="user" senderName="Dan">
|
|
40
40
|
{/* User message content */}
|
|
41
41
|
</MessageBubble>
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
| Prop | Type | Default | Description |
|
|
45
45
|
|------|------|---------|-------------|
|
|
46
|
-
| `
|
|
46
|
+
| `messageRole` | `'user' \| 'assistant'` | `'user'` | Determines alignment and color |
|
|
47
47
|
| `senderName` | `string` | — | Name displayed above the bubble |
|
|
48
|
-
| `avatar` | `string` | — | Avatar image URL |
|
|
49
48
|
| `timestamp` | `string` | — | Timestamp text |
|
|
50
49
|
| `variant` | `'filled' \| 'ghost'` | `'filled'` | Visual style |
|
|
51
50
|
| `shape` | `'sharp' \| 'rounded'` | `'rounded'` | Border radius |
|
|
52
51
|
|
|
53
|
-
**Alignment:** `
|
|
52
|
+
**Alignment:** `messageRole="user"` right-aligns, `messageRole="assistant"` left-aligns.
|
|
54
53
|
|
|
55
54
|
### MessageGroup
|
|
56
55
|
|
|
@@ -60,18 +59,17 @@ a group share edges (no gaps between them).
|
|
|
60
59
|
```tsx
|
|
61
60
|
import { MessageGroup } from '@colletdev/react';
|
|
62
61
|
|
|
63
|
-
<MessageGroup
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
</MessagePart>
|
|
68
|
-
</MessageGroup>
|
|
62
|
+
<MessageGroup messageRole="assistant" parts={[
|
|
63
|
+
'<div>Here is what I found:</div>',
|
|
64
|
+
'<pre><code>fn main() { println!("Hello"); }</code></pre>',
|
|
65
|
+
]} />
|
|
69
66
|
```
|
|
70
67
|
|
|
71
68
|
| Prop | Type | Default | Description |
|
|
72
69
|
|------|------|---------|-------------|
|
|
73
|
-
| `
|
|
70
|
+
| `messageRole` | `'user' \| 'assistant'` | `'user'` | Color scheme |
|
|
74
71
|
| `variant` | `'filled' \| 'ghost'` | `'filled'` | Visual style |
|
|
72
|
+
| `parts` | `string[]` | `[]` | Pre-rendered part HTML strings |
|
|
75
73
|
|
|
76
74
|
### MessagePart
|
|
77
75
|
|
|
@@ -108,18 +106,17 @@ import { MessagePart } from '@colletdev/react';
|
|
|
108
106
|
kind="tool-call"
|
|
109
107
|
toolName="search_docs"
|
|
110
108
|
toolArguments='{"query": "auth"}'
|
|
111
|
-
|
|
109
|
+
toolStatus="pending"
|
|
112
110
|
/>
|
|
113
111
|
|
|
114
112
|
{/* Tool result */}
|
|
115
113
|
<MessagePart
|
|
116
114
|
kind="tool-result"
|
|
117
115
|
toolName="search_docs"
|
|
118
|
-
|
|
116
|
+
toolStatus="success"
|
|
119
117
|
collapsible
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
</MessagePart>
|
|
118
|
+
content="Found 3 results..."
|
|
119
|
+
/>
|
|
123
120
|
|
|
124
121
|
{/* Thinking indicator */}
|
|
125
122
|
<MessagePart kind="thinking" thinkingLabel="Analyzing code..." />
|
|
@@ -136,10 +133,10 @@ The status is computed from child tool states — you don't set it manually.
|
|
|
136
133
|
```tsx
|
|
137
134
|
import { ActivityGroup } from '@colletdev/react';
|
|
138
135
|
|
|
139
|
-
<ActivityGroup
|
|
140
|
-
<
|
|
141
|
-
<
|
|
142
|
-
|
|
136
|
+
<ActivityGroup summary="Code analysis" parts={[
|
|
137
|
+
'<div>pre-rendered tool-call HTML</div>',
|
|
138
|
+
'<div>pre-rendered tool-call HTML</div>',
|
|
139
|
+
]} />
|
|
143
140
|
```
|
|
144
141
|
|
|
145
142
|
| Status | Meaning | Visual |
|
|
@@ -239,10 +236,10 @@ function StreamingMessage() {
|
|
|
239
236
|
|
|
240
237
|
---
|
|
241
238
|
|
|
242
|
-
## MessageTimeline (
|
|
239
|
+
## MessageTimeline (Event Reducer)
|
|
243
240
|
|
|
244
241
|
For production chat UIs with tool calls, streaming, and complex turn lifecycle,
|
|
245
|
-
Collet provides a
|
|
242
|
+
Collet provides a chronological event reducer. This is the recommended way
|
|
246
243
|
to build AI assistant interfaces.
|
|
247
244
|
|
|
248
245
|
**What it handles:**
|
|
@@ -253,74 +250,91 @@ to build AI assistant interfaces.
|
|
|
253
250
|
- Duplicate tool result deduplication
|
|
254
251
|
- Terminal turn immutability (completed/aborted turns reject new events)
|
|
255
252
|
|
|
256
|
-
**
|
|
257
|
-
|
|
253
|
+
**Available via WASM** — pass an `events` array and the reducer renders
|
|
254
|
+
the full turn to HTML:
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
import { MessageTimeline } from '@colletdev/react';
|
|
258
|
+
import type { TimelineEvent } from '@colletdev/react';
|
|
259
|
+
|
|
260
|
+
const events: TimelineEvent[] = [
|
|
261
|
+
{ type: 'text-delta', id: 'p1', delta: 'Hello ', markdown: true },
|
|
262
|
+
{ type: 'text-delta', id: 'p1', delta: '**world**' },
|
|
263
|
+
{ type: 'thinking-start', id: 't1', label: 'Analyzing...' },
|
|
264
|
+
{ type: 'thinking-done', id: 't1', label: 'Analysis complete' },
|
|
265
|
+
{ type: 'tool-call-start', group_id: 'g1', call_id: 'c1',
|
|
266
|
+
tool_name: 'read_file', description: 'Reading main.rs' },
|
|
267
|
+
{ type: 'tool-call-done', group_id: 'g1', call_id: 'c1' },
|
|
268
|
+
{ type: 'tool-result', group_id: 'g1', result_id: 'r1', call_id: 'c1',
|
|
269
|
+
tool_name: 'read_file', content: 'fn main() {}', status: 'success' },
|
|
270
|
+
{ type: 'code-block', id: 'cb1', code: 'fn main() {}',
|
|
271
|
+
language: 'rust', filename: 'main.rs' },
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
<MessageTimeline
|
|
275
|
+
messageRole="assistant"
|
|
276
|
+
senderName="Collet"
|
|
277
|
+
events={events}
|
|
278
|
+
/>
|
|
258
279
|
|
|
259
280
|
---
|
|
260
281
|
|
|
261
282
|
## Complete Example
|
|
262
283
|
|
|
263
|
-
A full AI assistant conversation
|
|
284
|
+
A full AI assistant conversation using MessageTimeline's event reducer:
|
|
264
285
|
|
|
265
286
|
```tsx
|
|
266
|
-
import {
|
|
267
|
-
|
|
268
|
-
} from '@colletdev/react';
|
|
287
|
+
import { Chat, MessageTimeline } from '@colletdev/react';
|
|
288
|
+
import type { TimelineEvent } from '@colletdev/react';
|
|
269
289
|
|
|
270
290
|
function Conversation() {
|
|
291
|
+
const assistantEvents: TimelineEvent[] = [
|
|
292
|
+
{ type: 'thinking-start', id: 't1', label: 'Searching documentation...' },
|
|
293
|
+
{ type: 'thinking-done', id: 't1', label: 'Searched documentation' },
|
|
294
|
+
{ type: 'tool-call-start', group_id: 'g1', call_id: 'c1',
|
|
295
|
+
tool_name: 'search_docs', description: 'Searched Next.js setup guide' },
|
|
296
|
+
{ type: 'tool-call-done', group_id: 'g1', call_id: 'c1' },
|
|
297
|
+
{ type: 'tool-result', group_id: 'g1', result_id: 'r1', call_id: 'c1',
|
|
298
|
+
tool_name: 'search_docs', content: '3 results found', status: 'success' },
|
|
299
|
+
{ type: 'text-done', id: 'p1', content: "Here's how to set up Collet in Next.js:\n\n1. Install the packages\n2. Add the Vite plugin\n3. Call `init()` in your root layout", markdown: true },
|
|
300
|
+
{ type: 'code-block', id: 'cb1',
|
|
301
|
+
code: "import { init } from '@colletdev/core';\n\ninit();\n\nexport default function RootLayout({ children }) {\n return <html><body>{children}</body></html>;\n}",
|
|
302
|
+
language: 'tsx', filename: 'app/layout.tsx' },
|
|
303
|
+
];
|
|
304
|
+
|
|
271
305
|
return (
|
|
272
|
-
<
|
|
273
|
-
{/* User
|
|
274
|
-
<MessageBubble
|
|
275
|
-
<MessageGroup
|
|
276
|
-
<
|
|
277
|
-
|
|
278
|
-
</MessagePart>
|
|
279
|
-
</MessageGroup>
|
|
306
|
+
<Chat height="h-[600px]" label="Collet assistant">
|
|
307
|
+
{/* User turn — simple text via MessageBubble */}
|
|
308
|
+
<MessageBubble messageRole="user" senderName="Dan">
|
|
309
|
+
<MessageGroup messageRole="user" parts={[
|
|
310
|
+
'<div>How do I set up Collet in my Next.js app?</div>'
|
|
311
|
+
]} />
|
|
280
312
|
</MessageBubble>
|
|
281
313
|
|
|
282
|
-
{/* Assistant
|
|
283
|
-
<
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
<ActivityGroup label="Documentation search" status="done">
|
|
290
|
-
<MessagePart
|
|
291
|
-
kind="tool-call"
|
|
292
|
-
toolName="search_docs"
|
|
293
|
-
status="success"
|
|
294
|
-
description="Searched Next.js setup guide"
|
|
295
|
-
/>
|
|
296
|
-
</ActivityGroup>
|
|
297
|
-
|
|
298
|
-
{/* Response text with markdown */}
|
|
299
|
-
<MessagePart kind="text" markdown>
|
|
300
|
-
Here's how to set up Collet in Next.js:
|
|
301
|
-
|
|
302
|
-
1. Install the packages
|
|
303
|
-
2. Add the Vite plugin (or configure manually for Next.js)
|
|
304
|
-
3. Call `init()` in your root layout
|
|
305
|
-
</MessagePart>
|
|
306
|
-
|
|
307
|
-
{/* Code example */}
|
|
308
|
-
<MessagePart kind="code-block" language="tsx" filename="app/layout.tsx">
|
|
309
|
-
{`import { init } from '@colletdev/core';
|
|
310
|
-
|
|
311
|
-
init();
|
|
312
|
-
|
|
313
|
-
export default function RootLayout({ children }) {
|
|
314
|
-
return <html><body>{children}</body></html>;
|
|
315
|
-
}`}
|
|
316
|
-
</MessagePart>
|
|
317
|
-
</MessageGroup>
|
|
318
|
-
</MessageBubble>
|
|
319
|
-
</div>
|
|
314
|
+
{/* Assistant turn — event-driven via MessageTimeline */}
|
|
315
|
+
<MessageTimeline
|
|
316
|
+
messageRole="assistant"
|
|
317
|
+
senderName="Collet"
|
|
318
|
+
events={assistantEvents}
|
|
319
|
+
/>
|
|
320
|
+
</Chat>
|
|
320
321
|
);
|
|
321
322
|
}
|
|
322
323
|
```
|
|
323
324
|
|
|
325
|
+
Or use individual components for full control:
|
|
326
|
+
|
|
327
|
+
```tsx
|
|
328
|
+
import { MessageBubble, MessageGroup, MessagePart } from '@colletdev/react';
|
|
329
|
+
|
|
330
|
+
<MessageBubble messageRole="assistant" senderName="Collet">
|
|
331
|
+
<MessageGroup messageRole="assistant" parts={[
|
|
332
|
+
MessagePart.render({ kind: 'text', content: 'Hello!', markdown: true }),
|
|
333
|
+
MessagePart.render({ kind: 'code-block', code: 'npm install', language: 'bash' }),
|
|
334
|
+
]} />
|
|
335
|
+
</MessageBubble>
|
|
336
|
+
```
|
|
337
|
+
|
|
324
338
|
---
|
|
325
339
|
|
|
326
340
|
## Standalone Code Blocks
|