@webority/chat-react 0.128.0 → 0.134.0

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 (90) hide show
  1. package/dist/chat-react.js +14 -11
  2. package/dist/types/ChatAgentTyping.d.ts +4 -0
  3. package/dist/types/ChatAuthorBadge.d.ts +4 -0
  4. package/dist/types/ChatComposer.d.ts +10 -0
  5. package/dist/types/ChatConversationActions.d.ts +7 -0
  6. package/dist/types/ChatEmbed.d.ts +5 -0
  7. package/dist/types/ChatExplain.d.ts +16 -0
  8. package/dist/types/ChatFooter.d.ts +8 -0
  9. package/dist/types/ChatFrame.d.ts +26 -0
  10. package/dist/types/ChatHistory.d.ts +9 -0
  11. package/dist/types/ChatLauncher.d.ts +5 -0
  12. package/dist/types/ChatLiveStatus.d.ts +4 -0
  13. package/dist/types/ChatMessageActions.d.ts +10 -0
  14. package/dist/types/ChatNudge.d.ts +10 -0
  15. package/dist/types/ChatOpenTickets.d.ts +9 -0
  16. package/dist/types/ChatPage.d.ts +49 -0
  17. package/dist/types/ChatPanel.d.ts +9 -0
  18. package/dist/types/ChatPastChats.d.ts +9 -0
  19. package/dist/types/ChatReadAloudButton.d.ts +8 -0
  20. package/dist/types/ChatShell.d.ts +32 -0
  21. package/dist/types/ChatStarters.d.ts +8 -0
  22. package/dist/types/ChatThread.d.ts +15 -0
  23. package/dist/types/chatLive.d.ts +5 -0
  24. package/dist/types/chatPrint.d.ts +6 -0
  25. package/dist/types/chatShared.d.ts +10 -0
  26. package/dist/types/dictationText.d.ts +31 -0
  27. package/dist/types/index.d.ts +20 -14
  28. package/dist/types/loaders/ChatLoader.d.ts +21 -0
  29. package/dist/types/loaders/OrbLoader.d.ts +11 -0
  30. package/dist/types/loaders/PhrasesLoader.d.ts +14 -0
  31. package/dist/types/loaders/SkeletonLoader.d.ts +11 -0
  32. package/dist/types/loaders/StepsLoader.d.ts +12 -0
  33. package/dist/types/loaders/TypingPill.d.ts +12 -0
  34. package/dist/types/recaptcha.d.ts +2 -0
  35. package/dist/types/renderers/ActionPart.d.ts +4 -0
  36. package/dist/types/renderers/ChartPart.d.ts +4 -0
  37. package/dist/types/renderers/ChatLinkContext.d.ts +8 -0
  38. package/dist/types/renderers/FigureText.d.ts +5 -0
  39. package/dist/types/renderers/FiguresPart.d.ts +4 -0
  40. package/dist/types/renderers/FilePart.d.ts +4 -0
  41. package/dist/types/renderers/HandoffPart.d.ts +4 -0
  42. package/dist/types/renderers/ImagePart.d.ts +4 -0
  43. package/dist/types/renderers/InputRequestPart.d.ts +5 -0
  44. package/dist/types/renderers/NoticePart.d.ts +3 -0
  45. package/dist/types/renderers/QuickRepliesPart.d.ts +4 -0
  46. package/dist/types/renderers/RecordCardPart.d.ts +4 -0
  47. package/dist/types/renderers/SourcesPart.d.ts +4 -0
  48. package/dist/types/renderers/TablePart.d.ts +4 -0
  49. package/dist/types/renderers/TextPart.d.ts +5 -0
  50. package/dist/types/renderers/TicketPart.d.ts +4 -0
  51. package/dist/types/renderers/VoiceClipPart.d.ts +7 -0
  52. package/dist/types/renderers/index.d.ts +32 -0
  53. package/dist/types/useAutoOpen.d.ts +11 -0
  54. package/dist/types/useChat.d.ts +34 -76
  55. package/dist/types/useChatDictation.d.ts +24 -0
  56. package/dist/types/useChatExplain.d.ts +57 -0
  57. package/dist/types/useChatHandoff.d.ts +19 -0
  58. package/dist/types/useChatReadAloud.d.ts +16 -0
  59. package/dist/types/useChatSound.d.ts +7 -0
  60. package/dist/types/useChatSpeech.d.ts +7 -0
  61. package/dist/types/useLauncherAvoid.d.ts +1 -0
  62. package/dist/types/useReducedMotion.d.ts +1 -0
  63. package/dist/types/useTranscriptActions.d.ts +12 -0
  64. package/package.json +18 -20
  65. package/README.md +0 -320
  66. package/dist/guidance.json +0 -216
  67. package/dist/types/ChatMarkdown.meta.d.ts +0 -31
  68. package/dist/types/components/ActionCard.d.ts +0 -27
  69. package/dist/types/components/ActionCard.meta.d.ts +0 -89
  70. package/dist/types/components/ChatComposer.d.ts +0 -38
  71. package/dist/types/components/ChatComposer.meta.d.ts +0 -56
  72. package/dist/types/components/ChatConversationList.d.ts +0 -20
  73. package/dist/types/components/ChatConversationList.meta.d.ts +0 -37
  74. package/dist/types/components/ChatLauncher.d.ts +0 -31
  75. package/dist/types/components/ChatLauncher.meta.d.ts +0 -50
  76. package/dist/types/components/ChatMessage.d.ts +0 -61
  77. package/dist/types/components/ChatMessage.meta.d.ts +0 -173
  78. package/dist/types/components/ChatPanel.d.ts +0 -74
  79. package/dist/types/components/ChatPanel.meta.d.ts +0 -228
  80. package/dist/types/components/ChatThread.d.ts +0 -54
  81. package/dist/types/components/ChatThread.meta.d.ts +0 -151
  82. package/dist/types/components/CitationChip.d.ts +0 -15
  83. package/dist/types/components/CitationChip.meta.d.ts +0 -48
  84. package/dist/types/components/ComposerAttachments.d.ts +0 -14
  85. package/dist/types/components/ConfirmCard.d.ts +0 -24
  86. package/dist/types/components/ConfirmCard.meta.d.ts +0 -43
  87. package/dist/types/components/ReplyRating.d.ts +0 -16
  88. package/dist/types/components/ReplyRating.meta.d.ts +0 -34
  89. package/dist/types/markdown.d.ts +0 -22
  90. /package/{LICENSE → LICENSE.txt} +0 -0
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The past chats of the empty state. It re-reads the list each time the panel opens, so a chat that
3
+ * ended while the panel was closed appears.
4
+ */
5
+ export default function ChatPastChats({ chat, labels, open }: {
6
+ chat: any;
7
+ labels: any;
8
+ open: any;
9
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The read-aloud action under one reply. It reads the Text parts only, so tables, sources and chips are not spoken.
3
+ */
4
+ export default function ChatReadAloudButton({ chat, labels, message }: {
5
+ chat: any;
6
+ labels: any;
7
+ message: any;
8
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The launcher and docked shell: the floating button, the panel it opens and the nudge. It draws
3
+ * nothing until the profile loads and while VisitorChat is off.
4
+ */
5
+ export default function ChatShell({ chat, layout, labels: labelOverrides, renderers, layoutParts, loader, motion, onOpenAttachment, onOpenTarget, onNavigate, resolveLink, linkComponent, className, style, theme, icon, look, open, defaultOpen, onOpenChange, position, offsetX, offsetY, panelId: panelIdProp, switchConfig, renderEmpty, }: {
6
+ chat: any;
7
+ className: any;
8
+ defaultOpen?: boolean | undefined;
9
+ icon?: string | undefined;
10
+ labels: any;
11
+ layout: any;
12
+ layoutParts: any;
13
+ linkComponent?: null | undefined;
14
+ loader: any;
15
+ look: any;
16
+ motion?: string | undefined;
17
+ offsetX?: number | undefined;
18
+ offsetY?: number | undefined;
19
+ onNavigate: any;
20
+ onOpenAttachment: any;
21
+ onOpenChange: any;
22
+ onOpenTarget: any;
23
+ open: any;
24
+ panelId: any;
25
+ position?: string | undefined;
26
+ renderEmpty: any;
27
+ renderers: any;
28
+ resolveLink?: null | undefined;
29
+ style: any;
30
+ switchConfig?: null | undefined;
31
+ theme: any;
32
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The empty state: the greeting, the starter questions, the resume row for the last conversation and the open tickets.
3
+ */
4
+ export default function ChatStarters({ chat, labels, onOpenTicket }: {
5
+ chat: any;
6
+ labels: any;
7
+ onOpenTicket: any;
8
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The conversation, oldest message first. It keeps the newest text in view while an answer streams.
3
+ */
4
+ export default function ChatThread({ chat, labels, renderers, layoutParts, loader, motion, onOpenAttachment, onOpenTarget, onOpenTicket, onNavigate, }: {
5
+ chat: any;
6
+ labels: any;
7
+ layoutParts: any;
8
+ loader: any;
9
+ motion: any;
10
+ onNavigate: any;
11
+ onOpenAttachment: any;
12
+ onOpenTarget: any;
13
+ onOpenTicket: any;
14
+ renderers: any;
15
+ }): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare function initialsOf(name: any): any;
2
+ export declare function ticketTone(status: any): string;
3
+ export declare function lastAgentName(messages: any): any;
4
+ export declare function liveStatusText(state: any, labels: any): any;
5
+ export declare function canOfferHandoff(state: any): any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Prints a transcript from a hidden iframe built with DOM calls only, so the host page is never printed
3
+ * and no markup is parsed from transcript text. Returns false when the frame has no document to print into.
4
+ * The printed date replaces the transcript date when the caller passes printedOn.
5
+ */
6
+ export declare function printTranscript(transcript: any, options?: {}): boolean;
@@ -0,0 +1,10 @@
1
+ export declare const webPrefs: {
2
+ get(key: any): string | null;
3
+ set(key: any, value: any): void;
4
+ };
5
+ export declare function copyText(text: any): Promise<boolean>;
6
+ export declare function openAttachmentDefault(client: any, part: any): Promise<boolean>;
7
+ export declare function openTargetDefault(target: any): void;
8
+ export declare function scrollBoxOf(node: any): any;
9
+ export declare function messageSignature(message: any): string;
10
+ export declare function motionClass(motion: any): "" | "wui-chat--reduced";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Places the transcript of a dictation in the composer box. A dictation owns one span of the box and
3
+ * overwrites it on every call, because the adapter sends the whole transcript so far.
4
+ *
5
+ * @param {object} input
6
+ * @param {string} input.value The box text.
7
+ * @param {{ start: number, end: number } | null} input.span The part of the box the running dictation owns.
8
+ * @param {number} input.selectionStart
9
+ * @param {number} input.selectionEnd
10
+ * @param {string} input.text The transcript so far.
11
+ * @param {number} input.maxLength
12
+ * @returns {{ value: string, span: { start: number, end: number }, caret: number }}
13
+ */
14
+ export declare function placeDictation({ value, span, selectionStart, selectionEnd, text, maxLength }: {
15
+ value: string;
16
+ span: {
17
+ start: number;
18
+ end: number;
19
+ } | null;
20
+ selectionStart: number;
21
+ selectionEnd: number;
22
+ text: string;
23
+ maxLength: number;
24
+ }): {
25
+ value: string;
26
+ span: {
27
+ start: number;
28
+ end: number;
29
+ };
30
+ caret: number;
31
+ };
@@ -1,14 +1,20 @@
1
- export { splitCitations } from "@webority/markdown-core";
2
- export { CHAT_CONTRACT_VERSION, ChatApiError, createChatClient, createChatSession, createConversationList, createSseParser, DEFAULT_CHAT_LABELS, mergeLabels, } from "@webority/markdown-core/chat";
3
- export { default as ActionCard } from "./components/ActionCard.jsx";
4
- export { default as ChatComposer } from "./components/ChatComposer.jsx";
5
- export { default as ChatConversationList } from "./components/ChatConversationList.jsx";
6
- export { default as ChatLauncher } from "./components/ChatLauncher.jsx";
7
- export { default as ChatMessage } from "./components/ChatMessage.jsx";
8
- export { default as ChatPanel } from "./components/ChatPanel.jsx";
9
- export { default as ChatThread } from "./components/ChatThread.jsx";
10
- export { default as CitationChip } from "./components/CitationChip.jsx";
11
- export { default as ConfirmCard } from "./components/ConfirmCard.jsx";
12
- export { default as ReplyRating } from "./components/ReplyRating.jsx";
13
- export { ChatMarkdown } from "./markdown.jsx";
14
- export { useChat } from "./useChat.js";
1
+ export { default as ChatComposer } from "./ChatComposer.jsx";
2
+ export { default as ChatConversationActions } from "./ChatConversationActions.jsx";
3
+ export { default as ChatEmbed } from "./ChatEmbed.jsx";
4
+ export { default as ChatExplain } from "./ChatExplain.jsx";
5
+ export { default as ChatFooter } from "./ChatFooter.jsx";
6
+ export { default as ChatLauncher } from "./ChatLauncher.jsx";
7
+ export { default as ChatOpenTickets } from "./ChatOpenTickets.jsx";
8
+ export { default as ChatPage } from "./ChatPage.jsx";
9
+ export { default as ChatPanel } from "./ChatPanel.jsx";
10
+ export { default as ChatPastChats } from "./ChatPastChats.jsx";
11
+ export { default as ChatReadAloudButton } from "./ChatReadAloudButton.jsx";
12
+ export { default as ChatThread } from "./ChatThread.jsx";
13
+ export { default as ChatLoader } from "./loaders/ChatLoader.jsx";
14
+ export { defaultRenderers } from "./renderers/index.js";
15
+ export { default as useChat } from "./useChat.js";
16
+ export { default as useChatDictation } from "./useChatDictation.js";
17
+ export { default as useChatExplain, formatResetTime } from "./useChatExplain.js";
18
+ export { default as useChatHandoff } from "./useChatHandoff.js";
19
+ export { default as useChatReadAloud } from "./useChatReadAloud.js";
20
+ export { default as useTranscriptActions } from "./useTranscriptActions.js";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The loader a reply shows while it is prepared. The rotation advances every intervalMs (the profile's phrase
3
+ * interval) and restarts when the style changes; under reduced motion it never advances, so the first phrase
4
+ * stays. The announce sentence is read once, 500 ms after mount.
5
+ *
6
+ * @param {object} props
7
+ * @param {"Steps" | "Phrases" | "Orb" | "Skeleton"} [props.style]
8
+ * @param {string[]} [props.steps] Server step labels of the reply in progress.
9
+ * @param {string[]} props.phrases The thinking phrases (the profile's thinking phrases).
10
+ * @param {number} props.intervalMs The rotation interval (the profile's phrase interval), in milliseconds.
11
+ * @param {string} props.announce The sentence a screen reader hears once, for example "Assistant is preparing an answer".
12
+ * @param {"On" | "Reduced"} [props.motion]
13
+ */
14
+ export default function ChatLoader({ style, steps, phrases, intervalMs, announce, motion }: {
15
+ style?: "Steps" | "Phrases" | "Orb" | "Skeleton";
16
+ steps?: string[];
17
+ phrases: string[];
18
+ intervalMs: number;
19
+ announce: string;
20
+ motion?: "On" | "Reduced";
21
+ }): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The breathing orb a reply's loader shows while the answer is prepared. Decorative; the label is the only text.
3
+ *
4
+ * @param {object} props
5
+ * @param {{ label: string }} props.view
6
+ */
7
+ export default function OrbLoader({ view }: {
8
+ view: {
9
+ label: string;
10
+ };
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A thinking word that cross-fades to the next one. The previous word stays for the cross-fade and is
3
+ * dropped at once under reduced motion.
4
+ *
5
+ * @param {object} props
6
+ * @param {{ label: string }} props.view
7
+ * @param {"On" | "Reduced"} props.motion
8
+ */
9
+ export default function PhrasesLoader({ view, motion }: {
10
+ view: {
11
+ label: string;
12
+ };
13
+ motion: "On" | "Reduced";
14
+ }): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A content-shaped placeholder for a reply that is still loading: the label, then four lines and a table block.
3
+ *
4
+ * @param {object} props
5
+ * @param {{ label: string }} props.view
6
+ */
7
+ export default function SkeletonLoader({ view }: {
8
+ view: {
9
+ label: string;
10
+ };
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The step list of a reply in progress: finished steps tick, the active one is ringed, later ones wait as dots.
3
+ *
4
+ * @param {object} props
5
+ * @param {{ steps: string[], activeIndex: number }} props.view
6
+ */
7
+ export default function StepsLoader({ view }: {
8
+ view: {
9
+ steps: string[];
10
+ activeIndex: number;
11
+ };
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The pill shown while a paced reply is held back: the mark with three dots bouncing. Under reduced motion
3
+ * the dots stay still through the loader's reduced class.
4
+ *
5
+ * @param {object} props
6
+ * @param {"On" | "Reduced"} props.motion
7
+ * @param {"Orb" | "Assistant" | "None"} props.mark "None" draws the dots alone, as a human agent's pill does.
8
+ */
9
+ export default function TypingPill({ motion, mark }: {
10
+ motion: "On" | "Reduced";
11
+ mark: "Orb" | "Assistant" | "None";
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export declare function recaptchaToken(siteKey: any, action: any): Promise<any>;
2
+ export declare function resetRecaptchaForTests(): void;
@@ -0,0 +1,4 @@
1
+ export default function ActionPart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export default function ChartPart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ export declare const ChatLinkContext: import("react").Context<{
2
+ resolveLink: null;
3
+ linkComponent: null;
4
+ }>;
5
+ export declare function useChatLinks(): {
6
+ resolveLink: null;
7
+ linkComponent: null;
8
+ };
@@ -0,0 +1,5 @@
1
+ export default function FigureText({ text, enabled }: {
2
+ enabled: any;
3
+ text: any;
4
+ }): any;
5
+ export declare function figurePlain(text: any, enabled: any): any;
@@ -0,0 +1,4 @@
1
+ export default function FiguresPart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ export default function FilePart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export default function HandoffPart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ export default function ImagePart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export default function InputRequestPart({ part, message, turn }: {
2
+ message: any;
3
+ part: any;
4
+ turn: any;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export default function NoticePart({ part }: {
2
+ part: any;
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export default function QuickRepliesPart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ export default function RecordCardPart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export default function SourcesPart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ export default function TablePart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export default function TextPart({ part, message, turn }: {
2
+ message: any;
3
+ part: any;
4
+ turn: any;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export default function TicketPart({ part, turn }: {
2
+ part: any;
3
+ turn: any;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A recorded voice message: a play control, a waveform that fills as it plays, the time and an optional transcript.
3
+ */
4
+ export default function VoiceClipPart({ part, turn }: {
5
+ part: any;
6
+ turn: any;
7
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,32 @@
1
+ import Action from "./ActionPart.jsx";
2
+ import Chart from "./ChartPart.jsx";
3
+ import Figures from "./FiguresPart.jsx";
4
+ import File from "./FilePart.jsx";
5
+ import Handoff from "./HandoffPart.jsx";
6
+ import Image from "./ImagePart.jsx";
7
+ import InputRequest from "./InputRequestPart.jsx";
8
+ import Notice from "./NoticePart.jsx";
9
+ import QuickReplies from "./QuickRepliesPart.jsx";
10
+ import RecordCard from "./RecordCardPart.jsx";
11
+ import Sources from "./SourcesPart.jsx";
12
+ import Table from "./TablePart.jsx";
13
+ import Text from "./TextPart.jsx";
14
+ import Ticket from "./TicketPart.jsx";
15
+ import VoiceClip from "./VoiceClipPart.jsx";
16
+ export declare const defaultRenderers: {
17
+ Text: typeof Text;
18
+ Sources: typeof Sources;
19
+ QuickReplies: typeof QuickReplies;
20
+ InputRequest: typeof InputRequest;
21
+ Action: typeof Action;
22
+ Notice: typeof Notice;
23
+ Table: typeof Table;
24
+ Chart: typeof Chart;
25
+ Figures: typeof Figures;
26
+ RecordCard: typeof RecordCard;
27
+ Image: typeof Image;
28
+ File: typeof File;
29
+ Ticket: typeof Ticket;
30
+ Handoff: typeof Handoff;
31
+ VoiceClip: typeof VoiceClip;
32
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Opens the panel automatically after the configured delay. The timer is cancelled on unmount.
3
+ */
4
+ export default function useAutoOpen({ enabled, settings, look, session, isOpen, panelId }: {
5
+ enabled: any;
6
+ isOpen: any;
7
+ look: any;
8
+ panelId: any;
9
+ session: any;
10
+ settings: any;
11
+ }): void;
@@ -1,80 +1,38 @@
1
- export type ChatTurnError = {
2
- code: string;
3
- /**
4
- * Written for the person.
5
- */
6
- message: string;
7
- resetsAtUtc: string | null;
8
- };
9
- export type ChatTurn = import('@webority/markdown-core/chat').ChatTurn;
10
1
  /**
11
- * @typedef {object} ChatTurnError
12
- * @property {string} code
13
- * @property {string} message Written for the person.
14
- * @property {string|null} resetsAtUtc
15
- */
16
- /** @typedef {import('@webority/markdown-core/chat').ChatTurn} ChatTurn One question and its answer. */
17
- /**
18
- * The chat's state and actions. The session lives in the component that calls it: one per client,
19
- * disposed when the client changes or the component unmounts. Call `reset()` when the signed-in
20
- * person or account changes so nothing of one person's chat shows to the next.
2
+ * The chat's state and actions. One session per client, screen, layout and narrowing, created in a mount effect
3
+ * (StrictMode runs effects twice and a disposed session never loads again) and disposed when any of them changes
4
+ * or the component unmounts. Until it exists, the state is idle and the actions do nothing.
21
5
  *
22
6
  * @param {object} options
23
- * @param {import('@webority/markdown-core/chat').ChatClient} options.client From `createChatClient`.
24
- * @param {any} [options.pageContext] Sent with each question; read at the moment of sending.
25
- * @returns {{
26
- * client: import('@webority/markdown-core/chat').ChatClient,
27
- * turns: ChatTurn[],
28
- * conversationId: string|null,
29
- * messagesLeftToday: number|null,
30
- * streaming: boolean,
31
- * loading: boolean,
32
- * loadError: ChatTurnError|null,
33
- * settings: import('@webority/markdown-core/chat').ChatSettings|null,
34
- * settingsError: ChatTurnError|null,
35
- * editing: import('@webority/markdown-core/chat').ChatEditing|null,
36
- * attachments: import('@webority/markdown-core/chat').ComposerAttachment[],
37
- * submit: (message: string) => Promise<void>,
38
- * stop: () => void,
39
- * retry: (turnId: string) => Promise<void>,
40
- * regenerate: (turnId: string) => Promise<void>,
41
- * startEdit: (turnId: string) => void,
42
- * cancelEdit: () => void,
43
- * attach: (files: import('@webority/markdown-core/chat').ChatUploadFile[]) => Promise<void>,
44
- * removeAttachment: (key: string) => Promise<void>,
45
- * openConversation: (id: string) => Promise<void>,
46
- * newConversation: () => void,
47
- * rate: (turnId: string, rating: "Up"|"Down", note?: string) => Promise<void>,
48
- * refreshAllowance: () => Promise<void>,
49
- * reset: () => void
50
- * }}
7
+ * @param {import('@webority/chat-core').ChatClient} options.client
8
+ * @param {string} [options.screen]
9
+ * @param {string} [options.layout] The surface the host draws, named in the chatOpened and chatClosed events.
10
+ * @param {Record<string, boolean>} [options.narrow]
11
+ * @param {string} [options.conversationId] Opened once after the profile loads.
12
+ * @param {() => import('@webority/chat-core').ChatBehaviour | null} [options.behaviour] Replaces the page collector.
13
+ * @param {() => import('@webority/chat-core').ChatAttribution | null} [options.attribution]
14
+ * @param {{ get(key: string): string | null, set(key: string, value: string): void }} [options.prefs]
15
+ * @param {unknown} [options.pageContext] Sent with each message; read at the moment of sending.
16
+ * @param {(action: string) => Promise<string | null> | string | null} [options.getCaptchaToken]
17
+ * @param {(name: string, data: object) => void} [options.onEvent]
18
+ * @param {(error: unknown) => void} [options.onError]
19
+ * @param {(path: string) => void} [options.onNavigate] Receives a relative link clicked in a reply.
51
20
  */
52
- export declare function useChat({ client, pageContext }: {
53
- client: import('@webority/markdown-core/chat').ChatClient;
54
- pageContext?: any;
55
- }): {
56
- client: import('@webority/markdown-core/chat').ChatClient;
57
- turns: ChatTurn[];
58
- conversationId: string | null;
59
- messagesLeftToday: number | null;
60
- streaming: boolean;
61
- loading: boolean;
62
- loadError: ChatTurnError | null;
63
- settings: import('@webority/markdown-core/chat').ChatSettings | null;
64
- settingsError: ChatTurnError | null;
65
- editing: import('@webority/markdown-core/chat').ChatEditing | null;
66
- attachments: import('@webority/markdown-core/chat').ComposerAttachment[];
67
- submit: (message: string) => Promise<void>;
68
- stop: () => void;
69
- retry: (turnId: string) => Promise<void>;
70
- regenerate: (turnId: string) => Promise<void>;
71
- startEdit: (turnId: string) => void;
72
- cancelEdit: () => void;
73
- attach: (files: import('@webority/markdown-core/chat').ChatUploadFile[]) => Promise<void>;
74
- removeAttachment: (key: string) => Promise<void>;
75
- openConversation: (id: string) => Promise<void>;
76
- newConversation: () => void;
77
- rate: (turnId: string, rating: "Up" | "Down", note?: string) => Promise<void>;
78
- refreshAllowance: () => Promise<void>;
79
- reset: () => void;
80
- };
21
+ export default function useChat(options: {
22
+ client: import('@webority/chat-core').ChatClient;
23
+ screen?: string;
24
+ layout?: string;
25
+ narrow?: Record<string, boolean>;
26
+ conversationId?: string;
27
+ behaviour?: () => import('@webority/chat-core').ChatBehaviour | null;
28
+ attribution?: () => import('@webority/chat-core').ChatAttribution | null;
29
+ prefs?: {
30
+ get(key: string): string | null;
31
+ set(key: string, value: string): void;
32
+ };
33
+ pageContext?: unknown;
34
+ getCaptchaToken?: (action: string) => Promise<string | null> | string | null;
35
+ onEvent?: (name: string, data: object) => void;
36
+ onError?: (error: unknown) => void;
37
+ onNavigate?: (path: string) => void;
38
+ }): any;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The dictation control of the composer: the microphone state, the note after a dictation that could not
3
+ * start or heard nothing, and the actions. The timing rules live in chat-core createDictation.
4
+ *
5
+ * @param {object} options
6
+ * @param {import('@webority/chat-core').ChatSpeechAdapter | null} options.speech
7
+ * @param {boolean} options.enabled
8
+ * @param {import('@webority/chat-core').ChatLabels} options.labels
9
+ * @param {(text: string, final: boolean) => void} options.onText Receives the whole transcript so far.
10
+ */
11
+ export default function useChatDictation({ speech, enabled, labels, onText }: {
12
+ speech: import('@webority/chat-core').ChatSpeechAdapter | null;
13
+ enabled: boolean;
14
+ labels: import('@webority/chat-core').ChatLabels;
15
+ onText: (text: string, final: boolean) => void;
16
+ }): {
17
+ available: boolean;
18
+ listening: boolean;
19
+ note: any;
20
+ noteKind: any;
21
+ toggle: () => any;
22
+ stop: () => any;
23
+ buttonRef: import("react").RefObject<null>;
24
+ };
@@ -0,0 +1,57 @@
1
+ export type UseChatExplainResult = {
2
+ state: import("@webority/chat-core").ChatExplainState;
3
+ /**
4
+ * Set only in the answered state.
5
+ */
6
+ answer: unknown;
7
+ /**
8
+ * True from 300 ms after the request began, and for at least 500 ms.
9
+ */
10
+ pillVisible: boolean;
11
+ /**
12
+ * Set only in the capacity state.
13
+ */
14
+ resetsDateTimeUtc: string | null;
15
+ /**
16
+ * True while the browser reports no connection.
17
+ */
18
+ offline: boolean;
19
+ /**
20
+ * Starts a request; supersedes one in flight.
21
+ */
22
+ ask: () => void;
23
+ /**
24
+ * Back to idle; drops any answer in flight.
25
+ */
26
+ reset: () => void;
27
+ };
28
+ /**
29
+ * @typedef {object} UseChatExplainResult
30
+ * @property {import("@webority/chat-core").ChatExplainState} state
31
+ * @property {unknown} answer Set only in the answered state.
32
+ * @property {boolean} pillVisible True from 300 ms after the request began, and for at least 500 ms.
33
+ * @property {string | null} resetsDateTimeUtc Set only in the capacity state.
34
+ * @property {boolean} offline True while the browser reports no connection.
35
+ * @property {() => void} ask Starts a request; supersedes one in flight.
36
+ * @property {() => void} reset Back to idle; drops any answer in flight.
37
+ */
38
+ /**
39
+ * The state of one "Why?" explanation. The timing and the state classification live in the engine
40
+ * (createExplain); this hook only subscribes to it.
41
+ *
42
+ * @param {object} options
43
+ * @param {(signal: AbortSignal) => Promise<unknown>} options.request Fetches the answer. Read through a ref, so a new function each render is free.
44
+ * @param {boolean} [options.enabled]
45
+ * @returns {UseChatExplainResult}
46
+ */
47
+ export default function useChatExplain({ request, enabled }: {
48
+ request: (signal: AbortSignal) => Promise<unknown>;
49
+ enabled?: boolean;
50
+ }): UseChatExplainResult;
51
+ /**
52
+ * The reset time of a capacity limit, in the viewer's zone and locale; empty when the value is missing or invalid.
53
+ *
54
+ * @param {string | null | undefined} iso
55
+ * @returns {string}
56
+ */
57
+ export declare function formatResetTime(iso: string | null | undefined): string;