@kevisual/cnb 0.0.56 → 0.0.58

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "basename": "/root/cnb",
package/src/index.ts CHANGED
@@ -8,6 +8,8 @@ import { Issue } from "./issue/index.ts";
8
8
  import { Mission } from "./mission/index.ts";
9
9
  import { AiBase } from "./ai/index.ts";
10
10
  import { RepoLabel, IssueLabel } from "./labels/index.ts";
11
+ import { RegistryPackage, PackageManagement } from "./package/index.ts";
12
+ import { Organization } from "./org/index.ts";
11
13
 
12
14
  type CNBOptions = CNBCoreOptions<{
13
15
  }>;
@@ -25,6 +27,11 @@ export class CNB extends CNBCore {
25
27
  repoLabel: RepoLabel;
26
28
  issueLabel: IssueLabel;
27
29
  };
30
+ packages!: {
31
+ registry: RegistryPackage;
32
+ package: PackageManagement;
33
+ };
34
+ org!: Organization;
28
35
  constructor(options: CNBOptions) {
29
36
  super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
30
37
  this.init(options);
@@ -47,6 +54,11 @@ export class CNB extends CNBCore {
47
54
  repoLabel: new RepoLabel(options),
48
55
  issueLabel: new IssueLabel(options),
49
56
  };
57
+ this.packages = {
58
+ registry: new RegistryPackage(options),
59
+ package: new PackageManagement(options),
60
+ };
61
+ this.org = new Organization(options);
50
62
  }
