# Chat Message

> 用稳定 Parts 组合正文、过程、状态、操作和分支，也支持已有内容 renderer。

网页来源：/components/chat-message

版本：@quirekit/ui 0.3.1；源码修订：d79a6b48d00e+worktree。此文档对应当前源码构建，接入方式以开始使用为准。

接入前置：[开始使用](/raw/components/getting-started.md)（Vue、样式、主题与图标 Provider）。

通过 `author` 命名发送者，`parts` 提供有稳定 `id` 的内容序列。`align="end"` 使用逻辑末端对齐；`variant="soft"` 为正文添加轻背景气泡，不会把过程和扩展内容也套进气泡。

消息默认居中于最大 `48rem` 的阅读列，作者、过程、正文与尾部操作有各自的层级。在共同祖先设置 `--qk-chat-content-width` 可同时调整 Message、MessageList 与 Composer 的阅读宽度。

## 消息与操作

`parts` 默认呈现正文、推理、工具、提示和自定义回退。`copyText` 开启内置复制；`actions` 配置常用与更多操作，点击只发出 `action` 请求。`branch` 提供受控的版本导航，宿主通过 `branchChange` 更新选中项。

### 示例：chat-message/content

文件：`content.vue`

```vue
<script setup lang="ts">
import { computed, onScopeDispose, ref } from 'vue';
import type { QuireKitChatActionDetails, QuireKitChatBranchChangeDetails, QuireKitChatMessagePart, QuireKitChatMessageState } from '@quirekit/ui';
import { QuireAvatar, QuireButton, QuireChatMessage, QuireCodeBlock, QuireCollapsible, QuireLocaleProvider, QuireProse } from '@quirekit/ui/vue';
const additions = ref(0); const state = ref<QuireKitChatMessageState>('complete');
const rtl = ref(false); const useful = ref(false); const selected = ref('practical'); const result = ref('');
const history = ref(false); const versions = ref(false); const authorVisible = ref(false);
const code = "const plan = { owner: '团队', state: 'review' }\nconsole.log(plan)";
const summary = '先明确目标和负责人，再补充每个阶段的验收标准。';
const steps = [
  { title: '明确范围', text: '约定要解决的问题、负责人和交付时间。' },
  { title: '拆解任务', text: '按优先级安排步骤，列出前置依赖。' },
  { title: '共同验收', text: '用具体产物检查结果，再安排下一轮。' }
];
const conclusion = '可以先用一份轻量记录保存当前计划，评审后再逐项补充：';
const copyText = computed(() => [summary, steps.map((step, index) => `${index + 1}. ${step.title}：${step.text}`).join('\n'),
  ...(selected.value === 'practical' ? [conclusion, code] : []),
  ...Array.from({ length: additions.value }, (_, index) => `补充 ${index + 1}：在评审前确认参与人员和依赖条件。`)].join('\n\n'));
const parts = computed<readonly QuireKitChatMessagePart[]>(() => [
  { id: 'reasoning', kind: 'reasoning', title: '思考过程', ...(state.value === 'streaming' ? { summary: '补充负责人和依赖条件' } : {}), meta: '3 秒', state: state.value === 'streaming' ? 'streaming' : 'complete', text: '先区分目标和实施步骤，再检查每个阶段是否有明确的负责人及可检验的产物。\n这份计划应足够轻量，方便团队在首次评审后继续细化。' },
  { id: 'lookup', kind: 'tool', title: '已检索 3 份项目资料', state: 'succeeded', input: '{ "query": "项目范围与交付标准" }', inputLanguage: 'json', output: '项目简介 · 范围与参与人\n需求记录 · 优先级与依赖\n验收清单 · 交付标准' },
  { id: 'answer', kind: 'text', text: summary },
  ...(selected.value === 'practical' ? [{ id: 'example-code', kind: 'custom' as const, name: '计划记录', fallback: code }] : []),
  ...Array.from({ length: additions.value }, (_, index) => ({ id: `addition-${index}`, kind: 'text' as const, text: `补充 ${index + 1}：在评审前确认参与人员和依赖条件。` }))
]);
const actions = computed(() => [
  { id: 'retry', label: state.value === 'error' ? '重试' : '重新生成', ...(state.value === 'error' ? {} : { icon: 'rotateCcw' }), busy: state.value === 'streaming' },
  { id: 'useful', label: '有帮助', icon: 'thumbsUp', pressed: useful.value },
  { id: 'stop', label: '停止生成', icon: 'stop', when: 'active' as const },
  { id: 'save', label: '保存为记录', icon: 'fileText', placement: 'more' as const }
]);
let timer: ReturnType<typeof setInterval> | undefined;
/** Stops the local stream without deleting received content. */
function stop(): void { clearInterval(timer); timer = undefined; state.value = 'stopped'; }
/** Makes a failed demo stream terminal until the consumer explicitly retries. */
function toggleFailure(): void { clearInterval(timer); timer = undefined; state.value = state.value === 'error' ? 'complete' : 'error'; }
/** Simulates identity-preserving updates without calling a model. */
function generate(): void {
  clearInterval(timer); state.value = 'streaming'; let chunks = 0;
  timer = setInterval(() => {
    additions.value += 1;
    if (++chunks === 3) { clearInterval(timer); timer = undefined; state.value = 'complete'; }
  }, 700);
}
/** Handles public command intents in the consumer.
 * @param details - The message action request.
 */
function act(details: QuireKitChatActionDetails): void {
  if (details.actionId === 'stop') stop();
  if (details.actionId === 'retry') {
    if (state.value === 'error') { state.value = 'complete'; result.value = '已恢复，原有内容保持不变。'; }
    else generate();
  }
  if (details.actionId === 'useful') useful.value = !useful.value;
  if (details.actionId === 'save') result.value = '已保存为本地演示记录。';
}
/** Acknowledges controlled version navigation.
 * @param details - Selected version request.
 */
function chooseBranch(details: QuireKitChatBranchChangeDetails): void { selected.value = details.branchId; }
onScopeDispose(() => clearInterval(timer));
</script>

<template>
  <div class="grid min-w-0 gap-qk-group p-qk-surface" :dir="rtl ? 'rtl' : 'ltr'" data-chat-message>
    <QuireLocaleProvider :locale="rtl ? 'ar' : 'zh-CN'">
    <QuireChatMessage message-id="request" author="你" align="end" variant="soft" :show-header="false"
      :parts="[{ id: 'question', kind: 'text', text: '帮我整理一份简短的项目计划，让团队可以直接开始行动。' }]" />
    <QuireChatMessage message-id="plan-answer" author="项目助手" meta="21:35" :parts="parts" :state="state" :show-header="authorVisible" :latest="!history"
      :copy-text="copyText" :actions="actions" :branch="{ ids: versions ? ['brief', 'practical'] : ['practical'], selectedId: selected }" @action="act" @branch-change="chooseBranch">
      <template #avatar><QuireAvatar name="项目助手" fallback="助" size="xs" shape="square" /></template>
      <template #text="{ part }">
        <QuireProse v-if="part.id === 'answer'" dir="auto">
          <p>{{ summary }}</p>
          <ol>
            <li v-for="step in steps" :key="step.title"><strong>{{ step.title }}</strong>：{{ step.text }}</li>
          </ol>
          <p v-if="selected === 'practical'">{{ conclusion }}</p>
        </QuireProse>
        <QuireProse v-else dir="auto"><p>{{ part.text }}</p></QuireProse>
      </template>
      <template #custom="{ part }"><QuireCodeBlock v-if="part.id === 'example-code'" :code="code" language="typescript" filename="计划记录" collapsible :default-collapsed="false" dir="ltr" /></template>
    </QuireChatMessage>
    </QuireLocaleProvider>
    <p v-if="result" class="m-0 text-qk-helper text-qk-text-secondary" role="status">{{ result }}</p>
    <QuireCollapsible title="交互演示设置" class="w-full mx-auto max-w-3xl">
      <div class="flex flex-wrap gap-qk-inline">
        <QuireButton variant="outline" @click="rtl = !rtl">{{ rtl ? '从左向右' : '从右向左' }}</QuireButton>
        <QuireButton variant="outline" @click="history = !history">{{ history ? '设为最新回复' : '设为历史回复' }}</QuireButton>
        <QuireButton variant="outline" @click="versions = !versions; selected = 'practical'">{{ versions ? '隐藏版本导航' : '显示版本导航' }}</QuireButton>
        <QuireButton variant="outline" @click="authorVisible = !authorVisible">{{ authorVisible ? '隐藏作者行' : '显示作者行' }}</QuireButton>
        <QuireButton variant="outline" @click="additions++">追加正文</QuireButton>
        <QuireButton variant="outline" @click="toggleFailure">{{ state === 'error' ? '恢复回复' : '模拟中断' }}</QuireButton>
        <QuireButton v-if="state !== 'streaming'" variant="outline" @click="generate">开始生成</QuireButton>
      </div>
    </QuireCollapsible>
  </div>
</template>
```

