@kevisual/cnb 0.0.75 → 0.0.77
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/agent/routes/knowledge/embedding.ts +166 -0
- package/agent/routes/knowledge/index.ts +2 -1
- package/agent/routes/labels/index.ts +1 -0
- package/agent/routes/labels/tags.ts +76 -0
- package/dist/cli-live.js +42 -24
- package/dist/cli.js +933 -381
- package/dist/keep.js +34 -16
- package/dist/npc.js +921 -370
- package/dist/opencode.js +918 -366
- package/dist/routes.d.ts +77 -32
- package/dist/routes.js +905 -353
- package/package.json +2 -2
- package/src/cnb-core.ts +26 -11
- package/src/knowledge/index.ts +81 -22
- package/src/labels/repo-label.ts +54 -1
- package/src/mission/index.ts +11 -4
- package/src/issue/issue-alive/issues-alive.html +0 -2
package/dist/routes.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ type CNBCoreOptions<T = {}> = {
|
|
|
13
13
|
cors?: {
|
|
14
14
|
baseUrl?: string;
|
|
15
15
|
};
|
|
16
|
+
openapi?: boolean;
|
|
16
17
|
} & T;
|
|
17
18
|
type RequestOptions = {
|
|
18
19
|
url?: string;
|
|
@@ -21,6 +22,7 @@ type RequestOptions = {
|
|
|
21
22
|
body?: any;
|
|
22
23
|
params?: Record<string, any>;
|
|
23
24
|
headers?: Record<string, any>;
|
|
25
|
+
token?: string;
|
|
24
26
|
useCookie?: boolean;
|
|
25
27
|
useOrigin?: boolean;
|
|
26
28
|
};
|
|
@@ -30,8 +32,9 @@ declare class CNBCore {
|
|
|
30
32
|
token: string;
|
|
31
33
|
cookie?: string;
|
|
32
34
|
isCors: boolean;
|
|
35
|
+
openapi?: boolean;
|
|
33
36
|
constructor(options: CNBCoreOptions);
|
|
34
|
-
request({ url, method, data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any>;
|
|
37
|
+
request({ url, method, data, params, headers, body, useCookie, useOrigin, ...rest }: RequestOptions): Promise<any>;
|
|
35
38
|
makeUrl(url?: string): string;
|
|
36
39
|
get<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
|
|
37
40
|
post<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
|
|
@@ -39,10 +42,11 @@ declare class CNBCore {
|
|
|
39
42
|
delete<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
|
|
40
43
|
patch<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
|
|
41
44
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
* 通过 PUT 请求上传文件内容
|
|
46
|
+
* assets上传的时候,第一次会获取到一个上传 URL 和 token,然后使用这个方法将文件内容上传到指定的 URL
|
|
47
|
+
* @param data 包含 URL、token 和文件内容
|
|
48
|
+
* @returns 上传结果
|
|
49
|
+
*/
|
|
46
50
|
putFile(data: {
|
|
47
51
|
url: string;
|
|
48
52
|
token: string;
|
|
@@ -249,24 +253,26 @@ declare class KnowledgeBase extends CNBCore {
|
|
|
249
253
|
deleteBase(repo: string): Promise<Result<any>>;
|
|
250
254
|
/**
|
|
251
255
|
* 未暴露
|
|
256
|
+
*
|
|
257
|
+
* 创建知识库接口,cnb 界面操作定制模块功能依赖该接口实现
|
|
252
258
|
* @param repo
|
|
253
259
|
* @param data
|
|
254
260
|
* @returns
|
|
255
261
|
*/
|
|
256
|
-
createKnowledgeBase(repo: string,
|
|
257
|
-
|
|
262
|
+
createKnowledgeBase(repo: string, params: {
|
|
263
|
+
/**
|
|
264
|
+
* hunyuan | bge-m3
|
|
265
|
+
*/
|
|
266
|
+
model_name: string;
|
|
258
267
|
include: string;
|
|
259
268
|
exclude: string;
|
|
269
|
+
chunk_size: number;
|
|
270
|
+
chunk_overlap: number;
|
|
271
|
+
text_separator: string;
|
|
260
272
|
issue_sync_enabled?: boolean;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
text_separator: string;
|
|
265
|
-
};
|
|
266
|
-
issue?: {
|
|
267
|
-
labels: string;
|
|
268
|
-
state: string;
|
|
269
|
-
};
|
|
273
|
+
issue_labels?: string;
|
|
274
|
+
issue_exclude_labels?: string;
|
|
275
|
+
issue_state?: string;
|
|
270
276
|
}): Promise<Result<any>>;
|
|
271
277
|
/**
|
|
272
278
|
* 未暴露
|
|
@@ -285,23 +291,28 @@ declare class KnowledgeBase extends CNBCore {
|
|
|
285
291
|
* @returns
|
|
286
292
|
*/
|
|
287
293
|
getEmbedding(repo: string, text: string): Promise<Result<{
|
|
288
|
-
|
|
294
|
+
embeddings: number[];
|
|
289
295
|
}>>;
|
|
290
296
|
/**
|
|
291
|
-
*
|
|
297
|
+
* 未暴露
|
|
298
|
+
* 只能运行在流水线,使用流水线的CNB_TOKEN去使用
|
|
299
|
+
* 否则会报错:sn not found in meta
|
|
300
|
+
* opts的token必须是流水线的CNB_TOKEN,不能是用户的token
|
|
292
301
|
* @param repo
|
|
293
302
|
* @param chunksData
|
|
294
303
|
* @returns
|
|
295
304
|
*/
|
|
296
|
-
addDocument(repo: string,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
addDocument(repo: string, AddDocument: AddDocument, opts?: RequestOptions): Promise<Result<null>>;
|
|
306
|
+
/**
|
|
307
|
+
* 未暴露
|
|
308
|
+
* @param repo
|
|
309
|
+
* @param paths
|
|
310
|
+
size: number;
|
|
311
|
+
}>;
|
|
312
|
+
}): Promise<Result<any>> {
|
|
313
|
+
const url = `/${repo}/-/knowledge/documents/upsert-document-with-chunks`;
|
|
314
|
+
return this.post({ url, data: chunksData });
|
|
315
|
+
}
|
|
305
316
|
/**
|
|
306
317
|
* 未暴露
|
|
307
318
|
* @param repo
|
|
@@ -316,7 +327,7 @@ declare class KnowledgeBase extends CNBCore {
|
|
|
316
327
|
* @param page_size
|
|
317
328
|
* @returns
|
|
318
329
|
*/
|
|
319
|
-
|
|
330
|
+
listDocuments(repo: string, page?: number, page_size?: number): Promise<Result<any[]>>;
|
|
320
331
|
}
|
|
321
332
|
type MetadataFilteringConditions = {
|
|
322
333
|
conditions: Array<{
|
|
@@ -341,6 +352,24 @@ type QueryRag = {
|
|
|
341
352
|
url: string;
|
|
342
353
|
};
|
|
343
354
|
};
|
|
355
|
+
type AddDocument = {
|
|
356
|
+
path: string;
|
|
357
|
+
name: string;
|
|
358
|
+
extension: string;
|
|
359
|
+
size: number;
|
|
360
|
+
hash: string;
|
|
361
|
+
type: "code" | "issue";
|
|
362
|
+
url: string;
|
|
363
|
+
chunks: Array<{
|
|
364
|
+
"content": string;
|
|
365
|
+
"hash": string;
|
|
366
|
+
"position": number;
|
|
367
|
+
"embedding": number[];
|
|
368
|
+
}>;
|
|
369
|
+
batch_index: number;
|
|
370
|
+
batch_count: number;
|
|
371
|
+
is_last_batch: boolean;
|
|
372
|
+
};
|
|
344
373
|
|
|
345
374
|
declare class Repo extends CNBCore {
|
|
346
375
|
constructor(options: CNBCoreOptions);
|
|
@@ -1012,10 +1041,10 @@ declare class Mission extends CNBCore {
|
|
|
1012
1041
|
/**
|
|
1013
1042
|
* 改变任务集可见性
|
|
1014
1043
|
* @param mission 任务集路径
|
|
1015
|
-
* @param visibility 可见性 (
|
|
1044
|
+
* @param visibility 可见性 (private 或 public)
|
|
1016
1045
|
* @returns 操作结果
|
|
1017
1046
|
*/
|
|
1018
|
-
setVisibility(mission: string, visibility: '
|
|
1047
|
+
setVisibility(mission: string, visibility: 'private' | 'public'): Promise<Result<any>>;
|
|
1019
1048
|
/**
|
|
1020
1049
|
* 查询任务集资源
|
|
1021
1050
|
* @param repo 仓库路径
|
|
@@ -1034,16 +1063,23 @@ type GetMissionsParams = {
|
|
|
1034
1063
|
search?: string;
|
|
1035
1064
|
};
|
|
1036
1065
|
type CreateMissionData = {
|
|
1066
|
+
/**
|
|
1067
|
+
* 任务集名称,必填
|
|
1068
|
+
*/
|
|
1037
1069
|
name: string;
|
|
1038
1070
|
description?: string;
|
|
1039
|
-
visibility?: '
|
|
1071
|
+
visibility?: 'private' | 'public';
|
|
1072
|
+
/**
|
|
1073
|
+
* 关联的仓库列表,格式为 `${group}/${repo}`,如 `my-group/my-repo`
|
|
1074
|
+
*/
|
|
1075
|
+
repos: string[];
|
|
1040
1076
|
};
|
|
1041
1077
|
type Missions4User = {
|
|
1042
1078
|
id: string;
|
|
1043
1079
|
name: string;
|
|
1044
1080
|
slug_path: string;
|
|
1045
1081
|
description: string;
|
|
1046
|
-
visibility: '
|
|
1082
|
+
visibility: 'private' | 'public';
|
|
1047
1083
|
created_at: string;
|
|
1048
1084
|
updated_at: string;
|
|
1049
1085
|
web_url: string;
|
|
@@ -1151,6 +1187,11 @@ declare class RepoLabel extends CNBCore {
|
|
|
1151
1187
|
* @param params 分页和搜索参数
|
|
1152
1188
|
*/
|
|
1153
1189
|
list(repo: string, params?: ListLabelsParams): Promise<Result<Label[]>>;
|
|
1190
|
+
getAll(repo: string): Promise<Result<Label[]>>;
|
|
1191
|
+
importLabels(opts: {
|
|
1192
|
+
repo: string;
|
|
1193
|
+
labels: PostLabelForm[];
|
|
1194
|
+
}): Promise<Result>;
|
|
1154
1195
|
/**
|
|
1155
1196
|
* 创建一个标签
|
|
1156
1197
|
* @param repo 仓库路径
|
|
@@ -1170,6 +1211,10 @@ declare class RepoLabel extends CNBCore {
|
|
|
1170
1211
|
* @param name 标签名称
|
|
1171
1212
|
*/
|
|
1172
1213
|
remove(repo: string, name: string): Promise<Result<void>>;
|
|
1214
|
+
removeLabels(opts: {
|
|
1215
|
+
repo: string;
|
|
1216
|
+
labels: string[];
|
|
1217
|
+
}): Promise<Result>;
|
|
1173
1218
|
}
|
|
1174
1219
|
type ListLabelsParams = {
|
|
1175
1220
|
/** 分页页码 */
|