# Chat Message List

> 展示一个会话内的有序消息，管理自动跟随、历史阅读与定位。

网页来源：/components/chat-message-list

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

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

## 消息列表

传入 `messages` 即可默认渲染 [Chat Message](/raw/components/chat-message.md) 与 [MessagePart](/raw/components/chat-message-part.md)，不需要手写循环或查找表。每条消息必须有稳定、唯一的 `messageId` 和可读 `author`；正文放在 `parts`，对齐、状态、元信息和操作沿用 Message 的字段。

默认使用 `actionsVisibility="auto"`：**消息序列最后一条**的操作与时间常驻，较早消息的整组 footer 在桌面 hover/focus 时出现。尾部是用户消息时，不会错误地让上一条助手回复继续常驻。`always` 让每条 footer 常驻，`hover` 让非必要 footer 按需出现；触屏和键盘仍能访问。单条 `message.actionsVisibility`、`message.latest` 可覆盖列表默认策略。生成停止、错误恢复等必要动作不被隐藏。

这里只展示**一个会话内的消息**，不包含会话导航、标题栏或输入框。`Conversation / Thread` 描述一段会话；多会话导航与这里的消息序列是不同的展示对象。

### 示例：chat-message-list/messages

文件：`messages.vue`

```vue
<script setup lang="ts">
import { ref } from 'vue';
import { QuireButton } from '@quirekit/ui/vue';
import { QuireChatMessageList } from '@quirekit/ui/vue/chat';
import type { QuireKitChatMessageListItem } from '@quirekit/ui';

const visibility = ref<'auto' | 'always' | 'hover'>('auto');
const messages: readonly QuireKitChatMessageListItem[] = [
  { messageId: 'question', author: '你', align: 'end', variant: 'soft', parts: [{ id: 'body', kind: 'text', text: '帮我整理今天的工作进展。' }] },
  { messageId: 'first-answer', author: '助手', parts: [
    { id: 'reasoning', kind: 'reasoning', text: '先归纳已完成事项，再整理待确认问题。', meta: '用时 3 秒' },
    { id: 'body', kind: 'text', text: '已完成组件联调和文档更新。\n下一步：确认交互细节，再安排验收。' }
  ], copyText: '已完成组件联调和文档更新。\n下一步：确认交互细节，再安排验收。', meta: '09:30' },
  { messageId: 'follow-up', author: '你', align: 'end', variant: 'soft', parts: [{ id: 'body', kind: 'text', text: '还有需要先确认的风险吗？' }] },
  { messageId: 'second-answer', author: '助手', parts: [{ id: 'body', kind: 'text', text: '有两项：窄屏布局和键盘操作。确认后就能安排验收。' }],
    copyText: '有两项：窄屏布局和键盘操作。确认后就能安排验收。', meta: '09:32' },
  { messageId: 'pending-question', author: '你', align: 'end', variant: 'soft', parts: [{ id: 'body', kind: 'text', text: '好，稍后给你结果。' }],
    copyText: '好，稍后给你结果。', meta: '09:33' }
];
</script>

<template>
  <div class="grid min-w-0 gap-qk-inline p-qk-surface" data-chat-list-only>
    <div class="flex flex-wrap items-center gap-qk-inline-tight" role="group" aria-label="消息操作展示模式">
      <QuireButton size="sm" :variant="visibility === 'auto' ? 'soft' : 'text'" :aria-pressed="visibility === 'auto'" @click="visibility = 'auto'">最新常驻</QuireButton>
      <QuireButton size="sm" :variant="visibility === 'always' ? 'soft' : 'text'" :aria-pressed="visibility === 'always'" @click="visibility = 'always'">全部常驻</QuireButton>
      <QuireButton size="sm" :variant="visibility === 'hover' ? 'soft' : 'text'" :aria-pressed="visibility === 'hover'" @click="visibility = 'hover'">仅悬停</QuireButton>
    </div>
    <QuireChatMessageList :messages="messages" :actions-visibility="visibility" height="24rem" label="工作进展消息" />
  </div>
</template>
```

## 组合输入框

与 [Chat Composer](/raw/components/chat-composer.md) 并列即可组成 Chat。标题栏和外框由此示例组合，不是列表的内置 UI。示例只模拟本地回复。

默认正文列最大 `48rem`；列表提供两侧 `surface` 留白。共同祖先的 `--qk-chat-content-width` 可调整阅读宽度，Composer 外侧保留相同留白即可对齐。

### 示例：chat-message-list/basic

文件：`basic.vue`