`state` 支持 pending / streaming / complete / stopped / error，`statusText` 可补充原因。停止或报错不删除已有内容。默认不重复显示作者行；多人场景可开启 `showHeader`。`meta` 显示尾部时间等次要信息。
pending / streaming 的短状态文字使用公共 [Shimmer](/raw/components/shimmer.md)，终态保持静态；系统减少动效时不扫光。无正文的等待消息也可以直接呈现状态。

消息操作的 `when` 默认为 `settled`，生成时隐藏复制和完成态命令；停止使用 `active`，必要恢复与确认使用 `always`。`actionsVisibility="auto"` 配合 `latest`：最新消息的操作和时间作为一组低强调常驻，历史消息的整组 footer 在桌面 hover/focus 时显示，触屏保持入口。`always` / `hover` 可显式覆盖，必要动作不受隐藏策略影响。独立 Message 默认按最新消息展示；放入 [Message List](/raw/components/chat-message-list.md) 时，列表只按顺序标记最后一条消息，不根据是否有操作跳过尾部用户消息。

## 内容与交互状态

`text`、`reasoning`、`tool-input`、`tool-output` 和 `custom` slots 只替换对应内容，保留 Part 的状态与交互。正文可直接使用 [Prose](/raw/components/prose.md) 和 [CodeBlock](/raw/components/code-block.md)，组件不解析 Markdown。独立 Part 用法见 [Chat Message Part](/raw/components/chat-message-part.md)。

仍可用默认 slot 接管整段内容；此时 `parts` 不重复渲染。`avatar`、`header`、`status` 和 `actions` slots 用于高级覆盖；`actions({ latest, visibility })` 会替换内置操作组，宿主应将这两个参数传给自定义操作组并自行保持 hover/焦点/触屏可达性。

保持 `messageId` 与 Part 的 `id` 稳定，内容追加和终态变化不会重建已有实例。切换消息或版本会清理内容的局部状态；分支导航自身保持。组件不逐 token 播报正文。

界面文案与排版方向跟随 [Locale Provider](/raw/components/locale-provider.md)。正文 renderer 可以使用 `dir="auto"`，代码保持 `dir="ltr"`。

## 独立组件组合

已有内容模型可以直接组合 [Reasoning](/raw/components/chat-reasoning.md)、[Tool](/raw/components/chat-tool.md) 和 [Process](/raw/components/chat-process.md)。[Actions](/raw/components/chat-message-actions.md)、[Action](/raw/components/chat-message-action.md) 和 [Branch](/raw/components/chat-message-branch.md) 也可独立使用，无需重写这些交互。

### 示例：chat-message/composition

文件：`composition.vue`

```vue
<script setup lang="ts">
import { QuireChatMessage, QuireChatProcess, QuireChatTool, QuireProse } from '@quirekit/ui/vue';
</script>
<template>
  <div class="p-qk-surface" data-message-composition>
    <QuireChatMessage message-id="composed-review" author="项目助手" meta="18:05" copy-text="两项检查已完成，可以安排团队评审。">
      <QuireChatProcess process-id="review-process" title="已完成 2 项检查" meta="6 秒">
        <QuireChatTool :part="{ id: 'scope', kind: 'tool', title: '检查项目范围', state: 'succeeded', output: '范围和目标已明确。' }" />
        <QuireChatTool :part="{ id: 'criteria', kind: 'tool', title: '检查验收条件', state: 'succeeded', output: '交付物和负责人已明确。' }" />
      </QuireChatProcess>
      <QuireProse><p>两项检查已完成，可以安排团队评审。</p></QuireProse>
    </QuireChatMessage>
  </div>
</template>
```

## API

### QuireChatMessage

#### Props

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| author | 是 | — | 可见发送者名称，也是 article 的辅助名称。 |
| messageId | 否 | — | 稳定消息身份；数据消费建议提供，改变时清理内部 Part/复制状态。 |
| align | 否 | "start" | 逻辑起始/结束位置，随 RTL 方向变化。 |
| variant | 否 | "plain" | plain 用于正文；soft 为短消息提供轻背景。 |
| showHeader | 否 | false | 是否显示作者行，默认 false；隐藏时仍保留 article 的辅助名称。 |
| meta | 否 | — | 宿主格式化的尾部时间或次要说明。 |
| parts | 否 | — | 有序稳定 Part；default slot 存在时由该 slot 接管内容。 |
| state | 否 | "complete" | 整条消息的展示状态，不从 Part 状态推断。 |
| statusText | 否 | — | 覆盖当前状态的可读说明，error 时可解释恢复方式。 |
| copyText | 否 | — | 权威复制原文；省略时不显示内置复制，不从 DOM 提取。 |
| actions | 否 | — | 消息级操作；组件只发 intent，执行由宿主负责。 |
| branch | 否 | — | 受控分支；数量不足二时不渲染导航。 |
| actionsVisibility | 否 | "auto" | auto 默认：最新消息的操作与时间常驻，历史 footer 在桌面 hover/focus 时显示；触屏常驻。 |
| latest | 否 | true | 是否为最新消息，默认 true；由消费者投影，不扫描会话。 |

**author**

```ts
string
```

**messageId**

```ts
string | undefined
```

```ts
undefined | string
```

**align**

```ts
"start" | "end" | undefined
```

```ts
undefined | "start" | "end"
```

**variant**

```ts
"soft" | "plain" | undefined
```

```ts
undefined | "soft" | "plain"
```

**showHeader**

```ts
boolean | undefined
```

**meta**

```ts
string | undefined
```

```ts
undefined | string
```

**parts**

```ts
readonly QuireKitChatMessagePart[] | undefined
```

