@pactor-app/chat 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/index.cjs +1468 -592
- package/dist/index.d.cts +111 -23
- package/dist/index.d.ts +111 -23
- package/dist/index.js +1441 -596
- package/package.json +7 -8
- package/styles.css +192 -180
package/dist/index.d.cts
CHANGED
|
@@ -655,6 +655,11 @@ declare function useChatAutoScroll({ messageCount, lastContentLength, isStreamin
|
|
|
655
655
|
* 数据以接口注入:greeting / subtitle / suggestions 均为受控 props;
|
|
656
656
|
* 点击建议经 `onSuggestionClick` 回调交还调用方(ChatView 接入时
|
|
657
657
|
* 复用 Composer 的同一条发送路径)。
|
|
658
|
+
*
|
|
659
|
+
* chrome DSL 渲染层(spec: chat-chrome-dsl):元素层在页面运行时内
|
|
660
|
+
* 优先经 ChromeSlot 以宿主组件(Typography / Text / Button)DSL 组合
|
|
661
|
+
* 渲染,建议点击经 chat.sendSuggestion 内建动作接回同一发送路径;
|
|
662
|
+
* 无 renderer 环境或类型缺失时回退下方手写实现(EmptyStateFallback)。
|
|
658
663
|
*/
|
|
659
664
|
type ChatSuggestion = string | {
|
|
660
665
|
label: string;
|
|
@@ -738,6 +743,10 @@ interface ChatWorkspaceServices {
|
|
|
738
743
|
/** Composer 工具栏左 / 右槽(ReactNode 闭包槽,纯 React 与 DSL 场景均可用) */
|
|
739
744
|
toolbarStart?: ReactNode;
|
|
740
745
|
toolbarEnd?: ReactNode;
|
|
746
|
+
/** Composer footer 槽(spec: chat-composer-slots;ReactNode 闭包槽) */
|
|
747
|
+
composerFooter?: ReactNode;
|
|
748
|
+
/** Composer 下方自定义内容槽(ReactNode 闭包槽;渲染在 Composer 之外正下方,未提供不渲染) */
|
|
749
|
+
composerBottom?: ReactNode;
|
|
741
750
|
/** 工作区头部右侧扩展区(提供 title 或 headerExtra 时渲染头部) */
|
|
742
751
|
headerExtra?: ReactNode;
|
|
743
752
|
}
|
|
@@ -764,8 +773,20 @@ interface ChatWorkspaceProps {
|
|
|
764
773
|
* 包裹工作区(侧栏 + 移动端抽屉)。仅页面运行时上下文内有效。
|
|
765
774
|
*/
|
|
766
775
|
sidebar?: DslNode;
|
|
776
|
+
/** Composer 工具栏左端 DslNode 槽(与服务注入的 toolbarStart 先后渲染,服务槽在先) */
|
|
777
|
+
toolbarStart?: DslNode;
|
|
767
778
|
/** Composer 工具栏右端 DslNode 槽(与服务注入的 toolbarEnd 先后渲染) */
|
|
768
779
|
toolbarEnd?: DslNode;
|
|
780
|
+
/** Composer footer DslNode 槽(spec: chat-composer-slots;与服务注入的 composerFooter 先后渲染,服务槽在先) */
|
|
781
|
+
composerFooter?: DslNode;
|
|
782
|
+
/** Composer 下方自定义内容 DslNode 槽(与服务注入的 composerBottom 先后渲染,服务槽在先;未提供不渲染) */
|
|
783
|
+
composerBottom?: DslNode;
|
|
784
|
+
/**
|
|
785
|
+
* 隐藏 Composer 工具栏行(缺省 false):true 时工具栏行整体不渲染,
|
|
786
|
+
* toolbarStart / toolbarEnd 槽一并抑制(composerFooter 槽不受影响),
|
|
787
|
+
* Enter 发送保留
|
|
788
|
+
*/
|
|
789
|
+
hideToolbar?: boolean;
|
|
769
790
|
/**
|
|
770
791
|
* 产出物面板受控 props(spec: chat-artifact-panel,决策 D2):
|
|
771
792
|
* 任一提供即全受控;都未提供时由内部 / 注入的 ArtifactStore 驱动
|
|
@@ -874,7 +895,7 @@ interface ChatProps {
|
|
|
874
895
|
conversationId?: string;
|
|
875
896
|
/** 注入 dsl part 作用域 params */
|
|
876
897
|
params?: Record<string, unknown>;
|
|
877
|
-
/** 传 false 关闭 header
|
|
898
|
+
/** 传 false 关闭 header;缺省按内容自动渲染(header 槽整体替换 > title + headerExtra / headerActions / header 位模型 chip 内建 header,均无内容时 header 节点不渲染) */
|
|
878
899
|
showHeader?: boolean;
|
|
879
900
|
/** 左侧菜单数据;提供时以 AppShell 承载内建侧栏 */
|
|
880
901
|
menu?: ChatMenuItem[];
|
|
@@ -882,6 +903,27 @@ interface ChatProps {
|
|
|
882
903
|
activeMenuKey?: string;
|
|
883
904
|
/** 侧栏槽:提供时替代内建菜单侧栏 */
|
|
884
905
|
sidebar?: DslNode | ReactNode;
|
|
906
|
+
/**
|
|
907
|
+
* Composer 槽(spec: chat-composer-slots / Composer 槽配置):
|
|
908
|
+
* toolbarStart 工具栏左端 / toolbarEnd 工具栏右端(发送钮之前)/
|
|
909
|
+
* composerFooter footer 区域(工具栏下方、带分隔线);
|
|
910
|
+
* 与服务注入的同名槽并存时服务槽在先
|
|
911
|
+
*/
|
|
912
|
+
toolbarStart?: DslNode | ReactNode;
|
|
913
|
+
toolbarEnd?: DslNode | ReactNode;
|
|
914
|
+
composerFooter?: DslNode | ReactNode;
|
|
915
|
+
/**
|
|
916
|
+
* Composer 下方自定义内容槽(DslNode | ReactNode):
|
|
917
|
+
* 渲染在 Composer 之外正下方(页面底部留白区内),
|
|
918
|
+
* 与服务注入的同名槽并存时服务槽在先;未提供不渲染
|
|
919
|
+
*/
|
|
920
|
+
composerBottom?: DslNode | ReactNode;
|
|
921
|
+
/**
|
|
922
|
+
* 隐藏 Composer 工具栏行(缺省 false;DSL 可序列化标量):
|
|
923
|
+
* true 时工具栏行整体不渲染,toolbarStart / toolbarEnd 槽一并抑制
|
|
924
|
+
* (composerFooter 槽不受影响),Enter 发送保留
|
|
925
|
+
*/
|
|
926
|
+
hideToolbar?: boolean;
|
|
885
927
|
/** 内建 header 标题右侧槽 */
|
|
886
928
|
headerExtra?: DslNode | ReactNode;
|
|
887
929
|
/** header 槽:整体替换内建 header */
|
|
@@ -941,12 +983,16 @@ interface ChatProps {
|
|
|
941
983
|
/** 菜单项点击回调(disabled 项不触发) */
|
|
942
984
|
onMenuSelect?: (key: string, item: ChatMenuItem) => void;
|
|
943
985
|
}
|
|
944
|
-
/**
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
986
|
+
/**
|
|
987
|
+
* 菜单图标名(spec: chat-icon-convergence):契约取值(plus / chat /
|
|
988
|
+
* history / settings / star / search / user / folder)直接作为 ui Icon
|
|
989
|
+
* 白名单名渲染,未知名由 ui Icon 渲染占位图标,不抛错。
|
|
990
|
+
* 白名单曾映射 lucide 子集(MENU_ICONS),收敛后删除。
|
|
991
|
+
*/
|
|
992
|
+
/** 内建侧栏:menu 数据驱动的菜单(分组标题 + 图标 + badge + disabled);ChatShell 同款复用。
|
|
993
|
+
* chrome DSL 渲染层(spec: chat-on-ui-components):DSL 环境优先经宿主
|
|
994
|
+
* Menu 组件组合渲染(chat.menuSelect 接回同一传播与 drawer close),
|
|
995
|
+
* 无 renderer / 类型缺失时回退下方手写菜单 */
|
|
950
996
|
declare function ChatSidebarMenu({ menu, activeMenuKey, onMenuSelect, }: {
|
|
951
997
|
menu: ChatMenuItem[];
|
|
952
998
|
activeMenuKey?: string;
|
|
@@ -960,7 +1006,7 @@ declare function ChatSidebarMenu({ menu, activeMenuKey, onMenuSelect, }: {
|
|
|
960
1006
|
* 「未配置聊天服务」提示并 console.warn,不抛错。组合逻辑与
|
|
961
1007
|
* createChatWorkspace 共用内部 ChatComposition(决策 D5)。
|
|
962
1008
|
*/
|
|
963
|
-
declare function Chat({ title, greeting, subtitle, suggestions, conversationId, params, showHeader, menu, activeMenuKey, sidebar, headerExtra, header, headerActions, editableTitle, onExport, onThemeChange, onClear, onTitleChange, models, model, onModelChange, modelPlacement, contexts, onContextsChange, messageActions, onMessageAction, artifact, panelOpen, onPanelClose, inspector, onArtifact, onOpenArtifact, className, onSend, onMenuSelect, }: ChatProps): ReactNode;
|
|
1009
|
+
declare function Chat({ title, greeting, subtitle, suggestions, conversationId, params, showHeader, menu, activeMenuKey, sidebar, toolbarStart, toolbarEnd, composerFooter, composerBottom, hideToolbar, headerExtra, header, headerActions, editableTitle, onExport, onThemeChange, onClear, onTitleChange, models, model, onModelChange, modelPlacement, contexts, onContextsChange, messageActions, onMessageAction, artifact, panelOpen, onPanelClose, inspector, onArtifact, onOpenArtifact, className, onSend, onMenuSelect, }: ChatProps): ReactNode;
|
|
964
1010
|
/** Chat 的 DSL 组件类型名 */
|
|
965
1011
|
declare const CHAT_COMPONENT_TYPE = "Chat";
|
|
966
1012
|
/**
|
|
@@ -970,6 +1016,20 @@ declare const CHAT_COMPONENT_TYPE = "Chat";
|
|
|
970
1016
|
* 一并注册,同样不覆盖已有同名类型。
|
|
971
1017
|
*/
|
|
972
1018
|
declare function registerChatComponent(registry: Registry<unknown>): void;
|
|
1019
|
+
/**
|
|
1020
|
+
* 便捷工厂:创建含全部内置组件 + Chat / ChatShell 的组件注册表,
|
|
1021
|
+
* 直接作为 createPactorApplication 的 componentRegistry 选项:
|
|
1022
|
+
*
|
|
1023
|
+
* ```ts
|
|
1024
|
+
* import { createChatComponentRegistry } from '@pactor-app/chat';
|
|
1025
|
+
*
|
|
1026
|
+
* createPactorApplication({
|
|
1027
|
+
* appId: 'my-chat',
|
|
1028
|
+
* componentRegistry: createChatComponentRegistry,
|
|
1029
|
+
* });
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
declare function createChatComponentRegistry(): Registry<unknown>;
|
|
973
1033
|
|
|
974
1034
|
/**
|
|
975
1035
|
* ChatShell(spec: chat-dsl-component / ChatShell 外壳组件,设计决策 D6):
|
|
@@ -1036,6 +1096,16 @@ interface ArtifactPanelProps {
|
|
|
1036
1096
|
}
|
|
1037
1097
|
declare function ArtifactPanel({ artifact, inspector, onClose, safeRegistry, user, className, }: ArtifactPanelProps): ReactNode;
|
|
1038
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* 侧栏抽屉 context(spec: chat-app-shell):侧栏内容(如导航项)在导航后
|
|
1101
|
+
* 调用 `close()` 关闭移动端抽屉;不在 AppShell 内时返回 null,
|
|
1102
|
+
* 调用方以可选链安全调用(`drawer?.close()`),不抛错。
|
|
1103
|
+
* `collapsed` 为桌面折叠(icon rail)状态(决策 D3):侧栏内容可据此
|
|
1104
|
+
* 降级为纯图标展示(如菜单项以 title 兜底可访问名)。
|
|
1105
|
+
*
|
|
1106
|
+
* 实现为 ui Sidebar 的 context 转发(chat-on-ui-sidebar):AppShell
|
|
1107
|
+
* 内部渲染 ui Sidebar,hook 签名与语义保持不变,调用方零改动。
|
|
1108
|
+
*/
|
|
1039
1109
|
declare function useSidebarDrawer(): {
|
|
1040
1110
|
close: () => void;
|
|
1041
1111
|
collapsed: boolean;
|
|
@@ -1068,12 +1138,14 @@ interface AppShellProps {
|
|
|
1068
1138
|
/**
|
|
1069
1139
|
* AppShell(spec: chat-app-shell):聊天工作区应用外壳 = 侧栏插槽 + 主区。
|
|
1070
1140
|
*
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1141
|
+
* 实现为 ui Sidebar 的薄封装(spec: chat-on-ui-sidebar):桌面(≥768px)
|
|
1142
|
+
* 侧栏与主区 flex 同行;移动端(<768px)侧栏变为覆盖抽屉(遮罩 +
|
|
1143
|
+
* 顶栏菜单按钮);折叠 / 抽屉 / inert 等交互全部由 ui Sidebar 承担,
|
|
1144
|
+
* chat 侧只挂 `pactor-chat-shell` 类做 `--sidebar*` → `--pactor-chat-*`
|
|
1145
|
+
* 令牌映射(皮肤唯一入口仍为 --pactor-chat-*,见 styles.css)与
|
|
1146
|
+
* 高度语义(h-full 填满父容器,嵌入契约)。
|
|
1075
1147
|
*/
|
|
1076
|
-
declare function AppShell({ sidebar, brand, locationKey, sidebarFooter, collapsible, children, className }: AppShellProps): react.JSX.Element;
|
|
1148
|
+
declare function AppShell({ sidebar, brand, locationKey, sidebarFooter, collapsible, children, className, }: AppShellProps): react.JSX.Element;
|
|
1077
1149
|
|
|
1078
1150
|
/**
|
|
1079
1151
|
* 上下文数据源解析与候选列表(spec: chat-context-sources,设计决策 D1/D5):
|
|
@@ -1105,6 +1177,10 @@ type CallChatService = (name: string, params?: Record<string, unknown>) => Promi
|
|
|
1105
1177
|
* 模型 chip(AnchoredPopover 列表,toolbarEnd 之前);contexts 配置
|
|
1106
1178
|
* 且未注入调用方回调时启用内建 @ 提及 / + 菜单弹层,选中项追加为
|
|
1107
1179
|
* 输入区上方的上下文 chips(受控:contextChips + onContextChipsChange)
|
|
1180
|
+
* - chrome DSL 渲染层(spec: chat-composer-on-chatinput):呈现层在
|
|
1181
|
+
* DSL 环境经宿主 ChatInput 组合渲染(非受控 + chat.composerSubmit
|
|
1182
|
+
* 桥接 + 冒泡同步 / 附件承接),无 renderer 或类型缺失时回退手写
|
|
1183
|
+
* 呈现(ComposerFallback),两条路径交互语义一致
|
|
1108
1184
|
*/
|
|
1109
1185
|
interface ComposerProps {
|
|
1110
1186
|
/** 发送回调;输入框在回调后清空 */
|
|
@@ -1126,6 +1202,15 @@ interface ComposerProps {
|
|
|
1126
1202
|
/** 工具栏左 / 右渲染槽 */
|
|
1127
1203
|
toolbarStart?: ReactNode;
|
|
1128
1204
|
toolbarEnd?: ReactNode;
|
|
1205
|
+
/** footer 槽(spec: chat-composer-slots / Composer footer 槽):渲染在工具栏下方、以分隔线相隔;未提供不渲染 */
|
|
1206
|
+
composerFooter?: ReactNode;
|
|
1207
|
+
/**
|
|
1208
|
+
* 隐藏工具栏行(缺省 false):true 时工具栏行整体不渲染——
|
|
1209
|
+
* 内建 + 钮 / 附件钮 / 模型 chip / 发送钮与 toolbarStart / toolbarEnd
|
|
1210
|
+
* 槽一并抑制(footer 槽不受影响);Enter 发送保留,DSL 路径由
|
|
1211
|
+
* ChatInput 工具栏行零渲染承担
|
|
1212
|
+
*/
|
|
1213
|
+
hideToolbar?: boolean;
|
|
1129
1214
|
/** 词边界 `@` 输入触发:query 为 `@` 后文本,anchorRect 为弹层锚点 */
|
|
1130
1215
|
onMentionTrigger?: (query: string, anchorRect: DOMRect) => void;
|
|
1131
1216
|
/** "+" 按钮触发弹层入口 */
|
|
@@ -1152,7 +1237,7 @@ interface ComposerProps {
|
|
|
1152
1237
|
/** service 引用解析出口(ChatServices.callService 透传) */
|
|
1153
1238
|
callService?: CallChatService;
|
|
1154
1239
|
}
|
|
1155
|
-
declare function Composer({ onSend, streaming, onStop, placeholder, disabled, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, onMentionTrigger, onPlusMenu, models, model, onModelChange, contextSources, contextChips, onContextChipsChange, callService, }: ComposerProps): react.JSX.Element;
|
|
1240
|
+
declare function Composer({ onSend, streaming, onStop, placeholder, disabled, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, onMentionTrigger, onPlusMenu, models, model, onModelChange, contextSources, contextChips, onContextChipsChange, callService, composerFooter, hideToolbar, }: ComposerProps): react.JSX.Element;
|
|
1156
1241
|
|
|
1157
1242
|
/**
|
|
1158
1243
|
* ChatView(设计决策 D6):消息列表(useSyncExternalStore 订阅
|
|
@@ -1171,7 +1256,7 @@ declare function Composer({ onSend, streaming, onStop, placeholder, disabled, at
|
|
|
1171
1256
|
* Composer 扩展 props(attachments / onAttachFiles / toolbar 槽 /
|
|
1172
1257
|
* 提及与 "+" 触发等,见 ComposerProps)原样透传给内建 Composer。
|
|
1173
1258
|
*/
|
|
1174
|
-
interface ChatViewProps extends Pick<ComposerProps, 'attachments' | 'onAttachmentsChange' | 'onAttachFiles' | 'onAttachmentClick' | 'toolbarStart' | 'toolbarEnd' | 'onMentionTrigger' | 'onPlusMenu'> {
|
|
1259
|
+
interface ChatViewProps extends Pick<ComposerProps, 'attachments' | 'onAttachmentsChange' | 'onAttachFiles' | 'onAttachmentClick' | 'toolbarStart' | 'toolbarEnd' | 'composerFooter' | 'hideToolbar' | 'onMentionTrigger' | 'onPlusMenu'> {
|
|
1175
1260
|
store: ConversationStore;
|
|
1176
1261
|
/** 注入后发送即驱动 turn;缺省时仅触发 onSend */
|
|
1177
1262
|
transport?: ChatTransport;
|
|
@@ -1233,9 +1318,15 @@ interface ChatViewProps extends Pick<ComposerProps, 'attachments' | 'onAttachmen
|
|
|
1233
1318
|
messageActions?: Array<BuiltinMessageAction | ChatMessageAction>;
|
|
1234
1319
|
/** 全部消息动作(含内建)点击的并行通知(event 语义,不影响内建默认行为) */
|
|
1235
1320
|
onMessageAction?: (actionId: string, message: ChatMessage) => void;
|
|
1321
|
+
/**
|
|
1322
|
+
* Composer 下方自定义内容槽(未提供不渲染):渲染在 Composer 之外、
|
|
1323
|
+
* 页面底部留白区内(空态 / 钉底两态一致),典型用途为免责声明、
|
|
1324
|
+
* 备案信息等弱提示行
|
|
1325
|
+
*/
|
|
1326
|
+
composerBottom?: ReactNode;
|
|
1236
1327
|
className?: string;
|
|
1237
1328
|
}
|
|
1238
|
-
declare function ChatView({ store, transport, onSend, safeRegistry, capabilities, permission, confirm, conversationId, user, params, greeting, subtitle, suggestions, className, onArtifact, onOpenArtifact, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, onMentionTrigger, onPlusMenu, models, model, onModelChange, modelPlacement, contexts, onContextsChange, callService, messageActions, onMessageAction, }: ChatViewProps): react.JSX.Element;
|
|
1329
|
+
declare function ChatView({ store, transport, onSend, safeRegistry, capabilities, permission, confirm, conversationId, user, params, greeting, subtitle, suggestions, className, onArtifact, onOpenArtifact, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, composerFooter, hideToolbar, onMentionTrigger, onPlusMenu, models, model, onModelChange, modelPlacement, contexts, onContextsChange, callService, messageActions, onMessageAction, composerBottom, }: ChatViewProps): react.JSX.Element;
|
|
1239
1330
|
|
|
1240
1331
|
/**
|
|
1241
1332
|
* ActivityTrace(spec: chat-activity-trace,设计决策 D1/D4):
|
|
@@ -1333,10 +1424,6 @@ interface MessageActionsProps {
|
|
|
1333
1424
|
/** 全部动作(含内建)点击的并行通知 */
|
|
1334
1425
|
onMessageAction?: (actionId: string, message: ChatMessage) => void;
|
|
1335
1426
|
}
|
|
1336
|
-
/** 动作图标名 → lucide 子集(白名单式,同菜单 MENU_ICONS 口径;未知名渲染占位图标,不抛错) */
|
|
1337
|
-
declare const MESSAGE_ACTION_ICONS: Record<string, ComponentType<{
|
|
1338
|
-
size?: number;
|
|
1339
|
-
}>>;
|
|
1340
1427
|
/** 收集消息的可复制文本(text / markdown part 按序拼接) */
|
|
1341
1428
|
declare function collectMessageText(message: ChatMessage): string;
|
|
1342
1429
|
declare function MessageActions({ message, actions, showRegenerate, onRegenerate, onEdit, onRetry, forceVisible, callService, onMessageAction, }: MessageActionsProps): react.JSX.Element | null;
|
|
@@ -1388,8 +1475,9 @@ declare function ChatLayout({ title, children }: ChatLayoutProps): react.JSX.Ele
|
|
|
1388
1475
|
declare const CHAT_LAYOUT_TYPE = "chat";
|
|
1389
1476
|
/**
|
|
1390
1477
|
* 结构化 LayoutRegistry(兼容 @pactor-app/ui layout 层的 LayoutRegistry =
|
|
1391
|
-
* Registry<LayoutComponent
|
|
1392
|
-
*
|
|
1478
|
+
* Registry<LayoutComponent>):结构化类型声明,调用方传入 ui layout 层
|
|
1479
|
+
* 的注册表即天然兼容(历史为零依赖约定而设;chat-icon-convergence 起
|
|
1480
|
+
* chat 正式依赖 @pactor-app/ui,本结构化声明保留以收窄本文件的 API 面)。
|
|
1393
1481
|
*/
|
|
1394
1482
|
interface ChatLayoutRegistry {
|
|
1395
1483
|
has(name: string): boolean;
|
|
@@ -1398,4 +1486,4 @@ interface ChatLayoutRegistry {
|
|
|
1398
1486
|
/** 注册 chat 布局(已注册时不覆盖,与 createLayoutRegistry 约定一致) */
|
|
1399
1487
|
declare function registerChatLayout(layoutRegistry: ChatLayoutRegistry): void;
|
|
1400
1488
|
|
|
1401
|
-
export { ActivityTrace, type ActivityTraceProps, AppShell, type AppShellProps, ArtifactPanel, type ArtifactPanelProps, type ArtifactPatch, ArtifactStore, type BuiltinMessageAction, CHAT_COMPONENT_TYPE, CHAT_DENIED_TYPE, CHAT_LAYOUT_TYPE, CHAT_SHELL_COMPONENT_TYPE, type CapabilityActionDeps, type CapabilityHandler, Chat, type ChatArtifact, type ChatAttachment, type ChatCapabilityRegistry, type ChatConfirm, type ChatConfirmRequest, type ChatContextItem, type ChatContextSource, ChatDenied, type ChatEvent, type ChatHeaderAction, type ChatInput, ChatLayout, type ChatLayoutProps, type ChatLayoutRegistry, type ChatMenuItem, type ChatMessage, type ChatMessageAction, type ChatModelOption, type ChatPart, type ChatPermissionChecker, type ChatProps, type ChatRole, type ChatRuntime, type ChatScope, type ChatServices, ChatServicesProvider, ChatShell, type ChatShellProps, ChatSidebarMenu, type ChatSuggestion, type ChatTransport, type ChatTurnResult, ChatView, type ChatViewProps, type ChatWorkspaceProps, type ChatWorkspaceServices, Composer, type ComposerProps, ConversationStore, type CreateChatRuntimeOptions, DEFAULT_CHAT_GREETING, EmptyState, type EmptyStateProps,
|
|
1489
|
+
export { ActivityTrace, type ActivityTraceProps, AppShell, type AppShellProps, ArtifactPanel, type ArtifactPanelProps, type ArtifactPatch, ArtifactStore, type BuiltinMessageAction, CHAT_COMPONENT_TYPE, CHAT_DENIED_TYPE, CHAT_LAYOUT_TYPE, CHAT_SHELL_COMPONENT_TYPE, type CapabilityActionDeps, type CapabilityHandler, Chat, type ChatArtifact, type ChatAttachment, type ChatCapabilityRegistry, type ChatConfirm, type ChatConfirmRequest, type ChatContextItem, type ChatContextSource, ChatDenied, type ChatEvent, type ChatHeaderAction, type ChatInput, ChatLayout, type ChatLayoutProps, type ChatLayoutRegistry, type ChatMenuItem, type ChatMessage, type ChatMessageAction, type ChatModelOption, type ChatPart, type ChatPermissionChecker, type ChatProps, type ChatRole, type ChatRuntime, type ChatScope, type ChatServices, ChatServicesProvider, ChatShell, type ChatShellProps, ChatSidebarMenu, type ChatSuggestion, type ChatTransport, type ChatTurnResult, ChatView, type ChatViewProps, type ChatWorkspaceProps, type ChatWorkspaceServices, Composer, type ComposerProps, ConversationStore, type CreateChatRuntimeOptions, DEFAULT_CHAT_GREETING, EmptyState, type EmptyStateProps, type ManualChatDriver, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, type MessagePatch, type MessageStatus, type PartPatch, type PartRef, PartRenderer, type PartRendererProps, type PartStatus, type RunChatTurnOptions, type StreamingMode, type ToolCallStatus, type ToolTraceEntry, type UseChatAutoScrollOptions, type UseChatAutoScrollResult, type UseSmoothStreamTextOptions, applyChatEvent, buildChatScope, collectMessageText, createChatComponentRegistry, createChatId, createChatRuntime, createChatWorkspace, createManualDriver, createSafeRegistry, detectStreamingMode, guardChatDsl, pairToolTraces, registerCapabilityAction, registerChatComponent, registerChatLayout, registerChatShellComponent, runChatTurn, runRegenerateTurn, useChatAutoScroll, useChatServices, useSidebarDrawer, useSmoothStreamText };
|
package/dist/index.d.ts
CHANGED
|
@@ -655,6 +655,11 @@ declare function useChatAutoScroll({ messageCount, lastContentLength, isStreamin
|
|
|
655
655
|
* 数据以接口注入:greeting / subtitle / suggestions 均为受控 props;
|
|
656
656
|
* 点击建议经 `onSuggestionClick` 回调交还调用方(ChatView 接入时
|
|
657
657
|
* 复用 Composer 的同一条发送路径)。
|
|
658
|
+
*
|
|
659
|
+
* chrome DSL 渲染层(spec: chat-chrome-dsl):元素层在页面运行时内
|
|
660
|
+
* 优先经 ChromeSlot 以宿主组件(Typography / Text / Button)DSL 组合
|
|
661
|
+
* 渲染,建议点击经 chat.sendSuggestion 内建动作接回同一发送路径;
|
|
662
|
+
* 无 renderer 环境或类型缺失时回退下方手写实现(EmptyStateFallback)。
|
|
658
663
|
*/
|
|
659
664
|
type ChatSuggestion = string | {
|
|
660
665
|
label: string;
|
|
@@ -738,6 +743,10 @@ interface ChatWorkspaceServices {
|
|
|
738
743
|
/** Composer 工具栏左 / 右槽(ReactNode 闭包槽,纯 React 与 DSL 场景均可用) */
|
|
739
744
|
toolbarStart?: ReactNode;
|
|
740
745
|
toolbarEnd?: ReactNode;
|
|
746
|
+
/** Composer footer 槽(spec: chat-composer-slots;ReactNode 闭包槽) */
|
|
747
|
+
composerFooter?: ReactNode;
|
|
748
|
+
/** Composer 下方自定义内容槽(ReactNode 闭包槽;渲染在 Composer 之外正下方,未提供不渲染) */
|
|
749
|
+
composerBottom?: ReactNode;
|
|
741
750
|
/** 工作区头部右侧扩展区(提供 title 或 headerExtra 时渲染头部) */
|
|
742
751
|
headerExtra?: ReactNode;
|
|
743
752
|
}
|
|
@@ -764,8 +773,20 @@ interface ChatWorkspaceProps {
|
|
|
764
773
|
* 包裹工作区(侧栏 + 移动端抽屉)。仅页面运行时上下文内有效。
|
|
765
774
|
*/
|
|
766
775
|
sidebar?: DslNode;
|
|
776
|
+
/** Composer 工具栏左端 DslNode 槽(与服务注入的 toolbarStart 先后渲染,服务槽在先) */
|
|
777
|
+
toolbarStart?: DslNode;
|
|
767
778
|
/** Composer 工具栏右端 DslNode 槽(与服务注入的 toolbarEnd 先后渲染) */
|
|
768
779
|
toolbarEnd?: DslNode;
|
|
780
|
+
/** Composer footer DslNode 槽(spec: chat-composer-slots;与服务注入的 composerFooter 先后渲染,服务槽在先) */
|
|
781
|
+
composerFooter?: DslNode;
|
|
782
|
+
/** Composer 下方自定义内容 DslNode 槽(与服务注入的 composerBottom 先后渲染,服务槽在先;未提供不渲染) */
|
|
783
|
+
composerBottom?: DslNode;
|
|
784
|
+
/**
|
|
785
|
+
* 隐藏 Composer 工具栏行(缺省 false):true 时工具栏行整体不渲染,
|
|
786
|
+
* toolbarStart / toolbarEnd 槽一并抑制(composerFooter 槽不受影响),
|
|
787
|
+
* Enter 发送保留
|
|
788
|
+
*/
|
|
789
|
+
hideToolbar?: boolean;
|
|
769
790
|
/**
|
|
770
791
|
* 产出物面板受控 props(spec: chat-artifact-panel,决策 D2):
|
|
771
792
|
* 任一提供即全受控;都未提供时由内部 / 注入的 ArtifactStore 驱动
|
|
@@ -874,7 +895,7 @@ interface ChatProps {
|
|
|
874
895
|
conversationId?: string;
|
|
875
896
|
/** 注入 dsl part 作用域 params */
|
|
876
897
|
params?: Record<string, unknown>;
|
|
877
|
-
/** 传 false 关闭 header
|
|
898
|
+
/** 传 false 关闭 header;缺省按内容自动渲染(header 槽整体替换 > title + headerExtra / headerActions / header 位模型 chip 内建 header,均无内容时 header 节点不渲染) */
|
|
878
899
|
showHeader?: boolean;
|
|
879
900
|
/** 左侧菜单数据;提供时以 AppShell 承载内建侧栏 */
|
|
880
901
|
menu?: ChatMenuItem[];
|
|
@@ -882,6 +903,27 @@ interface ChatProps {
|
|
|
882
903
|
activeMenuKey?: string;
|
|
883
904
|
/** 侧栏槽:提供时替代内建菜单侧栏 */
|
|
884
905
|
sidebar?: DslNode | ReactNode;
|
|
906
|
+
/**
|
|
907
|
+
* Composer 槽(spec: chat-composer-slots / Composer 槽配置):
|
|
908
|
+
* toolbarStart 工具栏左端 / toolbarEnd 工具栏右端(发送钮之前)/
|
|
909
|
+
* composerFooter footer 区域(工具栏下方、带分隔线);
|
|
910
|
+
* 与服务注入的同名槽并存时服务槽在先
|
|
911
|
+
*/
|
|
912
|
+
toolbarStart?: DslNode | ReactNode;
|
|
913
|
+
toolbarEnd?: DslNode | ReactNode;
|
|
914
|
+
composerFooter?: DslNode | ReactNode;
|
|
915
|
+
/**
|
|
916
|
+
* Composer 下方自定义内容槽(DslNode | ReactNode):
|
|
917
|
+
* 渲染在 Composer 之外正下方(页面底部留白区内),
|
|
918
|
+
* 与服务注入的同名槽并存时服务槽在先;未提供不渲染
|
|
919
|
+
*/
|
|
920
|
+
composerBottom?: DslNode | ReactNode;
|
|
921
|
+
/**
|
|
922
|
+
* 隐藏 Composer 工具栏行(缺省 false;DSL 可序列化标量):
|
|
923
|
+
* true 时工具栏行整体不渲染,toolbarStart / toolbarEnd 槽一并抑制
|
|
924
|
+
* (composerFooter 槽不受影响),Enter 发送保留
|
|
925
|
+
*/
|
|
926
|
+
hideToolbar?: boolean;
|
|
885
927
|
/** 内建 header 标题右侧槽 */
|
|
886
928
|
headerExtra?: DslNode | ReactNode;
|
|
887
929
|
/** header 槽:整体替换内建 header */
|
|
@@ -941,12 +983,16 @@ interface ChatProps {
|
|
|
941
983
|
/** 菜单项点击回调(disabled 项不触发) */
|
|
942
984
|
onMenuSelect?: (key: string, item: ChatMenuItem) => void;
|
|
943
985
|
}
|
|
944
|
-
/**
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
986
|
+
/**
|
|
987
|
+
* 菜单图标名(spec: chat-icon-convergence):契约取值(plus / chat /
|
|
988
|
+
* history / settings / star / search / user / folder)直接作为 ui Icon
|
|
989
|
+
* 白名单名渲染,未知名由 ui Icon 渲染占位图标,不抛错。
|
|
990
|
+
* 白名单曾映射 lucide 子集(MENU_ICONS),收敛后删除。
|
|
991
|
+
*/
|
|
992
|
+
/** 内建侧栏:menu 数据驱动的菜单(分组标题 + 图标 + badge + disabled);ChatShell 同款复用。
|
|
993
|
+
* chrome DSL 渲染层(spec: chat-on-ui-components):DSL 环境优先经宿主
|
|
994
|
+
* Menu 组件组合渲染(chat.menuSelect 接回同一传播与 drawer close),
|
|
995
|
+
* 无 renderer / 类型缺失时回退下方手写菜单 */
|
|
950
996
|
declare function ChatSidebarMenu({ menu, activeMenuKey, onMenuSelect, }: {
|
|
951
997
|
menu: ChatMenuItem[];
|
|
952
998
|
activeMenuKey?: string;
|
|
@@ -960,7 +1006,7 @@ declare function ChatSidebarMenu({ menu, activeMenuKey, onMenuSelect, }: {
|
|
|
960
1006
|
* 「未配置聊天服务」提示并 console.warn,不抛错。组合逻辑与
|
|
961
1007
|
* createChatWorkspace 共用内部 ChatComposition(决策 D5)。
|
|
962
1008
|
*/
|
|
963
|
-
declare function Chat({ title, greeting, subtitle, suggestions, conversationId, params, showHeader, menu, activeMenuKey, sidebar, headerExtra, header, headerActions, editableTitle, onExport, onThemeChange, onClear, onTitleChange, models, model, onModelChange, modelPlacement, contexts, onContextsChange, messageActions, onMessageAction, artifact, panelOpen, onPanelClose, inspector, onArtifact, onOpenArtifact, className, onSend, onMenuSelect, }: ChatProps): ReactNode;
|
|
1009
|
+
declare function Chat({ title, greeting, subtitle, suggestions, conversationId, params, showHeader, menu, activeMenuKey, sidebar, toolbarStart, toolbarEnd, composerFooter, composerBottom, hideToolbar, headerExtra, header, headerActions, editableTitle, onExport, onThemeChange, onClear, onTitleChange, models, model, onModelChange, modelPlacement, contexts, onContextsChange, messageActions, onMessageAction, artifact, panelOpen, onPanelClose, inspector, onArtifact, onOpenArtifact, className, onSend, onMenuSelect, }: ChatProps): ReactNode;
|
|
964
1010
|
/** Chat 的 DSL 组件类型名 */
|
|
965
1011
|
declare const CHAT_COMPONENT_TYPE = "Chat";
|
|
966
1012
|
/**
|
|
@@ -970,6 +1016,20 @@ declare const CHAT_COMPONENT_TYPE = "Chat";
|
|
|
970
1016
|
* 一并注册,同样不覆盖已有同名类型。
|
|
971
1017
|
*/
|
|
972
1018
|
declare function registerChatComponent(registry: Registry<unknown>): void;
|
|
1019
|
+
/**
|
|
1020
|
+
* 便捷工厂:创建含全部内置组件 + Chat / ChatShell 的组件注册表,
|
|
1021
|
+
* 直接作为 createPactorApplication 的 componentRegistry 选项:
|
|
1022
|
+
*
|
|
1023
|
+
* ```ts
|
|
1024
|
+
* import { createChatComponentRegistry } from '@pactor-app/chat';
|
|
1025
|
+
*
|
|
1026
|
+
* createPactorApplication({
|
|
1027
|
+
* appId: 'my-chat',
|
|
1028
|
+
* componentRegistry: createChatComponentRegistry,
|
|
1029
|
+
* });
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
declare function createChatComponentRegistry(): Registry<unknown>;
|
|
973
1033
|
|
|
974
1034
|
/**
|
|
975
1035
|
* ChatShell(spec: chat-dsl-component / ChatShell 外壳组件,设计决策 D6):
|
|
@@ -1036,6 +1096,16 @@ interface ArtifactPanelProps {
|
|
|
1036
1096
|
}
|
|
1037
1097
|
declare function ArtifactPanel({ artifact, inspector, onClose, safeRegistry, user, className, }: ArtifactPanelProps): ReactNode;
|
|
1038
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* 侧栏抽屉 context(spec: chat-app-shell):侧栏内容(如导航项)在导航后
|
|
1101
|
+
* 调用 `close()` 关闭移动端抽屉;不在 AppShell 内时返回 null,
|
|
1102
|
+
* 调用方以可选链安全调用(`drawer?.close()`),不抛错。
|
|
1103
|
+
* `collapsed` 为桌面折叠(icon rail)状态(决策 D3):侧栏内容可据此
|
|
1104
|
+
* 降级为纯图标展示(如菜单项以 title 兜底可访问名)。
|
|
1105
|
+
*
|
|
1106
|
+
* 实现为 ui Sidebar 的 context 转发(chat-on-ui-sidebar):AppShell
|
|
1107
|
+
* 内部渲染 ui Sidebar,hook 签名与语义保持不变,调用方零改动。
|
|
1108
|
+
*/
|
|
1039
1109
|
declare function useSidebarDrawer(): {
|
|
1040
1110
|
close: () => void;
|
|
1041
1111
|
collapsed: boolean;
|
|
@@ -1068,12 +1138,14 @@ interface AppShellProps {
|
|
|
1068
1138
|
/**
|
|
1069
1139
|
* AppShell(spec: chat-app-shell):聊天工作区应用外壳 = 侧栏插槽 + 主区。
|
|
1070
1140
|
*
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1141
|
+
* 实现为 ui Sidebar 的薄封装(spec: chat-on-ui-sidebar):桌面(≥768px)
|
|
1142
|
+
* 侧栏与主区 flex 同行;移动端(<768px)侧栏变为覆盖抽屉(遮罩 +
|
|
1143
|
+
* 顶栏菜单按钮);折叠 / 抽屉 / inert 等交互全部由 ui Sidebar 承担,
|
|
1144
|
+
* chat 侧只挂 `pactor-chat-shell` 类做 `--sidebar*` → `--pactor-chat-*`
|
|
1145
|
+
* 令牌映射(皮肤唯一入口仍为 --pactor-chat-*,见 styles.css)与
|
|
1146
|
+
* 高度语义(h-full 填满父容器,嵌入契约)。
|
|
1075
1147
|
*/
|
|
1076
|
-
declare function AppShell({ sidebar, brand, locationKey, sidebarFooter, collapsible, children, className }: AppShellProps): react.JSX.Element;
|
|
1148
|
+
declare function AppShell({ sidebar, brand, locationKey, sidebarFooter, collapsible, children, className, }: AppShellProps): react.JSX.Element;
|
|
1077
1149
|
|
|
1078
1150
|
/**
|
|
1079
1151
|
* 上下文数据源解析与候选列表(spec: chat-context-sources,设计决策 D1/D5):
|
|
@@ -1105,6 +1177,10 @@ type CallChatService = (name: string, params?: Record<string, unknown>) => Promi
|
|
|
1105
1177
|
* 模型 chip(AnchoredPopover 列表,toolbarEnd 之前);contexts 配置
|
|
1106
1178
|
* 且未注入调用方回调时启用内建 @ 提及 / + 菜单弹层,选中项追加为
|
|
1107
1179
|
* 输入区上方的上下文 chips(受控:contextChips + onContextChipsChange)
|
|
1180
|
+
* - chrome DSL 渲染层(spec: chat-composer-on-chatinput):呈现层在
|
|
1181
|
+
* DSL 环境经宿主 ChatInput 组合渲染(非受控 + chat.composerSubmit
|
|
1182
|
+
* 桥接 + 冒泡同步 / 附件承接),无 renderer 或类型缺失时回退手写
|
|
1183
|
+
* 呈现(ComposerFallback),两条路径交互语义一致
|
|
1108
1184
|
*/
|
|
1109
1185
|
interface ComposerProps {
|
|
1110
1186
|
/** 发送回调;输入框在回调后清空 */
|
|
@@ -1126,6 +1202,15 @@ interface ComposerProps {
|
|
|
1126
1202
|
/** 工具栏左 / 右渲染槽 */
|
|
1127
1203
|
toolbarStart?: ReactNode;
|
|
1128
1204
|
toolbarEnd?: ReactNode;
|
|
1205
|
+
/** footer 槽(spec: chat-composer-slots / Composer footer 槽):渲染在工具栏下方、以分隔线相隔;未提供不渲染 */
|
|
1206
|
+
composerFooter?: ReactNode;
|
|
1207
|
+
/**
|
|
1208
|
+
* 隐藏工具栏行(缺省 false):true 时工具栏行整体不渲染——
|
|
1209
|
+
* 内建 + 钮 / 附件钮 / 模型 chip / 发送钮与 toolbarStart / toolbarEnd
|
|
1210
|
+
* 槽一并抑制(footer 槽不受影响);Enter 发送保留,DSL 路径由
|
|
1211
|
+
* ChatInput 工具栏行零渲染承担
|
|
1212
|
+
*/
|
|
1213
|
+
hideToolbar?: boolean;
|
|
1129
1214
|
/** 词边界 `@` 输入触发:query 为 `@` 后文本,anchorRect 为弹层锚点 */
|
|
1130
1215
|
onMentionTrigger?: (query: string, anchorRect: DOMRect) => void;
|
|
1131
1216
|
/** "+" 按钮触发弹层入口 */
|
|
@@ -1152,7 +1237,7 @@ interface ComposerProps {
|
|
|
1152
1237
|
/** service 引用解析出口(ChatServices.callService 透传) */
|
|
1153
1238
|
callService?: CallChatService;
|
|
1154
1239
|
}
|
|
1155
|
-
declare function Composer({ onSend, streaming, onStop, placeholder, disabled, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, onMentionTrigger, onPlusMenu, models, model, onModelChange, contextSources, contextChips, onContextChipsChange, callService, }: ComposerProps): react.JSX.Element;
|
|
1240
|
+
declare function Composer({ onSend, streaming, onStop, placeholder, disabled, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, onMentionTrigger, onPlusMenu, models, model, onModelChange, contextSources, contextChips, onContextChipsChange, callService, composerFooter, hideToolbar, }: ComposerProps): react.JSX.Element;
|
|
1156
1241
|
|
|
1157
1242
|
/**
|
|
1158
1243
|
* ChatView(设计决策 D6):消息列表(useSyncExternalStore 订阅
|
|
@@ -1171,7 +1256,7 @@ declare function Composer({ onSend, streaming, onStop, placeholder, disabled, at
|
|
|
1171
1256
|
* Composer 扩展 props(attachments / onAttachFiles / toolbar 槽 /
|
|
1172
1257
|
* 提及与 "+" 触发等,见 ComposerProps)原样透传给内建 Composer。
|
|
1173
1258
|
*/
|
|
1174
|
-
interface ChatViewProps extends Pick<ComposerProps, 'attachments' | 'onAttachmentsChange' | 'onAttachFiles' | 'onAttachmentClick' | 'toolbarStart' | 'toolbarEnd' | 'onMentionTrigger' | 'onPlusMenu'> {
|
|
1259
|
+
interface ChatViewProps extends Pick<ComposerProps, 'attachments' | 'onAttachmentsChange' | 'onAttachFiles' | 'onAttachmentClick' | 'toolbarStart' | 'toolbarEnd' | 'composerFooter' | 'hideToolbar' | 'onMentionTrigger' | 'onPlusMenu'> {
|
|
1175
1260
|
store: ConversationStore;
|
|
1176
1261
|
/** 注入后发送即驱动 turn;缺省时仅触发 onSend */
|
|
1177
1262
|
transport?: ChatTransport;
|
|
@@ -1233,9 +1318,15 @@ interface ChatViewProps extends Pick<ComposerProps, 'attachments' | 'onAttachmen
|
|
|
1233
1318
|
messageActions?: Array<BuiltinMessageAction | ChatMessageAction>;
|
|
1234
1319
|
/** 全部消息动作(含内建)点击的并行通知(event 语义,不影响内建默认行为) */
|
|
1235
1320
|
onMessageAction?: (actionId: string, message: ChatMessage) => void;
|
|
1321
|
+
/**
|
|
1322
|
+
* Composer 下方自定义内容槽(未提供不渲染):渲染在 Composer 之外、
|
|
1323
|
+
* 页面底部留白区内(空态 / 钉底两态一致),典型用途为免责声明、
|
|
1324
|
+
* 备案信息等弱提示行
|
|
1325
|
+
*/
|
|
1326
|
+
composerBottom?: ReactNode;
|
|
1236
1327
|
className?: string;
|
|
1237
1328
|
}
|
|
1238
|
-
declare function ChatView({ store, transport, onSend, safeRegistry, capabilities, permission, confirm, conversationId, user, params, greeting, subtitle, suggestions, className, onArtifact, onOpenArtifact, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, onMentionTrigger, onPlusMenu, models, model, onModelChange, modelPlacement, contexts, onContextsChange, callService, messageActions, onMessageAction, }: ChatViewProps): react.JSX.Element;
|
|
1329
|
+
declare function ChatView({ store, transport, onSend, safeRegistry, capabilities, permission, confirm, conversationId, user, params, greeting, subtitle, suggestions, className, onArtifact, onOpenArtifact, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, composerFooter, hideToolbar, onMentionTrigger, onPlusMenu, models, model, onModelChange, modelPlacement, contexts, onContextsChange, callService, messageActions, onMessageAction, composerBottom, }: ChatViewProps): react.JSX.Element;
|
|
1239
1330
|
|
|
1240
1331
|
/**
|
|
1241
1332
|
* ActivityTrace(spec: chat-activity-trace,设计决策 D1/D4):
|
|
@@ -1333,10 +1424,6 @@ interface MessageActionsProps {
|
|
|
1333
1424
|
/** 全部动作(含内建)点击的并行通知 */
|
|
1334
1425
|
onMessageAction?: (actionId: string, message: ChatMessage) => void;
|
|
1335
1426
|
}
|
|
1336
|
-
/** 动作图标名 → lucide 子集(白名单式,同菜单 MENU_ICONS 口径;未知名渲染占位图标,不抛错) */
|
|
1337
|
-
declare const MESSAGE_ACTION_ICONS: Record<string, ComponentType<{
|
|
1338
|
-
size?: number;
|
|
1339
|
-
}>>;
|
|
1340
1427
|
/** 收集消息的可复制文本(text / markdown part 按序拼接) */
|
|
1341
1428
|
declare function collectMessageText(message: ChatMessage): string;
|
|
1342
1429
|
declare function MessageActions({ message, actions, showRegenerate, onRegenerate, onEdit, onRetry, forceVisible, callService, onMessageAction, }: MessageActionsProps): react.JSX.Element | null;
|
|
@@ -1388,8 +1475,9 @@ declare function ChatLayout({ title, children }: ChatLayoutProps): react.JSX.Ele
|
|
|
1388
1475
|
declare const CHAT_LAYOUT_TYPE = "chat";
|
|
1389
1476
|
/**
|
|
1390
1477
|
* 结构化 LayoutRegistry(兼容 @pactor-app/ui layout 层的 LayoutRegistry =
|
|
1391
|
-
* Registry<LayoutComponent
|
|
1392
|
-
*
|
|
1478
|
+
* Registry<LayoutComponent>):结构化类型声明,调用方传入 ui layout 层
|
|
1479
|
+
* 的注册表即天然兼容(历史为零依赖约定而设;chat-icon-convergence 起
|
|
1480
|
+
* chat 正式依赖 @pactor-app/ui,本结构化声明保留以收窄本文件的 API 面)。
|
|
1393
1481
|
*/
|
|
1394
1482
|
interface ChatLayoutRegistry {
|
|
1395
1483
|
has(name: string): boolean;
|
|
@@ -1398,4 +1486,4 @@ interface ChatLayoutRegistry {
|
|
|
1398
1486
|
/** 注册 chat 布局(已注册时不覆盖,与 createLayoutRegistry 约定一致) */
|
|
1399
1487
|
declare function registerChatLayout(layoutRegistry: ChatLayoutRegistry): void;
|
|
1400
1488
|
|
|
1401
|
-
export { ActivityTrace, type ActivityTraceProps, AppShell, type AppShellProps, ArtifactPanel, type ArtifactPanelProps, type ArtifactPatch, ArtifactStore, type BuiltinMessageAction, CHAT_COMPONENT_TYPE, CHAT_DENIED_TYPE, CHAT_LAYOUT_TYPE, CHAT_SHELL_COMPONENT_TYPE, type CapabilityActionDeps, type CapabilityHandler, Chat, type ChatArtifact, type ChatAttachment, type ChatCapabilityRegistry, type ChatConfirm, type ChatConfirmRequest, type ChatContextItem, type ChatContextSource, ChatDenied, type ChatEvent, type ChatHeaderAction, type ChatInput, ChatLayout, type ChatLayoutProps, type ChatLayoutRegistry, type ChatMenuItem, type ChatMessage, type ChatMessageAction, type ChatModelOption, type ChatPart, type ChatPermissionChecker, type ChatProps, type ChatRole, type ChatRuntime, type ChatScope, type ChatServices, ChatServicesProvider, ChatShell, type ChatShellProps, ChatSidebarMenu, type ChatSuggestion, type ChatTransport, type ChatTurnResult, ChatView, type ChatViewProps, type ChatWorkspaceProps, type ChatWorkspaceServices, Composer, type ComposerProps, ConversationStore, type CreateChatRuntimeOptions, DEFAULT_CHAT_GREETING, EmptyState, type EmptyStateProps,
|
|
1489
|
+
export { ActivityTrace, type ActivityTraceProps, AppShell, type AppShellProps, ArtifactPanel, type ArtifactPanelProps, type ArtifactPatch, ArtifactStore, type BuiltinMessageAction, CHAT_COMPONENT_TYPE, CHAT_DENIED_TYPE, CHAT_LAYOUT_TYPE, CHAT_SHELL_COMPONENT_TYPE, type CapabilityActionDeps, type CapabilityHandler, Chat, type ChatArtifact, type ChatAttachment, type ChatCapabilityRegistry, type ChatConfirm, type ChatConfirmRequest, type ChatContextItem, type ChatContextSource, ChatDenied, type ChatEvent, type ChatHeaderAction, type ChatInput, ChatLayout, type ChatLayoutProps, type ChatLayoutRegistry, type ChatMenuItem, type ChatMessage, type ChatMessageAction, type ChatModelOption, type ChatPart, type ChatPermissionChecker, type ChatProps, type ChatRole, type ChatRuntime, type ChatScope, type ChatServices, ChatServicesProvider, ChatShell, type ChatShellProps, ChatSidebarMenu, type ChatSuggestion, type ChatTransport, type ChatTurnResult, ChatView, type ChatViewProps, type ChatWorkspaceProps, type ChatWorkspaceServices, Composer, type ComposerProps, ConversationStore, type CreateChatRuntimeOptions, DEFAULT_CHAT_GREETING, EmptyState, type EmptyStateProps, type ManualChatDriver, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, type MessagePatch, type MessageStatus, type PartPatch, type PartRef, PartRenderer, type PartRendererProps, type PartStatus, type RunChatTurnOptions, type StreamingMode, type ToolCallStatus, type ToolTraceEntry, type UseChatAutoScrollOptions, type UseChatAutoScrollResult, type UseSmoothStreamTextOptions, applyChatEvent, buildChatScope, collectMessageText, createChatComponentRegistry, createChatId, createChatRuntime, createChatWorkspace, createManualDriver, createSafeRegistry, detectStreamingMode, guardChatDsl, pairToolTraces, registerCapabilityAction, registerChatComponent, registerChatLayout, registerChatShellComponent, runChatTurn, runRegenerateTurn, useChatAutoScroll, useChatServices, useSidebarDrawer, useSmoothStreamText };
|