# Chat Message Part

> 独立呈现正文、推理、工具与扩展内容，并保持局部交互状态。

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

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

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

`part` 是有稳定 `id` 的展示单元。支持 `text`、`reasoning`、`tool`、`attachment`、`sources`、`notice`、`custom`；也可交给 [Chat Message](/raw/components/chat-message.md) 的 `parts` 自动组合。

## 正文与回退

普通文本保留换行并安全转义。`notice` 使用提示外观；`custom` 默认显示名称与 `fallback`，通过 `custom` slot 接入业务内容，不自动显示原始 `data`。

### 示例：chat-message-part/content

文件：`content.vue`

```vue
<script setup lang="ts">
import { QuireChatMessagePart } from '@quirekit/ui/vue/chat';
</script>
<template>
  <div class="grid min-w-0 gap-qk-surface p-qk-surface" data-chat-part-content>
    <QuireChatMessagePart :part="{ id: 'text', kind: 'text', text: '正文默认保留换行和文本内容。\nPart 不把一段网络 chunk 当作一条新消息。' }" />
    <QuireChatMessagePart :part="{ id: 'hint', kind: 'notice', title: '本地演示', description: '工具操作仅更新示例状态，不执行真实导出。', color: 'neutral' }" />
    <QuireChatMessagePart :part="{ id: 'extension', kind: 'custom', name: '进度图表', fallback: '当前环境未提供图表 renderer。已完成 3 项，待处理 2 项。' }" />
  </div>
</template>
```

`text` slot 可接入 `@quirekit/incremark/vue` 的 `QuireMarkdown`，传入 `:components="expandedCodeComponents"` 可让回复代码默认展开。省略 slot 时，正文按纯文本安全显示。

## 推理与工具过程

默认分发复用独立的 [Chat Reasoning](/raw/components/chat-reasoning.md) 与 [Chat Tool](/raw/components/chat-tool.md)，并非两套实现。Part 局部操作默认一直可用，显式 `when` 可以按过程状态过滤。

推理和工具默认是紧凑的可展开行。用 `title`、`summary`、`meta` 组织标题、摘要与耗时；`state` 只负责展示。工具支持 `input`、`output`、`error` 和局部 `actions`，特殊内容通过 `tool-input` / `tool-output` slots 接入。

### 示例：chat-message-part/process

文件：`process.vue`

```vue
<script setup lang="ts">
import { computed, ref } from 'vue';
import type { QuireKitChatActionDetails, QuireKitChatToolPart } from '@quirekit/ui';
import { QuireButton, QuireChatMessagePart, QuireCollapsible } from '@quirekit/ui/vue';
const state = ref<QuireKitChatToolPart['state']>('waiting'); const open = ref(false);
const part = computed<QuireKitChatToolPart>(() => ({
  id: 'export-report', kind: 'tool', title: '导出项目摘要', summary: 'project-summary.md', state: state.value,
  ...(state.value === 'waiting' ? { stateLabel: '等待你的确认' } : {}),
  input: '{ "format": "markdown", "include": ["scope", "milestones"] }', inputLanguage: 'json',
  ...(state.value === 'succeeded' ? { output: 'project-summary.md\n3 个阶段 · 已生成（本地演示）' } : {}),
  ...(state.value === 'failed' ? { error: '输出位置暂不可用。已保留参数，可以重试。' } : {}),
  actions: state.value === 'waiting' ? [{ id: 'confirm', label: '确认导出' }, { id: 'cancel', label: '取消' }]
    : state.value === 'failed' ? [{ id: 'retry', label: '重试导出' }] : []
}));
/** Responds to local intents without performing filesystem or network work.
 * @param details - Part-scoped action request.
 */
function act(details: QuireKitChatActionDetails): void {
  state.value = details.actionId === 'cancel' ? 'cancelled' : details.actionId === 'confirm' ? 'failed' : 'succeeded';
}
</script>
<template>
  <div class="grid min-w-0 gap-qk-surface p-qk-surface" data-chat-part-process>
    <QuireChatMessagePart v-model:open="open" :part="part" @action="act" />
    <QuireCollapsible title="展示设置">
      <div class="flex flex-wrap gap-qk-inline">
        <QuireButton variant="outline" @click="open = !open">{{ open ? '外部收起' : '外部展开' }}</QuireButton>
        <QuireButton variant="outline" @click="state = 'waiting'">重置演示</QuireButton>
      </div>
    </QuireCollapsible>
  </div>
</template>
```

`v-model:open` 可控制展开；省略时组件按 Part 身份保存。追加内容和状态完成不会自动折叠，改变 `id` 会清理未受控状态。`outputTruncated` 明确输出只是预览，并关闭默认输出复制。