```ts
undefined | readonly ({
  /** 正文判别项。 */
  kind: "text";
  /** 原始内容，默认安全转义并保留换行。 */
  text: string;
  /** plain 为默认值；markdown 无 renderer 时显示带说明的源文本。 */
  format?: undefined | "plain" | "markdown";
  /** 内容接收状态，默认 complete。 */
  state?: undefined | "error" | "complete" | "streaming" | "stopped";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: undefined | readonly ({
    /** 在所属操作组内稳定且唯一的标识。 */
    id: string;
    /** 可见名称或图标操作的辅助名称。 */
    label: string;
    /** IconProvider 中的图标名；省略时显示文字按钮。 */
    icon?: undefined | string;
    /** 明确不可执行时禁用。 */
    disabled?: boolean | undefined;
    /** 宿主正在处理此操作；阻止重复触发。 */
    busy?: boolean | undefined;
    /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
    pressed?: boolean | undefined;
    /** 需要危险语义的操作。 */
    danger?: boolean | undefined;
    /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
    placement?: undefined | "inline" | "more";
    /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
    when?: undefined | "settled" | "active" | "always";
  })[];
} | {
  /** 推理判别项。 */
  kind: "reasoning";
  /** 标题；省略时使用语言包中的默认标题。 */
  title?: string | undefined;
  /** 可选单行摘要，不由 UI 猜测或定时生成。 */
  summary?: string | undefined;
  /** 宿主提供的耗时等次要文案。 */
  meta?: string | undefined;
  /** 完整推理文本。 */
  text: string;
  /** 推理状态，默认 complete；不会改变用户的展开选择。 */
  state?: QuireKitChatPartState | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** 工具判别项。 */
  kind: "tool";
  /** 可读工具名称。 */
  title: string;
  /** 公共 Icon 名称，默认 terminal；由宿主表达读取、编辑、图片等工具类别。 */
  icon?: string | undefined;
  /** 一行任务摘要。 */
  summary?: string | undefined;
  /** 耗时等由宿主提供的元信息。 */
  meta?: string | undefined;
  /** 权威展示状态，不能根据 output 是否存在猜测。 */
  state: "failed" | "queued" | "running" | "waiting" | "succeeded" | "cancelled" | "interrupted";
  /** 自定义状态文案，例如具体等待原因。 */
  stateLabel?: string | undefined;
  /** 可选原始输入文本。 */
  input?: string | undefined;
  /** 可选原始输出文本。 */
  output?: string | undefined;
  /** 输入代码语言标签，默认 text。 */
  inputLanguage?: string | undefined;
  /** 输出代码语言标签，默认 text。 */
  outputLanguage?: string | undefined;
  /** 可读错误说明；不替换已有输出。 */
  error?: string | undefined;
  /** 仅提供部分输出时必须传入的截断说明；默认禁止复制不完整输出。 */
  outputTruncated?: string | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** 提示判别项。 */
  kind: "notice";
  /** 可见标题。 */
  title: string;
  /** 补充说明。 */
  description?: string | undefined;
  /** 语义色，默认 neutral；不会隐式改变整条消息状态。 */
  color?: undefined | "primary" | "neutral" | "info" | "success" | "warning" | "danger";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** 扩展判别项，未知业务类型应显式投影到这里。 */
  kind: "custom";
  /** 扩展内容的可读名称。 */
  name: string;
  /** 无 renderer 时显示的安全回退文本，不自动转储 data。 */
  fallback: string;
  /** 不透明业务数据，仅转交自定义 slot。 */
  data?: unknown;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** 附件判别项；一个 Part 可展示一组相关附件。 */
  kind: "attachment";
  /** 公共附件投影，保留每个附件的稳定身份。 */
  items: readonly ({
    /** 集合内唯一、跨更新稳定的身份；不使用索引或资源地址。 */
    id: string;
    /** 可读文件名。 */
    name: string;
    /** MIME 类型；图片类型可启用缩略图和预览。 */
    mediaType?: string | undefined;
    /** 字节数；省略或无效时不显示大小。 */
    size?: undefined | number;
    /** 可选来源元数据，不改变 URL 所有权。 */
    source?: undefined | "local" | "remote";
    /** 宿主持有的资源地址；公共 UI 不创建或释放它。 */
    url?: string | undefined;
    /** 独立缩略图地址；省略时图片使用 url。 */
    thumbnailUrl?: string | undefined;
    /** 图片说明，省略时使用 name。 */
    alt?: string | undefined;
    /** 展示状态，默认 ready。 */
    state?: undefined | "failed" | "ready" | "uploading" | "unavailable";
    /** 上传百分比；有限数钳制至 0–100，无效或省略时为未知进度。 */
    progress?: number | undefined;
    /** 宿主补充的状态说明，例如失败原因。 */
    statusText?: string | undefined;
    /** 明确允许的操作，默认不显示任何业务操作；UI 再按 state 过滤。 */
    actions?: undefined | readonly ("open" | "download" | "retry" | "remove")[];
  })[];
  /** 默认 list；图片集合可使用 grid，紧凑上下文可用 inline。 */
  layout?: undefined | "inline" | "list" | "grid" | "strip";
  /** 集合辅助名称。 */
  label?: string | undefined;
  /** 是否允许图片预览，默认 true。 */
  preview?: boolean | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** Source list discriminator. */
  kind: "sources";
  /** Ordered source projections; retrieval and access control stay with the host. */
  sources: readonly ({
    /** Stable identity supplied by the host; it is not an array position. */
    id: string;
    /** Human-readable document or page title. */
    title: string;
    /** Optional origin, such as a host name or document collection. */
    label?: string | undefined;
    /** Short context shown in the expanded list and citation preview. */
    description?: string | undefined;
    /** Optional exact excerpt; never inferred from the answer text. */
    quote?: string | undefined;
    /** A host-owned address included in the intent, never opened by the component. */
    href?: string | undefined;
    /** Missing or inaccessible resources remain visible but cannot request navigation. */
    unavailable?: boolean | undefined;
  })[];
  /** Optional disclosure title. */
  title?: string | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** Approval Part discriminator. */
  kind: "confirmation";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
  /** Stable request identity, distinct from message or tool identity. */
  requestId: string;
  /** Action the user is being asked to authorize. */
  title: string;
  /** Concise scope or consequence of the action. */
  description?: string | undefined;
  /** Host-owned state; clicks never imply approval. */
  state: "pending" | "submitting" | "approved" | "rejected" | "expired" | "failed";
  /** Failure reason, retained while the same request can be retried. */
  error?: string | undefined;
  /** Wording of the decision; defaults to `permission`. */
  intent?: undefined | "permission" | "review";
} | {
  /** Question Part discriminator. */
  kind: "question";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
  /** Stable request identity; a change resets only the component's uncontrolled draft. */
  requestId: string;
  /** Request title. */
  title: string;
  /** Optional introductory text. */
  description?: string | undefined;
  /** Ordered, stable questions. */
  questions: readonly ({
    /** Stable identity within the request. */
    id: string;
    /** Visible and accessible prompt. */
    title: string;
    /** Supporting explanation. */
    description?: string | undefined;
    /** Input type. */
    kind: "text" | "single" | "multiple";
    /** Predefined choices for single/multiple questions; unused for text. */
    options?: undefined | readonly ({
      /** Stable option value. */
      value: string;
      /** Visible option text. */
      label: string;
      /** Optional detail below the label. */
      description?: string | undefined;
      /** Whether this option cannot be selected. */
      disabled?: boolean | undefined;
    })[];
    /** Optional free-text choice for single/multiple questions; its value must not occur in options. */
    customOption?: undefined | {
      /** Stable value distinct from every predefined option value in this question. */
      value: string;
      /** Visible choice label, such as “其他”. */
      label: string;
      /** Prompt shown only while this choice is selected; the language pack supplies the default. */
      placeholder?: string | undefined;
    };
    /** Whether a response is required; defaults to true. */
    required?: boolean | undefined;
    /** Text input placeholder. */
    placeholder?: string | undefined;
  })[];
  /** Host-owned lifecycle. */
  state: "pending" | "submitting" | "expired" | "failed" | "answered";
  /** Render answer controls or a compact transcript prompt; defaults to form. */
  presentation?: undefined | "form" | "prompt";
  /** Controlled answer draft, independent of the ordinary Composer draft. */
  draft?: undefined | readonly ({
    /** Question identity. */
    questionId: string;
    /** Single/text answers use a string, multiple answers use an ordered array. */
    value: string | readonly (string)[];
    /** Text belonging to the selected custom option; omitted from a submitted answer when not selected. */
    custom?: string | undefined;
  })[];
  /** Initial uncontrolled answer draft. */
  defaultDraft?: readonly QuireKitChatQuestionAnswer[] | undefined;
  /** Confirmed answers shown in the answered state. */
  answers?: readonly QuireKitChatQuestionAnswer[] | undefined;
  /** Submission error, shown without clearing the draft. */
  error?: string | undefined;
})[]
```

