larkcc 0.3.0 → 0.5.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/CHANGELOG.md +34 -0
- package/README.md +177 -23
- package/dist/agent.js +138 -32
- package/dist/agent.js.map +1 -1
- package/dist/app.js.map +1 -1
- package/dist/cardkit.d.ts +92 -0
- package/dist/cardkit.js +407 -0
- package/dist/cardkit.js.map +1 -0
- package/dist/config.d.ts +28 -2
- package/dist/config.js +49 -45
- package/dist/config.js.map +1 -1
- package/dist/feishu.d.ts +36 -5
- package/dist/feishu.js +343 -41
- package/dist/feishu.js.map +1 -1
- package/dist/format/builder.d.ts +126 -37
- package/dist/format/builder.js +276 -116
- package/dist/format/builder.js.map +1 -1
- package/dist/format/card-optimize.d.ts +42 -0
- package/dist/format/card-optimize.js +74 -0
- package/dist/format/card-optimize.js.map +1 -0
- package/dist/format/constants.d.ts +87 -14
- package/dist/format/constants.js +147 -58
- package/dist/format/constants.js.map +1 -1
- package/dist/format/document.d.ts +4 -2
- package/dist/format/document.js +57 -35
- package/dist/format/document.js.map +1 -1
- package/dist/format/guide.d.ts +19 -0
- package/dist/format/guide.js +201 -0
- package/dist/format/guide.js.map +1 -0
- package/dist/format/image-resolver.d.ts +31 -0
- package/dist/format/image-resolver.js +202 -0
- package/dist/format/image-resolver.js.map +1 -0
- package/dist/format/index.d.ts +8 -3
- package/dist/format/index.js +8 -2
- package/dist/format/index.js.map +1 -1
- package/dist/format/parser.d.ts +22 -0
- package/dist/format/parser.js +55 -12
- package/dist/format/parser.js.map +1 -1
- package/dist/format/sanitize.d.ts +3 -0
- package/dist/format/sanitize.js +16 -7
- package/dist/format/sanitize.js.map +1 -1
- package/dist/format/thinking.d.ts +29 -0
- package/dist/format/thinking.js +50 -0
- package/dist/format/thinking.js.map +1 -0
- package/dist/resources/format-guide.md +109 -0
- package/dist/streaming.d.ts +77 -0
- package/dist/streaming.js +293 -0
- package/dist/streaming.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
package/dist/format/builder.d.ts
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 飞书文档块构建器
|
|
3
|
+
*
|
|
4
|
+
* 所有数据结构严格对齐 @larksuiteoapi/node-sdk 类型定义
|
|
3
5
|
*/
|
|
4
6
|
import { CalloutType } from "./constants.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
text_run: {
|
|
11
|
-
content: string;
|
|
12
|
-
};
|
|
13
|
-
href: string;
|
|
14
|
-
};
|
|
7
|
+
/**
|
|
8
|
+
* text_element_style(对齐 SDK)
|
|
9
|
+
* 样式属性嵌套在 text_run 内部
|
|
10
|
+
*/
|
|
11
|
+
export interface TextElementStyle {
|
|
15
12
|
bold?: boolean;
|
|
16
13
|
italic?: boolean;
|
|
17
14
|
underline?: boolean;
|
|
18
15
|
strikethrough?: boolean;
|
|
19
|
-
inline_code?:
|
|
16
|
+
inline_code?: boolean;
|
|
17
|
+
text_color?: number;
|
|
18
|
+
background_color?: number;
|
|
19
|
+
link?: {
|
|
20
|
+
url: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* TextElement(对齐 SDK)
|
|
25
|
+
* 只有一个可选的 text_run 属性,样式在 text_run.text_element_style 内
|
|
26
|
+
*/
|
|
27
|
+
export interface TextElement {
|
|
28
|
+
text_run?: {
|
|
20
29
|
content: string;
|
|
30
|
+
text_element_style?: TextElementStyle;
|
|
21
31
|
};
|
|
22
|
-
text_color?: string;
|
|
23
|
-
background_color?: string;
|
|
24
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* 普通文档块(用于 children API 直接写入)
|
|
35
|
+
*/
|
|
25
36
|
export interface Block {
|
|
26
37
|
block_type: number;
|
|
27
38
|
text?: {
|
|
@@ -72,59 +83,137 @@ export interface Block {
|
|
|
72
83
|
};
|
|
73
84
|
todo?: {
|
|
74
85
|
style: {
|
|
75
|
-
|
|
86
|
+
done?: boolean;
|
|
76
87
|
};
|
|
77
88
|
elements: TextElement[];
|
|
78
89
|
};
|
|
79
90
|
equation?: {
|
|
80
|
-
|
|
91
|
+
elements: Array<{
|
|
92
|
+
equation: {
|
|
93
|
+
content: string;
|
|
94
|
+
};
|
|
95
|
+
}>;
|
|
81
96
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
divider?: {};
|
|
98
|
+
image?: {
|
|
99
|
+
token: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 高亮块 Descendants 结构
|
|
104
|
+
* callout 是容器块,内容通过子块实现
|
|
105
|
+
*/
|
|
106
|
+
export interface CalloutDescendants {
|
|
107
|
+
calloutBlock: {
|
|
108
|
+
block_type: 19;
|
|
109
|
+
block_id: string;
|
|
110
|
+
children: string[];
|
|
111
|
+
callout: {
|
|
112
|
+
background_color: number;
|
|
113
|
+
border_color: number;
|
|
85
114
|
};
|
|
86
|
-
elements: TextElement[];
|
|
87
115
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
116
|
+
contentDescendants: Array<{
|
|
117
|
+
block_type: 2;
|
|
118
|
+
block_id: string;
|
|
119
|
+
text: {
|
|
120
|
+
elements: TextElement[];
|
|
121
|
+
};
|
|
122
|
+
}>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* 表格 Descendants 结构
|
|
126
|
+
* table.cells 是 block ID 引用,table_cell 是空壳容器,内容通过子块实现
|
|
127
|
+
*/
|
|
128
|
+
export interface TableDescendants {
|
|
129
|
+
tableBlock: {
|
|
130
|
+
block_type: 31;
|
|
131
|
+
block_id: string;
|
|
132
|
+
children: string[];
|
|
133
|
+
table: {
|
|
134
|
+
property: {
|
|
135
|
+
row_size: number;
|
|
136
|
+
column_size: number;
|
|
137
|
+
column_width: number[];
|
|
138
|
+
merge_info?: Array<{
|
|
139
|
+
row_span?: number;
|
|
140
|
+
col_span?: number;
|
|
141
|
+
}>;
|
|
142
|
+
};
|
|
143
|
+
cells: string[];
|
|
94
144
|
};
|
|
95
|
-
cells: Block[];
|
|
96
145
|
};
|
|
146
|
+
cellDescendants: Array<{
|
|
147
|
+
block_type: 32;
|
|
148
|
+
block_id: string;
|
|
149
|
+
children: string[];
|
|
150
|
+
table_cell: {};
|
|
151
|
+
} | {
|
|
152
|
+
block_type: 2;
|
|
153
|
+
block_id: string;
|
|
154
|
+
text: {
|
|
155
|
+
elements: TextElement[];
|
|
156
|
+
};
|
|
157
|
+
}>;
|
|
158
|
+
/** 原始 Markdown 文本(用于降级时保留可读性) */
|
|
159
|
+
rawMarkdown?: string;
|
|
97
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* 文档块统一条目
|
|
163
|
+
* 保持原始顺序,区分简单块和需要 Descendants API 的复杂块
|
|
164
|
+
*/
|
|
165
|
+
export type DocumentBlockItem = {
|
|
166
|
+
type: "simple";
|
|
167
|
+
block: Block;
|
|
168
|
+
} | {
|
|
169
|
+
type: "table";
|
|
170
|
+
data: TableDescendants;
|
|
171
|
+
} | {
|
|
172
|
+
type: "callout";
|
|
173
|
+
data: CalloutDescendants;
|
|
174
|
+
};
|
|
98
175
|
/**
|
|
99
176
|
* 解析内联 Markdown 和 HTML 格式
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* -
|
|
103
|
-
* -
|
|
104
|
-
* -
|
|
105
|
-
* -
|
|
177
|
+
*
|
|
178
|
+
* 输出严格对齐飞书 SDK 的 TextElement 结构:
|
|
179
|
+
* - 所有样式属性放在 text_run.text_element_style 内
|
|
180
|
+
* - 链接通过 text_element_style.link 实现
|
|
181
|
+
* - 行内代码通过 text_element_style.inline_code 布尔值实现
|
|
182
|
+
* - 颜色为数字枚举值
|
|
106
183
|
*/
|
|
107
184
|
export declare function parseInlineText(text: string): TextElement[];
|
|
108
185
|
export declare function buildTextBlock(content: string): Block;
|
|
109
186
|
export declare function buildHeadingBlock(level: number, content: string): Block;
|
|
110
187
|
export declare function buildCodeBlock(code: string, lang?: string): Block;
|
|
111
|
-
export declare function buildBulletBlock(content: string): Block;
|
|
112
|
-
export declare function buildOrderedBlock(content: string): Block;
|
|
188
|
+
export declare function buildBulletBlock(content: string, level?: number): Block;
|
|
189
|
+
export declare function buildOrderedBlock(content: string, level?: number): Block;
|
|
113
190
|
export declare function buildQuoteBlock(content: string): Block;
|
|
114
191
|
export declare function buildTodoBlock(content: string, checked: boolean): Block;
|
|
115
192
|
export declare function buildEquationBlock(latex: string): Block;
|
|
116
|
-
|
|
193
|
+
/**
|
|
194
|
+
* 构建高亮块(Descendants API)
|
|
195
|
+
* callout 是容器块,没有 elements,内容通过子块实现
|
|
196
|
+
*/
|
|
197
|
+
export declare function buildCalloutBlock(type: CalloutType, content: string): CalloutDescendants;
|
|
117
198
|
export declare function buildDividerBlock(): Block;
|
|
199
|
+
export declare function buildImageBlock(imageKey: string): Block;
|
|
118
200
|
export interface CellMerge {
|
|
119
201
|
colspan: number;
|
|
120
202
|
rowspan: number;
|
|
121
203
|
}
|
|
122
204
|
export interface TableCell {
|
|
123
205
|
content: string;
|
|
124
|
-
align?: "left" | "center" | "right";
|
|
125
206
|
merge?: CellMerge;
|
|
126
207
|
}
|
|
127
208
|
export interface TableData {
|
|
128
209
|
rows: TableCell[][];
|
|
129
210
|
}
|
|
130
|
-
|
|
211
|
+
/**
|
|
212
|
+
* 构建表格 Descendants 结构
|
|
213
|
+
*
|
|
214
|
+
* 表格创建流程:
|
|
215
|
+
* 1. table.cells 是 string[](block ID 引用),不是 Block 对象
|
|
216
|
+
* 2. table_cell 是空壳容器 {},内容通过子块实现
|
|
217
|
+
* 3. 使用 Descendants API 一次性创建表格 + 单元格 + 单元格内容
|
|
218
|
+
*/
|
|
219
|
+
export declare function buildTableBlock(data: TableData): TableDescendants;
|