import type { ReactNode } from "react"; import { type CitationMap, type RenderLink } from "./Markdown.js"; import type { Speaker } from "../speech.js"; import type { AlertKind } from "../markdown.js"; import { type AnswerActionsLabels } from "./AnswerActions.js"; import type { AnswerFeedback } from "../review.js"; import type { RichRenderers } from "./renderers.js"; import type { MessageAttachment } from "../conversations.js"; export type ChatSpeaker = { /** Shown above the message when more than one agent can answer. */ name: string; /** Stable id for styling (`ck-from-`), e.g. "cat" or "loki". */ id?: string; /** * An agent is a member of the conversation, not a feature of it: say so. * `"agent"` draws a small "Agent" mark beside the name, so a reader in a * room of people and agents always knows which is which. */ kind?: "agent" | "person"; /** * Whose request the agent is working on — the person who asked and who * answers for what it does ("Loki · for Georgy"). An agent's words are * never unattributed in a shared room. */ onBehalfOf?: string; }; export type ChatMessageData = { id: string; role: "user" | "assistant"; content: string; speaker?: ChatSpeaker; citations?: CitationMap; /** The turn failed: shown as a failure with Retry, never as silence. */ failed?: boolean; /** Why THIS turn failed, kept with it: `message` is shown in its bubble * (else `content`, else the `failed` label), `kind` is the product's code * for the reason (a footer can link the fix). Two failures in one chat * each keep their own words. */ failure?: ChatFailure; /** What the person sent with their words: pictures drawn small above the * bubble, other files as their name. */ attachments?: readonly MessageAttachment[]; /** The product's own things that went with the person's words (one of * their listings, a document the model reads), drawn as chips beside the * pictures and files. Kept with the message, so they survive a reload. */ chips?: readonly MessageChip[]; /** * What the person is likely to say next, as one-tap buttons under the * latest answer. Leave it out and a `quick_replies` block in `content` is * used instead (see `REPLIES_INSTRUCTION`). */ replies?: readonly string[]; /** * What the model did before answering — "Thought for 3m 38s ›" with the * steps under it, the way the ChatGPT and Claude apps show it. Closed by * default; the answer is what the reader came for. */ thinking?: Thinking; }; /** Why a turn failed, as the transport said it (see `ChatTurnError`). */ export type ChatFailure = { kind?: string; message?: string; /** * The way on, when there is one the reader can take: "Get a pass" after a * spent allowance, "Connect a model" after a picture nothing can read. * Drawn as a link beside Retry (fleet AGENTS.md, "No dead ends"). */ action?: ChatFailureAction; /** False when trying again cannot work (an allowance that resets tomorrow): no Retry button. Default true. */ retry?: boolean; }; /** A link under a failed turn. */ export type ChatFailureAction = { label: string; href: string; }; /** A product's thing on the person's message: a label, and where it opens. */ export type MessageChip = { label: string; href?: string; kind?: string; }; /** What `renderFooter` knows about the answer it is drawn under. */ export type FooterInfo = { /** The newest answer in the thread — where "what next" belongs. */ isLatest: boolean; /** The message's place in the thread, from 0. */ index: number; }; export type ThinkingStep = { label: string; detail?: string; }; export type Thinking = { /** How long it took, in milliseconds. */ durationMs?: number; /** The steps, in order: searches, tool calls, reasoning in one line each. */ steps?: readonly ThinkingStep[]; /** A short summary of the reasoning, if the model gives one. */ summary?: string; }; /** "3m 38s", "42s", "1h 02m" — the ChatGPT app's unit words, so a product * translating the labels still gets one shape. */ export declare function formatThinkingDuration(ms: number): string; export type ThreadLabels = AnswerActionsLabels & { /** "Thought for {time}" — `{time}` is replaced; without a duration, `thought`. */ thoughtFor: string; thought: string; thinking: string; working: string; stopped: string; /** Under a question nothing answered: the page closed, or the turn was cut off. */ unanswered: string; jump: string; failed: string; loading: string; replies: string; /** The mark beside an agent's name (`speaker.kind: "agent"`). */ agent?: string; /** "for {name}" — whose request an agent is working on; `{name}` is replaced. */ onBehalfOf?: string; /** The word over a `> [!CAUTION]` callout in an answer, in the product's language. */ alerts?: Partial>; }; export declare const DEFAULT_THREAD_LABELS: ThreadLabels; /** * One turn. The asymmetry is deliberate: the person's own words get a pill — * a short aside they already know — and the answer gets the full column with * no box, because it is the thing being READ. Copy is on every answer; Retry * only on the last one (retrying an older turn would fork the thread). */ export declare function ChatMessage({ message, onRetry, renderLink, showSpeaker, footer, last, onReply, speaker, share, onFeedback, renderers, labels, }: { message: ChatMessageData; /** Thumbs under the answer; the product keeps and exports what it learns. */ onFeedback?: (feedback: AnswerFeedback) => void; /** The app's drawing for chart blocks (`{ chart }`); without it, a table. */ renderers?: RichRenderers; /** The app's voice for Listen (the browser's without it). */ speaker?: Speaker | null; /** What Share hands to the system sheet. `false` hides Share. */ share?: { title?: string; url?: string; } | false; /** Send a suggested reply. Without it no reply buttons are shown. */ onReply?: (text: string) => void; /** The latest answer: its actions stay visible (they are what you want next). */ last?: boolean; onRetry?: () => void; renderLink?: RenderLink; /** Hide the name when only one agent ever speaks. */ showSpeaker?: boolean; /** Under the answer: provenance, sources, an action card. */ footer?: ReactNode; labels?: ThreadLabels; }): import("react").JSX.Element; /** * The replies under an answer. Exported for apps that render their own * thread, so the buttons look and behave the same in every product. */ export declare function ChatReplies({ replies, onPick, label, disabled, }: { replies: readonly string[]; onPick: (text: string) => void; label?: string; disabled?: boolean; }): import("react").JSX.Element | null; export type LiveTurn = { /** What has streamed in so far. */ text?: string; /** What it is doing before the first word ("Reading the fleet map"). */ status?: string; /** The steps so far, newest last; shown open while the turn runs. */ steps?: readonly ThinkingStep[]; speaker?: ChatSpeaker; }; /** * "Thought for 3m 38s ›" above an answer, opening to the steps; while a turn * runs, the same row open with the steps arriving and the newest one marked. */ export declare function ThinkingRow({ thinking, live, labels, }: { thinking: Thinking; live?: boolean; labels?: ThreadLabels; }): import("react").JSX.Element | null; /** * The conversation. Follows new tokens only while the reader is at the * bottom, with a button back down once they are not; a turn in flight can be * stopped from where it is being written. */ export declare function ChatThread({ messages, live, loading, stopped, unanswered, onStop, onRetry, onReply, renderLink, renderFooter, showSpeakers, speaker, share, onFeedback, renderers, empty, children, labels: labelOverrides, }: { messages: ChatMessageData[]; /** Thumbs under every answer (chatkit's feedback loop, README). */ onFeedback?: (feedback: AnswerFeedback) => void; /** * The app's drawing for chart blocks: `{ chart: (block) => }`. * Without it (or when it returns null) chatkit shows the caption and a * table of the data. `ChatScreen renderers` sets the same for every answer. */ renderers?: RichRenderers; /** The app's voice for Listen under every answer (the browser's without it). */ speaker?: Speaker | null; /** What Share hands to the system sheet. `false` hides Share. */ share?: { title?: string; url?: string; } | false; live?: LiveTurn | null; loading?: boolean; /** The person stopped the last turn themselves. */ stopped?: boolean; /** * The last message is the person's and nothing is answering it * (`unansweredTurn`): the thread says so and, with `onRetry`, offers to ask * again. Without this a reload mid-answer left a question with nothing * under it and no way forward. */ unanswered?: boolean; onStop?: () => void; /** Retry the last answer (offered on it, and on a failed one). */ onRetry?: () => void; /** * Send a suggested reply — usually the same function the Composer's * `onSend` calls. Buttons appear under the latest answer only, and never * while a turn is in flight. */ onReply?: (text: string) => void; renderLink?: RenderLink; /** App-specific content under an answer (sources, an action card); the * second argument says whether it is the latest answer, and where it is. */ renderFooter?: (m: ChatMessageData, info: FooterInfo) => ReactNode; /** Default: shown when more than one speaker appears in the thread. */ showSpeakers?: boolean; /** Shown instead of the thread before the first message (starters). */ empty?: ReactNode; /** After the last turn (a note, a picker). */ children?: ReactNode; labels?: Partial; }): import("react").JSX.Element; /** * A starter: the words it sends, or an object when the button says something * else (`label`) or is in another language than the page (`lang`, set on the * button, so a screen reader and the font read it right). */ export type Starter = string | { label: string; prompt?: string; text?: string; lang?: string; } | { text: string; label?: string; prompt?: string; lang?: string; }; /** What a starter shows, what it sends, and its language. */ export declare function starterParts(s: Starter): { label: string; prompt: string; lang?: string; }; /** The empty state that starts a conversation. It disappears once one has. */ export declare function ChatStarters({ starters, onPick, title, }: { starters: readonly Starter[]; onPick: (prompt: string) => void; title?: ReactNode; }): import("react").JSX.Element; //# sourceMappingURL=Thread.d.ts.map