**state**

```ts
QuireKitChatMessageState | undefined
```

```ts
undefined | "error" | "pending" | "complete" | "streaming" | "stopped"
```

**statusText**

```ts
string | undefined
```

```ts
undefined | string
```

**copyText**

```ts
string | undefined
```

```ts
undefined | string
```

**actions**

```ts
readonly QuireKitChatAction[] | undefined
```

```ts
undefined | readonly ({
  /** 在所属操作组内稳定且唯一的标识。 */
  id: string;
  /** 可见名称或图标操作的辅助名称。 */
  label: string;
  /** IconProvider 中的图标名；省略时显示文字按钮。 */
  icon?: undefined | string;
  /** 明确不可执行时禁用。 */
  disabled?: boolean | undefined;
  /** 宿主正在处理此操作；阻止重复触发。 */
  busy?: boolean | undefined;
  /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
  pressed?: boolean | undefined;
  /** 需要危险语义的操作。 */
  danger?: boolean | undefined;
  /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
  placement?: undefined | "inline" | "more";
  /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
  when?: undefined | "settled" | "active" | "always";
})[]
```

**branch**

```ts
QuireKitChatMessageBranch | undefined
```

```ts
undefined | {
  /** 有序、唯一、非空的分支身份。 */
  ids: readonly (string)[];
  /** 由宿主确认的当前分支。 */
  selectedId: string;
}
```

**actionsVisibility**

```ts
"always" | "auto" | "hover" | undefined
```

```ts
undefined | "always" | "auto" | "hover"
```

**latest**

```ts
boolean | undefined
```

#### Events

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| action | 否 | — |  |
| copy | 否 | — |  |
| copyError | 否 | — |  |
| attachmentAction | 否 | — |  |
| sourceNavigate | 否 | — |  |
| confirmationDecision | 否 | — |  |
| questionDraftChange | 否 | — |  |
| questionOpen | 否 | — |  |
| questionSubmit | 否 | — |  |
| branchChange | 否 | — |  |

**action**

```ts
[details: QuireKitChatActionDetails]
```

**copy**

```ts
[]
```

**copyError**

```ts
[details: QuireKitClipboardErrorDetails]
```

**attachmentAction**

```ts
[details: QuireKitChatAttachmentActionDetails]
```

**sourceNavigate**

```ts
[details: QuireKitChatSourceNavigateDetails]
```

**confirmationDecision**

```ts
[details: QuireKitChatConfirmationDecisionDetails]
```

**questionDraftChange**

```ts
[details: QuireKitChatQuestionDraftDetails]
```

**questionOpen**

```ts
[details: QuireKitChatQuestionOpenPartDetails]
```

**questionSubmit**

```ts
[details: QuireKitChatQuestionSubmitPartDetails]
```

**branchChange**

```ts
[details: QuireKitChatBranchChangeDetails]
```

#### Slots

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| avatar | 否 | — | 发送者头像或标记。 |
| header | 否 | — | 替换发送者标题，例如加入时间。 |
| default | 否 | — | 正文、Prose、代码或业务 part；宿主提供稳定 key。 |
| status | 否 | — | 可读的生成、失败或停止状态。 |
| actions | 否 | — | 复制、重试、反馈等宿主操作；替换内置组时可沿用解析后的展示策略。 |
| text | 否 | — | 正文/Markdown renderer。 |
| reasoning | 否 | — | 推理详情 renderer；展开行为仍由 Part 持有。 |
| tool-input | 否 | — | 工具参数 renderer。 |
| tool-output | 否 | — | 工具输出 renderer，包括业务预览或审批组合。 |
| custom | 否 | — | 扩展内容 renderer，不存在时保留可读回退。 |

**avatar**

```ts
any
```

**header**

```ts
any
```

**default**

```ts
any
```

**status**

```ts
any
```

**actions**

```ts
QuireKitChatMessageActionsSlotContext
```

```ts
{
  /** 是否为最新消息。 */
  latest: boolean;
  /** 操作组的展示模式。 */
  visibility: "always" | "auto" | "hover";
}
```

**text**

```ts
{ part: QuireKitChatTextPart; }
```

```ts
{
  part: {
    /** 正文判别项。 */
    kind: "text";
    /** 原始内容，默认安全转义并保留换行。 */
    text: string;
    /** plain 为默认值；markdown 无 renderer 时显示带说明的源文本。 */
    format?: undefined | "plain" | "markdown";
    /** 内容接收状态，默认 complete。 */
    state?: undefined | "error" | "complete" | "streaming" | "stopped";
    /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
    id: string;
    /** 可选的局部操作。 */
    actions?: undefined | readonly ({
      /** 在所属操作组内稳定且唯一的标识。 */
      id: string;
      /** 可见名称或图标操作的辅助名称。 */
      label: string;
      /** IconProvider 中的图标名；省略时显示文字按钮。 */
      icon?: string | undefined;
      /** 明确不可执行时禁用。 */
      disabled?: boolean | undefined;
      /** 宿主正在处理此操作；阻止重复触发。 */
      busy?: boolean | undefined;
      /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
      pressed?: boolean | undefined;
      /** 需要危险语义的操作。 */
      danger?: boolean | undefined;
      /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
      placement?: "inline" | "more" | undefined;
      /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
      when?: "settled" | "active" | "always" | undefined;
    })[];
  };
}
```

**reasoning**

```ts
{ part: QuireKitChatReasoningPart; }
```

```ts
{
  part: {
    /** 推理判别项。 */
    kind: "reasoning";
    /** 标题；省略时使用语言包中的默认标题。 */
    title?: undefined | string;
    /** 可选单行摘要，不由 UI 猜测或定时生成。 */
    summary?: string | undefined;
    /** 宿主提供的耗时等次要文案。 */
    meta?: string | undefined;
    /** 完整推理文本。 */
    text: string;
    /** 推理状态，默认 complete；不会改变用户的展开选择。 */
    state?: undefined | "error" | "complete" | "streaming" | "stopped";
    /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
    id: string;
    /** 可选的局部操作。 */
    actions?: undefined | readonly ({
      /** 在所属操作组内稳定且唯一的标识。 */
      id: string;
      /** 可见名称或图标操作的辅助名称。 */
      label: string;
      /** IconProvider 中的图标名；省略时显示文字按钮。 */
      icon?: string | undefined;
      /** 明确不可执行时禁用。 */
      disabled?: boolean | undefined;
      /** 宿主正在处理此操作；阻止重复触发。 */
      busy?: boolean | undefined;
      /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
      pressed?: boolean | undefined;
      /** 需要危险语义的操作。 */
      danger?: boolean | undefined;
      /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
      placement?: "inline" | "more" | undefined;
      /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
      when?: "settled" | "active" | "always" | undefined;
    })[];
  };
}
```

**tool-input**

```ts
{ part: QuireKitChatToolPart; }
```