```vue
<script setup lang="ts">
import { ref } from 'vue';
import { QuireChatMessageList, QuireChatComposer } from '@quirekit/ui/vue/chat';
import { QuireIcon, QuireProse } from '@quirekit/ui/vue';
import type { QuireKitChatMessageListItem, QuireKitChatSubmitDetails } from '@quirekit/ui';
const draft = ref('');
const request = '帮我把新项目整理成一份可执行的计划。';
const steps = ['明确范围：确认目标、负责人和交付时间。', '拆解任务：按优先级安排工作，标明依赖。', '共同验收：逐项检查结果，记录后续行动。'];
const conclusion = '你可以先补充项目背景，我们再一起细化。';
const introduction = '我们可以从三个阶段开始，让每一步都有清楚的交付物。';
const messages = ref<QuireKitChatMessageListItem[]>([
  { messageId: 'request', author: '你', align: 'end', variant: 'soft', parts: [{ id: 'request/body', kind: 'text', text: request }], copyText: request },
  { messageId: 'welcome', author: '项目助手', parts: [{ id: 'welcome/body', kind: 'text', text: introduction }], copyText: [introduction, ...steps, conclusion].join('\n\n') }
]);
let sequence = 0;
/** A local response demonstrates ownership without depending on a transport or model.
 * @param details - Literal text from the public composer.
 */
function send(details: QuireKitChatSubmitDetails): void {
  sequence++;
  const text = '已记下你的想法。下一步可以补充负责人、时间和验收标准。';
  messages.value.push(
    { messageId: `user-${sequence}`, author: '你', align: 'end', variant: 'soft', parts: [{ id: 'body', kind: 'text', text: details.text }], copyText: details.text },
    { messageId: `reply-${sequence}`, author: '项目助手', parts: [{ id: 'body', kind: 'text', text }], copyText: text }
  );
  draft.value = '';
}
</script>

<template>
  <div class="min-w-0 p-qk-surface" data-chat-basic>
    <div class="mx-auto min-w-0 max-w-[50rem] rounded-qk-dialog border border-solid border-qk-border-subtle bg-qk-surface-page">
      <header class="flex items-center gap-qk-surface-compact px-qk-surface pt-qk-surface">
        <QuireIcon name="messageCircle" :size="20" class="text-qk-text-accent" />
        <h3 class="m-0 text-qk-body font-qk-control">项目计划</h3>
      </header>
      <QuireChatMessageList :messages="messages" height="22rem">
        <template #text="{ part }">
          <QuireProse>
            <p>{{ part.text }}</p>
            <template v-if="part.id === 'welcome/body'">
              <ol>
                <li v-for="step in steps" :key="step">{{ step }}</li>
              </ol>
              <p>{{ conclusion }}</p>
            </template>
          </QuireProse>
        </template>
      </QuireChatMessageList>
      <div class="px-qk-surface pb-qk-surface pt-qk-inline">
        <QuireChatComposer v-model="draft" label="发给项目助手" placeholder="补充项目背景，或继续讨论…" variant="elevated" density="compact" :rows="1" @submit="send">
          <template #footer>本地模拟回复 · Enter 发送，Shift + Enter 换行</template>
        </QuireChatComposer>
      </div>
    </div>
  </div>
</template>
```

## 跟随与历史阅读

初次挂载跟随底部；上滚阅读后暂停追尾，“回到最新”恢复跟随。`hasOlder` 显示历史入口；收到 `loadOlder` 时同步设置 `loadingOlder`，完成后 prepend 数据，失败则解除 pending 以重试。

`height` 默认 `24rem`，`100%` 要求父容器有确定高度。实例方法 `scrollToMessage(messageId)` 定位并暂停跟随，缺失返回 false；`scrollToLatest()` 恢复跟随。`conversationId` 改变时重建消息子树并返回底部，不保存跨会话阅读位置。

示例显示消息编号、总数和操作反馈。清空后可以直接追加或生成新回复；“重置示例”才恢复初始记录。
加载历史图片时保持阅读位置，用“查看图片”定位。清空、重置和切换会话会取消尚未完成的演示请求。

### 示例：chat-message-list/scrolling

文件：`scrolling.vue`

```vue
<script setup lang="ts">
import { QuireButton, QuireChatMessageList, QuireImage } from '@quirekit/ui/vue';
import { useScrollingDemo } from './scrolling/use-demo';

const { messageList, session, messages, following, feedback, loading, streaming, hasOlder, imageVisible,
  ninthExists, append, stream, stop, older, toggleImage, locate, removeNinth, clear, reset, switchSession } = useScrollingDemo();
</script>

<template>
  <div class="grid min-w-0 gap-qk-surface-compact p-qk-surface" data-chat-scrolling>
    <div class="flex flex-wrap items-center justify-between gap-qk-inline">
      <span class="font-medium">{{ session === 'A' ? '项目计划' : '发布准备' }} · 会话 {{ session }}</span>
      <span class="text-qk-helper text-qk-text-secondary" data-demo-count>共 {{ messages.length }} 条<span v-if="messages.length"> · 最新 {{ messages.at(-1)?.messageId }}</span></span>
    </div>
    <div class="flex flex-wrap items-center gap-qk-inline-tight" role="group" aria-label="消息演示">
      <QuireButton size="sm" variant="outline" @click="append">追加消息</QuireButton>
      <QuireButton size="sm" variant="soft" @click="streaming ? stop() : stream()">{{ streaming ? '停止生成' : '模拟流式回复' }}</QuireButton>
      <QuireButton size="sm" :disabled="!messages.length && !loading" @click="clear">清空消息</QuireButton>
    </div>
    <div class="flex flex-wrap items-center gap-qk-inline-tight" role="group" aria-label="历史与会话操作">
      <QuireButton size="sm" :disabled="!ninthExists" @click="locate(`${session}-09`)">定位第 9 条</QuireButton>
      <QuireButton size="sm" @click="toggleImage">{{ imageVisible ? '移除历史图片' : '加载历史图片' }}</QuireButton>
      <QuireButton size="sm" :disabled="!ninthExists" @click="removeNinth">删除第 9 条</QuireButton>
      <QuireButton size="sm" @click="switchSession">切换会话</QuireButton>
      <QuireButton size="sm" @click="reset">重置示例</QuireButton>
    </div>
    <QuireChatMessageList ref="messageList" :messages="messages" :conversation-id="session" height="24rem"
      :has-older="hasOlder" :loading-older="loading" @load-older="older" @following-change="following = $event">
      <template #custom="{ part }">
        <QuireImage v-if="part.id === 'history-image'" src="/examples/image/coast.svg" alt="海岸晨光参考图" width="100%" loading="eager" />
      </template>
      <template #empty><p class="m-0 text-qk-text-secondary">暂无消息。可以直接追加消息、模拟流式回复或加载历史图片。</p></template>
    </QuireChatMessageList>
    <div class="flex flex-wrap items-center justify-between gap-qk-inline text-qk-helper text-qk-text-secondary">
      <span data-follow-state>{{ following ? '正在跟随最新消息' : '正在阅读历史消息' }}</span>
      <QuireButton v-if="imageVisible" size="sm" @click="locate(`${session}-03`)">查看图片</QuireButton>
    </div>
    <p class="m-0 text-qk-helper text-qk-text-secondary" role="status" data-demo-feedback>{{ feedback }}</p>
  </div>
</template>
```