51
63
  setToken(token: string) {
52
64
  this.token = token;
@@ -58,6 +70,9 @@ export class CNB extends CNBCore {
58
70
  this.mission.token = token;
59
71
  this.labels.repoLabel.token = token;
60
72
  this.labels.issueLabel.token = token;
73
+ this.packages.registry.token = token;
74
+ this.packages.package.token = token;
75
+ this.org.token = token;
61
76
  }
62
77
  setCookie(cookie: string) {
63
78
  this.cookie = cookie;
@@ -69,6 +84,9 @@ export class CNB extends CNBCore {
69
84
  this.mission.cookie = cookie;
70
85
  this.labels.repoLabel.cookie = cookie;
71
86
  this.labels.issueLabel.cookie = cookie;
87
+ this.packages.registry.cookie = cookie;
88
+ this.packages.package.cookie = cookie;
89
+ this.org.cookie = cookie;
72
90
  }
73
91
  getCNBVersion = getCNBVersion
74
92
  }
@@ -95,4 +113,6 @@ type VersionInfo = {
95
113
  }
96
114
 
97
115
  export * from './issue/npc/env.ts'
98
- export * from './labels/index.ts'
116
+ export * from './labels/index.ts'
117
+ export * from './package/index.ts'
118
+ export * from './org/index.ts'
@@ -63,8 +63,11 @@ export type IssueItem = {
63
63
  number: string;
64
64
  priority: string;
65
65
  started_at: string;
66
- state: string;
67
- state_reason: string;
66
+ state: 'open' | 'closed';
67
+ /**
68
+ * state_reason must be one of completed, not_planned, reopened
69
+ */
70
+ state_reason: 'completed' | 'not_planned' | 'reopened';
68
71
  title: string;
69
72
  updated_at: string;
70
73
  };
@@ -1,5 +1,6 @@
1
1
  import { CNBCore, CNBCoreOptions, Result } from "../cnb-core.ts";
2
2
 
3
+ // https://cnb.cool/cnb/plugins/cnbcool/knowledge-base/-/blob/main/src/api.py
3
4
  export class KnowledgeBase extends CNBCore {
4
5
  constructor(options: CNBCoreOptions) {
5
6
  super(options);
@@ -12,10 +13,7 @@ export class KnowledgeBase extends CNBCore {
12
13
  metadata_filtering_conditions?: MetadataFilteringConditions
13
14
  }): Promise<Result<QueryRag[]>> {
14
15
  const url = `/${repo}/-/knowledge/base/query`;
15
- let postData = {
16
- query: data.query,
17
- };
18
- return this.post({ url, data: postData });
16
+ return this.post({ url, data });
19
17
  }
20
18
  getEmbeddingModels(repo: string): Promise<Result<Array<{ name: string, dimensions: number }>>> {
21
19
  const url = `/${repo}/-/knowledge/embedding/models`;
@@ -31,6 +29,95 @@ export class KnowledgeBase extends CNBCore {
31
29
  const url = `/${repo}/-/knowledge/base`;
32
30
  return this.request({ url, method: 'DELETE' });
33
31
  }
32
+
33
+ /**
34
+ * 未暴露
35
+ * @param repo
36
+ * @param data
37
+ * @returns
38
+ */
39
+ createKnowledgeBase(repo: string, data: {
40
+ embedding_model_name: string;
41
+ include: string;
42
+ exclude: string;
43
+ issue_sync_enabled?: boolean;
44
+ processing?: {
45
+ chunk_size: number;
46
+ chunk_overlap: number;
47
+ text_separator: string;
48
+ };
49
+ issue?: {
50
+ labels: string;
51
+ state: string;
52
+ };
53
+ }): Promise<Result<any>> {
54
+ const url = `/${repo}/-/knowledge/base`;
55
+ return this.post({ url, data });
56
+ }
57
+ /**
58
+ * 未暴露
59
+ * @param repo
60
+ * @param data
61
+ * @returns
62
+ */
63
+ updateKnowledgeBase(repo: string, data: {
64
+ last_commit_sha?: string;
65
+ issue_last_sync_time?: string;
66
+ }): Promise<Result<any>> {
67
+ const url = `/${repo}/-/knowledge/base`;
68
+ return this.put({ url, data });
69
+ }
70
+
71
+ /**
72
+ * 未暴露
73
+ * @param repo
74
+ * @param text
75
+ * @returns
76
+ */
77
+ getEmbedding(repo: string, text: string): Promise<Result<{ embedding: number[] }>> {
78
+ const url = `/${repo}/-/knowledge/embedding`;
79
+ return this.post({ url, data: { text } });
80
+ }
81
+ /**
82
+ * 未暴露
83
+ * @param repo
84
+ * @param chunksData
85
+ * @returns
86
+ */
87
+ addDocument(repo: string, chunksData: {
88
+ path: string;
89
+ chunks: Array<{
90
+ content: string;
91
+ hash: string;
92
+ offset: number;
93
+ size: number;
94
+ }>;
95
+ }): Promise<Result<any>> {
96
+ const url = `/${repo}/-/knowledge/documents/upsert-document-with-chunks`;
97
+ return this.post({ url, data: chunksData });
98
+ }
99
+ /**
100
+ * 未暴露
101
+ * @param repo
102
+ * @param paths
103
+ * @returns
104
+ */
105
+
106
+ deleteDocument(repo: string, paths: string[]): Promise<Result<any>> {
107
+ const url = `/${repo}/-/knowledge/documents`;
108
+ return this.delete({ url, data: { paths } });
109
+ }
110
+ /**
111
+ * 未暴露
112
+ * @param repo
113
+ * @param page
114
+ * @param page_size
115
+ * @returns
116
+ */
117
+ listDocument(repo: string, page: number = 1, page_size: number = 50): Promise<Result<any[]>> {
118
+ const url = `/${repo}/-/knowledge/documents`;
119
+ return this.get({ url, params: { page, page_size } });
120
+ }
34
121
  }
35
122
 
36
123
  type MetadataFilteringConditions = {
@@ -42,7 +129,7 @@ type MetadataFilteringConditions = {
42
129
  */
43
130
  value?: string
44
131
  }>
45
- logical_operator?: 'adn' | 'or'
132
+ logical_operator?: 'and' | 'or'
46
133
  }
47
134
 
48
135
  type QueryRag = {