```ts
{
  part: {
    /** 工具判别项。 */
    kind: "tool";
    /** 可读工具名称。 */
    title: string;
    /** 公共 Icon 名称，默认 terminal；由宿主表达读取、编辑、图片等工具类别。 */
    icon?: undefined | string;
    /** 一行任务摘要。 */
    summary?: string | undefined;
    /** 耗时等由宿主提供的元信息。 */
    meta?: string | undefined;
    /** 权威展示状态，不能根据 output 是否存在猜测。 */
    state: "failed" | "queued" | "running" | "waiting" | "succeeded" | "cancelled" | "interrupted";
    /** 自定义状态文案，例如具体等待原因。 */
    stateLabel?: string | undefined;
    /** 可选原始输入文本。 */
    input?: string | undefined;
    /** 可选原始输出文本。 */
    output?: string | undefined;
    /** 输入代码语言标签，默认 text。 */
    inputLanguage?: string | undefined;
    /** 输出代码语言标签，默认 text。 */
    outputLanguage?: string | undefined;
    /** 可读错误说明；不替换已有输出。 */
    error?: string | undefined;
    /** 仅提供部分输出时必须传入的截断说明；默认禁止复制不完整输出。 */
    outputTruncated?: string | undefined;
    /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
    id: string;
    /** 可选的局部操作。 */
    actions?: undefined | readonly ({
      /** 在所属操作组内稳定且唯一的标识。 */
      id: string;
      /** 可见名称或图标操作的辅助名称。 */
      label: string;
      /** IconProvider 中的图标名；省略时显示文字按钮。 */
      icon?: string | undefined;
      /** 明确不可执行时禁用。 */
      disabled?: boolean | undefined;
      /** 宿主正在处理此操作；阻止重复触发。 */
      busy?: boolean | undefined;
      /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
      pressed?: boolean | undefined;
      /** 需要危险语义的操作。 */
      danger?: boolean | undefined;
      /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
      placement?: "inline" | "more" | undefined;
      /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
      when?: "settled" | "active" | "always" | undefined;
    })[];
  };
}
```

**tool-output**

```ts
{ part: QuireKitChatToolPart; }
```

```ts
{
  part: {
    /** 工具判别项。 */
    kind: "tool";
    /** 可读工具名称。 */
    title: string;
    /** 公共 Icon 名称，默认 terminal；由宿主表达读取、编辑、图片等工具类别。 */
    icon?: undefined | string;
    /** 一行任务摘要。 */
    summary?: string | undefined;
    /** 耗时等由宿主提供的元信息。 */
    meta?: string | undefined;
    /** 权威展示状态，不能根据 output 是否存在猜测。 */
    state: "failed" | "queued" | "running" | "waiting" | "succeeded" | "cancelled" | "interrupted";
    /** 自定义状态文案，例如具体等待原因。 */
    stateLabel?: string | undefined;
    /** 可选原始输入文本。 */
    input?: string | undefined;
    /** 可选原始输出文本。 */
    output?: string | undefined;
    /** 输入代码语言标签，默认 text。 */
    inputLanguage?: string | undefined;
    /** 输出代码语言标签，默认 text。 */
    outputLanguage?: string | undefined;
    /** 可读错误说明；不替换已有输出。 */
    error?: string | undefined;
    /** 仅提供部分输出时必须传入的截断说明；默认禁止复制不完整输出。 */
    outputTruncated?: string | undefined;
    /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
    id: string;
    /** 可选的局部操作。 */
    actions?: undefined | readonly ({
      /** 在所属操作组内稳定且唯一的标识。 */
      id: string;
      /** 可见名称或图标操作的辅助名称。 */
      label: string;
      /** IconProvider 中的图标名；省略时显示文字按钮。 */
      icon?: string | undefined;
      /** 明确不可执行时禁用。 */
      disabled?: boolean | undefined;
      /** 宿主正在处理此操作；阻止重复触发。 */
      busy?: boolean | undefined;
      /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
      pressed?: boolean | undefined;
      /** 需要危险语义的操作。 */
      danger?: boolean | undefined;
      /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
      placement?: "inline" | "more" | undefined;
      /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
      when?: "settled" | "active" | "always" | undefined;
    })[];
  };
}
```

**custom**

```ts
{ part: QuireKitChatCustomPart; }
```

```ts
{
  part: {
    /** 扩展判别项，未知业务类型应显式投影到这里。 */
    kind: "custom";
    /** 扩展内容的可读名称。 */
    name: string;
    /** 无 renderer 时显示的安全回退文本，不自动转储 data。 */
    fallback: string;
    /** 不透明业务数据，仅转交自定义 slot。 */
    data?: unknown;
    /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
    id: string;
    /** 可选的局部操作。 */
    actions?: undefined | readonly ({
      /** 在所属操作组内稳定且唯一的标识。 */
      id: string;
      /** 可见名称或图标操作的辅助名称。 */
      label: string;
      /** IconProvider 中的图标名；省略时显示文字按钮。 */
      icon?: string | undefined;
      /** 明确不可执行时禁用。 */
      disabled?: boolean | undefined;
      /** 宿主正在处理此操作；阻止重复触发。 */
      busy?: boolean | undefined;
      /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
      pressed?: boolean | undefined;
      /** 需要危险语义的操作。 */
      danger?: boolean | undefined;
      /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
      placement?: "inline" | "more" | undefined;
      /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
      when?: "settled" | "active" | "always" | undefined;
    })[];
  };
}
```

#### 公开实例成员

无。

#### 相关类型