文件：`scrolling/use-demo.ts`

```ts
import { computed, onBeforeUnmount, ref } from 'vue';
import type { QuireKitChatMessageListHandle, QuireKitChatMessageListItem } from '@quirekit/ui';
import { createMessage, initialMessages, olderMessages, replyChunks, updateText } from './data';

/** Own the demo's data and finite asynchronous jobs; MessageList owns only reading position.
 * @returns State and commands used by the public scrolling example.
 */
export function useScrollingDemo() {
  const messageList = ref<QuireKitChatMessageListHandle>();
  const session = ref('A');
  const messages = ref<QuireKitChatMessageListItem[]>(initialMessages(session.value));
  const following = ref(true);
  const feedback = ref('追加会出现在底部；上滚阅读时保持当前位置，可点“回到最新”查看。');
  const loading = ref(false);
  const streaming = ref(false);
  const historyPage = ref(0);
  const hasOlder = computed(() => messages.value.length > 0 && historyPage.value < 2);
  const ninthExists = computed(() => messages.value.some(message => message.messageId === `${session.value}-09`));
  const imageVisible = computed(() => messages.value.some(message => message.parts?.some(part => part.id === 'history-image')));
  let nextNumber = 13;
  let replyId: string | undefined;
  let olderTimer: ReturnType<typeof setTimeout> | undefined;
  let streamTimer: ReturnType<typeof setInterval> | undefined;

  /** @param id - Stable message identity. @param patch - New content/state without replacing its identity. */
  function update(id: string, patch: Partial<QuireKitChatMessageListItem>): void {
    const index = messages.value.findIndex(message => message.messageId === id);
    if (index !== -1) messages.value[index] = { ...messages.value[index]!, ...patch };
  }

  /** Append a visibly numbered update, including from the empty state. */
  function append(): void {
    const number = nextNumber++;
    const message = createMessage(session.value, number, updateText(number));
    messages.value.push(message);
    feedback.value = `已追加 ${message.messageId}。${following.value ? '正在跟随最新消息。' : '保留当前阅读位置，点“回到最新”查看。'}`;
  }

  /** Stop only generation, preserving the received body in the same message. */
  function stop(): void {
    clearInterval(streamTimer); streamTimer = undefined; streaming.value = false;
    if (replyId) {
      update(replyId, { state: 'stopped', statusText: '生成已停止，已接收内容保留。' });
      feedback.value = `已停止 ${replyId}；再次生成会新增一条回复。`;
    }
    replyId = undefined;
  }

  /** Create a reply on every run, then append chunks to its stable body Part. */
  function stream(): void {
    if (streaming.value) return;
    const reply = createMessage(session.value, nextNumber++, replyChunks[0]!);
    replyId = reply.messageId; streaming.value = true;
    messages.value.push({ ...reply, state: 'streaming' });
    feedback.value = `正在生成 ${reply.messageId}；可随时停止，或上滚阅读历史。`;
    let received = 1;
    streamTimer = setInterval(() => {
      received++;
      const complete = received === replyChunks.length;
      update(reply.messageId, { state: complete ? 'complete' : 'streaming',
        parts: [{ id: 'body', kind: 'text', text: replyChunks.slice(0, received).join('') }] });
      if (complete) {
        clearInterval(streamTimer); streamTimer = undefined; streaming.value = false; replyId = undefined;
        feedback.value = `${reply.messageId} 已生成完毕，共 ${received} 段增量。`;
      }
    }, 250);
  }

  /** Prepend a finite page; clear/reset/switch cancel this callback before replacing its data. */
  function older(): void {
    if (loading.value || !hasOlder.value) return;
    loading.value = true;
    olderTimer = setTimeout(() => {
      const items = olderMessages(session.value, ++historyPage.value);
      messages.value.unshift(...items); loading.value = false; olderTimer = undefined;
      feedback.value = `已加载 ${items[0]!.messageId} 至 ${items.at(-1)!.messageId}，保留原阅读位置。`;
    }, 350);
  }

  /** Add the historical owner if absent; toggling never depends on an invisible seed array. */
  function toggleImage(): void {
    const id = `${session.value}-03`;
    const target = messages.value.find(message => message.messageId === id);
    if (imageVisible.value && target) {
      update(id, { parts: target.parts?.filter(part => part.id !== 'history-image') ?? [] });
      feedback.value = `已移除 ${id} 的图片，保留消息正文。`;
      return;
    }
    const owner = target ?? createMessage(session.value, 3, '补入一条历史记录：这份图片用于讨论页面的视觉方向。');
    const parts = [...(owner.parts ?? []), { id: 'history-image', kind: 'custom' as const, name: '海岸晨光参考图', fallback: '历史配图暂不可用。' }];
    if (target) update(id, { parts });
    else messages.value.unshift({ ...owner, parts });
    feedback.value = `已为 ${id} 加入历史图片，保留阅读位置；点“查看图片”定位。`;
  }

  /** @param id - Existing message to locate, never silently restores cleared/deleted content. */
  function locate(id: string): void {
    feedback.value = messageList.value?.scrollToMessage(id) ? `已定位 ${id}。` : `${id} 不在当前列表中，可以重置示例。`;
  }

  /** Delete by fixture identity without renumbering surviving messages. */
  function removeNinth(): void {
    messages.value = messages.value.filter(message => message.messageId !== `${session.value}-09`);
    feedback.value = `已删除 ${session.value}-09；其余消息编号不变。`;
  }

  /** Prevent in-flight demo work from repopulating a cleared, reset or switched conversation. */
  function cancelPending(): void {
    clearTimeout(olderTimer); clearInterval(streamTimer);
    olderTimer = undefined; streamTimer = undefined; replyId = undefined;
    loading.value = false; streaming.value = false;
  }

  /** Clear real data, leaving all creation actions available with fresh identities. */
  function clear(): void {
    cancelPending(); messages.value = []; historyPage.value = 0;
    feedback.value = '已清空消息；可以直接追加、生成回复或加载历史图片。';
  }

  /** Explicitly restore the original twelve messages and initial pagination state. */
  function reset(): void {
    cancelPending(); historyPage.value = 0; nextNumber = 13;
    messages.value = initialMessages(session.value);
    messageList.value?.scrollToLatest();
    feedback.value = `会话 ${session.value} 已重置为 12 条初始消息。`;
  }

  /** Switch the data scope and cancel all work owned by the previous conversation. */
  function switchSession(): void {
    session.value = session.value === 'A' ? 'B' : 'A'; reset();
    feedback.value = `已切换到会话 ${session.value}，上一会话的生成和历史请求已取消。`;
  }

  onBeforeUnmount(cancelPending);
  return { messageList, session, messages, following, feedback, loading, streaming, hasOlder, imageVisible,
    ninthExists, append, stream, stop, older, toggleImage, locate, removeNinth, clear, reset, switchSession };
}
```