操作只发出 `action` 请求，包含 `partId` 和 `actionId`；本例的确认、失败和重试均由示例处理，不代表内置审批或工具执行引擎。

## 附件

`kind: 'attachment'` 的 `items` 使用公共 [Attachments](/raw/components/attachments.md) 数据，`layout` 控制列表、网格或紧凑显示。图片组预览与文件操作都有默认呈现，无需再写一套附件 UI。

### 示例：chat-message-part/attachments

文件：`attachments.vue`

```vue
<script setup lang="ts">
import { computed, ref } from 'vue';
import { QuireChatMessageList } from '@quirekit/ui/vue';
import type { QuireKitAttachmentItem, QuireKitChatAttachmentActionDetails, QuireKitChatMessageListItem } from '@quirekit/ui';
const files = ref<QuireKitAttachmentItem[]>([
  { id: 'structure', name: '文档结构.svg', mediaType: 'image/svg+xml', url: '/examples/image/structure.svg', actions: ['download'] },
  { id: 'plan', name: '实施计划.pdf', mediaType: 'application/pdf', size: 98304, actions: ['open', 'download'] }
]);
const messages = computed<QuireKitChatMessageListItem[]>(() => [
  { messageId: 'request', author: '你', align: 'end', variant: 'soft', parts: [{ id: 'question', kind: 'text', text: '请整理出结构图和实施计划。' }] },
  { messageId: 'answer', author: '助手', parts: [
    { id: 'summary', kind: 'text', text: '结构图与计划已整理好，可以预览图片或打开文件继续查看。' },
    { id: 'files', kind: 'attachment', items: files.value, layout: 'grid', label: '交付文件' }
  ] }
]);
const feedback = ref('');
/** @param details - One public intent with all three identities, no AI protocol. */
function action(details: QuireKitChatAttachmentActionDetails): void {
  feedback.value = `${details.messageId} / ${details.partId} / ${details.attachmentId} → ${details.action}`;
}
</script>
<template>
  <div class="p-qk-surface grid gap-3" data-chat-attachments>
    <QuireChatMessageList :messages="messages" height="22rem" @attachment-action="action" />
    <p v-if="feedback" class="m-0 text-qk-helper text-qk-text-tertiary" role="status">{{ feedback }}</p>
  </div>
</template>
```

`attachmentAction` 包含 `messageId`、`partId`、`attachmentId` 和 `action`，会从 Part 经 Message 传到 MessageList。上传、打开和下载仍由宿主执行，本例只显示收到的意图。

`kind: 'sources'` 接受中立来源列表，默认复用 [Sources](/raw/components/sources.md)。`sourceNavigate` 沿 Part、Message、MessageList 转发来源身份，实际资源定位仍由宿主处理。

## API

### QuireChatMessagePart

#### Props

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| part | 是 | — | 有稳定身份的展示单元。 |
| showTextStatus | 否 | true | 正文是否单独显示停止或错误提示；所属消息已经显示相同状态时可关闭。 |
| messageId | 否 | — | 所属消息的身份，独立使用时可省略。 |
| open | 否 | undefined | 受控展开状态；省略时组件按 Part 身份持有。 |
| defaultOpen | 否 | false | 未受控时的初始状态；流式结束不会强行收起。 |

**part**

```ts
QuireKitChatMessagePart
```

```ts
{
  /** 正文判别项。 */
  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;
}
```

**showTextStatus**

```ts
boolean | undefined
```

**messageId**

```ts
string | undefined
```

```ts
undefined | string
```

**open**

```ts
boolean | undefined
```

**defaultOpen**

```ts
boolean | undefined
```

#### Events

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| action | 否 | — |  |
| attachmentAction | 否 | — |  |
| sourceNavigate | 否 | — |  |
| confirmationDecision | 否 | — |  |
| questionDraftChange | 否 | — |  |
| questionOpen | 否 | — |  |
| questionSubmit | 否 | — |  |
| update\:open | 否 | — |  |

**action**

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

**attachmentAction**

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

**sourceNavigate**

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

**confirmationDecision**

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

**questionDraftChange**

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

**questionOpen**

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

**questionSubmit**

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

**update:open**

```ts
[value: boolean]
```

#### Slots

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| text | 否 | — | 正文/Markdown renderer。 |
| reasoning | 否 | — | 推理详情 renderer；展开行为仍由 Part 持有。 |
| tool-input | 否 | — | 工具参数 renderer。 |
| tool-output | 否 | — | 工具输出 renderer，包括业务预览或审批组合。 |
| custom | 否 | — | 扩展内容 renderer，不存在时保留可读回退。 |

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