@kevisual/cnb 0.0.47 → 0.0.48

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.
@@ -0,0 +1,885 @@
1
+ import { QueryRouterServer } from '@kevisual/router';
2
+ import { Result as Result$1 } from '@kevisual/query/query';
3
+ import { Result as Result$2 } from '@kevisual/query';
4
+ import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
5
+
6
+ type CNBCoreOptions<T = {}> = {
7
+ token: string;
8
+ /**
9
+ * 对 cnb 界面操作定制模块功能时需要传入 cookie
10
+ */
11
+ cookie?: string;
12
+ cnb?: CNBCore;
13
+ cors?: {
14
+ baseUrl?: string;
15
+ };
16
+ } & T;
17
+ type RequestOptions = {
18
+ url?: string;
19
+ method?: string;
20
+ data?: Record<string, any>;
21
+ body?: any;
22
+ params?: Record<string, any>;
23
+ headers?: Record<string, any>;
24
+ useCookie?: boolean;
25
+ useOrigin?: boolean;
26
+ };
27
+ declare class CNBCore {
28
+ baseURL: string;
29
+ hackURL: string;
30
+ token: string;
31
+ cookie?: string;
32
+ isCors: boolean;
33
+ constructor(options: CNBCoreOptions);
34
+ request({ url, method, data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any>;
35
+ makeUrl(url?: string): string;
36
+ get<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
37
+ post<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
38
+ put<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
39
+ delete<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
40
+ patch<T = any>({ url, ...REST }: RequestOptions): Promise<T>;
41
+ /**
42
+ * 通过 PUT 请求上传文件内容
43
+ * @param data 包含 URL、token 和文件内容
44
+ * @returns 上传结果
45
+ */
46
+ putFile(data: {
47
+ url: string;
48
+ token: string;
49
+ content: string | Buffer;
50
+ }): Promise<any>;
51
+ }
52
+ type Result<T = any> = {
53
+ code: number;
54
+ message: string;
55
+ data: T;
56
+ };
57
+
58
+ /**
59
+ * @title 工作空间管理模块
60
+ * @description 提供云原生构建工作空间的管理功能,包括列表查询、创建、更新和删除工作空间,支持多种过滤条件和分页选项
61
+ * @tags workspace, cloud-native, development-environment, cnb, api
62
+ * @createdAt 2025-12-04
63
+ */
64
+
65
+ /**
66
+ * 工作空间列表查询参数
67
+ */
68
+ interface ListParams {
69
+ /** Git 分支名称,例如 "main" */
70
+ branch?: string;
71
+ /** 查询结束时间,格式 YYYY-MM-DD HH:mm:ssZZ,例如 2024-12-01 00:00:00+0800 */
72
+ end?: string;
73
+ /** 分页页码,默认为 1 */
74
+ page?: number;
75
+ /** 分页大小,默认 20,最大 100 */
76
+ pageSize?: number;
77
+ /** 仓库路径,例如 "groupname/reponame" */
78
+ slug?: string;
79
+ /** 查询开始时间,格式 YYYY-MM-DD HH:mm:ssZZ,例如 2024-12-01 00:00:00+0800 */
80
+ start?: string;
81
+ /** 开发环境状态,running: 开发环境已启动,closed: 开发环境已关闭 */
82
+ status?: 'running' | 'closed';
83
+ }
84
+ /**
85
+ * 云原生开发环境管理模块
86
+ * https://api.cnb.cool/#/operations/GetWorkspaceDetail
87
+ */
88
+ declare class Workspace extends CNBCore {
89
+ constructor(options: CNBCoreOptions);
90
+ /**
91
+ * 删除我的云原生开发环境
92
+ * @param params 删除参数,pipelineId 和 sn 二选一,优先使用 pipelineId
93
+ */
94
+ deleteWorkspace(params: {
95
+ pipelineId?: string;
96
+ sn?: string;
97
+ }): Promise<{
98
+ code: number;
99
+ message: string;
100
+ }>;
101
+ /** 获取我的云原生开发环境列表 */
102
+ list(params?: ListParams): Promise<Result$1<WorkspaceResult>>;
103
+ /**
104
+ * 停止我的云原生开发环境
105
+ * @param params 停止参数,pipelineId 和 sn 二选一,优先使用 pipelineId
106
+ */
107
+ stopWorkspace(params: {
108
+ pipelineId?: string;
109
+ sn?: string;
110
+ }): Promise<Result$1<{
111
+ buildLogUrl: string;
112
+ message: string;
113
+ sn: string;
114
+ }>>;
115
+ /**
116
+ * 根据流水线 SN 查询云原生开发访问地址
117
+ * @param repo 仓库路径,例如:groupname/reponame
118
+ * @param sn 流水线构建号
119
+ */
120
+ getDetail(repo: string, sn: string): Promise<Result$1<WorkspaceLinkDetail>>;
121
+ /**
122
+ * 启动云原生开发环境,已存在环境则直接打开,否则重新创建开发环境
123
+ * @param repo 仓库路径,例如:groupname/reponame
124
+ * @param params 启动参数
125
+ * @returns 返回启动结果,包含以下字段:
126
+ */
127
+ startWorkspace(repo: string, params: {
128
+ branch?: string;
129
+ ref?: string;
130
+ }): Promise<Result$1<{
131
+ /** 仅新创建开发环境时返回,表示创建开发环境的流水线日志地址 */
132
+ buildLogUrl?: string;
133
+ /** 仅新创建开发环境时返回,表示创建开发环境的提示信息 */
134
+ message?: string;
135
+ /** 仅新创建开发环境时返回,表示创建开发环境的流水线 sn */
136
+ sn?: string;
137
+ /** 如果存在开发环境,则返回 WebIDE 访问 url;如果不存在开发环境,则返回启动云原生开发的 loading 页面 url 地址 */
138
+ url: string;
139
+ }>>;
140
+ /**
141
+ * 添加使用cookie获取工作空间访问权限的功能,适用于需要保持工作空间连接状态的场景,
142
+ * 例如使用 WebSocket 连接工作空间时需要携带 cookie 进行身份验证。
143
+ * https://cnb.cool/kevisual/dev-env/-/workspace/vscode-web/cnb-708-1ji9sog7o-001
144
+ * @param repo
145
+ * @param pipelineId
146
+ * @returns
147
+ */
148
+ getWorkspaceCookie(repo: string, pipelineId: string): Promise<Result$1<{
149
+ value: string;
150
+ cookie: string;
151
+ cookieName: string;
152
+ }>>;
153
+ }
154
+ interface WorkspaceLinkDetail {
155
+ codebuddy: string;
156
+ codebuddycn: string;
157
+ cursor: string;
158
+ jetbrains: Record<string, string>;
159
+ jumpUrl: string;
160
+ remoteSsh: string;
161
+ ssh: string;
162
+ vscode: string;
163
+ 'vscode-insiders': string;
164
+ webide: string;
165
+ }
166
+ /**
167
+ * 工作空间信息接口
168
+ */
169
+ interface WorkspaceInfo {
170
+ /** 分支名,例如:main */
171
+ branch: string;
172
+ /** 业务 ID */
173
+ business_id: string;
174
+ /** 备份的 commit 数 */
175
+ commit_count: number | null;
176
+ /** 开发环境创建时间,例如:2024-12-02T03:20:22.000Z */
177
+ create_time: string;
178
+ /** 开发环境持续时间,单位:ms(非实时更新) */
179
+ duration: number;
180
+ /** 备份的文件数 */
181
+ file_count: number;
182
+ /** 备份的文件列表,仅前五个备份文件相对路径 */
183
+ file_list: string;
184
+ /** 是否为预览环境,0: 否,1: 是 */
185
+ is_preview: number;
186
+ /** JetBrains IDE 列表 */
187
+ jetbrainsList: any[];
188
+ /** 环境销毁时远程最新的 commit short hash */
189
+ latest_sha: string | null;
190
+ /** 创建环境的子流水线 id */
191
+ pipeline_id: string;
192
+ /** 备份的 stash 数 */
193
+ remote_stash_count: number | null;
194
+ /** 仓库 ID */
195
+ repo_id: string;
196
+ /** 仓库地址 */
197
+ repo_url: string;
198
+ /** 恢复备份代码的流水线 id,如果有值表示备份代码已被恢复(重建环境时会恢复备份代码) */
199
+ restore_id: string | null;
200
+ /** 单个 stash 标识,1: 是,0: 否 */
201
+ single_stash: number;
202
+ /** 仓库路径,例如:groupname/reponame */
203
+ slug: string;
204
+ /** 创建开发环境的流水线 sn */
205
+ sn: string;
206
+ /** 开发环境是否支持 ssh 链接 */
207
+ ssh: boolean;
208
+ /** 本地 stash 数 */
209
+ stash_count: number;
210
+ /** 工作区状态,running: 开发环境已启动,closed:开发环境已关闭 */
211
+ status: string;
212
+ /** 用户名 */
213
+ user_name: string;
214
+ /** 开发环境默认工作区路径 */
215
+ workspace: string;
216
+ }
217
+ /**
218
+ * 工作空间列表响应结果
219
+ */
220
+ type WorkspaceResult = {
221
+ /** 是否有更多数据 */
222
+ hasMore: boolean;
223
+ /** 工作空间列表 */
224
+ list: WorkspaceInfo[];
225
+ /** 分页信息 */
226
+ pageInfo: {
227
+ /** 当前页码 */
228
+ page: number;
229
+ /** 每页大小 */
230
+ pageSize: number;
231
+ };
232
+ /** 总数量 */
233
+ total: number;
234
+ };
235
+
236
+ declare class KnowledgeBase extends CNBCore {
237
+ constructor(options: CNBCoreOptions);
238
+ queryKnowledgeBase(repo: string, data: {
239
+ query: string;
240
+ score_threshold?: number;
241
+ top_k?: number;
242
+ metadata_filtering_conditions?: MetadataFilteringConditions;
243
+ }): Promise<Result<QueryRag[]>>;
244
+ getEmbeddingModels(repo: string): Promise<Result<Array<{
245
+ name: string;
246
+ dimensions: number;
247
+ }>>>;
248
+ getBase(repo: string): Promise<Result<any>>;
249
+ deleteBase(repo: string): Promise<Result<any>>;
250
+ }
251
+ type MetadataFilteringConditions = {
252
+ conditions: Array<{
253
+ comparison_operator?: 'is' | 'is not' | 'contains' | 'not contains' | 'start with' | 'end with' | 'is empty' | 'is not empty';
254
+ name?: "position" | "path" | "type";
255
+ /**
256
+ * "is empty" and "is not empty" 时候忽略该字段
257
+ */
258
+ value?: string;
259
+ }>;
260
+ logical_operator?: 'adn' | 'or';
261
+ };
262
+ type QueryRag = {
263
+ chunk: string;
264
+ score: number;
265
+ metadata: {
266
+ hash: string;
267
+ name: string;
268
+ path: string;
269
+ position: string;
270
+ type: string;
271
+ url: string;
272
+ };
273
+ };
274
+
275
+ declare class Repo extends CNBCore {
276
+ constructor(options: CNBCoreOptions);
277
+ /**
278
+ * 创建代码仓库
279
+ * @param data
280
+ * @returns
281
+ */
282
+ createRepo(data: CreateRepoData): Promise<any>;
283
+ deleteRepoCookie(repo: string): Promise<any>;
284
+ deleteRepo(repo: string): Promise<any>;
285
+ /**
286
+ * 使用cookie创建提交,如果没有指定parent_commit_sha,则会自动获取最新的提交作为父提交
287
+ * @param repo
288
+ * @param data
289
+ * @returns
290
+ */
291
+ createCommit(repo: string, data: CreateCommitData): Promise<any>;
292
+ createBlobs(repo: string, data: {
293
+ content: string;
294
+ encoding?: 'utf-8' | 'base64';
295
+ }): Promise<any>;
296
+ uploadFiles(repo: string, data: {
297
+ ext?: any;
298
+ name?: string;
299
+ path?: string;
300
+ size?: number;
301
+ }): Promise<any>;
302
+ getCommitList(repo: string, params: {
303
+ author?: string;
304
+ commiter?: string;
305
+ page?: number;
306
+ page_size?: number;
307
+ sha?: string;
308
+ since?: string;
309
+ until?: string;
310
+ }, opts?: RequestOptions): Promise<any>;
311
+ getRepoList(params: {
312
+ desc?: boolean;
313
+ filter_type?: 'private' | 'public' | 'secret';
314
+ flags?: 'KnowledgeBase';
315
+ order_by?: 'created_at' | 'last_updated_at' | 'stars' | 'slug_path' | 'forks';
316
+ page?: number;
317
+ page_size?: number;
318
+ role?: 'owner' | 'maintainer' | 'developer' | 'reporter' | 'guest';
319
+ search?: string;
320
+ status?: 'active' | 'archived';
321
+ }): Promise<Result<RepoItem[]>>;
322
+ updateRepoInfo(repo: string, params: UpdateRepoInfo): Promise<any>;
323
+ getRepo(repo: string): Promise<Result<RepoItem>>;
324
+ }
325
+ type UpdateRepoInfo = {
326
+ description?: string;
327
+ license?: 'MIT' | 'Apache-2.0' | 'GPL-3.0' | 'Unlicense';
328
+ site?: string;
329
+ topics?: string[];
330
+ };
331
+ type CreateRepoData = {
332
+ description: string;
333
+ license?: 'MIT' | 'Apache-2.0' | 'GPL-3.0' | 'Unlicense';
334
+ name: string;
335
+ visibility: 'private' | 'public' | 'secret';
336
+ };
337
+ type CreateCommitData = {
338
+ base_branch?: string;
339
+ new_branch?: string;
340
+ message?: string;
341
+ parent_commit_sha?: string;
342
+ files?: Array<{
343
+ content: string;
344
+ path: string;
345
+ encoding?: 'raw' | 'utf-8' | 'base64';
346
+ is_delete?: boolean;
347
+ is_executable?: boolean;
348
+ }>;
349
+ };
350
+ type RepoItem = {
351
+ id: string;
352
+ name: string;
353
+ freeze: boolean;
354
+ status: number;
355
+ visibility_level: 'Public' | 'Private' | 'Secret';
356
+ flags: string;
357
+ created_at: string;
358
+ updated_at: string;
359
+ description: string;
360
+ site: string;
361
+ topics: string;
362
+ license: string;
363
+ display_module: {
364
+ activity: boolean;
365
+ contributors: boolean;
366
+ release: boolean;
367
+ };
368
+ star_count: number;
369
+ fork_count: number;
370
+ mark_count: number;
371
+ last_updated_at: string | null;
372
+ web_url: string;
373
+ path: string;
374
+ tags: string[] | null;
375
+ open_issue_count: number;
376
+ open_pull_request_count: number;
377
+ languages: {
378
+ language: string;
379
+ color: string;
380
+ };
381
+ second_languages: {
382
+ language: string;
383
+ color: string;
384
+ };
385
+ last_update_username: string;
386
+ last_update_nickname: string;
387
+ access: string;
388
+ stared: boolean;
389
+ star_time: string;
390
+ pinned: boolean;
391
+ pinned_time: string;
392
+ };
393
+
394
+ declare class User extends CNBCore {
395
+ constructor(options: CNBCoreOptions<{}>);
396
+ /**
397
+ * 获取当前用户信息,使用 Cookie 认证
398
+ * @returns
399
+ */
400
+ getCurrentUser(): Promise<Result$2<UserInfo>>;
401
+ /**
402
+ * 判断当前 Cookie 是否有效
403
+ * @returns
404
+ */
405
+ checkCookieValid(): Promise<Result$2>;
406
+ /**
407
+ * 使用 Token 获取用户信息
408
+ * @returns
409
+ */
410
+ getUser(): Promise<Result$2<UserInfo>>;
411
+ createAccessToken(data?: {
412
+ description?: string;
413
+ scope?: string;
414
+ }): Promise<AccessTokenResponse>;
415
+ getAccessTokens(params?: {
416
+ page?: number;
417
+ page_size?: number;
418
+ }): Promise<AccessTokenResponse[]>;
419
+ deleteAccessToken(tokenId: string): Promise<any>;
420
+ }
421
+ type AccessTokenResponse = {
422
+ token: string;
423
+ description: string;
424
+ };
425
+ type UserInfo = {
426
+ id: string;
427
+ username: string;
428
+ nickname: string;
429
+ type: number;
430
+ verified: number;
431
+ verified_expire_in: string;
432
+ created_at: string;
433
+ freeze: boolean;
434
+ locked: boolean;
435
+ avatar: string;
436
+ email: string;
437
+ next_updated_name_at: string;
438
+ updated_name_at: string;
439
+ updated_nick_at: string;
440
+ editable: {
441
+ avatar: boolean;
442
+ email: boolean;
443
+ logoff: boolean;
444
+ nickname: boolean;
445
+ 'sync-data': boolean;
446
+ username: boolean;
447
+ };
448
+ language: string;
449
+ appearance: string;
450
+ gender: number;
451
+ bio: string;
452
+ company: string;
453
+ location: string;
454
+ site: string;
455
+ address: string;
456
+ wechat_mp: string;
457
+ wechat_mp_qrcode: string;
458
+ appreciate_status: number;
459
+ follow_count: number;
460
+ follower_count: number;
461
+ reward_count: number;
462
+ reward_amount: number;
463
+ stars_count: number;
464
+ group_count: number;
465
+ repo_count: number;
466
+ mission_count: number;
467
+ registry_count: number;
468
+ public_repo_count: number;
469
+ public_mission_count: number;
470
+ public_registry_count: number;
471
+ follow_repo_count: number;
472
+ follow_mission_count: number;
473
+ readme_repo_path: string;
474
+ last_login_at: string;
475
+ last_login_ip: string;
476
+ };
477
+
478
+ declare class Build extends CNBCore {
479
+ constructor(options: CNBCoreOptions);
480
+ startBuild(repo: string, data: StartBuildData): Promise<any>;
481
+ }
482
+ type StartBuildData = {
483
+ /**
484
+ * 触发分支,默认为主分支
485
+ */
486
+ branch?: string;
487
+ /**
488
+ * 指定配置文件内容,yaml 格式
489
+ */
490
+ config?: string;
491
+ /**
492
+ * 环境变量,对象格式
493
+ */
494
+ env?: Record<string, string>;
495
+ /**
496
+ * 事件名,必须是 api_trigger 或以 api_trigger_ 开头,默认为 api_trigger
497
+ */
498
+ event?: string;
499
+ /**
500
+ * commit id ,优先级比 tag 高,默认为分支最新提交记录
501
+ */
502
+ sha?: string;
503
+ /**
504
+ * 是否等待构建正式触发,为false时会立刻返回 sn 和 buildLogUrl
505
+ */
506
+ sync?: string;
507
+ /**
508
+ * 触发 tag,优先级比 branch 高
509
+ */
510
+ tag?: string;
511
+ };
512
+
513
+ type IssueAssignee = {
514
+ nickname: string;
515
+ username: string;
516
+ };
517
+ type IssueLabel = {
518
+ color: string;
519
+ description: string;
520
+ id: string;
521
+ name: string;
522
+ creator?: {
523
+ username: string;
524
+ nickname: string;
525
+ email: string;
526
+ is_npc: boolean;
527
+ };
528
+ applied_by?: {
529
+ username: string;
530
+ nickname: string;
531
+ email: string;
532
+ is_npc: boolean;
533
+ };
534
+ };
535
+ type IssueAuthor = {
536
+ name: string;
537
+ body: string;
538
+ comment_count: number;
539
+ created_at: string;
540
+ ended_at: string;
541
+ };
542
+ type IssueCommentUser = {
543
+ username: string;
544
+ nickname: string;
545
+ avatar: string;
546
+ is_npc: boolean;
547
+ };
548
+ type IssueCommentReaction = {};
549
+ type IssueComment = {
550
+ id: string;
551
+ body: string;
552
+ author: IssueCommentUser;
553
+ reactions: IssueCommentReaction[];
554
+ created_at: string;
555
+ updated_at: string;
556
+ };
557
+ type IssueItem = {
558
+ assignees: IssueAssignee[];
559
+ author: IssueAuthor;
560
+ labels: IssueLabel[];
561
+ body: string;
562
+ last_acted_at: string;
563
+ number: string;
564
+ priority: string;
565
+ started_at: string;
566
+ state: string;
567
+ state_reason: string;
568
+ title: string;
569
+ updated_at: string;
570
+ };
571
+ declare class Issue extends CNBCore {
572
+ constructor(options: CNBCoreOptions);
573
+ createIssue(repo: string, data: Partial<IssueItem>): Promise<Result<IssueItem>>;
574
+ updateIssue(repo: string, issueNumber: string | number, data: Partial<IssueItem>): Promise<Result<IssueItem>>;
575
+ getItem(repo: string, issueNumber: string | number): Promise<Result<IssueItem>>;
576
+ getList(repo: string, params?: Partial<GetListParams>): Promise<Result<IssueItem[]>>;
577
+ getCommentList(repo: string, issueNumber: string | number, params?: {
578
+ page?: number;
579
+ page_size?: number;
580
+ }): Promise<Result<IssueComment[]>>;
581
+ getComment(repo: string, issueNumber: string | number, commentId: string | number): Promise<Result<IssueComment>>;
582
+ createComment(repo: string, issueNumber: string | number, body: string): Promise<Result<IssueComment>>;
583
+ updateComment(repo: string, issueNumber: string | number, commentId: string | number, body: string): Promise<Result<IssueComment>>;
584
+ setIssueProperty(repo: string, issueNumber: string | number, properties: {
585
+ [key: string]: any;
586
+ }[]): Promise<any>;
587
+ /**
588
+ * 获取alive issue的元数据
589
+ * @param repo
590
+ * @param issueNumber
591
+ * @returns
592
+ */
593
+ getAliveMetadata(repo: string, issueNumber: string | number): Promise<Result<AliveMetadata>>;
594
+ useNPCEnv(): {
595
+ npcSlug: any;
596
+ npcSlugLabel: string;
597
+ npcName: any;
598
+ npcNameLabel: string;
599
+ npcSha: any;
600
+ npcShaLabel: string;
601
+ npcPrompt: any;
602
+ npcPromptLabel: string;
603
+ npcAvatar: any;
604
+ npcAvatarLabel: string;
605
+ npcEnableThinking: any;
606
+ npcEnableThinkingLabel: string;
607
+ };
608
+ useCommentEnv(): {
609
+ commentId: any;
610
+ commentIdLabel: string;
611
+ commentBody: any;
612
+ commentBodyLabel: string;
613
+ commentType: any;
614
+ commentTypeLabel: string;
615
+ commentFilePath: any;
616
+ commentFilePathLabel: string;
617
+ commentRange: any;
618
+ commentRangeLabel: string;
619
+ reviewId: any;
620
+ reviewIdLabel: string;
621
+ };
622
+ usePullRequestEnv(): {
623
+ pullRequest: any;
624
+ pullRequestLabel: string;
625
+ pullRequestLike: any;
626
+ pullRequestLikeLabel: string;
627
+ pullRequestProposer: any;
628
+ pullRequestProposerLabel: string;
629
+ pullRequestTitle: any;
630
+ pullRequestTitleLabel: string;
631
+ pullRequestBranch: any;
632
+ pullRequestBranchLabel: string;
633
+ pullRequestSha: any;
634
+ pullRequestShaLabel: string;
635
+ pullRequestTargetSha: any;
636
+ pullRequestTargetShaLabel: string;
637
+ pullRequestMergeSha: any;
638
+ pullRequestMergeShaLabel: string;
639
+ pullRequestSlug: any;
640
+ pullRequestSlugLabel: string;
641
+ pullRequestAction: any;
642
+ pullRequestActionLabel: string;
643
+ pullRequestId: any;
644
+ pullRequestIdLabel: string;
645
+ };
646
+ useRepoInfoEnv(): {
647
+ repoSlug: any;
648
+ repoSlugLabel: string;
649
+ repoSlugLowercase: any;
650
+ repoSlugLowercaseLabel: string;
651
+ repoName: any;
652
+ repoNameLabel: string;
653
+ repoNameLowercase: any;
654
+ repoNameLowercaseLabel: string;
655
+ repoId: any;
656
+ repoIdLabel: string;
657
+ repoUrlHttps: any;
658
+ repoUrlHttpsLabel: string;
659
+ };
660
+ }
661
+ type GetListParams = {
662
+ /** 问题指派人名称,例如: 张三, 李四, -; - 表示不指派给任何人 */
663
+ assignees?: string;
664
+ /** 问题作者名称,例如: 张三, 李四 */
665
+ authors?: string;
666
+ /** 问题关闭时间过滤-开始,例如: 2022-01-31 */
667
+ close_time_begin?: string;
668
+ /** 问题关闭时间过滤-结束,例如: 2022-01-31 */
669
+ close_time_end?: string;
670
+ /** 问题搜索关键词 */
671
+ keyword?: string;
672
+ /** 问题标签,例如: git, bug, feature */
673
+ labels?: string;
674
+ /** 问题标签操作符,例如: contains_any, contains_all,默认: contains_any */
675
+ labels_operator?: string;
676
+ /** 问题排序,例如: created_at, -updated_at, reference_count;'-' 前缀表示降序 */
677
+ order_by?: string;
678
+ /** 分页页码。如果值小于 1,将自动调整为 1,默认: 1 */
679
+ page?: number;
680
+ /** 分页每页大小。如果值大于 100,将自动调整为 100,默认: 30 */
681
+ page_size?: number;
682
+ /** 问题优先级,例如: -1P, -2P, P0, P1, P2, P3 */
683
+ priority?: string;
684
+ /** 问题状态:open 或 closed */
685
+ state?: string;
686
+ /** 问题更新时间过滤-开始,例如: 2022-01-31 */
687
+ updated_time_begin?: string;
688
+ /** 问题更新时间过滤-结束,例如: 2022-01-31 */
689
+ updated_time_end?: string;
690
+ };
691
+ type AliveMetadata = {
692
+ aliveSessionID: string;
693
+ aliveChannelID: string;
694
+ domain: string;
695
+ subscriptions: {
696
+ event: 'subscribe';
697
+ data: {
698
+ id: string;
699
+ off: number;
700
+ };
701
+ }[];
702
+ };
703
+
704
+ declare class Mission extends CNBCore {
705
+ constructor(options: CNBCoreOptions);
706
+ /**
707
+ * 查询组织下用户有权限查看的任务集
708
+ * @param params 查询参数
709
+ * @returns 任务集列表
710
+ */
711
+ getMissions(group: string, params?: GetMissionsParams): Promise<Result<Missions4User[]>>;
712
+ /**
713
+ * 创建任务集
714
+ * @param data 创建任务集数据
715
+ * @returns 创建结果
716
+ */
717
+ createMission(repo: string, data: CreateMissionData): Promise<Result<any>>;
718
+ /**
719
+ * 删除任务集
720
+ * @param mission 任务集路径
721
+ * @param identityTicket 微信身份验证票据
722
+ * @returns 删除结果
723
+ */
724
+ deleteMission(mission: string, identityTicket?: string): Promise<Result<any>>;
725
+ /**
726
+ * 获取任务集视图配置
727
+ * @param mission 任务集 slug
728
+ * @param viewId 视图 ID
729
+ * @returns 视图配置
730
+ */
731
+ getMissionViewConfig(mission: string, viewId: string): Promise<Result<MissionViewConfig>>;
732
+ /**
733
+ * 设置任务集视图配置
734
+ * @param mission 任务集 slug
735
+ * @param config 视图配置
736
+ * @returns 设置结果
737
+ */
738
+ setMissionViewConfig(mission: string, config: MissionViewConfig): Promise<Result<any>>;
739
+ /**
740
+ * 获取任务集视图列表
741
+ * @param mission 任务集 slug
742
+ * @returns 视图列表
743
+ */
744
+ getMissionViewList(mission: string): Promise<Result<MissionView[]>>;
745
+ /**
746
+ * 添加或修改任务集视图
747
+ * @param mission 任务集 slug
748
+ * @param view 视图数据
749
+ * @returns 操作结果
750
+ */
751
+ putMissionView(mission: string, view: MissionView): Promise<Result<any>>;
752
+ /**
753
+ * 排序任务集视图
754
+ * @param mission 任务集 slug
755
+ * @param data 排序数据
756
+ * @returns 操作结果
757
+ */
758
+ sortMissionViews(mission: string, data: MissionPostViewReq): Promise<Result<any>>;
759
+ /**
760
+ * 改变任务集可见性
761
+ * @param mission 任务集路径
762
+ * @param visibility 可见性 (Private 或 Public)
763
+ * @returns 操作结果
764
+ */
765
+ setVisibility(mission: string, visibility: 'Private' | 'Public'): Promise<Result<any>>;
766
+ }
767
+ type GetMissionsParams = {
768
+ page?: number;
769
+ page_size?: number;
770
+ filter_type?: 'private' | 'public';
771
+ order_by?: 'created_at' | 'name';
772
+ desc?: boolean;
773
+ descendant?: 'all' | 'sub' | 'grand';
774
+ search?: string;
775
+ };
776
+ type CreateMissionData = {
777
+ name: string;
778
+ description?: string;
779
+ visibility?: 'Private' | 'Public';
780
+ };
781
+ type Missions4User = {
782
+ id: string;
783
+ name: string;
784
+ slug_path: string;
785
+ description: string;
786
+ visibility: 'Private' | 'Public';
787
+ created_at: string;
788
+ updated_at: string;
789
+ web_url: string;
790
+ };
791
+ type MissionView = {
792
+ id: string;
793
+ name: string;
794
+ description?: string;
795
+ config?: MissionViewConfig;
796
+ created_at?: string;
797
+ updated_at?: string;
798
+ };
799
+ type MissionViewConfig = {
800
+ id: string;
801
+ name: string;
802
+ description?: string;
803
+ columns?: MissionViewColumn[];
804
+ filters?: MissionViewFilter[];
805
+ sort_by?: string;
806
+ sort_order?: 'asc' | 'desc';
807
+ };
808
+ type MissionViewColumn = {
809
+ key: string;
810
+ label: string;
811
+ width?: number;
812
+ visible?: boolean;
813
+ sortable?: boolean;
814
+ };
815
+ type MissionViewFilter = {
816
+ key: string;
817
+ operator?: 'eq' | 'ne' | 'contains' | 'gt' | 'lt' | 'gte' | 'lte';
818
+ value?: any;
819
+ };
820
+ type MissionPostViewReq = {
821
+ view_ids: string[];
822
+ };
823
+
824
+ declare class AiBase extends CNBCore {
825
+ group: string;
826
+ constructor(options: CNBCoreOptions);
827
+ autoPr(repo: string, data: {
828
+ body: string;
829
+ branch?: string;
830
+ title: string;
831
+ }): Promise<Result<any>>;
832
+ }
833
+
834
+ type CNBOptions = CNBCoreOptions<{}>;
835
+ declare class CNB extends CNBCore {
836
+ workspace: Workspace;
837
+ knowledgeBase: KnowledgeBase;
838
+ repo: Repo;
839
+ user: User;
840
+ build: Build;
841
+ issue: Issue;
842
+ mission: Mission;
843
+ ai: AiBase;
844
+ constructor(options: CNBOptions);
845
+ init(cnbOptions?: CNBOptions): void;
846
+ setToken(token: string): void;
847
+ setCookie(cookie: string): void;
848
+ }
849
+
850
+ type CNBItem = {
851
+ username: string;
852
+ token: string;
853
+ cookie?: string;
854
+ runAt?: number;
855
+ owner?: boolean;
856
+ cnb: CNB;
857
+ cnbAi: ReturnType<typeof createOpenAICompatible>;
858
+ };
859
+ declare class CNBManager {
860
+ cnbMap: Map<string, CNBItem>;
861
+ constructor();
862
+ getDefaultCNB(): CNBItem;
863
+ getCNB(opts?: {
864
+ username?: string;
865
+ kevisualToken?: string;
866
+ }): Promise<CNBItem | null>;
867
+ /**
868
+ * 通过上下文获取 CNB 实例(直接返回 cnb 对象)
869
+ * @param ctx
870
+ * @returns CNB 实例
871
+ */
872
+ getContext(ctx: any): Promise<CNB>;
873
+ getCNBItem(ctx: any): Promise<CNBItem>;
874
+ addCNB(opts: Partial<CNBItem>): CNBItem;
875
+ clearExpiredCNB(expireTime?: number): void;
876
+ clearUsername(username: string): void;
877
+ }
878
+
879
+ declare const cnbManager: CNBManager;
880
+ declare const app: QueryRouterServer<{
881
+ [x: string]: any;
882
+ }>;
883
+ declare const notCNBCheck: (ctx: any) => boolean;
884
+
885
+ export { app, cnbManager, notCNBCheck };