文件：`scrolling/data.ts`

```ts
import type { QuireKitChatMessageListItem } from '@quirekit/ui';

const project = [
  ['你', '这次项目先解决什么问题？'],
  ['项目助手', '先打通从收集需求到确认交付的一条完整流程，暂不扩展统计报表。'],
  ['项目助手', '视觉方向先保留这份参考图，后续可以在这里补充图片。'],
  ['你', '第一阶段由谁负责？'],
  ['项目助手', '小林整理需求，小周负责交互。每个任务都补齐负责人和预计完成时间。'],
  ['你', '把依赖关系也列出来。'],
  ['项目助手', '先确认数据字段，再开始界面联调；验收清单可以与开发同时准备。'],
  ['你', '我们需要怎样的验收标准？'],
  ['项目助手', '验收项 09：正常提交、失败恢复、键盘操作和窄屏布局都要逐项检查。'],
  ['你', '如果联调延期怎么办？'],
  ['项目助手', '预留一天缓冲，先交付可独立验证的部分；阻塞项单独记录原因和下一步。'],
  ['项目助手', '计划已经整理好。你可以追加一条进展，或生成一份新的阶段总结。'],
] as const;
const release = [
  ['你', '这次发布包含哪些内容？'],
  ['发布助手', '包含消息列表、输入框和附件展示，使用文档与示例一起发布。'],
  ['发布助手', '这里预留一份发布配图，可以加载后检查媒体增高时的阅读位置。'],
  ['你', '先核对公开入口。'],
  ['发布助手', '组件和共享类型各自从公开入口导出，示例不导入内部文件。'],
  ['你', '文档还有哪些遗漏？'],
  ['发布助手', '补充空态恢复、失败重试与键盘操作；代码示例和预览使用同一份源文件。'],
  ['你', '发布前的检查清单呢？'],
  ['发布助手', '验收项 09：确认类型、构建和实际浏览器操作，并记录仍未覆盖的范围。'],
  ['你', '发现问题之后如何处理？'],
  ['发布助手', '保留复现步骤，修复后只重跑受影响的检查，再更新说明。'],
  ['发布助手', '发布准备已就绪。继续追加检查结果，或者生成发布摘要。'],
] as const;
const updates = ['补齐负责人和交付时间。', '记录前置依赖，安排联调顺序。', '增加失败恢复的验收步骤。', '确认窄屏和键盘操作结果。', '整理待确认问题与下一步行动。', '同步文档中的使用说明。'];
const history = ['收集项目背景与已有资料。', '整理最初的使用场景。', '确认本期范围与暂缓事项。', '完成第一轮任务讨论。', '记录访谈中的主要问题。', '核对参与人员与职责。', '补充早期方案的取舍。', '归档讨论结论与待办。'];

/** Twelve meaningful chunks extend one stable reply rather than repeating a filler sentence. */
export const replyChunks = ['我会把当前进展', '整理成三个部分：\n', '一、范围已经明确，', '先完成核心流程，', '暂缓无关扩展。\n', '二、每项任务', '都补齐负责人、', '依赖和完成时间。\n', '三、交付前逐项检查', '正常路径、失败恢复、', '键盘与窄屏体验。\n', '下一步：确认清单后开始联调。'];

/** Build a stable fixture identity and visible author/number, independent of array position.
 * @param session - Current demo conversation.
 * @param number - Monotonic message number or distinct historical identity.
 * @param text - Message body.
 * @param author - Display author.
 * @returns Public MessageList data, without a second rendering model.
 */
export function createMessage(session: string, number: number | string, text: string, author = session === 'A' ? '项目助手' : '发布助手'): QuireKitChatMessageListItem {
  const messageId = `${session}-${String(number).padStart(2, '0')}`;
  return { messageId, author: `${author} · ${messageId}`, showHeader: true,
    align: author === '你' ? 'end' : 'start', variant: author === '你' ? 'soft' : 'plain',
    parts: [{ id: 'body', kind: 'text', text }] };
}

/** @param session - Demo conversation. @returns Twelve distinct starting messages. */
export function initialMessages(session: string): QuireKitChatMessageListItem[] {
  return (session === 'A' ? project : release).map(([author, text], index) => createMessage(session, index + 1, text, author));
}

/** @param number - Monotonic new-message identity. @returns A distinguishable update, including its number. */
export function updateText(number: number): string {
  return `新增进展 ${number}：${updates[(number - 13) % updates.length]}`;
}

/** @param session - Demo conversation. @param page - One-based older page. @returns Four ordered, stable historical messages. */
export function olderMessages(session: string, page: number): QuireKitChatMessageListItem[] {
  return Array.from({ length: 4 }, (_, index) => {
    const number = page * 4 - index;
    return createMessage(session, `H${String(number).padStart(2, '0')}`, history[number - 1]!, '历史记录');
  });
}
```