```ts
type QuireKitChatMessagePart = {
  /** 正文判别项。 */
  kind: "text";
  /** 原始内容，默认安全转义并保留换行。 */
  text: string;
  /** plain 为默认值；markdown 无 renderer 时显示带说明的源文本。 */
  format?: undefined | "plain" | "markdown";
  /** 内容接收状态，默认 complete。 */
  state?: undefined | "error" | "complete" | "streaming" | "stopped";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: undefined | readonly ({
    /** 在所属操作组内稳定且唯一的标识。 */
    id: string;
    /** 可见名称或图标操作的辅助名称。 */
    label: string;
    /** IconProvider 中的图标名；省略时显示文字按钮。 */
    icon?: string | undefined;
    /** 明确不可执行时禁用。 */
    disabled?: boolean | undefined;
    /** 宿主正在处理此操作；阻止重复触发。 */
    busy?: boolean | undefined;
    /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
    pressed?: boolean | undefined;
    /** 需要危险语义的操作。 */
    danger?: boolean | undefined;
    /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
    placement?: "inline" | "more" | undefined;
    /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
    when?: "settled" | "active" | "always" | undefined;
  })[];
} | {
  /** 推理判别项。 */
  kind: "reasoning";
  /** 标题；省略时使用语言包中的默认标题。 */
  title?: string | undefined;
  /** 可选单行摘要，不由 UI 猜测或定时生成。 */
  summary?: string | undefined;
  /** 宿主提供的耗时等次要文案。 */
  meta?: string | undefined;
  /** 完整推理文本。 */
  text: string;
  /** 推理状态，默认 complete；不会改变用户的展开选择。 */
  state?: QuireKitChatPartState | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** 工具判别项。 */
  kind: "tool";
  /** 可读工具名称。 */
  title: string;
  /** 公共 Icon 名称，默认 terminal；由宿主表达读取、编辑、图片等工具类别。 */
  icon?: string | undefined;
  /** 一行任务摘要。 */
  summary?: string | undefined;
  /** 耗时等由宿主提供的元信息。 */
  meta?: string | undefined;
  /** 权威展示状态，不能根据 output 是否存在猜测。 */
  state: "failed" | "queued" | "running" | "waiting" | "succeeded" | "cancelled" | "interrupted";
  /** 自定义状态文案，例如具体等待原因。 */
  stateLabel?: string | undefined;
  /** 可选原始输入文本。 */
  input?: string | undefined;
  /** 可选原始输出文本。 */
  output?: string | undefined;
  /** 输入代码语言标签，默认 text。 */
  inputLanguage?: string | undefined;
  /** 输出代码语言标签，默认 text。 */
  outputLanguage?: string | undefined;
  /** 可读错误说明；不替换已有输出。 */
  error?: string | undefined;
  /** 仅提供部分输出时必须传入的截断说明；默认禁止复制不完整输出。 */
  outputTruncated?: string | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** 提示判别项。 */
  kind: "notice";
  /** 可见标题。 */
  title: string;
  /** 补充说明。 */
  description?: string | undefined;
  /** 语义色，默认 neutral；不会隐式改变整条消息状态。 */
  color?: undefined | "primary" | "neutral" | "info" | "success" | "warning" | "danger";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** 扩展判别项，未知业务类型应显式投影到这里。 */
  kind: "custom";
  /** 扩展内容的可读名称。 */
  name: string;
  /** 无 renderer 时显示的安全回退文本，不自动转储 data。 */
  fallback: string;
  /** 不透明业务数据，仅转交自定义 slot。 */
  data?: unknown;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** 附件判别项；一个 Part 可展示一组相关附件。 */
  kind: "attachment";
  /** 公共附件投影，保留每个附件的稳定身份。 */
  items: readonly ({
    /** 集合内唯一、跨更新稳定的身份；不使用索引或资源地址。 */
    id: string;
    /** 可读文件名。 */
    name: string;
    /** MIME 类型；图片类型可启用缩略图和预览。 */
    mediaType?: string | undefined;
    /** 字节数；省略或无效时不显示大小。 */
    size?: number | undefined;
    /** 可选来源元数据，不改变 URL 所有权。 */
    source?: "local" | "remote" | undefined;
    /** 宿主持有的资源地址；公共 UI 不创建或释放它。 */
    url?: string | undefined;
    /** 独立缩略图地址；省略时图片使用 url。 */
    thumbnailUrl?: string | undefined;
    /** 图片说明，省略时使用 name。 */
    alt?: string | undefined;
    /** 展示状态，默认 ready。 */
    state?: QuireKitAttachmentState | undefined;
    /** 上传百分比；有限数钳制至 0–100，无效或省略时为未知进度。 */
    progress?: number | undefined;
    /** 宿主补充的状态说明，例如失败原因。 */
    statusText?: string | undefined;
    /** 明确允许的操作，默认不显示任何业务操作；UI 再按 state 过滤。 */
    actions?: readonly QuireKitAttachmentAction[] | undefined;
  })[];
  /** 默认 list；图片集合可使用 grid，紧凑上下文可用 inline。 */
  layout?: undefined | "inline" | "list" | "grid" | "strip";
  /** 集合辅助名称。 */
  label?: string | undefined;
  /** 是否允许图片预览，默认 true。 */
  preview?: boolean | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** Source list discriminator. */
  kind: "sources";
  /** Ordered source projections; retrieval and access control stay with the host. */
  sources: readonly ({
    /** Stable identity supplied by the host; it is not an array position. */
    id: string;
    /** Human-readable document or page title. */
    title: string;
    /** Optional origin, such as a host name or document collection. */
    label?: string | undefined;
    /** Short context shown in the expanded list and citation preview. */
    description?: string | undefined;
    /** Optional exact excerpt; never inferred from the answer text. */
    quote?: string | undefined;
    /** A host-owned address included in the intent, never opened by the component. */
    href?: string | undefined;
    /** Missing or inaccessible resources remain visible but cannot request navigation. */
    unavailable?: boolean | undefined;
  })[];
  /** Optional disclosure title. */
  title?: string | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
} | {
  /** Approval Part discriminator. */
  kind: "confirmation";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
  /** Stable request identity, distinct from message or tool identity. */
  requestId: string;
  /** Action the user is being asked to authorize. */
  title: string;
  /** Concise scope or consequence of the action. */
  description?: string | undefined;
  /** Host-owned state; clicks never imply approval. */
  state: "pending" | "submitting" | "approved" | "rejected" | "expired" | "failed";
  /** Failure reason, retained while the same request can be retried. */
  error?: string | undefined;
  /** Wording of the decision; defaults to `permission`. */
  intent?: undefined | "permission" | "review";
} | {
  /** Question Part discriminator. */
  kind: "question";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
  /** Stable request identity; a change resets only the component's uncontrolled draft. */
  requestId: string;
  /** Request title. */
  title: string;
  /** Optional introductory text. */
  description?: string | undefined;
  /** Ordered, stable questions. */
  questions: readonly ({
    /** Stable identity within the request. */
    id: string;
    /** Visible and accessible prompt. */
    title: string;
    /** Supporting explanation. */
    description?: string | undefined;
    /** Input type. */
    kind: QuireKitChatQuestionKind;
    /** Predefined choices for single/multiple questions; unused for text. */
    options?: readonly QuireKitChatQuestionOption[] | undefined;
    /** Optional free-text choice for single/multiple questions; its value must not occur in options. */
    customOption?: QuireKitChatQuestionCustomOption | undefined;
    /** Whether a response is required; defaults to true. */
    required?: boolean | undefined;
    /** Text input placeholder. */
    placeholder?: string | undefined;
  })[];
  /** Host-owned lifecycle. */
  state: "pending" | "submitting" | "expired" | "failed" | "answered";
  /** Render answer controls or a compact transcript prompt; defaults to form. */
  presentation?: undefined | "form" | "prompt";
  /** Controlled answer draft, independent of the ordinary Composer draft. */
  draft?: undefined | readonly ({
    /** Question identity. */
    questionId: string;
    /** Single/text answers use a string, multiple answers use an ordered array. */
    value: string | readonly string[];
    /** Text belonging to the selected custom option; omitted from a submitted answer when not selected. */
    custom?: string | undefined;
  })[];
  /** Initial uncontrolled answer draft. */
  defaultDraft?: readonly QuireKitChatQuestionAnswer[] | undefined;
  /** Confirmed answers shown in the answered state. */
  answers?: readonly QuireKitChatQuestionAnswer[] | undefined;
  /** Submission error, shown without clearing the draft. */
  error?: string | undefined;
};
```

```ts
type QuireKitChatTextPart = {
  /** 正文判别项。 */
  kind: "text";
  /** 原始内容，默认安全转义并保留换行。 */
  text: string;
  /** plain 为默认值；markdown 无 renderer 时显示带说明的源文本。 */
  format?: undefined | "plain" | "markdown";
  /** 内容接收状态，默认 complete。 */
  state?: undefined | "error" | "complete" | "streaming" | "stopped";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: undefined | readonly ({
    /** 在所属操作组内稳定且唯一的标识。 */
    id: string;
    /** 可见名称或图标操作的辅助名称。 */
    label: string;
    /** IconProvider 中的图标名；省略时显示文字按钮。 */
    icon?: string | undefined;
    /** 明确不可执行时禁用。 */
    disabled?: boolean | undefined;
    /** 宿主正在处理此操作；阻止重复触发。 */
    busy?: boolean | undefined;
    /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
    pressed?: boolean | undefined;
    /** 需要危险语义的操作。 */
    danger?: boolean | undefined;
    /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
    placement?: "inline" | "more" | undefined;
    /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
    when?: "settled" | "active" | "always" | undefined;
  })[];
};
```

```ts
type QuireKitChatAction = {
  /** 在所属操作组内稳定且唯一的标识。 */
  id: string;
  /** 可见名称或图标操作的辅助名称。 */
  label: string;
  /** IconProvider 中的图标名；省略时显示文字按钮。 */
  icon?: undefined | string;
  /** 明确不可执行时禁用。 */
  disabled?: boolean | undefined;
  /** 宿主正在处理此操作；阻止重复触发。 */
  busy?: boolean | undefined;
  /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
  pressed?: boolean | undefined;
  /** 需要危险语义的操作。 */
  danger?: boolean | undefined;
  /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
  placement?: undefined | "inline" | "more";
  /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
  when?: undefined | "settled" | "active" | "always";
};
```

