@undefineds.co/models 0.1.1 → 0.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 +125 -515
- package/dist/core/file/file.schema.d.ts +1 -1
- package/dist/core/file/file.schema.js +1 -1
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +3 -3
- package/dist/core/schema.d.ts +1 -1
- package/dist/core/schema.js +1 -1
- package/dist/core/types/{collaboration-blocks.d.ts → collaboration-rich-content.d.ts} +7 -7
- package/dist/core/types/collaboration-rich-content.js +7 -0
- package/dist/core/types/message-rich-content.d.ts +121 -0
- package/dist/core/types/message-rich-content.js +85 -0
- package/dist/fixtures/contracts-chat-contact.d.ts +4 -4
- package/dist/fixtures/contracts-chat-contact.js +8 -4
- package/dist/governance/index.d.ts +1 -0
- package/dist/governance/index.js +1 -0
- package/dist/{sidecar/persistence-mapping.d.ts → governance/runtime-projections.d.ts} +3 -3
- package/dist/{sidecar/persistence-mapping.js → governance/runtime-projections.js} +1 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +11 -8
- package/dist/protocols/index.d.ts +1 -0
- package/dist/protocols/index.js +1 -0
- package/dist/{sidecar/sidecar-events.d.ts → protocols/runtime-events.d.ts} +11 -11
- package/dist/{sidecar/sidecar-events.js → protocols/runtime-events.js} +4 -21
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/types/{collaboration-blocks.d.ts → collaboration-rich-content.d.ts} +7 -7
- package/dist/types/collaboration-rich-content.js +7 -0
- package/dist/types/message-rich-content.d.ts +121 -0
- package/dist/types/message-rich-content.js +85 -0
- package/package.json +9 -1
- package/dist/core/types/collaboration-blocks.js +0 -7
- package/dist/core/types/message-block.d.ts +0 -270
- package/dist/core/types/message-block.js +0 -125
- package/dist/sidecar/index.d.ts +0 -2
- package/dist/sidecar/index.js +0 -2
- package/dist/types/collaboration-blocks.js +0 -7
- package/dist/types/message-block.d.ts +0 -270
- package/dist/types/message-block.js +0 -125
- /package/dist/core/vocab/{sidecar.vocab.d.ts → governance.vocab.d.ts} +0 -0
- /package/dist/core/vocab/{sidecar.vocab.js → governance.vocab.js} +0 -0
- /package/dist/vocab/{sidecar.vocab.d.ts → governance.vocab.d.ts} +0 -0
- /package/dist/vocab/{sidecar.vocab.js → governance.vocab.js} +0 -0
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Message Block Types - 基于 Cherry Studio 的 block-based 消息系统
|
|
3
|
-
*
|
|
4
|
-
* 将消息内容拆分为多个块(blocks),支持:
|
|
5
|
-
* - 主文本 (Markdown)
|
|
6
|
-
* - 思考过程 (CoT/Reasoning)
|
|
7
|
-
* - 工具调用
|
|
8
|
-
* - 图片/文件
|
|
9
|
-
* - 引用/搜索结果
|
|
10
|
-
* - 错误信息
|
|
11
|
-
*/
|
|
12
|
-
// 块类型枚举
|
|
13
|
-
export var MessageBlockType;
|
|
14
|
-
(function (MessageBlockType) {
|
|
15
|
-
/** 未知类型,用于流式响应开始前 */
|
|
16
|
-
MessageBlockType["UNKNOWN"] = "unknown";
|
|
17
|
-
/** 主要文本内容(Markdown) */
|
|
18
|
-
MessageBlockType["MAIN_TEXT"] = "main_text";
|
|
19
|
-
/** 思考过程(Claude、DeepSeek R1、OpenAI o-系列等) */
|
|
20
|
-
MessageBlockType["THINKING"] = "thinking";
|
|
21
|
-
/** 图片内容 */
|
|
22
|
-
MessageBlockType["IMAGE"] = "image";
|
|
23
|
-
/** 代码块(独立可运行) */
|
|
24
|
-
MessageBlockType["CODE"] = "code";
|
|
25
|
-
/** 工具调用及响应 */
|
|
26
|
-
MessageBlockType["TOOL"] = "tool";
|
|
27
|
-
/** 工具审批卡片 */
|
|
28
|
-
MessageBlockType["TOOL_APPROVAL"] = "tool_approval";
|
|
29
|
-
/** 任务进度卡片 */
|
|
30
|
-
MessageBlockType["TASK_PROGRESS"] = "task_progress";
|
|
31
|
-
/** 文件内容 */
|
|
32
|
-
MessageBlockType["FILE"] = "file";
|
|
33
|
-
/** 错误信息 */
|
|
34
|
-
MessageBlockType["ERROR"] = "error";
|
|
35
|
-
/** 引用类型(Web 搜索、知识库等) */
|
|
36
|
-
MessageBlockType["CITATION"] = "citation";
|
|
37
|
-
})(MessageBlockType || (MessageBlockType = {}));
|
|
38
|
-
// 块状态定义
|
|
39
|
-
export var MessageBlockStatus;
|
|
40
|
-
(function (MessageBlockStatus) {
|
|
41
|
-
/** 等待处理 */
|
|
42
|
-
MessageBlockStatus["PENDING"] = "pending";
|
|
43
|
-
/** 正在处理,等待接收 */
|
|
44
|
-
MessageBlockStatus["PROCESSING"] = "processing";
|
|
45
|
-
/** 正在流式接收 */
|
|
46
|
-
MessageBlockStatus["STREAMING"] = "streaming";
|
|
47
|
-
/** 处理成功 */
|
|
48
|
-
MessageBlockStatus["SUCCESS"] = "success";
|
|
49
|
-
/** 处理错误 */
|
|
50
|
-
MessageBlockStatus["ERROR"] = "error";
|
|
51
|
-
/** 处理暂停 */
|
|
52
|
-
MessageBlockStatus["PAUSED"] = "paused";
|
|
53
|
-
})(MessageBlockStatus || (MessageBlockStatus = {}));
|
|
54
|
-
/**
|
|
55
|
-
* 创建块的工厂函数
|
|
56
|
-
*/
|
|
57
|
-
export function createMessageBlock(type, messageId, partial) {
|
|
58
|
-
const id = `block-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
59
|
-
return {
|
|
60
|
-
id,
|
|
61
|
-
messageId,
|
|
62
|
-
type,
|
|
63
|
-
createdAt: new Date().toISOString(),
|
|
64
|
-
status: MessageBlockStatus.PENDING,
|
|
65
|
-
...partial,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 判断块类型
|
|
70
|
-
*/
|
|
71
|
-
export function isBlockType(block, type) {
|
|
72
|
-
return block.type === type;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* 从 richContent JSON 解析块
|
|
76
|
-
*/
|
|
77
|
-
export function parseMessageBlocks(richContent) {
|
|
78
|
-
if (!richContent)
|
|
79
|
-
return [];
|
|
80
|
-
try {
|
|
81
|
-
const parsed = JSON.parse(richContent);
|
|
82
|
-
// 如果有新的块系统,直接返回
|
|
83
|
-
if (parsed.blocks && parsed.blocks.length > 0) {
|
|
84
|
-
return parsed.blocks;
|
|
85
|
-
}
|
|
86
|
-
// 向后兼容:转换旧格式
|
|
87
|
-
const blocks = [];
|
|
88
|
-
if (parsed.thought) {
|
|
89
|
-
blocks.push({
|
|
90
|
-
id: 'legacy-thought',
|
|
91
|
-
messageId: '',
|
|
92
|
-
type: MessageBlockType.THINKING,
|
|
93
|
-
content: parsed.thought,
|
|
94
|
-
createdAt: new Date().toISOString(),
|
|
95
|
-
status: MessageBlockStatus.SUCCESS,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
if (parsed.toolInvocations) {
|
|
99
|
-
parsed.toolInvocations.forEach((ti, index) => {
|
|
100
|
-
blocks.push({
|
|
101
|
-
id: `legacy-tool-${index}`,
|
|
102
|
-
messageId: '',
|
|
103
|
-
type: MessageBlockType.TOOL,
|
|
104
|
-
toolId: ti.id,
|
|
105
|
-
toolName: ti.toolName,
|
|
106
|
-
arguments: ti.input,
|
|
107
|
-
content: ti.output ?? ti.error,
|
|
108
|
-
createdAt: new Date().toISOString(),
|
|
109
|
-
status: ti.error ? MessageBlockStatus.ERROR : MessageBlockStatus.SUCCESS,
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
return blocks;
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* 序列化块到 richContent JSON
|
|
121
|
-
*/
|
|
122
|
-
export function serializeMessageBlocks(blocks) {
|
|
123
|
-
const content = { blocks };
|
|
124
|
-
return JSON.stringify(content);
|
|
125
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|