## 接入自己的数据

业务角色、事件和协议由宿主投影为展示字段，UI 不导入特定 AI SDK。不要使用数组下标作为消息或 Part 身份。

### 示例：chat-message-list/adapters

文件：`adapters.vue`

```vue
<script setup lang="ts">
import { computed, ref } from 'vue';
import { QuireChatMessageList, QuireSegmented } from '@quirekit/ui/vue';
import { fromEvents, fromParts } from './adapters/projection';
const source = ref('parts');
const sources = [{ value: 'parts', label: 'Parts 消息' }, { value: 'events', label: 'Node 事件' }];
const records = computed(() => source.value === 'parts'
  ? fromParts([
    { id: 'request', role: 'user', parts: [{ id: 'question', kind: 'text', text: '整理一下本周进展。' }] },
    { id: 'answer', role: 'assistant', parts: [{ id: 'answer-text', kind: 'text', text: '本周已经完成基础组件的联调。' }, { id: 'chart', kind: 'custom-chart' }] }
  ])
  : fromEvents([
    { node: 'run-1', operation: 'open', actor: '执行助手', content: '已读取任务。' },
    { node: 'run-1', operation: 'append', content: '\n现在开始整理验收清单。' },
    { node: 'run-2', operation: 'open', actor: '审阅助手' }
  ]));
</script>

<template>
  <div class="grid min-w-0 gap-qk-surface p-qk-surface" data-chat-adapters>
    <QuireSegmented v-model="source" :items="sources" label="模拟数据来源" class="justify-self-start" />
    <QuireChatMessageList :messages="records" :conversation-id="source" height="16rem" />
  </div>
</template>
```

文件：`adapters/projection.ts`

```ts
import type { DisplayMessage, NodeEvent, PartsMessage } from './types';

/** Translate parts without leaking the source schema into UI props.
 * @param messages - Mock parts source.
 * @returns Ordered display records with visible unknown-part fallbacks.
 */
export function fromParts(messages: readonly PartsMessage[]): DisplayMessage[] {
  return messages.map(message => ({
    messageId: message.id, author: message.role === 'user' ? '你' : '项目助手',
    align: message.role === 'user' ? 'end' : 'start',
    parts: message.parts.map(part => part.kind === 'text'
      ? { id: part.id, kind: 'text', text: part.text ?? '' }
      : { id: part.id, kind: 'custom', name: part.kind, fallback: `[暂不支持：${part.kind}]` })
  }));
}

/** Fold node events in source order; unsupported/missing payload remains visible.
 * @param events - Mock ordered event source.
 * @returns Display records with source identities, never array-index keys.
 */
export function fromEvents(events: readonly NodeEvent[]): DisplayMessage[] {
  const nodes = new Map<string, DisplayMessage>();
  for (const event of events) {
    const previous = nodes.get(event.node);
    const body = previous?.parts?.[0];
    const text = (body?.kind === 'text' ? body.text : '') + (event.content ?? '[暂无可展示内容]');
    nodes.set(event.node, {
      messageId: event.node, author: event.actor ?? previous?.author ?? '未知来源', align: 'start',
      // A node's text remains one part across open/append, not a part per event.
      parts: [{ id: `${event.node}/body`, kind: 'text', text }]
    });
  }
  return [...nodes.values()];
}
```