```ts
type QuireKitChatReasoningPart = {
  /** 推理判别项。 */
  kind: "reasoning";
  /** 标题；省略时使用语言包中的默认标题。 */
  title?: undefined | string;
  /** 可选单行摘要，不由 UI 猜测或定时生成。 */
  summary?: string | undefined;
  /** 宿主提供的耗时等次要文案。 */
  meta?: string | undefined;
  /** 完整推理文本。 */
  text: string;
  /** 推理状态，默认 complete；不会改变用户的展开选择。 */
  state?: undefined | "error" | "complete" | "streaming" | "stopped";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: undefined | readonly ({
    /** 在所属操作组内稳定且唯一的标识。 */
    id: string;
    /** 可见名称或图标操作的辅助名称。 */
    label: string;
    /** IconProvider 中的图标名；省略时显示文字按钮。 */
    icon?: string | undefined;
    /** 明确不可执行时禁用。 */
    disabled?: boolean | undefined;
    /** 宿主正在处理此操作；阻止重复触发。 */
    busy?: boolean | undefined;
    /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
    pressed?: boolean | undefined;
    /** 需要危险语义的操作。 */
    danger?: boolean | undefined;
    /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
    placement?: "inline" | "more" | undefined;
    /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
    when?: "settled" | "active" | "always" | undefined;
  })[];
};
```

```ts
type QuireKitChatToolPart = {
  /** 工具判别项。 */
  kind: "tool";
  /** 可读工具名称。 */
  title: string;
  /** 公共 Icon 名称，默认 terminal；由宿主表达读取、编辑、图片等工具类别。 */
  icon?: undefined | string;
  /** 一行任务摘要。 */
  summary?: string | undefined;
  /** 耗时等由宿主提供的元信息。 */
  meta?: string | undefined;
  /** 权威展示状态，不能根据 output 是否存在猜测。 */
  state: "failed" | "queued" | "running" | "waiting" | "succeeded" | "cancelled" | "interrupted";
  /** 自定义状态文案，例如具体等待原因。 */
  stateLabel?: string | undefined;
  /** 可选原始输入文本。 */
  input?: string | undefined;
  /** 可选原始输出文本。 */
  output?: string | undefined;
  /** 输入代码语言标签，默认 text。 */
  inputLanguage?: string | undefined;
  /** 输出代码语言标签，默认 text。 */
  outputLanguage?: string | undefined;
  /** 可读错误说明；不替换已有输出。 */
  error?: string | undefined;
  /** 仅提供部分输出时必须传入的截断说明；默认禁止复制不完整输出。 */
  outputTruncated?: string | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: undefined | readonly ({
    /** 在所属操作组内稳定且唯一的标识。 */
    id: string;
    /** 可见名称或图标操作的辅助名称。 */
    label: string;
    /** IconProvider 中的图标名；省略时显示文字按钮。 */
    icon?: string | undefined;
    /** 明确不可执行时禁用。 */
    disabled?: boolean | undefined;
    /** 宿主正在处理此操作；阻止重复触发。 */
    busy?: boolean | undefined;
    /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
    pressed?: boolean | undefined;
    /** 需要危险语义的操作。 */
    danger?: boolean | undefined;
    /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
    placement?: "inline" | "more" | undefined;
    /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
    when?: "settled" | "active" | "always" | undefined;
  })[];
};
```

```ts
type QuireKitChatToolState = "failed" | "queued" | "running" | "waiting" | "succeeded" | "cancelled" | "interrupted";
```

```ts
type QuireKitChatNoticePart = {
  /** 提示判别项。 */
  kind: "notice";
  /** 可见标题。 */
  title: string;
  /** 补充说明。 */
  description?: string | undefined;
  /** 语义色，默认 neutral；不会隐式改变整条消息状态。 */
  color?: undefined | "primary" | "neutral" | "info" | "success" | "warning" | "danger";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
};
```

```ts
type QuireKitChatCustomPart = {
  /** 扩展判别项，未知业务类型应显式投影到这里。 */
  kind: "custom";
  /** 扩展内容的可读名称。 */
  name: string;
  /** 无 renderer 时显示的安全回退文本，不自动转储 data。 */
  fallback: string;
  /** 不透明业务数据，仅转交自定义 slot。 */
  data?: unknown;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: undefined | readonly ({
    /** 在所属操作组内稳定且唯一的标识。 */
    id: string;
    /** 可见名称或图标操作的辅助名称。 */
    label: string;
    /** IconProvider 中的图标名；省略时显示文字按钮。 */
    icon?: string | undefined;
    /** 明确不可执行时禁用。 */
    disabled?: boolean | undefined;
    /** 宿主正在处理此操作；阻止重复触发。 */
    busy?: boolean | undefined;
    /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
    pressed?: boolean | undefined;
    /** 需要危险语义的操作。 */
    danger?: boolean | undefined;
    /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
    placement?: "inline" | "more" | undefined;
    /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
    when?: "settled" | "active" | "always" | undefined;
  })[];
};
```

```ts
type QuireKitChatAttachmentPart = {
  /** 附件判别项；一个 Part 可展示一组相关附件。 */
  kind: "attachment";
  /** 公共附件投影，保留每个附件的稳定身份。 */
  items: readonly ({
    /** 集合内唯一、跨更新稳定的身份；不使用索引或资源地址。 */
    id: string;
    /** 可读文件名。 */
    name: string;
    /** MIME 类型；图片类型可启用缩略图和预览。 */
    mediaType?: string | undefined;
    /** 字节数；省略或无效时不显示大小。 */
    size?: number | undefined;
    /** 可选来源元数据，不改变 URL 所有权。 */
    source?: "local" | "remote" | undefined;
    /** 宿主持有的资源地址；公共 UI 不创建或释放它。 */
    url?: string | undefined;
    /** 独立缩略图地址；省略时图片使用 url。 */
    thumbnailUrl?: string | undefined;
    /** 图片说明，省略时使用 name。 */
    alt?: string | undefined;
    /** 展示状态，默认 ready。 */
    state?: QuireKitAttachmentState | undefined;
    /** 上传百分比；有限数钳制至 0–100，无效或省略时为未知进度。 */
    progress?: number | undefined;
    /** 宿主补充的状态说明，例如失败原因。 */
    statusText?: string | undefined;
    /** 明确允许的操作，默认不显示任何业务操作；UI 再按 state 过滤。 */
    actions?: readonly QuireKitAttachmentAction[] | undefined;
  })[];
  /** 默认 list；图片集合可使用 grid，紧凑上下文可用 inline。 */
  layout?: undefined | "inline" | "list" | "grid" | "strip";
  /** 集合辅助名称。 */
  label?: string | undefined;
  /** 是否允许图片预览，默认 true。 */
  preview?: boolean | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
};
```

```ts
type QuireKitAttachmentItem = {
  /** 集合内唯一、跨更新稳定的身份；不使用索引或资源地址。 */
  id: string;
  /** 可读文件名。 */
  name: string;
  /** MIME 类型；图片类型可启用缩略图和预览。 */
  mediaType?: string | undefined;
  /** 字节数；省略或无效时不显示大小。 */
  size?: undefined | number;
  /** 可选来源元数据，不改变 URL 所有权。 */
  source?: undefined | "local" | "remote";
  /** 宿主持有的资源地址；公共 UI 不创建或释放它。 */
  url?: string | undefined;
  /** 独立缩略图地址；省略时图片使用 url。 */
  thumbnailUrl?: string | undefined;
  /** 图片说明，省略时使用 name。 */
  alt?: string | undefined;
  /** 展示状态，默认 ready。 */
  state?: undefined | "failed" | "ready" | "uploading" | "unavailable";
  /** 上传百分比；有限数钳制至 0–100，无效或省略时为未知进度。 */
  progress?: number | undefined;
  /** 宿主补充的状态说明，例如失败原因。 */
  statusText?: string | undefined;
  /** 明确允许的操作，默认不显示任何业务操作；UI 再按 state 过滤。 */
  actions?: undefined | readonly ("open" | "download" | "retry" | "remove")[];
};
```

