@collective-intelligence/ui-react 0.3.5 → 0.3.7

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.
Files changed (64) hide show
  1. package/README.md +133 -3
  2. package/dist/chat.d.ts +578 -0
  3. package/dist/chat.js +2 -0
  4. package/dist/components/icons/index.js +1 -1
  5. package/dist/components/illustrations/index.js +1 -1
  6. package/dist/components/ui/index.d.ts +28 -17
  7. package/dist/components/ui/index.js +2 -2
  8. package/dist/components/ui-extensions/atoms/ThemeToggle/index.js +1 -1
  9. package/dist/components/ui-extensions/hooks/use-mobile.js +1 -1
  10. package/dist/components/ui-extensions/index.d.ts +6 -6
  11. package/dist/components/ui-extensions/index.js +5 -5
  12. package/dist/components/ui-extensions/molecules/VideoPlayer/index.js +2 -2
  13. package/dist/hooks/index.js +1 -1
  14. package/dist/hooks/operations.js +1 -1
  15. package/dist/hooks/use-debounced-callback.js +1 -1
  16. package/dist/hooks/use-mount-action.js +1 -1
  17. package/dist/{index-y2h3pwvb.js → index-07wswd5f.js} +2 -2
  18. package/dist/index-1wmmfj25.js +2 -0
  19. package/dist/index-2thxhq0q.js +2 -0
  20. package/dist/index-3yxm33ex.js +42 -0
  21. package/dist/index-4ekvdxt4.js +2 -0
  22. package/dist/{index-r4k327de.js → index-4mm4a7nt.js} +2 -2
  23. package/dist/{index-dhysnhdt.js → index-590xzssr.js} +2 -2
  24. package/dist/index-7fcrqgn8.js +2 -0
  25. package/dist/index-99ad0xy6.js +2 -0
  26. package/dist/index-9at1018y.js +2 -0
  27. package/dist/index-9az9jb0y.js +2 -0
  28. package/dist/index-9me7rg96.js +2 -0
  29. package/dist/{index-t5c4bv5n.js → index-aahc5q93.js} +2 -2
  30. package/dist/index-adta20n6.js +2 -0
  31. package/dist/index-b3s2d1rk.js +2 -0
  32. package/dist/index-e105w3b8.js +2 -0
  33. package/dist/index-ek4ar1qs.js +2 -0
  34. package/dist/{index-38vsn5nv.js → index-hcecckjn.js} +2 -2
  35. package/dist/index-md173efw.js +2 -0
  36. package/dist/{index-fwsd4nes.js → index-mp8nkq9m.js} +2 -2
  37. package/dist/index-mxgt32b6.js +2 -0
  38. package/dist/index-n43k1xpt.js +6 -0
  39. package/dist/index-nadagexv.js +2 -0
  40. package/dist/{index-cx7rgb00.js → index-q04zgt5k.js} +2 -2
  41. package/dist/index-rbdjqvhp.js +2 -0
  42. package/dist/index-rvwx0vhw.js +2 -0
  43. package/dist/index-v31zghad.js +2 -0
  44. package/dist/index-vejf6hg0.js +2 -0
  45. package/dist/{index-a27yrhds.js → index-wwq9v1me.js} +2 -2
  46. package/dist/index.js +1 -1
  47. package/dist/resources.js +1 -1
  48. package/dist/styles.css +2 -0
  49. package/dist/tokens/theme.js +1 -1
  50. package/dist/utils/cn.js +1 -1
  51. package/package.json +22 -6
  52. package/dist/index-0warxk1d.js +0 -2
  53. package/dist/index-1qb5701q.js +0 -2
  54. package/dist/index-38vag578.js +0 -2
  55. package/dist/index-3y40hfmd.js +0 -2
  56. package/dist/index-4d90e50j.js +0 -2
  57. package/dist/index-50g897x2.js +0 -42
  58. package/dist/index-58jcemv5.js +0 -2
  59. package/dist/index-956qe6w8.js +0 -2
  60. package/dist/index-dcmmdjnn.js +0 -2
  61. package/dist/index-k8bsc1hv.js +0 -2
  62. package/dist/index-kgq1r8sg.js +0 -2
  63. package/dist/index-rvcf3zsv.js +0 -2
  64. package/dist/index-s18na57g.js +0 -6