文件：`adapters/types.ts`

```ts
import type { QuireKitChatMessageListItem } from '@quirekit/ui';

/** View data owned by this example, not by the component library. */
export type DisplayMessage = QuireKitChatMessageListItem;

/** One mock source groups content in parts. */
export interface PartsMessage {
  /** Source message identity. */
  readonly id: string;
  /** Source role. */
  readonly role: 'user' | 'assistant';
  /** Ordered typed parts. */
  readonly parts: readonly { readonly id: string; readonly kind: string; readonly text?: string }[];
}

/** A second mock source publishes ordered node events. */
export interface NodeEvent {
  /** Persistent node identity. */
  readonly node: string;
  /** Event operation, not a UI state. */
  readonly operation: 'open' | 'append';
  /** Optional author for opening records. */
  readonly actor?: string;
  /** Displayable payload. */
  readonly content?: string;
}
```

`text/reasoning/tool-input/tool-output/custom` 插槽替换对应 Part 的内容；`message({ message, index, latest, actionsVisibility })` 替换整条消息，此时自定义组件使用解析后的操作策略并自行连接事件。

默认 Message 的 `action/branchChange/copy/copyError` 事件携带 `messageId` 转发。列表不执行重试、分支持久化或分页请求。列表只按消息顺序判定 `latest`，不推断业务角色或有无操作；更特殊的回合策略由宿主通过 `message.latest` 指定。

本组件不虚拟化消息，不解析 Markdown。Chat 组件可从 `@quirekit/ui/vue/chat` 或 `@quirekit/ui/vue` 导入；类型从 `@quirekit/ui` 导入。样式与主题配置见[开始使用](/raw/components/getting-started.md)。

## API

### QuireChatMessageList

#### Props

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| messages | 是 | — | 已排序的消息展示数据，不包含分页、模型或存储协议。 |
| conversationId | 否 | "default" | 改变时重置消息子树和滚动位置；不缓存跨会话位置。 |
| height | 否 | "24rem" | CSS 高度；100% 要求父容器具有确定高度。 |
| label | 否 | — | 可滚动区域名称；省略时取语言包。 |
| hasOlder | 否 | false | 是否显示加载更早内容的显式入口。 |
| loadingOlder | 否 | false | 历史加载中；宿主应在 loadOlder 后同步设置。 |
| actionsVisibility | 否 | "auto" | 默认 Message 的操作展示策略；单条 message.actionsVisibility 优先。 |

**messages**

```ts
readonly QuireKitChatMessageListItem[]
```

```ts
readonly ({
  /** 会话内唯一、非空且稳定的身份；不要使用数组下标。 */
  messageId: string;
  /** 可见发送者名称，也是 article 的辅助名称。 */
  author: string;
  /** 逻辑起始/结束位置，随 RTL 方向变化。 */
  align?: undefined | "start" | "end";
  /** plain 用于正文；soft 为短消息提供轻背景。 */
  variant?: undefined | "soft" | "plain";
  /** 是否显示作者行，默认 false；隐藏时仍保留 article 的辅助名称。 */
  showHeader?: boolean | undefined;
  /** 宿主格式化的尾部时间或次要说明。 */
  meta?: undefined | string;
  /** 有序稳定 Part；default slot 存在时由该 slot 接管内容。 */
  parts?: 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?: 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;
  })[];
  /** 整条消息的展示状态，不从 Part 状态推断。 */
  state?: undefined | "error" | "pending" | "complete" | "streaming" | "stopped";
  /** 覆盖当前状态的可读说明，error 时可解释恢复方式。 */
  statusText?: string | undefined;
  /** 权威复制原文；省略时不显示内置复制，不从 DOM 提取。 */
  copyText?: string | undefined;
  /** 消息级操作；组件只发 intent，执行由宿主负责。 */
  actions?: readonly QuireKitChatAction[] | undefined;
  /** 受控分支；数量不足二时不渲染导航。 */
  branch?: undefined | {
    /** 有序、唯一、非空的分支身份。 */
    ids: readonly string[];
    /** 由宿主确认的当前分支。 */
    selectedId: string;
  };
  /** auto 默认：最新消息的操作与时间常驻，历史 footer 在桌面 hover/focus 时显示；触屏常驻。 */
  actionsVisibility?: undefined | "always" | "auto" | "hover";
  /** 是否为最新消息，默认 true；由消费者投影，不扫描会话。 */
  latest?: boolean | undefined;
})[]
```

**conversationId**

```ts
string | undefined
```

```ts
undefined | string
```

**height**

```ts
string | undefined
```

```ts
undefined | string
```

**label**

```ts
string | undefined
```

```ts
undefined | string
```

**hasOlder**

```ts
boolean | undefined
```

**loadingOlder**

```ts
boolean | undefined
```

**actionsVisibility**

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

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

#### Events

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

**action**

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

**copy**

```ts
[details: QuireKitChatMessageListCopyDetails]
```

**copyError**

```ts
[details: QuireKitChatMessageListCopyErrorDetails]
```

**loadOlder**

```ts
[]
```

**followingChange**

```ts
[following: boolean]
```