```ts
type QuireKitAttachmentAction = "open" | "download" | "retry" | "remove";
```

```ts
type QuireKitChatSourcesPart = {
  /** Source list discriminator. */
  kind: "sources";
  /** Ordered source projections; retrieval and access control stay with the host. */
  sources: readonly ({
    /** Stable identity supplied by the host; it is not an array position. */
    id: string;
    /** Human-readable document or page title. */
    title: string;
    /** Optional origin, such as a host name or document collection. */
    label?: string | undefined;
    /** Short context shown in the expanded list and citation preview. */
    description?: string | undefined;
    /** Optional exact excerpt; never inferred from the answer text. */
    quote?: string | undefined;
    /** A host-owned address included in the intent, never opened by the component. */
    href?: string | undefined;
    /** Missing or inaccessible resources remain visible but cannot request navigation. */
    unavailable?: boolean | undefined;
  })[];
  /** Optional disclosure title. */
  title?: string | undefined;
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
};
```

```ts
type QuireKitSource = {
  /** Stable identity supplied by the host; it is not an array position. */
  id: string;
  /** Human-readable document or page title. */
  title: string;
  /** Optional origin, such as a host name or document collection. */
  label?: string | undefined;
  /** Short context shown in the expanded list and citation preview. */
  description?: string | undefined;
  /** Optional exact excerpt; never inferred from the answer text. */
  quote?: string | undefined;
  /** A host-owned address included in the intent, never opened by the component. */
  href?: string | undefined;
  /** Missing or inaccessible resources remain visible but cannot request navigation. */
  unavailable?: boolean | undefined;
};
```

```ts
type QuireKitChatConfirmationPart = {
  /** Approval Part discriminator. */
  kind: "confirmation";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
  /** Stable request identity, distinct from message or tool identity. */
  requestId: string;
  /** Action the user is being asked to authorize. */
  title: string;
  /** Concise scope or consequence of the action. */
  description?: string | undefined;
  /** Host-owned state; clicks never imply approval. */
  state: "pending" | "submitting" | "approved" | "rejected" | "expired" | "failed";
  /** Failure reason, retained while the same request can be retried. */
  error?: string | undefined;
  /** Wording of the decision; defaults to `permission`. */
  intent?: undefined | "permission" | "review";
};
```

```ts
type QuireKitChatConfirmationState = "pending" | "submitting" | "approved" | "rejected" | "expired" | "failed";
```

```ts
type QuireKitChatQuestionPart = {
  /** Question Part discriminator. */
  kind: "question";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: readonly QuireKitChatAction[] | undefined;
  /** Stable request identity; a change resets only the component's uncontrolled draft. */
  requestId: string;
  /** Request title. */
  title: string;
  /** Optional introductory text. */
  description?: string | undefined;
  /** Ordered, stable questions. */
  questions: readonly ({
    /** Stable identity within the request. */
    id: string;
    /** Visible and accessible prompt. */
    title: string;
    /** Supporting explanation. */
    description?: string | undefined;
    /** Input type. */
    kind: QuireKitChatQuestionKind;
    /** Predefined choices for single/multiple questions; unused for text. */
    options?: readonly QuireKitChatQuestionOption[] | undefined;
    /** Optional free-text choice for single/multiple questions; its value must not occur in options. */
    customOption?: QuireKitChatQuestionCustomOption | undefined;
    /** Whether a response is required; defaults to true. */
    required?: boolean | undefined;
    /** Text input placeholder. */
    placeholder?: string | undefined;
  })[];
  /** Host-owned lifecycle. */
  state: "pending" | "submitting" | "expired" | "failed" | "answered";
  /** Render answer controls or a compact transcript prompt; defaults to form. */
  presentation?: undefined | "form" | "prompt";
  /** Controlled answer draft, independent of the ordinary Composer draft. */
  draft?: undefined | readonly ({
    /** Question identity. */
    questionId: string;
    /** Single/text answers use a string, multiple answers use an ordered array. */
    value: string | readonly string[];
    /** Text belonging to the selected custom option; omitted from a submitted answer when not selected. */
    custom?: string | undefined;
  })[];
  /** Initial uncontrolled answer draft. */
  defaultDraft?: readonly QuireKitChatQuestionAnswer[] | undefined;
  /** Confirmed answers shown in the answered state. */
  answers?: readonly QuireKitChatQuestionAnswer[] | undefined;
  /** Submission error, shown without clearing the draft. */
  error?: string | undefined;
};
```

```ts
type QuireKitChatQuestionItem = {
  /** Stable identity within the request. */
  id: string;
  /** Visible and accessible prompt. */
  title: string;
  /** Supporting explanation. */
  description?: string | undefined;
  /** Input type. */
  kind: "text" | "single" | "multiple";
  /** Predefined choices for single/multiple questions; unused for text. */
  options?: undefined | readonly ({
    /** Stable option value. */
    value: string;
    /** Visible option text. */
    label: string;
    /** Optional detail below the label. */
    description?: string | undefined;
    /** Whether this option cannot be selected. */
    disabled?: boolean | undefined;
  })[];
  /** Optional free-text choice for single/multiple questions; its value must not occur in options. */
  customOption?: undefined | {
    /** Stable value distinct from every predefined option value in this question. */
    value: string;
    /** Visible choice label, such as “其他”. */
    label: string;
    /** Prompt shown only while this choice is selected; the language pack supplies the default. */
    placeholder?: string | undefined;
  };
  /** Whether a response is required; defaults to true. */
  required?: boolean | undefined;
  /** Text input placeholder. */
  placeholder?: string | undefined;
};
```

```ts
type QuireKitChatQuestionKind = "text" | "single" | "multiple";
```

```ts
type QuireKitChatQuestionOption = {
  /** Stable option value. */
  value: string;
  /** Visible option text. */
  label: string;
  /** Optional detail below the label. */
  description?: string | undefined;
  /** Whether this option cannot be selected. */
  disabled?: boolean | undefined;
};
```

```ts
type QuireKitChatQuestionCustomOption = {
  /** Stable value distinct from every predefined option value in this question. */
  value: string;
  /** Visible choice label, such as “其他”. */
  label: string;
  /** Prompt shown only while this choice is selected; the language pack supplies the default. */
  placeholder?: string | undefined;
};
```

```ts
type QuireKitChatQuestionState = "pending" | "submitting" | "expired" | "failed" | "answered";
```

```ts
type QuireKitChatQuestionAnswer = {
  /** Question identity. */
  questionId: string;
  /** Single/text answers use a string, multiple answers use an ordered array. */
  value: string | readonly (string)[];
  /** Text belonging to the selected custom option; omitted from a submitted answer when not selected. */
  custom?: string | undefined;
};
```

```ts
type QuireKitChatMessageBranch = {
  /** 有序、唯一、非空的分支身份。 */
  ids: readonly (string)[];
  /** 由宿主确认的当前分支。 */
  selectedId: string;
};
```

```ts
type QuireKitChatMessageActionsSlotContext = {
  /** 是否为最新消息。 */
  latest: boolean;
  /** 操作组的展示模式。 */
  visibility: "always" | "auto" | "hover";
};
```
