@pactor-app/chat 1.15.6 → 1.17.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 +8 -4
- package/dist/index.cjs +1303 -578
- package/dist/index.d.cts +205 -43
- package/dist/index.d.ts +205 -43
- package/dist/index.js +1236 -526
- package/package.json +6 -6
- package/styles.css +322 -29
package/dist/index.d.cts
CHANGED
|
@@ -9,7 +9,9 @@ import { RefObject, ReactNode, ComponentType } from 'react';
|
|
|
9
9
|
*
|
|
10
10
|
* 零 React,可纯 Node 测试;状态语义与 ConversationStore 同模式
|
|
11
11
|
* (不可变更新 + subscribe 通知,兼容 useSyncExternalStore)。
|
|
12
|
-
* store
|
|
12
|
+
* store 持会话内全部产出物列表 + 当前激活项:open 按 id upsert 并
|
|
13
|
+
* 激活;面板 tabs / 目录列表视图经 list() 读取;close 只关闭面板
|
|
14
|
+
* (清空激活项),列表保留供重开时继续切换。
|
|
13
15
|
*/
|
|
14
16
|
/** 产出物:dsl kind 的 content 为 DslNode 普通对象,其余 kind 为字符串 */
|
|
15
17
|
interface ChatArtifact {
|
|
@@ -19,25 +21,85 @@ interface ChatArtifact {
|
|
|
19
21
|
content: string | DslNode;
|
|
20
22
|
/** code kind 的语言标记(仅作角标展示) */
|
|
21
23
|
language?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 文件类型(扩展名,大小写 / 带点均可,如 'png' / '.MD'):
|
|
26
|
+
* 图片类扩展名走内建图片预览(content 为 URL / data URL,
|
|
27
|
+
* svg 另支持原始标记);自定义查看器(artifactViewers)按此键匹配。
|
|
28
|
+
* 缺省从 title 的扩展名推导
|
|
29
|
+
*/
|
|
30
|
+
fileType?: string;
|
|
22
31
|
meta?: Record<string, unknown>;
|
|
23
32
|
}
|
|
33
|
+
/** 内建图片预览的扩展名(小写不带点) */
|
|
34
|
+
declare const ARTIFACT_IMAGE_EXTENSIONS: readonly string[];
|
|
35
|
+
/** 解析产物文件类型:显式 fileType 优先,缺省取 title 扩展名;均无返回 null */
|
|
36
|
+
declare function resolveArtifactFileType(artifact: ChatArtifact): string | null;
|
|
37
|
+
/** 是否图片类产物(扩展名命中内建图片集合) */
|
|
38
|
+
declare function isImageArtifact(artifact: ChatArtifact): boolean;
|
|
39
|
+
/** 产物图标的着色档位(卡片图标底色 / 前景色按 tone 取色) */
|
|
40
|
+
type ArtifactIconTone = 'green' | 'blue' | 'amber' | 'violet' | 'slate';
|
|
41
|
+
/** 产物图标规格:ui Icon 白名单名 + 着色档位 */
|
|
42
|
+
interface ArtifactIconSpec {
|
|
43
|
+
name: string;
|
|
44
|
+
tone: ArtifactIconTone;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 产物图标(图标名 + 着色档位):文件扩展名优先(图片类 → image/violet,
|
|
48
|
+
* 表格 / 数据 / 脚本 / 代码 / 文档按扩展名分桶),无扩展名或未知扩展名
|
|
49
|
+
* 时按 kind 兜底(code → code/blue、dsl → layout-grid/slate、其余
|
|
50
|
+
* file-text 或 file,均 slate)。卡片 / 面板下拉 / 目录树共用,
|
|
51
|
+
* 保证同一产物在各处图标一致。
|
|
52
|
+
*/
|
|
53
|
+
declare function resolveArtifactIcon(artifact: ChatArtifact): ArtifactIconSpec;
|
|
54
|
+
/** 产物图标名(resolveArtifactIcon 的 name 部分,面板下拉 / 目录树用) */
|
|
55
|
+
declare function resolveArtifactIconName(artifact: ChatArtifact): string;
|
|
56
|
+
/** 产物尺寸展示(meta.size 字节数 → "512 B / 3.5 KB / 12.0 MB";非法输入返回 null) */
|
|
57
|
+
declare function formatArtifactSize(size: unknown): string | null;
|
|
24
58
|
/** update 的补丁:id 不可改 */
|
|
25
59
|
type ArtifactPatch = Partial<Omit<ChatArtifact, 'id'>>;
|
|
60
|
+
/** 消息形态的最小契约(与 model.ts ChatMessage 结构化兼容,保持本文件零依赖) */
|
|
61
|
+
interface ArtifactPartCarrier {
|
|
62
|
+
parts: Array<{
|
|
63
|
+
type: string;
|
|
64
|
+
artifact?: ChatArtifact;
|
|
65
|
+
status?: string;
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 从会话消息流归集产出物(tabs / 目录列表视图的默认数据源):
|
|
70
|
+
* 按消息序遍历 artifact part,同 id 后者覆盖(流式更新取最新),
|
|
71
|
+
* 顺序保持首次出现序;streaming 中的 part 跳过(就绪后再入列)。
|
|
72
|
+
* 纯函数,输入消息数组引用不变时结果可经 useMemo 缓存。
|
|
73
|
+
*/
|
|
74
|
+
declare function collectArtifacts(messages: readonly ArtifactPartCarrier[]): ChatArtifact[];
|
|
75
|
+
/**
|
|
76
|
+
* 合并消息流归集与 store 打开记录:stream 顺序为主,冲突 id 取
|
|
77
|
+
* store 版本(store.update 的流式补丁可能领先消息 part),
|
|
78
|
+
* store 中未入流的产物(宿主直接 open 的)追加在后。
|
|
79
|
+
*/
|
|
80
|
+
declare function mergeArtifacts(stream: readonly ChatArtifact[], opened: readonly ChatArtifact[]): ChatArtifact[];
|
|
26
81
|
/**
|
|
27
|
-
* ArtifactStore(设计决策 D1
|
|
82
|
+
* ArtifactStore(设计决策 D1):产出物列表的可变容器。
|
|
28
83
|
* 可注入(services.artifactStore)或由组合层自持(ref 保持)。
|
|
29
84
|
* 对未 open 状态下的 update 宽容:console.warn 并忽略,不抛错。
|
|
85
|
+
* list() 返回的内部数组不可变、引用在不变时保持稳定
|
|
86
|
+
* (useSyncExternalStore 快照安全)。
|
|
30
87
|
*/
|
|
31
88
|
declare class ArtifactStore {
|
|
32
|
-
private
|
|
89
|
+
private artifacts;
|
|
90
|
+
private activeId;
|
|
33
91
|
private readonly listeners;
|
|
34
|
-
/**
|
|
92
|
+
/** 当前激活产出物(未打开时为 null;引用在不变时保持稳定) */
|
|
35
93
|
get(): ChatArtifact | null;
|
|
36
|
-
/**
|
|
94
|
+
/** 全部产出物(插入序;数组不可变,引用稳定) */
|
|
95
|
+
list(): ChatArtifact[];
|
|
96
|
+
/** 打开(或按 id 替换)产出物并激活 */
|
|
37
97
|
open(artifact: ChatArtifact): void;
|
|
38
|
-
/**
|
|
98
|
+
/** 切换激活项(未知 id 告警并忽略,不抛错) */
|
|
99
|
+
activate(id: string): void;
|
|
100
|
+
/** 部分更新当前激活产出物(id 不可改);未 open 时告警并忽略 */
|
|
39
101
|
update(patch: ArtifactPatch): void;
|
|
40
|
-
/**
|
|
102
|
+
/** 关闭面板:清空激活项,列表保留(未打开时幂等,不重复通知) */
|
|
41
103
|
close(): void;
|
|
42
104
|
/** 订阅变更;返回退订函数 */
|
|
43
105
|
subscribe(listener: () => void): () => void;
|
|
@@ -261,6 +323,21 @@ declare class ConversationStore {
|
|
|
261
323
|
private commit;
|
|
262
324
|
}
|
|
263
325
|
|
|
326
|
+
/** 下载文件名:title 已带扩展名原样使用;否则补 fileType / kind 缺省扩展名 */
|
|
327
|
+
declare function resolveArtifactFilename(artifact: ChatArtifact): string;
|
|
328
|
+
/**
|
|
329
|
+
* 构建下载 Blob;图片内容为 http(s) URL 时返回 null(由 downloadArtifact
|
|
330
|
+
* 走 fetch 取回,失败降级新标签打开)
|
|
331
|
+
*/
|
|
332
|
+
declare function buildArtifactBlob(artifact: ChatArtifact): Blob | null;
|
|
333
|
+
/** 触发浏览器下载(Object URL + 临时锚点) */
|
|
334
|
+
declare function saveBlob(blob: Blob, filename: string): void;
|
|
335
|
+
/**
|
|
336
|
+
* 下载产物:文本类 / dsl JSON / 图片 data URL 与 svg 标记直接存 Blob;
|
|
337
|
+
* 图片 http(s) URL fetch 取回(跨域失败降级新标签打开)
|
|
338
|
+
*/
|
|
339
|
+
declare function downloadArtifact(artifact: ChatArtifact): Promise<void>;
|
|
340
|
+
|
|
264
341
|
/**
|
|
265
342
|
* Streaming 事件模型与 reducer(设计决策 D2,设计文档第 69 节)。
|
|
266
343
|
*
|
|
@@ -653,6 +730,77 @@ interface UseChatAutoScrollResult {
|
|
|
653
730
|
}
|
|
654
731
|
declare function useChatAutoScroll({ messageCount, lastContentLength, isStreaming, }: UseChatAutoScrollOptions): UseChatAutoScrollResult;
|
|
655
732
|
|
|
733
|
+
/**
|
|
734
|
+
* ArtifactPanel(spec: chat-artifact-panel,设计决策 D2/D3):
|
|
735
|
+
* 产出物预览面板 = 标题栏(标题 + kind 角标 + 关闭按钮)+ 内容区。
|
|
736
|
+
*
|
|
737
|
+
* 内容按 artifact.kind 分发内建渲染器:markdown 经 @pactor-app/markdown
|
|
738
|
+
* 安全渲染;code 只读代码块(language 仅作角标,不引高亮依赖);
|
|
739
|
+
* text 预格式文本;dsl 经 guardChatDsl 白名单守卫 + renderChildren
|
|
740
|
+
* 活预览(与消息流 dsl part 同安全级),被拦截 / 渲染失败一律降级为
|
|
741
|
+
* 受控占位块(ChatDenied 同款),MUST NOT 抛错。
|
|
742
|
+
*
|
|
743
|
+
* 纯展示组件:关闭只触发 onClose,不单方面修改外部状态。
|
|
744
|
+
*/
|
|
745
|
+
interface ArtifactPanelProps {
|
|
746
|
+
/** 当前产出物;null 时内容区为空态(inspector 槽场景常见) */
|
|
747
|
+
artifact?: ChatArtifact | null;
|
|
748
|
+
/**
|
|
749
|
+
* 会话内全部产出物(多产物场景):提供后 header 左端展示目录列表
|
|
750
|
+
* 切换钮,文件名处展示产物切换下拉
|
|
751
|
+
*/
|
|
752
|
+
artifacts?: ChatArtifact[];
|
|
753
|
+
/** 当前激活产出物 id(下拉高亮;缺省取 artifact.id) */
|
|
754
|
+
activeArtifactId?: string;
|
|
755
|
+
/** 下拉 / 目录列表点击切换回调(受控切换,面板不自改外部状态) */
|
|
756
|
+
onSelectArtifact?: (artifact: ChatArtifact) => void;
|
|
757
|
+
/**
|
|
758
|
+
* 定位产物目录视图的请求信号(卡片区"查看所有产物"):数值变化即
|
|
759
|
+
* 切换列表视图并经 onViewRequestConsumed 消费复位(消费后普通
|
|
760
|
+
* 打开回内容视图)
|
|
761
|
+
*/
|
|
762
|
+
viewRequest?: number | null;
|
|
763
|
+
/** viewRequest 消费回调(组合层复位信号) */
|
|
764
|
+
onViewRequestConsumed?: () => void;
|
|
765
|
+
/** 面板内容槽:提供时整体替代内建渲染器(标题栏保留) */
|
|
766
|
+
inspector?: ReactNode;
|
|
767
|
+
/** 关闭按钮 / 遮罩点击回调 */
|
|
768
|
+
onClose?: () => void;
|
|
769
|
+
/** dsl 产出物活预览的 Safe Registry;缺省时 dsl 内容渲染降级块 */
|
|
770
|
+
safeRegistry?: Registry<unknown>;
|
|
771
|
+
/** 注入 dsl 预览作用域 user */
|
|
772
|
+
user?: Record<string, unknown>;
|
|
773
|
+
/**
|
|
774
|
+
* 自定义产物查看器(spec: chat-artifact-panel / 自定义预览):
|
|
775
|
+
* 按扩展名 / kind 对特定文件格式提供自定义预览,优先于内建渲染器
|
|
776
|
+
*/
|
|
777
|
+
artifactViewers?: ArtifactViewers;
|
|
778
|
+
className?: string;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* 产物目录树(纯函数):按 id 的 '/' 分段建目录层级——
|
|
782
|
+
* id 形如 `reports/q3/月报` 时产出 reports → q3 两级目录;
|
|
783
|
+
* 无 '/' 分段的产物平铺在根层。目录先于文件、各自按名称排序。
|
|
784
|
+
*/
|
|
785
|
+
interface ArtifactTreeNode {
|
|
786
|
+
/** 段名(目录名或产物标题) */
|
|
787
|
+
name: string;
|
|
788
|
+
/** 完整路径(目录为 id 前缀,文件为产物 id) */
|
|
789
|
+
path: string;
|
|
790
|
+
artifact?: ChatArtifact;
|
|
791
|
+
children: ArtifactTreeNode[];
|
|
792
|
+
}
|
|
793
|
+
declare function buildArtifactTree(artifacts: ChatArtifact[]): ArtifactTreeNode[];
|
|
794
|
+
/**
|
|
795
|
+
* 自定义产物查看器(spec: chat-artifact-panel / 自定义预览):
|
|
796
|
+
* 键为扩展名(小写不带点,如 'png' / 'md')或 kind
|
|
797
|
+
* ('markdown' / 'code' / 'text' / 'dsl');扩展名键优先于 kind 键,
|
|
798
|
+
* 均优先于内建渲染器。查看器抛错不经守卫——宿主代码自负。
|
|
799
|
+
*/
|
|
800
|
+
type ArtifactViewer = (artifact: ChatArtifact) => ReactNode;
|
|
801
|
+
type ArtifactViewers = Record<string, ArtifactViewer>;
|
|
802
|
+
declare function ArtifactPanel({ artifact, artifacts, activeArtifactId, onSelectArtifact, viewRequest, onViewRequestConsumed, inspector, onClose, safeRegistry, user, artifactViewers, className, }: ArtifactPanelProps): ReactNode;
|
|
803
|
+
|
|
656
804
|
/**
|
|
657
805
|
* EmptyState(spec: chat-empty-state,设计决策 D0/D1):空会话欢迎页。
|
|
658
806
|
*
|
|
@@ -716,6 +864,12 @@ interface ChatWorkspaceServices {
|
|
|
716
864
|
storeFactory?: () => ConversationStore;
|
|
717
865
|
/** 产出物面板 store(spec: chat-artifact-panel);缺省包内默认构造 */
|
|
718
866
|
artifactStore?: ArtifactStore;
|
|
867
|
+
/**
|
|
868
|
+
* 自定义产物查看器(spec: chat-artifact-panel / 自定义预览):
|
|
869
|
+
* 按键(扩展名小写不带点,或 kind)对特定文件格式提供自定义预览,
|
|
870
|
+
* 优先于内建渲染器;函数不进 DSL props,统一经服务注入
|
|
871
|
+
*/
|
|
872
|
+
artifactViewers?: ArtifactViewers;
|
|
719
873
|
/** Safe Registry(createSafeRegistry 包装后的白名单注册表) */
|
|
720
874
|
safeRegistry?: Registry<unknown>;
|
|
721
875
|
/** capability 白名单与确认链 */
|
|
@@ -805,6 +959,14 @@ interface ChatWorkspaceProps {
|
|
|
805
959
|
onArtifact?: (artifact: ChatArtifact) => void;
|
|
806
960
|
/** 产出物卡片"在面板中打开"回调(runtime 绑定 events.onOpenArtifact 时传入) */
|
|
807
961
|
onOpenArtifact?: (artifact: ChatArtifact) => void;
|
|
962
|
+
/** 卡片区"查看所有产物"回调(runtime 绑定 events.onOpenArtifactList 时传入) */
|
|
963
|
+
onOpenArtifactList?: () => void;
|
|
964
|
+
/**
|
|
965
|
+
* 面板 tab / 目录列表点击切换回调(runtime 绑定 events.onSelectArtifact
|
|
966
|
+
* 时传入;受控典型接法:setState artifact=${event.artifact})。
|
|
967
|
+
* 多产物列表缺省由组合层从消息流归集,无需显式注入
|
|
968
|
+
*/
|
|
969
|
+
onSelectArtifact?: (artifact: ChatArtifact) => void;
|
|
808
970
|
/**
|
|
809
971
|
* 内建 header 操作组(spec: chat-dsl-component / Header 配置,决策 D4):
|
|
810
972
|
* 按数组顺序渲染(headerExtra 槽之前);缺省不渲染
|
|
@@ -981,6 +1143,10 @@ interface ChatProps {
|
|
|
981
1143
|
onArtifact?: (artifact: ChatArtifact) => void;
|
|
982
1144
|
/** 产出物卡片"在面板中打开"按钮点击回调(event 作用域含 artifact;受控场景的开面板入口) */
|
|
983
1145
|
onOpenArtifact?: (artifact: ChatArtifact) => void;
|
|
1146
|
+
/** 卡片区"查看所有产物"点击回调(event 为空对象 {};受控典型接法:setState panelOpen=true,面板自动定位产物目录视图) */
|
|
1147
|
+
onOpenArtifactList?: () => void;
|
|
1148
|
+
/** 面板 tab / 目录列表点击切换回调(event 作用域含 artifact;受控典型接法:setState artifact=${event.artifact}) */
|
|
1149
|
+
onSelectArtifact?: (artifact: ChatArtifact) => void;
|
|
984
1150
|
className?: string;
|
|
985
1151
|
/** 发送回调:与 transport 驱动 turn 并行(同 ChatView onSend 语义) */
|
|
986
1152
|
onSend?: (text: string) => void;
|
|
@@ -1010,7 +1176,7 @@ declare function ChatSidebarMenu({ menu, activeMenuKey, onMenuSelect, }: {
|
|
|
1010
1176
|
* 「未配置聊天服务」提示并 console.warn,不抛错。组合逻辑与
|
|
1011
1177
|
* createChatWorkspace 共用内部 ChatComposition(决策 D5)。
|
|
1012
1178
|
*/
|
|
1013
|
-
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;
|
|
1179
|
+
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, onOpenArtifactList, onSelectArtifact, className, onSend, onMenuSelect, }: ChatProps): ReactNode;
|
|
1014
1180
|
/** Chat 的 DSL 组件类型名 */
|
|
1015
1181
|
declare const CHAT_COMPONENT_TYPE = "Chat";
|
|
1016
1182
|
/**
|
|
@@ -1074,31 +1240,22 @@ declare const CHAT_SHELL_COMPONENT_TYPE = "ChatShell";
|
|
|
1074
1240
|
declare function registerChatShellComponent(registry: Registry<unknown>): void;
|
|
1075
1241
|
|
|
1076
1242
|
/**
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1243
|
+
* artifact 卡片(spec: chat-chrome-dsl / chat-artifact-panel):
|
|
1244
|
+
* 整卡可点击的产物卡片——文件类型图标(着色图标盒,扩展名优先
|
|
1245
|
+
* kind 兜底)+ 标题 + 元信息行(尺寸 · 类型标签)+ 右上箭头,
|
|
1246
|
+
* 点击经 invokeChatOpenArtifact 走 chat.openArtifact 同一 handlers
|
|
1247
|
+
* 注册表(DSL 片段与 fallback 共用本组件,行为零分叉)。
|
|
1079
1248
|
*
|
|
1080
|
-
*
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1083
|
-
* 活预览(与消息流 dsl part 同安全级),被拦截 / 渲染失败一律降级为
|
|
1084
|
-
* 受控占位块(ChatDenied 同款),MUST NOT 抛错。
|
|
1085
|
-
*
|
|
1086
|
-
* 纯展示组件:关闭只触发 onClose,不单方面修改外部状态。
|
|
1249
|
+
* 图标盒按文件类型着色(tone:表格 green / 数据 amber / 代码 blue /
|
|
1250
|
+
* 图片 violet / 文档与兜底 slate),修饰类
|
|
1251
|
+
* pactor-chat-artifact-card--{tone} 挂在卡片根上。
|
|
1087
1252
|
*/
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
onClose?: () => void;
|
|
1095
|
-
/** dsl 产出物活预览的 Safe Registry;缺省时 dsl 内容渲染降级块 */
|
|
1096
|
-
safeRegistry?: Registry<unknown>;
|
|
1097
|
-
/** 注入 dsl 预览作用域 user */
|
|
1098
|
-
user?: Record<string, unknown>;
|
|
1099
|
-
className?: string;
|
|
1100
|
-
}
|
|
1101
|
-
declare function ArtifactPanel({ artifact, inspector, onClose, safeRegistry, user, className, }: ArtifactPanelProps): ReactNode;
|
|
1253
|
+
/** 卡片元信息行:尺寸(meta.size 字节数)· 类型标签(扩展名大写,缺省 kind 大写) */
|
|
1254
|
+
declare function artifactCardMeta(artifact: ChatArtifact): string;
|
|
1255
|
+
/** 产物卡片本体(chat 内部组件,DSL 片段与 fallback 共用) */
|
|
1256
|
+
declare function ChatArtifactCard({ artifact, }: {
|
|
1257
|
+
artifact: ChatArtifact;
|
|
1258
|
+
}): ReactNode;
|
|
1102
1259
|
|
|
1103
1260
|
/**
|
|
1104
1261
|
* 侧栏抽屉 context(spec: chat-app-shell):侧栏内容(如导航项)在导航后
|
|
@@ -1287,8 +1444,10 @@ interface ChatViewProps extends Pick<ComposerProps, 'attachments' | 'onAttachmen
|
|
|
1287
1444
|
* 产出物事件);同一 part 只触发一次,框架不擅自打开面板
|
|
1288
1445
|
*/
|
|
1289
1446
|
onArtifact?: (artifact: ChatArtifact) => void;
|
|
1290
|
-
/** artifact 卡片"在面板中打开"
|
|
1447
|
+
/** artifact 卡片"在面板中打开"回调(整卡点击,经包级 handlers 桥接) */
|
|
1291
1448
|
onOpenArtifact?: (artifact: ChatArtifact) => void;
|
|
1449
|
+
/** 卡片区"查看所有产物"回调(打开面板并定位产物目录视图) */
|
|
1450
|
+
onOpenArtifactList?: () => void;
|
|
1292
1451
|
/**
|
|
1293
1452
|
* 内建模型选择(spec: chat-model-selector,决策 D5):
|
|
1294
1453
|
* `model` + `onModelChange` 同时提供即受控(以 props 为准);
|
|
@@ -1330,7 +1489,7 @@ interface ChatViewProps extends Pick<ComposerProps, 'attachments' | 'onAttachmen
|
|
|
1330
1489
|
composerBottom?: ReactNode;
|
|
1331
1490
|
className?: string;
|
|
1332
1491
|
}
|
|
1333
|
-
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;
|
|
1492
|
+
declare function ChatView({ store, transport, onSend, safeRegistry, capabilities, permission, confirm, conversationId, user, params, greeting, subtitle, suggestions, className, onArtifact, onOpenArtifact, onOpenArtifactList, attachments, onAttachmentsChange, onAttachFiles, onAttachmentClick, toolbarStart, toolbarEnd, composerFooter, hideToolbar, onMentionTrigger, onPlusMenu, models, model, onModelChange, modelPlacement, contexts, onContextsChange, callService, messageActions, onMessageAction, composerBottom, }: ChatViewProps): react.JSX.Element;
|
|
1334
1493
|
|
|
1335
1494
|
/**
|
|
1336
1495
|
* ActivityTrace(spec: chat-activity-trace,设计决策 D1/D4):
|
|
@@ -1346,7 +1505,9 @@ declare function ChatView({ store, transport, onSend, safeRegistry, capabilities
|
|
|
1346
1505
|
* 答案阶段自动折叠,用户操作后 pin。
|
|
1347
1506
|
*
|
|
1348
1507
|
* 折叠状态机(每条消息独立,随组件实例记忆):`auto | pinned-open |
|
|
1349
|
-
* pinned-closed`——auto
|
|
1508
|
+
* pinned-closed`——auto 跟随流式阶段但带单向闩锁(自动折叠一次后
|
|
1509
|
+
* 不再自动展开,防止 mode 回跳引起展开/折叠闪烁);用户点击后 pin,
|
|
1510
|
+
* 不再自动变更。
|
|
1350
1511
|
*/
|
|
1351
1512
|
interface ActivityTraceProps {
|
|
1352
1513
|
message: ChatMessage;
|
|
@@ -1388,10 +1549,13 @@ interface MessageBubbleProps {
|
|
|
1388
1549
|
callService?: CallChatService;
|
|
1389
1550
|
/** 全部动作(含内建)点击的并行通知 */
|
|
1390
1551
|
onMessageAction?: (actionId: string, message: ChatMessage) => void;
|
|
1391
|
-
/** artifact 卡片"在面板中打开"回调(透传 PartRenderer) */
|
|
1392
|
-
onOpenArtifact?: (artifact: ChatArtifact) => void;
|
|
1393
1552
|
}
|
|
1394
|
-
|
|
1553
|
+
/**
|
|
1554
|
+
* 消息时间格式化(assistant 消息底部时间戳):
|
|
1555
|
+
* 当天 HH:mm;非当天 M月d日 HH:mm
|
|
1556
|
+
*/
|
|
1557
|
+
declare function formatMessageTime(ts: number, now?: number): string;
|
|
1558
|
+
declare function MessageBubble({ message, runtime, scope, showRegenerate, onRegenerate, onRetry, onEditResend, messageActions, callService, onMessageAction, }: MessageBubbleProps): react.JSX.Element;
|
|
1395
1559
|
|
|
1396
1560
|
/**
|
|
1397
1561
|
* MessageActions(spec: chat-message-actions / 消息操作条):
|
|
@@ -1445,8 +1609,8 @@ declare function MessageActions({ message, actions, showRegenerate, onRegenerate
|
|
|
1445
1609
|
* - tool-call / tool-result / thinking → 不在此渲染(由 assistant 消息
|
|
1446
1610
|
* 顶部的 ActivityTrace 配对 / 折叠呈现,见 chat-activity-trace)
|
|
1447
1611
|
* - error → 自绘警示条;status → 弱提示文本
|
|
1448
|
-
* - artifact →
|
|
1449
|
-
* spec: chat-artifact-panel)
|
|
1612
|
+
* - artifact → 产出物卡片(ChatArtifactCard 内部组件:着色图标盒 +
|
|
1613
|
+
* 标题 + 元信息 + 右上箭头,整卡点击打开面板,spec: chat-artifact-panel)
|
|
1450
1614
|
*
|
|
1451
1615
|
* 视图零 antd 依赖,颜色经 `@pactor-app/chat/styles.css` 的
|
|
1452
1616
|
* `--pactor-chat-*` 变量表达。
|
|
@@ -1459,14 +1623,12 @@ interface PartRendererProps {
|
|
|
1459
1623
|
scope?: ChatScope;
|
|
1460
1624
|
/** 所属消息是否流式中(text/markdown 启用平滑揭示) */
|
|
1461
1625
|
streaming?: boolean;
|
|
1462
|
-
/** artifact 卡片"在面板中打开"回调(spec: chat-artifact-panel) */
|
|
1463
|
-
onOpenArtifact?: (artifact: ChatArtifact) => void;
|
|
1464
1626
|
}
|
|
1465
1627
|
/** 白名单外组件的受控占位(注册名 ChatDenied,见 dsl-guard) */
|
|
1466
1628
|
declare function ChatDenied({ deniedType }: {
|
|
1467
1629
|
deniedType?: string;
|
|
1468
1630
|
}): react.JSX.Element;
|
|
1469
|
-
declare function PartRenderer({ part, runtime, scope, streaming
|
|
1631
|
+
declare function PartRenderer({ part, runtime, scope, streaming }: PartRendererProps): react.JSX.Element | null;
|
|
1470
1632
|
|
|
1471
1633
|
/**
|
|
1472
1634
|
* ChatLayout(设计决策 D6):chat 布局 = header(title)+ ChatView 区。
|
|
@@ -1493,4 +1655,4 @@ interface ChatLayoutRegistry {
|
|
|
1493
1655
|
/** 注册 chat 布局(已注册时不覆盖,与 createLayoutRegistry 约定一致) */
|
|
1494
1656
|
declare function registerChatLayout(layoutRegistry: ChatLayoutRegistry): void;
|
|
1495
1657
|
|
|
1496
|
-
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 };
|
|
1658
|
+
export { ARTIFACT_IMAGE_EXTENSIONS, ActivityTrace, type ActivityTraceProps, AppShell, type AppShellProps, type ArtifactIconSpec, type ArtifactIconTone, ArtifactPanel, type ArtifactPanelProps, type ArtifactPatch, ArtifactStore, type ArtifactTreeNode, type ArtifactViewer, type ArtifactViewers, type BuiltinMessageAction, CHAT_COMPONENT_TYPE, CHAT_DENIED_TYPE, CHAT_LAYOUT_TYPE, CHAT_SHELL_COMPONENT_TYPE, type CapabilityActionDeps, type CapabilityHandler, Chat, type ChatArtifact, ChatArtifactCard, 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, artifactCardMeta, buildArtifactBlob, buildArtifactTree, buildChatScope, collectArtifacts, collectMessageText, createChatComponentRegistry, createChatId, createChatRuntime, createChatWorkspace, createManualDriver, createSafeRegistry, detectStreamingMode, downloadArtifact, formatArtifactSize, formatMessageTime, guardChatDsl, isImageArtifact, mergeArtifacts, pairToolTraces, registerCapabilityAction, registerChatComponent, registerChatLayout, registerChatShellComponent, resolveArtifactFileType, resolveArtifactFilename, resolveArtifactIcon, resolveArtifactIconName, runChatTurn, runRegenerateTurn, saveBlob, useChatAutoScroll, useChatServices, useSidebarDrawer, useSmoothStreamText };
|