**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

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| message | 否 | — | 替换默认 Message；自定义组件事件由消费端连接。 |
| empty | 否 | — | 无消息时的内容。 |
| text | 否 | — | 正文/Markdown renderer。 |
| reasoning | 否 | — | 推理详情 renderer；展开行为仍由 Part 持有。 |
| tool-input | 否 | — | 工具参数 renderer。 |
| tool-output | 否 | — | 工具输出 renderer，包括业务预览或审批组合。 |
| custom | 否 | — | 扩展内容 renderer，不存在时保留可读回退。 |

**message**

```ts
QuireKitChatMessageListItemContext
```

```ts
{
  /** 当前消息的中立展示数据。 */
  message: {
    /** 会话内唯一、非空且稳定的身份；不要使用数组下标。 */
    messageId: string;
    /** 可见发送者名称，也是 article 的辅助名称。 */
    author: string;
    /** 逻辑起始/结束位置，随 RTL 方向变化。 */
    align?: undefined | "start" | "end";
    /** plain 用于正文；soft 为短消息提供轻背景。 */
    variant?: undefined | "soft" | "plain";
    /** 是否显示作者行，默认 false；隐藏时仍保留 article 的辅助名称。 */
    showHeader?: boolean | undefined;
    /** 宿主格式化的尾部时间或次要说明。 */
    meta?: undefined | string;
    /** 有序稳定 Part；default slot 存在时由该 slot 接管内容。 */
    parts?: undefined | readonly ({
      /** 正文判别项。 */
      kind: "text";
      /** 原始内容，默认安全转义并保留换行。 */
      text: string;
      /** plain 为默认值；markdown 无 renderer 时显示带说明的源文本。 */
      format?: "plain" | "markdown" | undefined;
      /** 内容接收状态，默认 complete。 */
      state?: QuireKitChatPartState | undefined;
      /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
      id: string;
      /** 可选的局部操作。 */
      actions?: readonly QuireKitChatAction[] | 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: QuireKitChatToolState;
      /** 自定义状态文案，例如具体等待原因。 */
      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?: QuireKitAlertColor | undefined;
      /** 消息内唯一、非空的稳定 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 QuireKitAttachmentItem[];
      /** 默认 list；图片集合可使用 grid，紧凑上下文可用 inline。 */
      layout?: QuireKitAttachmentLayout | undefined;
      /** 集合辅助名称。 */
      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 QuireKitSource[];
      /** 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: QuireKitChatConfirmationState;
      /** Failure reason, retained while the same request can be retried. */
      error?: string | undefined;
      /** Wording of the decision; defaults to `permission`. */
      intent?: QuireKitChatConfirmationIntent | undefined;
    } | {
      /** 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 QuireKitChatQuestionItem[];
      /** Host-owned lifecycle. */
      state: QuireKitChatQuestionState;
      /** Render answer controls or a compact transcript prompt; defaults to form. */
      presentation?: QuireKitChatQuestionPresentation | undefined;
      /** Controlled answer draft, independent of the ordinary Composer draft. */
      draft?: readonly QuireKitChatQuestionAnswer[] | 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;
    })[];
    /** 整条消息的展示状态，不从 Part 状态推断。 */
    state?: undefined | "error" | "pending" | "complete" | "streaming" | "stopped";
    /** 覆盖当前状态的可读说明，error 时可解释恢复方式。 */
    statusText?: string | undefined;
    /** 权威复制原文；省略时不显示内置复制，不从 DOM 提取。 */
    copyText?: string | undefined;
    /** 消息级操作；组件只发 intent，执行由宿主负责。 */
    actions?: readonly QuireKitChatAction[] | undefined;
    /** 受控分支；数量不足二时不渲染导航。 */
    branch?: undefined | {
      /** 有序、唯一、非空的分支身份。 */
      ids: readonly string[];
      /** 由宿主确认的当前分支。 */
      selectedId: string;
    };
    /** auto 默认：最新消息的操作与时间常驻，历史 footer 在桌面 hover/focus 时显示；触屏常驻。 */
    actionsVisibility?: undefined | "always" | "auto" | "hover";
    /** 是否为最新消息，默认 true；由消费者投影，不扫描会话。 */
    latest?: boolean | undefined;
  };
  /** 当前显示顺序；不可作为持久身份。 */
  index: number;
  /** 当前项是否为消息序列最后一条，显式 message.latest 优先。 */
  latest: boolean;
  /** 列表策略与单条消息覆盖后的操作展示模式。 */
  actionsVisibility: "always" | "auto" | "hover";
}
```

**empty**

```ts
any
```

