@pactor-app/chat 1.43.0 → 1.46.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/dist/chunk-TBPUSGKL.js +2633 -0
- package/dist/components/index.cjs +2651 -0
- package/dist/components/index.d.cts +793 -0
- package/dist/components/index.d.ts +793 -0
- package/dist/components/index.js +52 -0
- package/dist/download-DnP2uArc.d.cts +134 -0
- package/dist/download-DnP2uArc.d.ts +134 -0
- package/dist/index.cjs +3876 -1685
- package/dist/index.d.cts +41 -69
- package/dist/index.d.ts +41 -69
- package/dist/index.js +624 -1002
- package/package.json +28 -10
- package/styles.css +1154 -844
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentStatus,
|
|
3
|
+
ArtifactPanel,
|
|
4
|
+
Attachment,
|
|
5
|
+
Bubble,
|
|
6
|
+
ChatMessage,
|
|
7
|
+
ChatPage,
|
|
8
|
+
Citation,
|
|
9
|
+
Composer,
|
|
10
|
+
ConversationList,
|
|
11
|
+
MessageList,
|
|
12
|
+
Prompt,
|
|
13
|
+
Sender,
|
|
14
|
+
StepsPanel,
|
|
15
|
+
StreamingText,
|
|
16
|
+
Suggestion,
|
|
17
|
+
Thinking,
|
|
18
|
+
ToolCall,
|
|
19
|
+
Welcome,
|
|
20
|
+
buildArtifactBlob,
|
|
21
|
+
buildArtifactTree,
|
|
22
|
+
downloadArtifact,
|
|
23
|
+
registerChatComponents,
|
|
24
|
+
resolveArtifactFilename,
|
|
25
|
+
saveBlob
|
|
26
|
+
} from "../chunk-TBPUSGKL.js";
|
|
27
|
+
export {
|
|
28
|
+
AgentStatus,
|
|
29
|
+
ArtifactPanel,
|
|
30
|
+
Attachment,
|
|
31
|
+
Bubble,
|
|
32
|
+
ChatMessage,
|
|
33
|
+
ChatPage,
|
|
34
|
+
Citation,
|
|
35
|
+
Composer,
|
|
36
|
+
ConversationList,
|
|
37
|
+
MessageList,
|
|
38
|
+
Prompt,
|
|
39
|
+
Sender,
|
|
40
|
+
StepsPanel,
|
|
41
|
+
StreamingText,
|
|
42
|
+
Suggestion,
|
|
43
|
+
Thinking,
|
|
44
|
+
ToolCall,
|
|
45
|
+
Welcome,
|
|
46
|
+
buildArtifactBlob,
|
|
47
|
+
buildArtifactTree,
|
|
48
|
+
downloadArtifact,
|
|
49
|
+
registerChatComponents,
|
|
50
|
+
resolveArtifactFilename,
|
|
51
|
+
saveBlob
|
|
52
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { DslNode, Registry } from '@pactor-app/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ArtifactPanel 产物模型与纯函数助手(自 @pactor-app/chat 的 artifact 模型
|
|
7
|
+
* 移植面板所需子集):零 React,可纯 Node 测试。
|
|
8
|
+
*/
|
|
9
|
+
/** 产物:dsl kind 的 content 为 DslNode 普通对象,其余 kind 为字符串 */
|
|
10
|
+
interface ChatPageArtifact {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: 'markdown' | 'code' | 'text' | 'dsl';
|
|
13
|
+
title: string;
|
|
14
|
+
content: string | DslNode;
|
|
15
|
+
/** code kind 的语言标记(角标 / CodeBlock 高亮) */
|
|
16
|
+
language?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 文件类型(扩展名,大小写 / 带点均可,如 'png' / '.MD'):
|
|
19
|
+
* 图片类扩展名走内建图片预览(content 为 URL / data URL,
|
|
20
|
+
* svg 另支持原始标记);自定义查看器(artifactViewers)按此键匹配。
|
|
21
|
+
* 缺省从 title 的扩展名推导
|
|
22
|
+
*/
|
|
23
|
+
fileType?: string;
|
|
24
|
+
meta?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/** 产物目录树节点(buildArtifactTree 产出) */
|
|
27
|
+
interface ArtifactTreeNode {
|
|
28
|
+
/** 段名(目录名或产物标题) */
|
|
29
|
+
name: string;
|
|
30
|
+
/** 完整路径(目录为 id 前缀,文件为产物 id) */
|
|
31
|
+
path: string;
|
|
32
|
+
artifact?: ChatPageArtifact;
|
|
33
|
+
children: ArtifactTreeNode[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 产物目录树(纯函数):按 id 的 '/' 分段建目录层级——
|
|
37
|
+
* id 形如 `reports/q3/月报` 时产出 reports → q3 两级目录;
|
|
38
|
+
* 无 '/' 分段的产物平铺在根层。目录先于文件、各自按名称排序。
|
|
39
|
+
*/
|
|
40
|
+
declare function buildArtifactTree(artifacts: ChatPageArtifact[]): ArtifactTreeNode[];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 自定义产物查看器:键为扩展名(小写不带点,如 'png' / 'md')或 kind
|
|
44
|
+
* ('markdown' / 'code' / 'text' / 'dsl');扩展名键优先于 kind 键,
|
|
45
|
+
* 均优先于内建渲染器。查看器抛错不经守卫——宿主代码自负。
|
|
46
|
+
*/
|
|
47
|
+
type ArtifactViewer = (artifact: ChatPageArtifact) => ReactNode;
|
|
48
|
+
type ArtifactViewers = Record<string, ArtifactViewer>;
|
|
49
|
+
interface ArtifactPanelProps {
|
|
50
|
+
/** 当前产物;空时内容区展示 emptyText 空态 */
|
|
51
|
+
artifact?: ChatPageArtifact | null;
|
|
52
|
+
/** 会话内全部产物:提供后 header 左端展示目录列表切换钮,标题处展示产物切换下拉 */
|
|
53
|
+
artifacts?: ChatPageArtifact[];
|
|
54
|
+
/** 当前激活产物 id(下拉高亮;缺省取 artifact.id) */
|
|
55
|
+
activeArtifactId?: string;
|
|
56
|
+
/** 下拉 / 目录列表点击切换事件,传出产物 id(受控切换,面板不自改外部状态) */
|
|
57
|
+
onSelectArtifact?: (id: string) => void;
|
|
58
|
+
/** 标题兜底(无当前产物时展示,如「产物」) */
|
|
59
|
+
title?: string;
|
|
60
|
+
/** 无产物空态文案 */
|
|
61
|
+
emptyText?: string;
|
|
62
|
+
/**
|
|
63
|
+
* 面板内容槽:提供时整体替代内容区内建渲染(标题栏保留;
|
|
64
|
+
* 目录列表视图优先于 inspector)
|
|
65
|
+
*/
|
|
66
|
+
inspector?: ReactNode;
|
|
67
|
+
/** 标题栏槽:提供时整体替代内建标题栏(宿主接管 header 呈现与行为) */
|
|
68
|
+
header?: ReactNode;
|
|
69
|
+
/** 视图受控('content' 内容 / 'list' 目录列表);提供即受控,切换经 onViewChange 传出 */
|
|
70
|
+
view?: "content" | "list";
|
|
71
|
+
/** 视图切换事件(目录钮 / 激活产物变化复位 / viewRequest 定位均经此传出) */
|
|
72
|
+
onViewChange?: (view: "content" | "list") => void;
|
|
73
|
+
/**
|
|
74
|
+
* 定位产物目录视图的请求信号(如卡片区「查看所有产物」):数值变化
|
|
75
|
+
* 即切换列表视图并经 onViewRequestConsumed 消费复位(消费后普通
|
|
76
|
+
* 打开回内容视图)
|
|
77
|
+
*/
|
|
78
|
+
viewRequest?: number | null;
|
|
79
|
+
/** viewRequest 消费回调(组合层复位信号) */
|
|
80
|
+
onViewRequestConsumed?: () => void;
|
|
81
|
+
/**
|
|
82
|
+
* 面板左缘拖拽调宽手柄(缺省 false):pointer 拖拽实时改宽,结果
|
|
83
|
+
* 内部自持(inline width 覆盖),不向外部受控
|
|
84
|
+
*/
|
|
85
|
+
resizable?: boolean;
|
|
86
|
+
/** 关闭按钮事件 */
|
|
87
|
+
onClose?: () => void;
|
|
88
|
+
/** 下载事件;缺省内部走浏览器下载(downloadArtifact) */
|
|
89
|
+
onDownload?: (artifact: ChatPageArtifact) => void;
|
|
90
|
+
/** dsl 产物活预览的 Safe Registry;缺省时 dsl 内容渲染降级块 */
|
|
91
|
+
safeRegistry?: Registry<unknown>;
|
|
92
|
+
/** 注入 dsl 预览作用域 user */
|
|
93
|
+
user?: Record<string, unknown>;
|
|
94
|
+
/** 自定义产物查看器(扩展名 / kind → 预览),优先于内建渲染器 */
|
|
95
|
+
artifactViewers?: ArtifactViewers;
|
|
96
|
+
/** 通用:根节点 class(与内置样式合并) */
|
|
97
|
+
className?: string;
|
|
98
|
+
/** 通用:根节点内联样式 */
|
|
99
|
+
style?: CSSProperties;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* ArtifactPanel 产物预览面板(shadcn kit;功能移植自 @pactor-app/chat
|
|
103
|
+
* 的 ArtifactPanel):标题栏(目录列表切换钮 + 标题 / 产物切换下拉 +
|
|
104
|
+
* kind 角标 + 下载钮 + 关闭钮)+ 内容区。
|
|
105
|
+
*
|
|
106
|
+
* 内容按 artifact.kind 分发内建渲染器:markdown 安全渲染;code 经
|
|
107
|
+
* CodeBlock;text 预格式文本;dsl 经白名单守卫 + 活预览,被拦截 /
|
|
108
|
+
* 渲染失败一律降级为受控占位块,MUST NOT 抛错。图片类产物(扩展名
|
|
109
|
+
* 识别)走内建 <img> 预览。inspector 槽提供时整体替代内容区内建
|
|
110
|
+
* 渲染(目录列表视图优先);header 槽提供时整体替代内建标题栏;
|
|
111
|
+
* view / onViewChange 提供时目录列表视图受控;viewRequest 信号到达
|
|
112
|
+
* 即定位目录列表视图并经 onViewRequestConsumed 消费复位;resizable
|
|
113
|
+
* 时左缘渲染拖拽调宽手柄(宽度内部自持)。数据与行为全部经 props /
|
|
114
|
+
* events 进出,面板不持有业务状态(列表 / 内容视图与目录折叠为内部
|
|
115
|
+
* 展示状态)。
|
|
116
|
+
*/
|
|
117
|
+
declare function ArtifactPanel({ artifact, artifacts, activeArtifactId, onSelectArtifact, title, emptyText, inspector, header, view: viewProp, onViewChange, viewRequest, onViewRequestConsumed, resizable, onClose, onDownload, safeRegistry, user, artifactViewers, className, style, }: ArtifactPanelProps): react.JSX.Element;
|
|
118
|
+
|
|
119
|
+
/** 下载文件名:title 已带扩展名原样使用;否则补 fileType / kind 缺省扩展名 */
|
|
120
|
+
declare function resolveArtifactFilename(artifact: ChatPageArtifact): string;
|
|
121
|
+
/**
|
|
122
|
+
* 构建下载 Blob;图片内容为 http(s) URL 时返回 null(由 downloadArtifact
|
|
123
|
+
* 走 fetch 取回,失败降级新标签打开)
|
|
124
|
+
*/
|
|
125
|
+
declare function buildArtifactBlob(artifact: ChatPageArtifact): Blob | null;
|
|
126
|
+
/** 触发浏览器下载(Object URL + 临时锚点) */
|
|
127
|
+
declare function saveBlob(blob: Blob, filename: string): void;
|
|
128
|
+
/**
|
|
129
|
+
* 下载产物:文本类 / dsl JSON / 图片 data URL 与 svg 标记直接存 Blob;
|
|
130
|
+
* 图片 http(s) URL fetch 取回(跨域失败降级新标签打开)
|
|
131
|
+
*/
|
|
132
|
+
declare function downloadArtifact(artifact: ChatPageArtifact): Promise<void>;
|
|
133
|
+
|
|
134
|
+
export { type ArtifactViewers as A, type ChatPageArtifact as C, ArtifactPanel as a, type ArtifactPanelProps as b, type ArtifactTreeNode as c, type ArtifactViewer as d, buildArtifactBlob as e, buildArtifactTree as f, downloadArtifact as g, resolveArtifactFilename as r, saveBlob as s };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { DslNode, Registry } from '@pactor-app/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ArtifactPanel 产物模型与纯函数助手(自 @pactor-app/chat 的 artifact 模型
|
|
7
|
+
* 移植面板所需子集):零 React,可纯 Node 测试。
|
|
8
|
+
*/
|
|
9
|
+
/** 产物:dsl kind 的 content 为 DslNode 普通对象,其余 kind 为字符串 */
|
|
10
|
+
interface ChatPageArtifact {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: 'markdown' | 'code' | 'text' | 'dsl';
|
|
13
|
+
title: string;
|
|
14
|
+
content: string | DslNode;
|
|
15
|
+
/** code kind 的语言标记(角标 / CodeBlock 高亮) */
|
|
16
|
+
language?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 文件类型(扩展名,大小写 / 带点均可,如 'png' / '.MD'):
|
|
19
|
+
* 图片类扩展名走内建图片预览(content 为 URL / data URL,
|
|
20
|
+
* svg 另支持原始标记);自定义查看器(artifactViewers)按此键匹配。
|
|
21
|
+
* 缺省从 title 的扩展名推导
|
|
22
|
+
*/
|
|
23
|
+
fileType?: string;
|
|
24
|
+
meta?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/** 产物目录树节点(buildArtifactTree 产出) */
|
|
27
|
+
interface ArtifactTreeNode {
|
|
28
|
+
/** 段名(目录名或产物标题) */
|
|
29
|
+
name: string;
|
|
30
|
+
/** 完整路径(目录为 id 前缀,文件为产物 id) */
|
|
31
|
+
path: string;
|
|
32
|
+
artifact?: ChatPageArtifact;
|
|
33
|
+
children: ArtifactTreeNode[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 产物目录树(纯函数):按 id 的 '/' 分段建目录层级——
|
|
37
|
+
* id 形如 `reports/q3/月报` 时产出 reports → q3 两级目录;
|
|
38
|
+
* 无 '/' 分段的产物平铺在根层。目录先于文件、各自按名称排序。
|
|
39
|
+
*/
|
|
40
|
+
declare function buildArtifactTree(artifacts: ChatPageArtifact[]): ArtifactTreeNode[];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 自定义产物查看器:键为扩展名(小写不带点,如 'png' / 'md')或 kind
|
|
44
|
+
* ('markdown' / 'code' / 'text' / 'dsl');扩展名键优先于 kind 键,
|
|
45
|
+
* 均优先于内建渲染器。查看器抛错不经守卫——宿主代码自负。
|
|
46
|
+
*/
|
|
47
|
+
type ArtifactViewer = (artifact: ChatPageArtifact) => ReactNode;
|
|
48
|
+
type ArtifactViewers = Record<string, ArtifactViewer>;
|
|
49
|
+
interface ArtifactPanelProps {
|
|
50
|
+
/** 当前产物;空时内容区展示 emptyText 空态 */
|
|
51
|
+
artifact?: ChatPageArtifact | null;
|
|
52
|
+
/** 会话内全部产物:提供后 header 左端展示目录列表切换钮,标题处展示产物切换下拉 */
|
|
53
|
+
artifacts?: ChatPageArtifact[];
|
|
54
|
+
/** 当前激活产物 id(下拉高亮;缺省取 artifact.id) */
|
|
55
|
+
activeArtifactId?: string;
|
|
56
|
+
/** 下拉 / 目录列表点击切换事件,传出产物 id(受控切换,面板不自改外部状态) */
|
|
57
|
+
onSelectArtifact?: (id: string) => void;
|
|
58
|
+
/** 标题兜底(无当前产物时展示,如「产物」) */
|
|
59
|
+
title?: string;
|
|
60
|
+
/** 无产物空态文案 */
|
|
61
|
+
emptyText?: string;
|
|
62
|
+
/**
|
|
63
|
+
* 面板内容槽:提供时整体替代内容区内建渲染(标题栏保留;
|
|
64
|
+
* 目录列表视图优先于 inspector)
|
|
65
|
+
*/
|
|
66
|
+
inspector?: ReactNode;
|
|
67
|
+
/** 标题栏槽:提供时整体替代内建标题栏(宿主接管 header 呈现与行为) */
|
|
68
|
+
header?: ReactNode;
|
|
69
|
+
/** 视图受控('content' 内容 / 'list' 目录列表);提供即受控,切换经 onViewChange 传出 */
|
|
70
|
+
view?: "content" | "list";
|
|
71
|
+
/** 视图切换事件(目录钮 / 激活产物变化复位 / viewRequest 定位均经此传出) */
|
|
72
|
+
onViewChange?: (view: "content" | "list") => void;
|
|
73
|
+
/**
|
|
74
|
+
* 定位产物目录视图的请求信号(如卡片区「查看所有产物」):数值变化
|
|
75
|
+
* 即切换列表视图并经 onViewRequestConsumed 消费复位(消费后普通
|
|
76
|
+
* 打开回内容视图)
|
|
77
|
+
*/
|
|
78
|
+
viewRequest?: number | null;
|
|
79
|
+
/** viewRequest 消费回调(组合层复位信号) */
|
|
80
|
+
onViewRequestConsumed?: () => void;
|
|
81
|
+
/**
|
|
82
|
+
* 面板左缘拖拽调宽手柄(缺省 false):pointer 拖拽实时改宽,结果
|
|
83
|
+
* 内部自持(inline width 覆盖),不向外部受控
|
|
84
|
+
*/
|
|
85
|
+
resizable?: boolean;
|
|
86
|
+
/** 关闭按钮事件 */
|
|
87
|
+
onClose?: () => void;
|
|
88
|
+
/** 下载事件;缺省内部走浏览器下载(downloadArtifact) */
|
|
89
|
+
onDownload?: (artifact: ChatPageArtifact) => void;
|
|
90
|
+
/** dsl 产物活预览的 Safe Registry;缺省时 dsl 内容渲染降级块 */
|
|
91
|
+
safeRegistry?: Registry<unknown>;
|
|
92
|
+
/** 注入 dsl 预览作用域 user */
|
|
93
|
+
user?: Record<string, unknown>;
|
|
94
|
+
/** 自定义产物查看器(扩展名 / kind → 预览),优先于内建渲染器 */
|
|
95
|
+
artifactViewers?: ArtifactViewers;
|
|
96
|
+
/** 通用:根节点 class(与内置样式合并) */
|
|
97
|
+
className?: string;
|
|
98
|
+
/** 通用:根节点内联样式 */
|
|
99
|
+
style?: CSSProperties;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* ArtifactPanel 产物预览面板(shadcn kit;功能移植自 @pactor-app/chat
|
|
103
|
+
* 的 ArtifactPanel):标题栏(目录列表切换钮 + 标题 / 产物切换下拉 +
|
|
104
|
+
* kind 角标 + 下载钮 + 关闭钮)+ 内容区。
|
|
105
|
+
*
|
|
106
|
+
* 内容按 artifact.kind 分发内建渲染器:markdown 安全渲染;code 经
|
|
107
|
+
* CodeBlock;text 预格式文本;dsl 经白名单守卫 + 活预览,被拦截 /
|
|
108
|
+
* 渲染失败一律降级为受控占位块,MUST NOT 抛错。图片类产物(扩展名
|
|
109
|
+
* 识别)走内建 <img> 预览。inspector 槽提供时整体替代内容区内建
|
|
110
|
+
* 渲染(目录列表视图优先);header 槽提供时整体替代内建标题栏;
|
|
111
|
+
* view / onViewChange 提供时目录列表视图受控;viewRequest 信号到达
|
|
112
|
+
* 即定位目录列表视图并经 onViewRequestConsumed 消费复位;resizable
|
|
113
|
+
* 时左缘渲染拖拽调宽手柄(宽度内部自持)。数据与行为全部经 props /
|
|
114
|
+
* events 进出,面板不持有业务状态(列表 / 内容视图与目录折叠为内部
|
|
115
|
+
* 展示状态)。
|
|
116
|
+
*/
|
|
117
|
+
declare function ArtifactPanel({ artifact, artifacts, activeArtifactId, onSelectArtifact, title, emptyText, inspector, header, view: viewProp, onViewChange, viewRequest, onViewRequestConsumed, resizable, onClose, onDownload, safeRegistry, user, artifactViewers, className, style, }: ArtifactPanelProps): react.JSX.Element;
|
|
118
|
+
|
|
119
|
+
/** 下载文件名:title 已带扩展名原样使用;否则补 fileType / kind 缺省扩展名 */
|
|
120
|
+
declare function resolveArtifactFilename(artifact: ChatPageArtifact): string;
|
|
121
|
+
/**
|
|
122
|
+
* 构建下载 Blob;图片内容为 http(s) URL 时返回 null(由 downloadArtifact
|
|
123
|
+
* 走 fetch 取回,失败降级新标签打开)
|
|
124
|
+
*/
|
|
125
|
+
declare function buildArtifactBlob(artifact: ChatPageArtifact): Blob | null;
|
|
126
|
+
/** 触发浏览器下载(Object URL + 临时锚点) */
|
|
127
|
+
declare function saveBlob(blob: Blob, filename: string): void;
|
|
128
|
+
/**
|
|
129
|
+
* 下载产物:文本类 / dsl JSON / 图片 data URL 与 svg 标记直接存 Blob;
|
|
130
|
+
* 图片 http(s) URL fetch 取回(跨域失败降级新标签打开)
|
|
131
|
+
*/
|
|
132
|
+
declare function downloadArtifact(artifact: ChatPageArtifact): Promise<void>;
|
|
133
|
+
|
|
134
|
+
export { type ArtifactViewers as A, type ChatPageArtifact as C, ArtifactPanel as a, type ArtifactPanelProps as b, type ArtifactTreeNode as c, type ArtifactViewer as d, buildArtifactBlob as e, buildArtifactTree as f, downloadArtifact as g, resolveArtifactFilename as r, saveBlob as s };
|