package/dist/chat.d.ts ADDED
@@ -0,0 +1,578 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import * as React$1 from 'react';
4
+ import { KeyboardEvent as KeyboardEvent$1, ReactNode } from 'react';
5
+ import { Components } from 'react-markdown';
6
+
7
+ export type ChatAnswerFeedbackSentiment = "negative" | "positive";
8
+ /** A rating to save; `note` is set only for a negative rating. */
9
+ export interface ChatAnswerFeedbackInput {
10
+ note: string | null;
11
+ sentiment: ChatAnswerFeedbackSentiment;
12
+ }
13
+ export interface ChatAnswerFeedbackLabels {
14
+ readonly cancel: string;
15
+ /** Accessible name of the rating buttons. */
16
+ readonly group: string;
17
+ readonly negative: string;
18
+ /** Accessible name and placeholder of the note input. */
19
+ readonly note: string;
20
+ readonly noteDescription: string;
21
+ readonly noteTitle: string;
22
+ readonly positive: string;
23
+ /** Shown while a rating is saved. */
24
+ readonly saving: string;
25
+ readonly submit: string;
26
+ }
27
+ export interface ChatAnswerFeedbackProps {
28
+ className?: string | undefined;
29
+ /** Display-ready text of a failed save. */
30
+ error?: React$1.ReactNode;
31
+ labels: ChatAnswerFeedbackLabels;
32
+ onClear: () => void;
33
+ onSubmit: (input: ChatAnswerFeedbackInput) => void;
34
+ /** A rating is being saved; the buttons wait for it. */
35
+ pending?: boolean | undefined;
36
+ /** The user's current rating; leave it out for none. */
37
+ value?: ChatAnswerFeedbackSentiment | null | undefined;
38
+ }
39
+ /**
40
+ * Thumbs up and down for an answer. Thumbs down asks for an optional note
41
+ * first. A second press clears the rating.
42
+ */
43
+ export declare const ChatAnswerFeedback: ({ className, error, labels, onClear, onSubmit, pending, value }: ChatAnswerFeedbackProps) => React$1.JSX.Element;
44
+ /** The state of an approval request. */
45
+ export type ChatApprovalStatus = "approved" | "cancelled" | "expired" | "pending" | "rejected";
46
+ /** What a recorded decision led to. */
47
+ export type ChatApprovalOutcome = "already_approved" | "already_decided" | "continuation_failed" | "continuation_in_progress" | "reconciliation_required" | "recorded";
48
+ /** A decision the user can record. */
49
+ export type ChatApprovalAction = "approve" | "reject";
50
+ /** One step of the approval rule and its progress. */
51
+ export interface ChatApprovalStep {
52
+ approved: number;
53
+ id: string;
54
+ label: React$1.ReactNode;
55
+ required: number;
56
+ }
57
+ /** One recorded decision, display-ready: actor, decision and time. */
58
+ export interface ChatApprovalDecision {
59
+ id: string;
60
+ label: React$1.ReactNode;
61
+ }
62
+ export interface ChatApprovalCardLabels {
63
+ readonly approve: string;
64
+ /** Shown on the approve button while the approval is recorded. */
65
+ readonly approving: string;
66
+ readonly cancel: string;
67
+ /** Label of the optional approve comment. */
68
+ readonly comment: string;
69
+ readonly commentPlaceholder: string;
70
+ readonly confirmReject: string;
71
+ /** Shown below the title while the user can decide; leave it out to hide it. */
72
+ readonly decideHint?: string | undefined;
73
+ /** Accessible name of the recorded decisions list. */
74
+ readonly decisions: string;
75
+ readonly outcomes: Readonly<Record<ChatApprovalOutcome, string>>;
76
+ /** Badge of a pending request that the user cannot decide. */
77
+ readonly readOnly: string;
78
+ /** Shown below the title in the read-only state; leave it out to hide it. */
79
+ readonly readOnlyHint?: string | undefined;
80
+ readonly reject: string;
81
+ /** Label of the required reject reason. */
82
+ readonly rejectReason: string;
83
+ readonly rejectReasonPlaceholder: string;
84
+ readonly statuses: Readonly<Record<ChatApprovalStatus, string>>;
85
+ readonly stepProgress: (approved: number, required: number) => string;
86
+ /** Accessible name of the steps list. */
87
+ readonly steps: string;
88
+ readonly title: string;
89
+ }
90
+ export interface ChatApprovalCardProps {
91
+ /** Caller content below the details, for example the request context. */
92
+ children?: React$1.ReactNode;
93
+ className?: string | undefined;
94
+ classNames?: Partial<Record<"actions" | "details" | "header", string>> | undefined;
95
+ /** The decisions recorded so far. */
96
+ decisions?: readonly ChatApprovalDecision[] | undefined;
97
+ /** Display-ready text of a failed decision or load. */
98
+ error?: React$1.ReactNode;
99
+ labels: ChatApprovalCardLabels;
100
+ /** Display-ready rule facts: mode, expiry, eligibility. */
101
+ meta?: readonly React$1.ReactNode[] | undefined;
102
+ /** Leave it out when the user cannot approve; the approve control hides. */
103
+ onApprove?: ((comment: string | null) => void) | undefined;
104
+ /** Leave it out when the user cannot reject; the reject control hides. */
105
+ onReject?: ((reason: string) => void) | undefined;
106
+ /** The outcome of the user's decision; it replaces the decision controls. */
107
+ outcome?: ChatApprovalOutcome | undefined;
108
+ /** The decision being recorded; every control waits for it. */
109
+ pendingAction?: ChatApprovalAction | undefined;
110
+ /** Display-ready reason why the request closed. */
111
+ resolution?: React$1.ReactNode;
112
+ status: ChatApprovalStatus;
113
+ steps?: readonly ChatApprovalStep[] | undefined;
114
+ /** Display-ready summary of the request. */
115
+ summary?: React$1.ReactNode;
116
+ }
117
+ /**
118
+ * An approval request inline in a chat: its status, summary and steps, the
119
+ * approve and reject controls, and the outcome of the user's decision.
120
+ */
121
+ export declare const ChatApprovalCard: ({ children, className, classNames, decisions, error, labels, meta, onApprove, onReject, outcome, pendingAction, resolution, status, steps, summary }: ChatApprovalCardProps) => React$1.JSX.Element;
122
+ export interface ChatAttachmentChipLabels {
123
+ /** Visible text of the download button. */
124
+ readonly download: string;
125
+ /** Accessible name of the download button. */
126
+ readonly downloadFile: (name: string) => string;
127
+ /** Visible text of the download button while the download starts. */
128
+ readonly downloading: string;
129
+ /** Accessible name of the image preview button. */
130
+ readonly preview: (name: string) => string;
131
+ readonly previewDescription: string;
132
+ /** Accessible name of the remove button. */
133
+ readonly remove: (name: string) => string;
134
+ }
135
+ export interface ChatAttachmentChipBaseProps {
136
+ className?: string | undefined;
137
+ /** Display-ready detail beside the name, for example the reading status. */
138
+ detail?: React$1.ReactNode;
139
+ labels: ChatAttachmentChipLabels;
140
+ /** The file name. */
141
+ name: string;
142
+ /**
143
+ * An image URL that the chip shows as a thumbnail and opens in a dialog,
144
+ * for example an object URL of a draft image.
145
+ */
146
+ previewUrl?: string | undefined;
147
+ }
148
+ /**
149
+ * `draft` is a file in the composer that the user can remove; `stored` is a
150
+ * file of a sent message that the user can download.
151
+ */
152
+ export type ChatAttachmentChipProps = ChatAttachmentChipBaseProps & ({
153
+ mode: "draft";
154
+ onRemove: () => void;
155
+ } | {
156
+ /** Display-ready text of a failed download. */
157
+ error?: React$1.ReactNode;
158
+ mode: "stored";
159
+ /** Leave it out when the file cannot be downloaded; the button hides. */
160
+ onDownload?: (() => void) | undefined;
161
+ /** The download is starting; the button waits for it. */
162
+ pending?: boolean | undefined;
163
+ });
164
+ /** One attached file: its name, an optional image preview and its action. */
165
+ export declare const ChatAttachmentChip: (props: ChatAttachmentChipProps) => React$1.JSX.Element;
166
+ export interface ChatCompactionMarkerLabels {
167
+ /** The marker text and the accessible name of its rule. */
168
+ readonly compacted: string;
169
+ readonly messages: (count: number) => string;
170
+ readonly runs: (count: number) => string;
171
+ }
172
+ export interface ChatCompactionMarkerProps {
173
+ className?: string | undefined;
174
+ labels: ChatCompactionMarkerLabels;
175
+ /** Messages covered by the compaction summary. */
176
+ messageCount?: number | undefined;
177
+ /** Runs covered by the compaction summary; shown when no message count is. */
178
+ runCount?: number | undefined;
179
+ }
180
+ /**
181
+ * The line in a transcript above which a summary replaces the older context.
182
+ */
183
+ export declare const ChatCompactionMarker: ({ className, labels, messageCount, runCount }: ChatCompactionMarkerProps) => React$1.JSX.Element;
184
+ /**
185
+ * `submitting` waits for the send to start; `running` is an answer in
186
+ * progress, which `onStop` can stop.
187
+ */
188
+ export type ChatComposerState = "idle" | "running" | "submitting";
189
+ export interface ChatComposerLabels {
190
+ /** Shown over the composer while files are dragged onto it. */
191
+ drop: string;
192
+ /** Accessible name of the message input. */
193
+ input: string;
194
+ send: string;
195
+ stop: string;
196
+ submitting: string;
197
+ }
198
+ export interface ChatComposerShellProps {
199
+ /** Attachment chips above the input. */
200
+ attachments?: React$1.ReactNode;
201
+ className?: string;
202
+ classNames?: Partial<Record<"frame" | "input" | "send" | "toolbar", string>>;
203
+ disabled?: boolean;
204
+ /** Shown below the composer, for example a voice input status. */
205
+ footer?: React$1.ReactNode;
206
+ labels: ChatComposerLabels;
207
+ /** Controls at the start of the toolbar: attach, voice, pickers. */
208
+ leading?: React$1.ReactNode;
209
+ /** Shown above the composer. */
210
+ notice?: React$1.ReactNode;
211
+ /** Files dropped on or pasted into the composer. Without it, files are ignored. */
212
+ onFilesAdd?: (files: readonly File[]) => void;
213
+ /** Runs before the Enter-to-send handling; prevent default to replace it. */
214
+ onInputKeyDown?: (event: React$1.KeyboardEvent<HTMLTextAreaElement>) => void;
215
+ onStop?: () => void;
216
+ onSubmit: () => void;
217
+ onValueChange: (value: string) => void;
218
+ placeholder?: string;
219
+ /**
220
+ * Shows the stop button of `onStop` while Send stays available, in any
221
+ * `state`: an answer runs and still takes messages, for example to steer
222
+ * it. The stop button comes first in the trailing controls, so a send
223
+ * menu in `trailing` stays beside Send. Without it, the stop button
224
+ * replaces Send in the `running` state.
225
+ */
226
+ showStop?: boolean | undefined;
227
+ state?: ChatComposerState;
228
+ /** A stop request runs: the stop button waits and takes no second press. */
229
+ stopping?: boolean;
230
+ /** Suggestions below the input, for example slash commands. */
231
+ suggestions?: React$1.ReactNode;
232
+ /** Controls at the end of the toolbar, before the send button. */
233
+ trailing?: React$1.ReactNode;
234
+ value: string;
235
+ }
236
+ /**
237
+ * The chat composer frame: notice, attachments, a controlled message input,
238
+ * suggestions and a toolbar with caller controls and the send or stop button.
239
+ * Enter sends; Shift+Enter adds a line.
240
+ */
241
+ export declare const ChatComposerShell: ({ attachments, className, classNames, disabled, footer, labels, leading, notice, onFilesAdd, onInputKeyDown, onStop, onSubmit, onValueChange, placeholder, showStop, state, stopping, suggestions, trailing, value }: ChatComposerShellProps) => React$1.JSX.Element;
242
+ export interface ChatContextUsageRingProps {
243
+ className?: string | undefined;
244
+ /** Accessible name of the meter, for example "Context usage". */
245
+ label: string;
246
+ /** How full the context is, from 0 to 1; other values are clamped. */
247
+ ratio: number;
248
+ }
249
+ /** How full the conversation context is, as a ring meter. */
250
+ export declare const ChatContextUsageRing: ({ className, label, ratio }: ChatContextUsageRingProps) => React$1.JSX.Element;
251
+ export interface ChatMarkdownProps {
252
+ className?: string;
253
+ /** Replaces the element renderers, merged over the chat defaults. */
254
+ components?: Components;
255
+ /** Markdown with GitHub extensions: tables, task lists, strikethrough. */
256
+ content: string;
257
+ }
258
+ /** Renders an answer's Markdown with the chat typography. */
259
+ export declare const ChatMarkdown: ({ className, components, content }: ChatMarkdownProps) => React$1.JSX.Element;
260
+ /** One memory event of an answer, display-ready. */
261
+ export interface ChatMemoryEvidenceEvent {
262
+ /** Small facts beside the label: category, scope, status, reason. */
263
+ details?: readonly React$1.ReactNode[] | undefined;
264
+ id: string;
265
+ /** What happened to the memory, for example "Used" or "Created". */
266
+ label: React$1.ReactNode;
267
+ }
268
+ export interface ChatMemoryEvidenceLabels {
269
+ /** Badge shown when memory was off for the answer. */
270
+ readonly disabled: string;
271
+ readonly saved: (count: number) => string;
272
+ readonly title: string;
273
+ readonly used: (count: number) => string;
274
+ }
275
+ export interface ChatMemoryEvidenceProps {
276
+ className?: string | undefined;
277
+ classNames?: Partial<Record<"events" | "header", string>> | undefined;
278
+ events: readonly ChatMemoryEvidenceEvent[];
279
+ labels: ChatMemoryEvidenceLabels;
280
+ /** Memory was off for the answer. */
281
+ memoryDisabled?: boolean | undefined;
282
+ /** Memories saved or suggested by the answer. */
283
+ saved: number;
284
+ /** Memories the answer used. */
285
+ used: number;
286
+ }
287
+ /**
288
+ * The memories an answer used or saved: count badges and the first events.
289
+ * Renders nothing without events.
290
+ */
291
+ export declare const ChatMemoryEvidence: ({ className, classNames, events, labels, memoryDisabled, saved, used }: ChatMemoryEvidenceProps) => React$1.JSX.Element | null;
292
+ /** Who wrote a chat message. */
293
+ export type ChatMessageSender = "assistant" | "user";
294
+ export interface ChatMessageProps {
295
+ /** Display-ready author name, for example the user or the agent name. */
296
+ author: React$1.ReactNode;
297
+ /** Replaces the default sender avatar. */
298
+ avatar?: React$1.ReactNode;
299
+ /** The message body: Markdown, text, tool evidence or controls. */
300
+ children?: React$1.ReactNode;
301
+ className?: string;
302
+ classNames?: Partial<Record<"author" | "avatar" | "body" | "header" | "timestamp", string>>;
303
+ sender: ChatMessageSender;
304
+ /** Display-ready time label; the caller formats it. */
305
+ timestamp?: React$1.ReactNode;
306
+ }
307
+ /**
308
+ * One chat message row: the author avatar beside a header with the author and
309
+ * time, and the body below the header.
310
+ */
311
+ export declare const ChatMessage: ({ author, avatar, children, className, classNames, sender, timestamp }: ChatMessageProps) => React$1.JSX.Element;
312
+ /** The user's answer to a capability permission prompt. */
313
+ export type ChatPermissionDecision = "allow_always" | "allow_this_conversation" | "deny";
314
+ export interface ChatPermissionPromptLabels {
315
+ readonly allowAlways: string;
316
+ readonly allowThisConversation: string;
317
+ readonly deny: string;
318
+ /** Shown below the title; leave it out to hide it. */
319
+ readonly description?: string | undefined;
320
+ /** Accessible name of the prompt. */
321
+ readonly region: (name: string) => string;
322
+ readonly title: (name: string) => string;
323
+ }
324
+ export interface ChatPermissionPromptProps {
325
+ className?: string | undefined;
326
+ classNames?: Partial<Record<"actions" | "description" | "title", string>> | undefined;
327
+ /** Display-ready description of the capability. */
328
+ description?: React$1.ReactNode;
329
+ /** Display-ready text of a failed decision. */
330
+ error?: React$1.ReactNode;
331
+ labels: ChatPermissionPromptLabels;
332
+ /** Display name of the capability that asks for permission. */
333
+ name: string;
334
+ onDecide: (decision: ChatPermissionDecision) => void;
335
+ /** The decision being saved; every button waits for it. */
336
+ pendingDecision?: ChatPermissionDecision | undefined;
337
+ }
338
+ /**
339
+ * A capability permission prompt inline in a chat: deny, allow for this
340
+ * conversation, or allow always.
341
+ */
342
+ export declare const ChatPermissionPrompt: ({ className, classNames, description, error, labels, name, onDecide, pendingDecision }: ChatPermissionPromptProps) => React$1.JSX.Element;
343
+ export type ChatProcessingStepKind = "approval" | "command" | "compaction" | "file" | "model" | "permission" | "request" | "run" | "skill" | "step" | "tool";
344
+ export type ChatProcessingStepStatus = "active" | "done" | "failed";
345
+ /** One display-ready step of an answer's run. */
346
+ export interface ChatProcessingStep {
347
+ /** A short value beside the label, for example a model or a tool name. */
348
+ detail?: React$1.ReactNode;
349
+ id: string;
350
+ kind: ChatProcessingStepKind;
351
+ label: React$1.ReactNode;
352
+ status: ChatProcessingStepStatus;
353
+ }
354
+ export interface ChatProcessingStepsProps {
355
+ className?: string;
356
+ classNames?: Partial<Record<"list" | "step" | "summary", string>>;
357
+ defaultOpen?: boolean;
358
+ onOpenChange?: (open: boolean) => void;
359
+ /** Controls the expanded state; leave it out for an uncontrolled list. */
360
+ open?: boolean;
361
+ steps: readonly ChatProcessingStep[];
362
+ /** Display-ready summary of the steps, the toggle of the list. */
363
+ summary: React$1.ReactNode;
364
+ }
365
+ /**
366
+ * A collapsed summary of an answer's run that opens to a timeline of its
367
+ * steps. Renders nothing without steps.
368
+ */
369
+ export declare const ChatProcessingSteps: ({ className, classNames, defaultOpen, onOpenChange, open, steps, summary }: ChatProcessingStepsProps) => React$1.JSX.Element | null;
370
+ /** One choice of a question. */
371
+ export interface ChatQuestionOption {
372
+ description?: React$1.ReactNode;
373
+ id: string;
374
+ label: React$1.ReactNode;
375
+ }
376
+ export interface ChatQuestionCardLabels {
377
+ readonly answer: string;
378
+ /** The confirm button of a direct confirmation. */
379
+ readonly approve: string;
380
+ readonly cancelled: string;
381
+ readonly completed: string;
382
+ /** Shown below the confirmation title; leave it out to hide it. */
383
+ readonly confirmHint?: string | undefined;
384
+ readonly confirmTitle: string;
385
+ readonly continue: string;
386
+ readonly failed: string;
387
+ /** Accessible name of the free-text input beside the choices. */
388
+ readonly otherAnswer: string;
389
+ /** The choice that opens the free-text input. */
390
+ readonly otherOption: string;
391
+ /** Title of the preview box. */
392
+ readonly preview: string;
393
+ /** Shown on the confirm button while the answer is applied. */
394
+ readonly responding: string;
395
+ readonly revise: string;
396
+ /** Label of the revision input of a direct confirmation. */
397
+ readonly reviseLabel: string;
398
+ /** Accessible name of the open answer input. */
399
+ readonly textAnswer: string;
400
+ readonly textPlaceholder?: string | undefined;
401
+ }
402
+ /**
403
+ * `pending` takes an answer; `responding` applies one; the others are closed.
404
+ */
405
+ export type ChatQuestionStatus = "cancelled" | "completed" | "failed" | "pending" | "responding";
406
+ /** The user's answer to a question or a direct confirmation. */
407
+ export type ChatQuestionResponse = {
408
+ action: "answer";
409
+ optionId: string;
410
+ } | {
411
+ action: "answer";
412
+ text: string;
413
+ } | {
414
+ action: "approve";
415
+ } | {
416
+ action: "revise";
417
+ text: string;
418
+ };
419
+ export interface ChatQuestionCardBaseProps {
420
+ className?: string | undefined;
421
+ classNames?: Partial<Record<"actions" | "preview" | "prompt", string>> | undefined;
422
+ /** Display-ready text of a failed answer. */
423
+ error?: React$1.ReactNode;
424
+ labels: ChatQuestionCardLabels;
425
+ /** Display-ready facts below the prompt, for example the tool name. */
426
+ meta?: readonly React$1.ReactNode[] | undefined;
427
+ onRespond: (response: ChatQuestionResponse) => void;
428
+ /** Display-ready result of a closed question. */
429
+ outcome?: React$1.ReactNode;
430
+ /** Display-ready preview of what the answer changes. */
431
+ preview?: React$1.ReactNode;
432
+ /** Display-ready question, or the summary of a direct confirmation. */
433
+ prompt: React$1.ReactNode;
434
+ status: ChatQuestionStatus;
435
+ }
436
+ /**
437
+ * `choice` answers on the first click; `choice_or_text` adds a free-text
438
+ * answer; `text` is an open answer; `confirm` is a direct confirmation that
439
+ * approves or asks for a revision.
440
+ */
441
+ export type ChatQuestionCardProps = ChatQuestionCardBaseProps & ({
442
+ mode: "choice" | "choice_or_text";
443
+ options: readonly ChatQuestionOption[];
444
+ } | {
445
+ mode: "confirm" | "text";
446
+ });
447
+ /**
448
+ * A question or a direct confirmation inline in a chat: the prompt, the
449
+ * answer controls, and the result once the question closes.
450
+ */
451
+ export declare const ChatQuestionCard: (props: ChatQuestionCardProps) => React$1.JSX.Element;
452
+ export type StatusDotTone = "success" | "warning" | "danger" | "primary" | "neutral";
453
+ /** The color of a run status: its dot and its label. */
454
+ export type ChatRunStatusTone = StatusDotTone;
455
+ export interface ChatRunStatusLabels {
456
+ /** Shown before the status label. */
457
+ readonly status: string;
458
+ readonly title: string;
459
+ }
460
+ export interface ChatRunStatusProps {
461
+ className?: string | undefined;
462
+ classNames?: Partial<Record<"status" | "title", string>> | undefined;
463
+ /** Display-ready run reference, for example a short run id. */
464
+ detail?: React$1.ReactNode;
465
+ /** Display-ready status of the run. */
466
+ label: React$1.ReactNode;
467
+ labels: ChatRunStatusLabels;
468
+ tone: ChatRunStatusTone;
469
+ }
470
+ /** The status of an answer's run: a titled card with a colored status. */
471
+ export declare const ChatRunStatus: ({ className, classNames, detail, label, labels, tone }: ChatRunStatusProps) => React$1.JSX.Element;
472
+ export interface ChatEvidenceItem {
473
+ /** A caller control, for example an open or download button. */
474
+ action?: React$1.ReactNode;
475
+ excerpt?: React$1.ReactNode;
476
+ id: string;
477
+ /** Small labels below the item: provenance, relevance, dates. */
478
+ meta?: readonly React$1.ReactNode[];
479
+ title: React$1.ReactNode;
480
+ }
481
+ export interface ChatEvidenceGroup {
482
+ id: string;
483
+ items: readonly ChatEvidenceItem[];
484
+ label: React$1.ReactNode;
485
+ }
486
+ export interface ChatEvidenceColumn {
487
+ description?: string;
488
+ key: string;
489
+ label: React$1.ReactNode;
490
+ }
491
+ export interface ChatEvidenceRow {
492
+ /** Display-ready cells by column key. */
493
+ cells: Readonly<Record<string, React$1.ReactNode>>;
494
+ id: string;
495
+ }
496
+ export interface ChatEvidenceSource {
497
+ excerpt?: React$1.ReactNode;
498
+ id: string;
499
+ meta?: readonly React$1.ReactNode[];
500
+ rank?: React$1.ReactNode;
501
+ title: React$1.ReactNode;
502
+ /** Linked only for an `http` or `https` URL. */
503
+ url?: string;
504
+ }
505
+ export interface ChatEvidenceLink {
506
+ description?: React$1.ReactNode;
507
+ id: string;
508
+ label: React$1.ReactNode;
509
+ /** Linked only for an `http` or `https` URL. */
510
+ url: string;
511
+ }
512
+ export interface ChatEvidenceSummaryItem {
513
+ description?: React$1.ReactNode;
514
+ id: string;
515
+ label: React$1.ReactNode;
516
+ value: React$1.ReactNode;
517
+ }
518
+ export interface ChatEvidenceWarning {
519
+ id: string;
520
+ message: React$1.ReactNode;
521
+ }
522
+ export interface ChatToolEvidencePartBase {
523
+ description?: React$1.ReactNode;
524
+ id: string;
525
+ title: React$1.ReactNode;
526
+ }
527
+ /** One display-ready part of a tool result. */
528
+ export type ChatToolEvidencePart = ChatToolEvidencePartBase & ({
529
+ content: React$1.ReactNode;
530
+ icon?: React$1.ReactNode;
531
+ kind: "custom";
532
+ } | {
533
+ groups: readonly ChatEvidenceGroup[];
534
+ kind: "evidence";
535
+ note?: React$1.ReactNode;
536
+ } | {
537
+ json: string;
538
+ kind: "json";
539
+ } | {
540
+ kind: "links";
541
+ links: readonly ChatEvidenceLink[];
542
+ } | {
543
+ kind: "sources";
544
+ sources: readonly ChatEvidenceSource[];
545
+ } | {
546
+ items: readonly ChatEvidenceSummaryItem[];
547
+ kind: "summary";
548
+ } | {
549
+ columns: readonly ChatEvidenceColumn[];
550
+ kind: "table";
551
+ rows: readonly ChatEvidenceRow[];
552
+ } | {
553
+ kind: "text";
554
+ text: string;
555
+ } | {
556
+ kind: "warnings";
557
+ warnings: readonly ChatEvidenceWarning[];
558
+ });
559
+ export interface ChatToolEvidenceLabels {
560
+ /** Shown for a part without content. */
561
+ empty: string;
562
+ /** Label of the button that shows the hidden rows or sources. */
563
+ showMore: (count: number) => string;
564
+ }
565
+ export interface ChatToolEvidenceProps {
566
+ className?: string;
567
+ classNames?: Partial<Record<"body" | "header" | "part", string>>;
568
+ labels: ChatToolEvidenceLabels;
569
+ parts: readonly ChatToolEvidencePart[];
570
+ }
571
+ /**
572
+ * The display parts of an answer's tool results, each in a titled frame:
573
+ * evidence, tables, sources, links, summaries, warnings, text, JSON, or
574
+ * caller content.
575
+ */
576
+ export declare const ChatToolEvidence: ({ className, classNames, labels, parts }: ChatToolEvidenceProps) => React$1.JSX.Element | null;
577
+
578
+ export {};
package/dist/chat.js ADDED
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import"./index-99ad0xy6.js";import{n}from"./index-3yxm33ex.js";import{w,or,R,vr,k,pt,L,N,f,y,I}from"./index-2thxhq0q.js";import{B,ut,ft}from"./index-vejf6hg0.js";import{Ft,qe}from"./index-9az9jb0y.js";import{e}from"./index-mp8nkq9m.js";import{Dt,vt,Rr,Lr,Ve,Nt,Ir,He,Pr,_t,Tr,kr,Er,Mr}from"./index-9at1018y.js";import{F,re,Ct,Ze,Ge}from"./index-4ekvdxt4.js";import{h}from"./index-ek4ar1qs.js";import{g,S}from"./index-9me7rg96.js";import{useState as Ne}from"react";import{jsx as z,jsxs as K,Fragment as je}from"react/jsx-runtime";var Ce=({active:t,disabled:a,label:o,onClick:r,sentiment:s})=>{let i=s==="positive"?kr:Tr;return z(n,{"aria-label":o,"aria-pressed":t,disabled:a,className:e("h-7 min-w-7 px-2 text-base",t&&(s==="positive"?"border-(--success) text-(--success)":"border-(--danger) text-(--danger)")),onClick:r,size:"sm",type:"button",variant:"ghost",children:z(i,{"aria-hidden":"true",className:e("size-4",t&&"fill-current")})})},Qe=({labels:t,onCancel:a,onSubmit:o})=>{let[r,s]=Ne("");return K(je,{children:[z(B,{"aria-label":t.note,autoFocus:!0,onChange:(i)=>{s(i.target.value)},placeholder:t.note,value:r}),K(pt,{children:[z(n,{onClick:a,type:"button",variant:"outline",children:t.cancel}),z(n,{onClick:()=>{o(r.trim()===""?null:r.trim())},type:"button",children:t.submit})]})]})},_e=({className:t,error:a,labels:o,onClear:r,onSubmit:s,pending:i=!1,value:d})=>{let[p,u]=Ne(!1);return K("div",{className:e("flex flex-wrap items-center gap-2 text-xs text-muted-foreground",t),"data-part":"answer-feedback",children:[K("fieldset",{"aria-busy":i,"aria-label":o.group,className:"flex items-center gap-1",children:[z(Ce,{active:d==="positive",disabled:i,label:o.positive,onClick:()=>{if(d==="positive"){r();return}s({note:null,sentiment:"positive"})},sentiment:"positive"}),z(Ce,{active:d==="negative",disabled:i,label:o.negative,onClick:()=>{if(d==="negative"){r();return}u(!0)},sentiment:"negative"})]}),i?z("span",{children:o.saving}):null,a===void 0||a===null?null:z("span",{className:"text-destructive",role:"alert",children:a}),z(w,{onOpenChange:u,open:p,children:K(R,{children:[K(k,{children:[z(L,{children:o.noteTitle}),z(N,{children:o.noteDescription})]}),z(Qe,{labels:o,onCancel:()=>{u(!1)},onSubmit:(x)=>{s({note:x,sentiment:"negative"}),u(!1)}})]})})]})};import{useId as ye,useState as ie}from"react";import{jsx as c,jsxs as A}from"react/jsx-runtime";var Ue=new Set(["continuation_failed","reconciliation_required"]),Ke=({status:t})=>c("div",{className:"mt-0.5 rounded-md border border-border bg-muted/40 p-1.5",children:(()=>{if(t==="approved")return c(F,{className:"size-4 text-emerald-600"});if(t==="pending")return c(Nt,{className:"size-4 text-muted-foreground"});return c(vt,{className:"size-4 text-destructive"})})()}),$e=({label:t,outcome:a})=>A("output",{className:"mt-3 flex items-center gap-2 border-t border-border pt-3 text-sm font-medium text-foreground",children:[Ue.has(a)?c(re,{className:"size-4 shrink-0 text-destructive"}):c(F,{className:"size-4 shrink-0 text-emerald-600"}),t]}),se=[],We=({onApprove:t,onReject:a,outcome:o,status:r})=>{if(r!=="pending"||o!==void 0)return"closed";return t===void 0&&a===void 0?"read_only":"decide"},Xe={closed:null,decide:"decideHint",read_only:"readOnlyHint"},Je=({className:t,decisions:a=se,labels:o,meta:r=se,resolution:s,steps:i=se})=>{if(r.length===0&&i.length===0&&a.length===0&&s===void 0)return null;return A("div",{className:e("mt-3 grid gap-2 text-xs text-muted-foreground",t),children:[r.length===0?null:c("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:r.map((d,p)=>c("span",{children:d},p))}),i.length===0?null:c("ul",{"aria-label":o.steps,className:"grid gap-1",children:i.map((d)=>A("li",{className:"flex items-center justify-between gap-3",children:[c("span",{className:"truncate",children:d.label}),c("span",{className:"shrink-0",children:o.stepProgress(d.approved,d.required)})]},d.id))}),a.length===0?null:c("ul",{"aria-label":o.decisions,className:"grid gap-1 border-t border-border pt-2",children:a.map((d)=>c("li",{children:d.label},d.id))}),s===void 0?null:c("p",{className:"border-t border-border pt-2",children:s})]})},de=500,Ye=({labels:t,onCancel:a,onReject:o,pending:r})=>{let s=ye(),[i,d]=ie(""),p=i.trim();return A("div",{className:"mt-3 grid gap-2 border-t border-border pt-3",children:[c(y,{htmlFor:s,children:t.rejectReason}),c(B,{autoFocus:!0,disabled:r,id:s,maxLength:de,onChange:(u)=>{d(u.target.value)},placeholder:t.rejectReasonPlaceholder,value:i}),A("div",{className:"flex items-center justify-between gap-2",children:[A("span",{className:"text-xs text-muted-foreground",children:[i.length,"/",de]}),A("div",{className:"flex gap-2",children:[c(n,{disabled:r,onClick:a,size:"sm",type:"button",variant:"ghost",children:t.cancel}),A(n,{disabled:r||p==="",onClick:()=>{o(p)},size:"sm",type:"button",variant:"destructive",children:[r?c(h,{className:"size-3.5 animate-spin"}):null,t.confirmReject]})]})]})]})},et=({labels:t,onApprove:a,onReject:o,pendingAction:r})=>{let s=ye(),[i,d]=ie(""),[p,u]=ie(!1),x=r!==void 0;if(p&&o!==void 0)return c(Ye,{labels:t,onCancel:()=>{u(!1)},onReject:o,pending:r==="reject"});return A("div",{className:"mt-3 grid gap-2 border-t border-border pt-3",children:[a===void 0?null:A("div",{className:"grid gap-1.5",children:[c(y,{className:"text-xs",htmlFor:s,children:t.comment}),c(f,{disabled:x,id:s,maxLength:de,onChange:(v)=>{d(v.target.value)},placeholder:t.commentPlaceholder,value:i})]}),A("div",{className:"flex gap-2",children:[a===void 0?null:A(n,{disabled:x,onClick:()=>{a(i.trim()===""?null:i.trim())},size:"sm",type:"button",children:[r==="approve"?c(h,{className:"size-3.5 animate-spin"}):c(F,{className:"size-3.5"}),r==="approve"?t.approving:t.approve]}),o===void 0?null:A(n,{disabled:x,onClick:()=>{u(!0)},size:"sm",type:"button",variant:"outline",children:[c(vt,{className:"size-3.5"}),t.reject]})]})]})},tt=({children:t,className:a,classNames:o,decisions:r,error:s,labels:i,meta:d,onApprove:p,onReject:u,outcome:x,pendingAction:v,resolution:E,status:C,steps:_,summary:J})=>{let j=We({onApprove:p,onReject:u,outcome:x,status:C}),Y=Xe[j],Z=Y===null?void 0:i[Y];return A("section",{"aria-label":i.title,className:e("rounded-md border border-border bg-background p-3 text-sm",a),"data-part":"approval-card","data-status":C,children:[A("div",{className:e("flex items-start gap-3",o?.header),children:[c(Ke,{status:C}),A("div",{className:"min-w-0 flex-1",children:[A("div",{className:"flex flex-wrap items-center gap-2",children:[c("p",{className:"font-medium text-foreground",children:i.title}),c(I,{variant:j==="decide"?"default":"outline",children:i.statuses[C]}),j==="read_only"?c(I,{variant:"secondary",children:i.readOnly}):null]}),Z===void 0?null:c("p",{className:"mt-1 text-muted-foreground",children:Z}),J===void 0?null:c("div",{className:"mt-1 break-words text-foreground",children:J}),c(Je,{className:o?.details,decisions:r,labels:i,meta:d,resolution:E,steps:_})]})]}),t,j==="decide"?c("div",{className:o?.actions,children:c(et,{labels:i,onApprove:p,onReject:u,pendingAction:v})}):null,s===void 0||s===null?null:c("p",{className:"mt-2 text-destructive",role:"alert",children:s}),x===void 0?null:c($e,{label:i.outcomes[x],outcome:x})]})};import{jsx as P,jsxs as q,Fragment as rt}from"react/jsx-runtime";var at=({labels:t,name:a,onDownload:o,pending:r})=>q("button",{"aria-label":t.downloadFile(a),className:"inline-flex items-center gap-1 rounded-sm px-1 text-(--accent) hover:text-(--accent-hover) focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-60",disabled:r,onClick:o,type:"button",children:[r?P(h,{className:"size-3.5 animate-spin"}):P(Ct,{className:"size-3.5"}),P("span",{children:r?t.downloading:t.download})]}),nt=({description:t,label:a,name:o,url:r})=>q(w,{children:[P(or,{asChild:!0,children:P("button",{"aria-label":a,className:"shrink-0 overflow-hidden rounded-sm focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",type:"button",children:P("img",{alt:"",className:"size-7 object-cover",src:r})})}),P(or,{asChild:!0,children:P("button",{className:"max-w-[220px] truncate text-left hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",type:"button",children:o})}),q(R,{size:"xl",children:[q(k,{children:[P(L,{children:o}),P(N,{children:t})]}),P(vr,{children:P("img",{alt:o,className:"max-h-[70vh] w-full rounded-md object-contain",src:r})})]})]}),ot=(t)=>{let{className:a,detail:o,labels:r,name:s,previewUrl:i}=t;return q("span",{className:e("inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-muted/50 px-2 py-1 text-xs text-foreground",a),"data-mode":t.mode,"data-part":"attachment-chip",children:[i===void 0?q(rt,{children:[P(He,{className:"size-3.5 shrink-0 text-muted-foreground"}),P("span",{className:"max-w-[220px] truncate",children:s})]}):P(nt,{description:r.previewDescription,label:r.preview(s),name:s,url:i}),o===void 0?null:P("span",{className:"text-muted-foreground",children:o}),t.mode==="draft"?P("button",{"aria-label":r.remove(s),className:"rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",onClick:t.onRemove,type:"button",children:P(S,{className:"size-3.5"})}):null,t.mode==="stored"&&t.onDownload!==void 0?P(at,{labels:r,name:s,onDownload:t.onDownload,pending:t.pending??!1}):null,t.mode==="stored"&&t.error!==void 0&&t.error!==null?P("span",{className:"text-destructive",role:"alert",children:t.error}):null]})};import{jsx as we,jsxs as ke}from"react/jsx-runtime";var st=(t,a,o)=>{if(a>0)return` · ${t.messages(a)}`;if(o>0)return` · ${t.runs(o)}`;return""},it=({className:t,labels:a,messageCount:o=0,runCount:r=0})=>ke("div",{className:e("flex items-center gap-3 text-xs text-muted-foreground",t),"data-part":"compaction-marker",children:[we("hr",{"aria-label":a.compacted,className:"h-px flex-1 border-0 bg-border"}),ke("span",{className:"shrink-0 rounded-md border border-border bg-background px-2 py-1",children:[a.compacted,st(a,o,r)]}),we("span",{"aria-hidden":"true",className:"h-px flex-1 bg-border"})]});import{useState as dt}from"react";import{jsx as T,jsxs as ee}from"react/jsx-runtime";var le=(t)=>[...t.dataTransfer.types].includes("Files"),lt=({state:t})=>{if(t==="idle")return T(Lr,{className:"size-4"});return T(h,{className:"size-4 animate-spin"})},Re=({className:t,label:a,onStop:o,stopping:r})=>T(n,{"aria-busy":r||void 0,"aria-label":a,className:e("size-8 shrink-0 rounded-md bg-destructive text-destructive-foreground hover:bg-destructive/90",t),disabled:r,onClick:o,size:"icon",type:"button",children:r?T(h,{className:"size-4 animate-spin"}):T("span",{className:"size-3 rounded-[2px] bg-current"})}),ct=({canSubmit:t,labels:a,onStop:o,sendClassName:r,showStop:s,state:i,stopping:d,submit:p,trailing:u})=>{let x=s&&o!==void 0,v=!x&&i==="running"&&o!==void 0;return ee("div",{className:"flex shrink-0 items-center gap-1.5",children:[x?T(Re,{className:void 0,label:a.stop,onStop:o,stopping:d}):null,u,v?T(Re,{className:r,label:a.stop,onStop:o,stopping:d}):T(n,{"aria-label":i==="idle"?a.send:a.submitting,className:e("size-8 shrink-0 rounded-md bg-foreground text-background hover:bg-foreground/90",r),disabled:!t,onClick:p,size:"icon",type:"button",children:T(lt,{state:i})})]})},mt=({attachments:t,className:a,classNames:o,disabled:r=!1,footer:s,labels:i,leading:d,notice:p,onFilesAdd:u,onInputKeyDown:x,onStop:v,onSubmit:E,onValueChange:C,placeholder:_,showStop:J=!1,state:j="idle",stopping:Y=!1,suggestions:Z,trailing:Ie,value:ge})=>{let[fe,oe]=dt(!1),be=j==="idle"&&!r&&ge.trim()!=="",xe=()=>{if(be)E()},he=(b)=>{if(u!==void 0&&b.length>0)u([...b])},Oe=u===void 0?{}:{onDragEnter:(b)=>{if(le(b))b.preventDefault(),oe(!0)},onDragLeave:(b)=>{let{relatedTarget:ve}=b;if(!(ve instanceof Node)||!b.currentTarget.contains(ve))oe(!1)},onDragOver:(b)=>{if(le(b))b.preventDefault()},onDrop:(b)=>{if(le(b))b.preventDefault(),oe(!1),he(b.dataTransfer.files)}};return ee("div",{className:e("w-full",a),"data-part":"composer",children:[p===void 0?null:T("div",{className:"mb-2",children:p}),ee("div",{className:e("relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-colors dark:border-border/80 dark:bg-black dark:shadow-none",fe&&"border-primary/70 bg-primary/5 ring-2 ring-primary/20",o?.frame),"data-part":"composer-frame",...Oe,children:[fe?T("div",{className:"pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-xl border border-primary/40 bg-background/80 text-sm font-medium text-foreground backdrop-blur-sm",children:i.drop}):null,t===void 0?null:T("div",{className:"flex flex-wrap gap-2 border-b border-border px-3 py-2",children:t}),T(B,{"aria-label":i.input,className:e("max-h-44 min-h-20 resize-none border-0 bg-transparent px-5 py-4 text-base text-foreground shadow-none placeholder:text-muted-foreground focus-visible:ring-0 dark:bg-transparent",o?.input),disabled:r,onChange:(b)=>{C(b.target.value)},onKeyDown:(b)=>{if(x?.(b),b.defaultPrevented||b.key!=="Enter"||b.shiftKey||b.nativeEvent.isComposing)return;b.preventDefault(),xe()},onPaste:(b)=>{if(u!==void 0&&b.clipboardData.files.length>0)b.preventDefault(),he(b.clipboardData.files)},placeholder:_,value:ge}),Z,ee("div",{className:e("flex min-h-14 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-t border-border/80 bg-muted/30 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-950",o?.toolbar),children:[T("div",{className:"flex min-w-0 flex-1 items-center gap-1 text-muted-foreground",children:d}),T(ct,{canSubmit:be,labels:i,onStop:v,sendClassName:o?.send,showStop:J,state:j,stopping:Y,submit:xe,trailing:Ie})]})]}),s]})};import{jsx as xt}from"react/jsx-runtime";var gt=(t)=>Number.isFinite(t)?Math.round(Math.min(1,Math.max(0,t))*100):0,bt=({className:t,label:a,ratio:o})=>{let r=gt(o);return xt(Ft,{"aria-valuenow":r,className:t,"data-part":"context-usage-ring",label:a,role:"meter",value:r})};import ht from"react-markdown";import yt from"remark-gfm";import{jsx as W}from"react/jsx-runtime";var wt=({children:t,href:a})=>W("a",{href:a,rel:"noreferrer",target:"_blank",children:t}),kt=({children:t,...a})=>W("div",{className:"my-4 max-w-full overflow-x-auto",children:W("table",{...a,className:"w-max min-w-full",children:t})}),Pe={a:wt,table:kt},Rt=[yt],Pt=({className:t,components:a,content:o})=>W("div",{className:e("prose prose-sm min-w-0 max-w-none break-words text-[15px] leading-7 text-foreground dark:prose-invert prose-headings:font-semibold prose-pre:bg-muted prose-th:text-left",t),"data-part":"markdown",children:W(ht,{components:a===void 0?Pe:{...Pe,...a},remarkPlugins:Rt,children:o})});import{jsx as H,jsxs as te}from"react/jsx-runtime";var St=6,Et=({className:t,classNames:a,events:o,labels:r,memoryDisabled:s=!1,saved:i,used:d})=>{if(o.length===0)return null;return te("div",{className:e("rounded-lg border border-border bg-muted/30 px-4 py-3 text-sm",t),"data-part":"memory-evidence",children:[te("div",{className:e("flex flex-wrap items-center justify-between gap-2",a?.header),children:[H("div",{className:"font-semibold",children:r.title}),te("div",{className:"flex flex-wrap gap-1.5",children:[d>0?H(I,{className:"rounded-md",variant:"secondary",children:r.used(d)}):null,i>0?H(I,{className:"rounded-md",variant:"secondary",children:r.saved(i)}):null,s?H(I,{className:"rounded-md",variant:"secondary",children:r.disabled}):null]})]}),H("ul",{className:e("mt-2 space-y-1.5",a?.events),children:o.slice(0,St).map((p)=>te("li",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[H("span",{className:"font-medium text-foreground",children:p.label}),(p.details??[]).map((u,x)=>H("span",{children:u},x))]},p.id))})]})};import{jsx as G,jsxs as ce}from"react/jsx-runtime";var Se={assistant:{className:"bg-accent text-accent-foreground",icon:G(Ve,{className:"size-5"})},user:{className:"bg-primary text-primary-foreground",icon:G(Er,{className:"size-5"})}},At=({author:t,avatar:a,children:o,className:r,classNames:s,sender:i,timestamp:d})=>ce("article",{className:e("grid grid-cols-[36px_minmax(0,1fr)] gap-3",r),"data-part":"message","data-sender":i,children:[G("div",{"aria-hidden":"true",className:e("grid size-9 place-items-center overflow-hidden rounded-full",a===void 0&&Se[i].className,s?.avatar),children:a??Se[i].icon}),ce("div",{className:"min-w-0 text-sm text-foreground",children:[ce("div",{className:e("mb-1.5 flex flex-wrap items-center gap-2",s?.header),children:[G("span",{className:e("font-semibold",s?.author),children:t}),d===void 0?null:G("span",{className:e("text-xs text-muted-foreground",s?.timestamp),children:d})]}),G("div",{className:e("flex flex-col gap-3",s?.body),children:o})]})]});import{jsx as O,jsxs as V}from"react/jsx-runtime";var me=({className:t,decision:a,label:o,onDecide:r,pendingDecision:s,variant:i="default"})=>V(n,{className:t,disabled:s!==void 0,onClick:()=>{r(a)},type:"button",variant:i,children:[s===a?O(h,{className:"size-4 animate-spin"}):null,o]}),Lt=({className:t,classNames:a,description:o,error:r,labels:s,name:i,onDecide:d,pendingDecision:p})=>O("section",{"aria-label":s.region(i),className:e("rounded-lg border border-border bg-card p-4 text-card-foreground shadow-sm",t),"data-part":"permission-prompt",children:V("div",{className:"flex items-start gap-3",children:[O("div",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md bg-(--bg-accent-soft) text-(--accent)",children:O(_t,{className:"size-4"})}),V("div",{className:"@container/permission min-w-0 flex-1 space-y-3",children:[V("div",{children:[O("h2",{className:e("break-words text-base font-semibold text-foreground",a?.title),children:s.title(i)}),s.description===void 0?null:O("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:s.description})]}),o===void 0||o===null?null:O("p",{className:e("rounded-md border border-border bg-muted/50 px-3 py-2 text-sm leading-6 text-muted-foreground",a?.description),children:o}),r===void 0||r===null?null:O("p",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm leading-6 text-destructive",role:"alert",children:r}),V("div",{className:e("flex flex-col gap-2 @2xl/permission:flex-row @2xl/permission:items-center",a?.actions),children:[O(me,{className:"w-full @2xl/permission:w-auto",decision:"deny",label:s.deny,onDecide:d,pendingDecision:p,variant:"outline"}),V("div",{className:"flex flex-col gap-2 @md/permission:flex-row @2xl/permission:ml-auto @2xl/permission:justify-end",children:[O(me,{className:"w-full @md/permission:w-auto",decision:"allow_this_conversation",label:s.allowThisConversation,onDecide:d,pendingDecision:p}),O(me,{className:"w-full @md/permission:w-auto",decision:"allow_always",label:s.allowAlways,onDecide:d,pendingDecision:p})]})]})]})]})});import{useState as Tt}from"react";import{jsx as Q,jsxs as X}from"react/jsx-runtime";var Mt={approval:Nt,command:Rr,compaction:F,file:He,model:Ve,permission:_t,request:F,run:F,skill:Ve,step:F,tool:Mr},zt=({step:t})=>{if(t.status==="active")return Q(h,{className:"size-4 animate-spin"});let a=Mt[t.kind];return Q(a,{className:"size-4"})},Bt=({className:t,classNames:a,defaultOpen:o=!1,onOpenChange:r,open:s,steps:i,summary:d})=>{let[p,u]=Tt(o),x=s??p;if(i.length===0)return null;return X("details",{className:e("group ml-12 text-sm text-muted-foreground",t),"data-part":"processing-steps",onToggle:(v)=>{let E=v.currentTarget.open;if(E!==x)u(E),r?.(E)},open:x,children:[X("summary",{className:e("flex w-fit cursor-pointer list-none items-center gap-1.5 font-medium text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",a?.summary),children:[Q("span",{children:d}),Q(g,{className:"size-4 transition-transform group-open:rotate-180"})]}),x?Q("ol",{className:e("mt-4",a?.list),children:i.map((v,E)=>X("li",{className:e("grid grid-cols-[32px_minmax(0,1fr)] gap-3",a?.step),"data-status":v.status,children:[X("div",{className:"relative flex justify-center",children:[Q("span",{className:"mt-0.5 grid size-6 place-items-center rounded-md border border-border bg-background text-muted-foreground",children:Q(zt,{step:v})}),E<i.length-1?Q("span",{className:"absolute top-8 bottom-0 w-px bg-border"}):null]}),Q("div",{className:"min-w-0 pb-5",children:X("div",{className:"flex min-h-6 flex-wrap items-center gap-2",children:[Q("span",{className:e("break-words text-base",v.status==="active"?"text-foreground":"text-muted-foreground"),children:v.label}),v.detail===void 0?null:Q("span",{className:"rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:v.detail})]})})]},v.id))}):null]})};import{useId as Te,useState as ae}from"react";import{jsx as m,jsxs as M,Fragment as qt}from"react/jsx-runtime";var pe="other",De=(t)=>`option:${t}`,Ee=({description:t,id:a,label:o,value:r})=>M("div",{className:"flex items-start gap-2",children:[m(ft,{className:"mt-0.5",id:a,value:r}),M("div",{className:"grid gap-0.5",children:[m(y,{htmlFor:a,children:o}),t===void 0?null:m("span",{className:"text-xs text-muted-foreground",children:t})]})]}),It=({disabled:t,labels:a,onRespond:o,options:r,withText:s})=>{let i=Te(),[d,p]=ae(null),[u,x]=ae(""),v=(C)=>r.find((_)=>De(_.id)===C),E=(()=>{if(d===pe)return u.trim()===""?null:{action:"answer",text:u.trim()};let C=d===null?void 0:v(d);return C===void 0?null:{action:"answer",optionId:C.id}})();return M(qt,{children:[M(ut,{className:"grid gap-2",disabled:t,onValueChange:(C)=>{p(C);let _=v(C);if(!s&&_!==void 0)o({action:"answer",optionId:_.id})},value:d??"",children:[r.map((C,_)=>m(Ee,{description:C.description,id:`${i}-${_}`,label:C.label,value:De(C.id)},C.id)),s?m(Ee,{id:`${i}-other`,label:a.otherOption,value:pe}):null]}),s?M("div",{className:"flex gap-2",children:[m(f,{"aria-label":a.otherAnswer,disabled:t||d!==pe,onChange:(C)=>{x(C.target.value)},value:u}),m(n,{disabled:t||E===null,onClick:()=>{if(E!==null)o(E)},type:"button",children:a.continue})]}):null]})},Ot=({disabled:t,labels:a,onRespond:o})=>{let[r,s]=ae("");return M("div",{className:"grid gap-2",children:[m(B,{"aria-label":a.textAnswer,disabled:t,onChange:(i)=>{s(i.target.value)},placeholder:a.textPlaceholder,value:r}),m(n,{className:"justify-self-start",disabled:t||r.trim()==="",onClick:()=>{o({action:"answer",text:r.trim()})},type:"button",children:a.answer})]})},Qt=({disabled:t,labels:a,onRespond:o})=>{let r=Te(),[s,i]=ae("");return M("div",{className:"grid gap-2",children:[m(n,{className:"justify-self-start",disabled:t,onClick:()=>{o({action:"approve"})},type:"button",children:t?a.responding:a.approve}),m(y,{htmlFor:r,children:a.reviseLabel}),M("div",{className:"flex gap-2",children:[m(f,{disabled:t,id:r,onChange:(d)=>{i(d.target.value)},value:s}),m(n,{disabled:t||s.trim()==="",onClick:()=>{o({action:"revise",text:s.trim()})},type:"button",variant:"outline",children:a.revise})]})]})},Ae=({error:t})=>t===void 0||t===null?null:m("p",{className:"text-destructive",role:"alert",children:t}),Le=({meta:t})=>t.length===0?null:m("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:t.map((a,o)=>m("span",{children:a},o))}),jt=({className:t,label:a,preview:o})=>o===void 0||o===null?null:M("div",{className:e("grid gap-2 rounded-md border border-border bg-muted/30 p-3",t),children:[m("p",{className:"font-semibold",children:a}),m("div",{className:"break-words",children:o})]}),Ht=(t)=>t!=="pending"&&t!=="responding",Ut=({className:t,classNames:a,labels:o,outcome:r,prompt:s,status:i})=>M("section",{className:e("grid gap-2 rounded-lg border border-border bg-muted/30 p-4 text-sm",t),"data-part":"question-card","data-status":i,children:[m("div",{className:e("break-words",a?.prompt),children:s}),M("p",{className:"flex items-center gap-2 font-medium",children:[i==="completed"?m(F,{className:"size-4 shrink-0 text-emerald-600"}):m(vt,{className:"size-4 shrink-0 text-destructive"}),o[i]]}),r===void 0||r===null?null:m("output",{className:"text-muted-foreground",children:r})]}),Kt=(t)=>{let{className:a,classNames:o,error:r,labels:s,meta:i=[],onRespond:d,outcome:p,preview:u,prompt:x,status:v}=t;if(Ht(v))return m(Ut,{className:a,classNames:o,labels:s,outcome:p,prompt:x,status:v});let E=v==="responding",C=m(jt,{className:o?.preview,label:s.preview,preview:u});if(t.mode==="confirm")return M("section",{className:e("grid gap-3 rounded-lg border border-border bg-muted/30 p-4 text-sm",a),"data-part":"question-card","data-status":v,children:[M("div",{children:[m("p",{className:"text-xs font-semibold tracking-wide text-muted-foreground uppercase",children:s.confirmTitle}),s.confirmHint===void 0?null:m("p",{className:"text-xs text-muted-foreground",children:s.confirmHint})]}),m("div",{className:e("break-words font-semibold",o?.prompt),children:x}),m(Le,{meta:i}),C,m(Qt,{disabled:E,labels:s,onRespond:d}),m(Ae,{error:r})]});return M("section",{className:e("grid gap-3 rounded-lg border border-border p-4 text-sm",a),"data-part":"question-card","data-status":v,children:[C,m("div",{className:e("break-words",o?.prompt),children:x}),m(Le,{meta:i}),t.mode==="choice"||t.mode==="choice_or_text"?m(It,{disabled:E,labels:s,onRespond:d,options:t.options,withText:t.mode==="choice_or_text"}):null,t.mode==="text"?m(Ot,{disabled:E,labels:s,onRespond:d}):null,m(Ae,{error:r})]})};import{jsx as U,jsxs as ne,Fragment as Vt}from"react/jsx-runtime";var Gt={danger:"text-destructive",neutral:"text-muted-foreground",primary:"text-primary",success:"text-emerald-600",warning:"text-amber-600"},$t=({className:t,classNames:a,detail:o,label:r,labels:s,tone:i})=>ne("div",{className:e("rounded-lg border border-border bg-muted/30 px-4 py-3",t),"data-part":"run-status","data-tone":i,children:[ne("div",{className:"flex min-w-0 items-center gap-2",children:[U(Ve,{className:"size-4 shrink-0 text-muted-foreground"}),U("span",{className:e("truncate font-semibold",a?.title),children:s.title})]}),ne("div",{className:e("mt-1.5 flex flex-wrap items-center gap-2 text-sm",a?.status),children:[U(qe,{size:"md",tone:i}),U("span",{className:"text-muted-foreground",children:s.status}),U("span",{className:Gt[i],children:r}),o===void 0||o===null?null:ne(Vt,{children:[U("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"·"}),U("span",{className:"font-mono text-xs text-muted-foreground",children:o})]})]})]});import{useState as Me}from"react";import{jsx as l,jsxs as D}from"react/jsx-runtime";var Wt=5,Xt=4,Jt={custom:He,evidence:He,json:Dt,links:Ge,sources:Pr,summary:Dt,table:Ir,text:Dt,warnings:re},Yt=(t)=>{try{let{protocol:a}=new URL(t);return a==="http:"||a==="https:"?t:null}catch{return null}},ze=({children:t,url:a})=>{let o=Yt(a);if(o===null)return l("span",{className:"break-words font-medium",children:t});return D("a",{className:"inline-flex max-w-full items-center gap-1 break-all font-medium text-primary hover:text-(--accent-hover)",href:o,rel:"noreferrer",target:"_blank",children:[l("span",{className:"min-w-0 break-words",children:t}),l(Ze,{className:"size-3 shrink-0"})]})},Be=({meta:t})=>t===void 0||t.length===0?null:l("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:t.map((a,o)=>l("span",{children:a},o))}),ue=({excerpt:t})=>t===void 0?null:l("p",{className:"mt-1 break-words text-xs leading-5 text-muted-foreground",children:t}),Fe=({hidden:t,label:a,onShow:o})=>t>0?D("button",{className:"inline-flex items-center gap-1 text-xs font-medium text-primary hover:text-(--accent-hover)",onClick:o,type:"button",children:[a(t),l(g,{className:"size-3"})]}):null,Zt=({groups:t,note:a})=>D("div",{className:"flex flex-col gap-3",children:[t.map((o)=>D("section",{className:"flex flex-col gap-2",children:[l("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o.label}),l("ol",{className:"flex flex-col gap-2",children:o.items.map((r)=>D("li",{className:"rounded-md border border-border bg-background/70 p-2.5",children:[D("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[D("div",{className:"min-w-0",children:[l("div",{className:"font-medium",children:r.title}),l(ue,{excerpt:r.excerpt})]}),r.action]}),l(Be,{meta:r.meta})]},r.id))})]},o.id)),a===void 0?null:l("p",{className:"text-xs text-muted-foreground",children:a})]}),ea=({columns:t,labels:a,rows:o})=>{let[r,s]=Me(!1),i=r?o:o.slice(0,Wt);return D("div",{className:"flex flex-col items-start gap-2",children:[l("div",{className:"w-full max-w-full overflow-x-auto",children:D("table",{className:"w-full min-w-[520px] table-fixed border-collapse text-left text-xs",children:[l("thead",{children:l("tr",{className:"border-b border-border",children:t.map((d)=>l("th",{className:"w-[180px] px-2 py-2 font-semibold text-muted-foreground",title:d.description,children:d.label},d.key))})}),l("tbody",{children:i.map((d)=>l("tr",{className:"border-b border-border/70 last:border-0",children:t.map((p)=>l("td",{className:"px-2 py-2 align-top break-words",children:d.cells[p.key]},p.key))},d.id))})]})}),l(Fe,{hidden:o.length-i.length,label:a.showMore,onShow:()=>{s(!0)}})]})},ta=({labels:t,sources:a})=>{let[o,r]=Me(!1),s=o?a:a.slice(0,Xt);return D("div",{className:"flex flex-col items-start gap-2",children:[l("ol",{className:"flex w-full flex-col gap-2",children:s.map((i)=>D("li",{className:"rounded-md border border-border bg-background/70 p-2",children:[D("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[D("div",{className:"min-w-0",children:[i.url===void 0?l("span",{className:"font-medium",children:i.title}):l(ze,{url:i.url,children:i.title}),l(ue,{excerpt:i.excerpt})]}),i.rank===void 0?null:l("span",{className:"shrink-0 text-xs text-muted-foreground",children:i.rank})]}),l(Be,{meta:i.meta})]},i.id))}),l(Fe,{hidden:a.length-s.length,label:t.showMore,onShow:()=>{r(!0)}})]})},aa=(t)=>{switch(t.kind){case"custom":return!1;case"evidence":return t.groups.every((a)=>a.items.length===0);case"json":return t.json==="";case"links":return t.links.length===0;case"sources":return t.sources.length===0;case"summary":return t.items.length===0;case"table":return t.columns.length===0||t.rows.length===0;case"text":return t.text==="";case"warnings":return t.warnings.length===0;default:return t}},na=({labels:t,part:a})=>{if(aa(a))return l("p",{className:"text-xs text-muted-foreground",children:t.empty});switch(a.kind){case"custom":return a.content;case"evidence":return l(Zt,{groups:a.groups,note:a.note});case"json":return l("pre",{className:"max-h-[280px] overflow-auto rounded-md bg-background p-2 text-xs leading-5 text-foreground",children:a.json});case"links":return l("ul",{className:"grid gap-2",children:a.links.map((o)=>D("li",{className:"min-w-0 rounded-md border border-border bg-background/70 p-2",children:[l(ze,{url:o.url,children:o.label}),l(ue,{excerpt:o.description})]},o.id))});case"sources":return l(ta,{labels:t,sources:a.sources});case"summary":return l("dl",{className:"grid gap-2 @lg/chat:grid-cols-2",children:a.items.map((o)=>D("div",{className:"min-w-0 rounded-md border border-border bg-background/70 p-2",children:[l("dt",{className:"text-xs font-medium text-muted-foreground",children:o.label}),l("dd",{className:"mt-1 break-words text-sm",children:o.value}),o.description===void 0?null:l("dd",{className:"mt-1 text-xs text-muted-foreground",children:o.description})]},o.id))});case"table":return l(ea,{columns:a.columns,labels:t,rows:a.rows});case"text":return l("p",{className:"whitespace-pre-wrap break-words text-sm leading-6",children:a.text});case"warnings":return l("ul",{className:"flex flex-col gap-2",children:a.warnings.map((o)=>D("li",{className:"flex min-w-0 gap-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-2 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:[l(re,{className:"mt-0.5 size-3.5 shrink-0"}),l("span",{className:"break-words text-xs",children:o.message})]},o.id))});default:return a}},oa=({part:t})=>{if(t.kind==="custom"&&t.icon!==void 0)return t.icon;let a=Jt[t.kind];return l(a,{className:"size-4"})},ra=({className:t,classNames:a,labels:o,parts:r})=>r.length===0?null:l("div",{className:e("flex flex-col gap-3",t),"data-part":"tool-evidence",children:r.map((s)=>D("section",{className:e("overflow-hidden rounded-md border border-border bg-muted/20",a?.part),"data-kind":s.kind,children:[D("div",{className:e("flex min-w-0 items-start gap-2 border-b border-border px-3 py-2",a?.header),children:[l("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:l(oa,{part:s})}),D("div",{className:"min-w-0",children:[l("h3",{className:"truncate text-sm font-medium",children:s.title}),s.description===void 0?null:l("p",{className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:s.description})]})]}),l("div",{className:e("min-w-0 p-3",a?.body),children:l(na,{labels:o,part:s})})]},s.id))});export{_e as ChatAnswerFeedback,tt as ChatApprovalCard,ot as ChatAttachmentChip,it as ChatCompactionMarker,mt as ChatComposerShell,bt as ChatContextUsageRing,Pt as ChatMarkdown,Et as ChatMemoryEvidence,At as ChatMessage,Lt as ChatPermissionPrompt,Bt as ChatProcessingSteps,Kt as ChatQuestionCard,$t as ChatRunStatus,ra as ChatToolEvidence};