**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;
    })[];
  };
}
```

#### 公开实例成员

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| scrollToLatest | 否 | — | 跳到底部并恢复跟随，不移动焦点。 |
| scrollToMessage | 否 | — | 按 key 定位并暂停跟随；不存在时返回 false。 |

**scrollToLatest**

```ts
() => void
```

```ts
{ (): void; }
```

**scrollToMessage**

```ts
(messageId: string) => boolean
```

```ts
{ (messageId: string): boolean; }
```

#### 相关类型

```ts
type QuireKitChatMessageListItem = {
  /** 会话内唯一、非空且稳定的身份；不要使用数组下标。 */
  messageId: string;
  /** 可见发送者名称，也是 article 的辅助名称。 */
  author: string;
  /** 逻辑起始/结束位置，随 RTL 方向变化。 */
  align?: undefined | "start" | "end";
  /** plain 用于正文；soft 为短消息提供轻背景。 */
  variant?: undefined | "soft" | "plain";
  /** 是否显示作者行，默认 false；隐藏时仍保留 article 的辅助名称。 */
  showHeader?: boolean | undefined;
  /** 宿主格式化的尾部时间或次要说明。 */
  meta?: undefined | string;
  /** 有序稳定 Part；default slot 存在时由该 slot 接管内容。 */
  parts?: undefined | readonly ({
    /** 正文判别项。 */
    kind: "text";
    /** 原始内容，默认安全转义并保留换行。 */
    text: string;
    /** plain 为默认值；markdown 无 renderer 时显示带说明的源文本。 */
    format?: "plain" | "markdown" | undefined;
    /** 内容接收状态，默认 complete。 */
    state?: QuireKitChatPartState | undefined;
    /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
    id: string;
    /** 可选的局部操作。 */
    actions?: readonly QuireKitChatAction[] | 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: QuireKitChatToolState;
    /** 自定义状态文案，例如具体等待原因。 */
    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?: QuireKitAlertColor | undefined;
    /** 消息内唯一、非空的稳定 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 QuireKitAttachmentItem[];
    /** 默认 list；图片集合可使用 grid，紧凑上下文可用 inline。 */
    layout?: QuireKitAttachmentLayout | undefined;
    /** 集合辅助名称。 */
    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 QuireKitSource[];
    /** 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: QuireKitChatConfirmationState;
    /** Failure reason, retained while the same request can be retried. */
    error?: string | undefined;
    /** Wording of the decision; defaults to `permission`. */
    intent?: QuireKitChatConfirmationIntent | undefined;
  } | {
    /** 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 QuireKitChatQuestionItem[];
    /** Host-owned lifecycle. */
    state: QuireKitChatQuestionState;
    /** Render answer controls or a compact transcript prompt; defaults to form. */
    presentation?: QuireKitChatQuestionPresentation | undefined;
    /** Controlled answer draft, independent of the ordinary Composer draft. */
    draft?: readonly QuireKitChatQuestionAnswer[] | 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;
  })[];
  /** 整条消息的展示状态，不从 Part 状态推断。 */
  state?: undefined | "error" | "pending" | "complete" | "streaming" | "stopped";
  /** 覆盖当前状态的可读说明，error 时可解释恢复方式。 */
  statusText?: string | undefined;
  /** 权威复制原文；省略时不显示内置复制，不从 DOM 提取。 */
  copyText?: string | undefined;
  /** 消息级操作；组件只发 intent，执行由宿主负责。 */
  actions?: readonly QuireKitChatAction[] | undefined;
  /** 受控分支；数量不足二时不渲染导航。 */
  branch?: undefined | {
    /** 有序、唯一、非空的分支身份。 */
    ids: readonly string[];
    /** 由宿主确认的当前分支。 */
    selectedId: string;
  };
  /** auto 默认：最新消息的操作与时间常驻，历史 footer 在桌面 hover/focus 时显示；触屏常驻。 */
  actionsVisibility?: undefined | "always" | "auto" | "hover";
  /** 是否为最新消息，默认 true；由消费者投影，不扫描会话。 */
  latest?: boolean | 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 QuireKitChatMessageListItemContext = {
  /** 当前消息的中立展示数据。 */
  message: {
    /** 会话内唯一、非空且稳定的身份；不要使用数组下标。 */
    messageId: string;
    /** 可见发送者名称，也是 article 的辅助名称。 */
    author: string;
    /** 逻辑起始/结束位置，随 RTL 方向变化。 */
    align?: "start" | "end" | undefined;
    /** plain 用于正文；soft 为短消息提供轻背景。 */
    variant?: "soft" | "plain" | undefined;
    /** 是否显示作者行，默认 false；隐藏时仍保留 article 的辅助名称。 */
    showHeader?: boolean | undefined;
    /** 宿主格式化的尾部时间或次要说明。 */
    meta?: string | undefined;
    /** 有序稳定 Part；default slot 存在时由该 slot 接管内容。 */
    parts?: readonly QuireKitChatMessagePart[] | undefined;
    /** 整条消息的展示状态，不从 Part 状态推断。 */
    state?: QuireKitChatMessageState | undefined;
    /** 覆盖当前状态的可读说明，error 时可解释恢复方式。 */
    statusText?: string | undefined;
    /** 权威复制原文；省略时不显示内置复制，不从 DOM 提取。 */
    copyText?: string | undefined;
    /** 消息级操作；组件只发 intent，执行由宿主负责。 */
    actions?: readonly QuireKitChatAction[] | undefined;
    /** 受控分支；数量不足二时不渲染导航。 */
    branch?: QuireKitChatMessageBranch | undefined;
    /** auto 默认：最新消息的操作与时间常驻，历史 footer 在桌面 hover/focus 时显示；触屏常驻。 */
    actionsVisibility?: "always" | "auto" | "hover" | undefined;
    /** 是否为最新消息，默认 true；由消费者投影，不扫描会话。 */
    latest?: boolean | undefined;
  };
  /** 当前显示顺序；不可作为持久身份。 */
  index: number;
  /** 当前项是否为消息序列最后一条，显式 message.latest 优先。 */
  latest: boolean;
  /** 列表策略与单条消息覆盖后的操作展示模式。 */
  actionsVisibility: "always" | "auto" | "hover";
};
```
