@kevisual/cnb 0.0.52 → 0.0.54

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/dist/routes.js CHANGED
@@ -2339,7 +2339,7 @@ var require_src = __commonJS((exports) => {
2339
2339
  };
2340
2340
  });
2341
2341
 
2342
- // ../../node_modules/.pnpm/@kevisual+router@0.1.3/node_modules/@kevisual/router/dist/router.js
2342
+ // ../../node_modules/.pnpm/@kevisual+router@0.1.6/node_modules/@kevisual/router/dist/router.js
2343
2343
  import { createRequire as createRequire2 } from "node:module";
2344
2344
  import { webcrypto as crypto } from "node:crypto";
2345
2345
  import url2 from "node:url";
@@ -19854,7 +19854,7 @@ class QueryRouter {
19854
19854
  console.error("=====debug====:", e);
19855
19855
  console.error("=====debug====:[path:key]:", `${route.path}-${route.key}`);
19856
19856
  }
19857
- if (e instanceof CustomError) {
19857
+ if (e instanceof CustomError || e?.code) {
19858
19858
  ctx.code = e.code;
19859
19859
  ctx.message = e.message;
19860
19860
  } else {
@@ -20117,6 +20117,39 @@ class QueryRouterServer extends QueryRouter {
20117
20117
  const { path, key, id } = api2;
20118
20118
  return this.run({ path, key, id, payload }, ctx);
20119
20119
  }
20120
+ async createAuth(fun) {
20121
+ this.route({
20122
+ path: "auth",
20123
+ key: "auth",
20124
+ id: "auth",
20125
+ description: "token验证"
20126
+ }).define(async (ctx) => {
20127
+ if (fun) {
20128
+ await fun(ctx, "auth");
20129
+ }
20130
+ }).addTo(this, { overwrite: false });
20131
+ this.route({
20132
+ path: "auth-admin",
20133
+ key: "auth-admin",
20134
+ id: "auth-admin",
20135
+ description: "admin token验证",
20136
+ middleware: ["auth"]
20137
+ }).define(async (ctx) => {
20138
+ if (fun) {
20139
+ await fun(ctx, "auth-admin");
20140
+ }
20141
+ }).addTo(this, { overwrite: false });
20142
+ this.route({
20143
+ path: "auth-can",
20144
+ key: "auth-can",
20145
+ id: "auth-can",
20146
+ description: "权限验证"
20147
+ }).define(async (ctx) => {
20148
+ if (fun) {
20149
+ await fun(ctx, "auth-can");
20150
+ }
20151
+ }).addTo(this, { overwrite: false });
20152
+ }
20120
20153
  }
20121
20154
  var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
20122
20155
  var isBrowser2 = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
@@ -22927,6 +22960,22 @@ class Issue extends CNBCore {
22927
22960
  }
22928
22961
  }
22929
22962
 
22963
+ // src/mission/modules/resources.ts
22964
+ var queryResources = async (cnb, opts) => {
22965
+ const url3 = `${cnb.hackURL}/${opts?.repo || "kevisual/projects"}/-/mission-resource/resources`;
22966
+ return cnb.post({
22967
+ url: url3,
22968
+ data: {
22969
+ selectors: opts?.selectors,
22970
+ slugName: opts?.repo
22971
+ },
22972
+ headers: {
22973
+ Accept: "application/vnd.cnb.web+json"
22974
+ },
22975
+ useCookie: true
22976
+ });
22977
+ };
22978
+
22930
22979
  // src/mission/index.ts
22931
22980
  class Mission extends CNBCore {
22932
22981
  constructor(options) {
@@ -22989,6 +23038,9 @@ class Mission extends CNBCore {
22989
23038
  params: { visibility }
22990
23039
  });
22991
23040
  }
23041
+ queryResources(repo, selectors) {
23042
+ return queryResources(this, { repo, selectors });
23043
+ }
22992
23044
  }
22993
23045
 
22994
23046
  // src/ai/index.ts
@@ -23008,6 +23060,78 @@ class AiBase extends CNBCore {
23008
23060
  }
23009
23061
  }
23010
23062
 
23063
+ // src/labels/repo-label.ts
23064
+ class RepoLabel extends CNBCore {
23065
+ constructor(options) {
23066
+ super(options);
23067
+ }
23068
+ list(repo, params) {
23069
+ const url3 = `/${repo}/-/labels`;
23070
+ return this.get({
23071
+ url: url3,
23072
+ params,
23073
+ headers: {
23074
+ Accept: "application/vnd.cnb.api+json"
23075
+ }
23076
+ });
23077
+ }
23078
+ create(repo, data) {
23079
+ const url3 = `/${repo}/-/labels`;
23080
+ return this.post({
23081
+ url: url3,
23082
+ data
23083
+ });
23084
+ }
23085
+ update(repo, name, data) {
23086
+ const url3 = `/${repo}/-/labels/${encodeURIComponent(name)}`;
23087
+ return this.patch({
23088
+ url: url3,
23089
+ data
23090
+ });
23091
+ }
23092
+ remove(repo, name) {
23093
+ const url3 = `/${repo}/-/labels/${encodeURIComponent(name)}`;
23094
+ return this.delete({ url: url3 });
23095
+ }
23096
+ }
23097
+
23098
+ class IssueLabel extends CNBCore {
23099
+ constructor(options) {
23100
+ super(options);
23101
+ }
23102
+ list(repo, number4, params) {
23103
+ const url3 = `/${repo}/-/issues/${number4}/labels`;
23104
+ return this.get({
23105
+ url: url3,
23106
+ params,
23107
+ headers: {
23108
+ Accept: "application/vnd.cnb.api+json"
23109
+ }
23110
+ });
23111
+ }
23112
+ set(repo, number4, data) {
23113
+ const url3 = `/${repo}/-/issues/${number4}/labels`;
23114
+ return this.put({
23115
+ url: url3,
23116
+ data
23117
+ });
23118
+ }
23119
+ add(repo, number4, data) {
23120
+ const url3 = `/${repo}/-/issues/${number4}/labels`;
23121
+ return this.post({
23122
+ url: url3,
23123
+ data
23124
+ });
23125
+ }
23126
+ clear(repo, number4) {
23127
+ const url3 = `/${repo}/-/issues/${number4}/labels`;
23128
+ return this.delete({ url: url3 });
23129
+ }
23130
+ remove(repo, number4, name) {
23131
+ const url3 = `/${repo}/-/issues/${number4}/labels/${encodeURIComponent(name)}`;
23132
+ return this.delete({ url: url3 });
23133
+ }
23134
+ }
23011
23135
  // src/index.ts
23012
23136
  class CNB extends CNBCore {
23013
23137
  workspace;
@@ -23018,6 +23142,7 @@ class CNB extends CNBCore {
23018
23142
  issue;
23019
23143
  mission;
23020
23144
  ai;
23145
+ labels;
23021
23146
  constructor(options) {
23022
23147
  super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
23023
23148
  this.init(options);
@@ -23036,6 +23161,10 @@ class CNB extends CNBCore {
23036
23161
  this.issue = new Issue(options);
23037
23162
  this.mission = new Mission(options);
23038
23163
  this.ai = new AiBase(options);
23164
+ this.labels = {
23165
+ repoLabel: new RepoLabel(options),
23166
+ issueLabel: new IssueLabel(options)
23167
+ };
23039
23168
  }
23040
23169
  setToken(token) {
23041
23170
  this.token = token;
@@ -23045,6 +23174,8 @@ class CNB extends CNBCore {
23045
23174
  this.build.token = token;
23046
23175
  this.issue.token = token;
23047
23176
  this.mission.token = token;
23177
+ this.labels.repoLabel.token = token;
23178
+ this.labels.issueLabel.token = token;
23048
23179
  }
23049
23180
  setCookie(cookie) {
23050
23181
  this.cookie = cookie;
@@ -23054,8 +23185,15 @@ class CNB extends CNBCore {
23054
23185
  this.build.cookie = cookie;
23055
23186
  this.issue.cookie = cookie;
23056
23187
  this.mission.cookie = cookie;
23188
+ this.labels.repoLabel.cookie = cookie;
23189
+ this.labels.issueLabel.cookie = cookie;
23057
23190
  }
23191
+ getCNBVersion = getCNBVersion;
23058
23192
  }
23193
+ var getCNBVersion = () => {
23194
+ const url3 = "https://cnb.cool/api/version";
23195
+ return fetch(url3).then((res) => res.json());
23196
+ };
23059
23197
 
23060
23198
  // ../../node_modules/.pnpm/@ai-sdk+provider@3.0.8/node_modules/@ai-sdk/provider/dist/index.mjs
23061
23199
  var marker = "vercel.ai.error";
@@ -44765,6 +44903,169 @@ app.route({
44765
44903
  const res = await cnb.repo.updateRepoInfo(name15, { description, license, site, topics });
44766
44904
  ctx.forward(res);
44767
44905
  }).addTo(app);
44906
+ app.route({
44907
+ path: "cnb",
44908
+ key: "update-repo-visibility",
44909
+ description: "更新代码仓库的可见性, 参数name, visibility",
44910
+ middleware: ["auth"],
44911
+ metadata: {
44912
+ args: {
44913
+ name: tool.schema.string().describe("代码仓库名称"),
44914
+ visibility: tool.schema.string().describe("代码仓库可见性, public 或 private 或 protected")
44915
+ }
44916
+ }
44917
+ }).define(async (ctx) => {
44918
+ const cnb = await cnbManager.getContext(ctx);
44919
+ const name15 = ctx.query?.name;
44920
+ const visibility = ctx.query?.visibility;
44921
+ if (!name15) {
44922
+ ctx.throw(400, "缺少参数 name");
44923
+ }
44924
+ if (!visibility) {
44925
+ ctx.throw(400, "缺少参数 visibility");
44926
+ }
44927
+ const res = await cnb.post({
44928
+ url: `/${name15}/-/settings/set_visibility`,
44929
+ data: { visibility }
44930
+ });
44931
+ ctx.forward(res);
44932
+ }).addTo(app);
44933
+
44934
+ // agent/routes/repo/repo-label.ts
44935
+ app.route({
44936
+ path: "cnb",
44937
+ key: "list-repo-labels",
44938
+ description: "查询仓库的标签列表",
44939
+ middleware: ["auth"],
44940
+ metadata: {
44941
+ tags: ["opencode"],
44942
+ ...createSkill({
44943
+ skill: "list-repo-labels",
44944
+ title: "查询仓库标签列表",
44945
+ summary: "查询仓库的标签列表",
44946
+ args: {
44947
+ repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
44948
+ page: tool.schema.number().optional().describe("分页页码,默认 1"),
44949
+ pageSize: tool.schema.number().optional().describe("分页每页大小,默认 30"),
44950
+ keyword: tool.schema.string().optional().describe("标签搜索关键词")
44951
+ }
44952
+ })
44953
+ }
44954
+ }).define(async (ctx) => {
44955
+ const cnb = await cnbManager.getContext(ctx);
44956
+ const repo2 = ctx.query?.repo;
44957
+ const page = ctx.query?.page;
44958
+ const pageSize = ctx.query?.pageSize;
44959
+ const keyword = ctx.query?.keyword;
44960
+ if (!repo2) {
44961
+ ctx.throw(400, "缺少参数 repo");
44962
+ }
44963
+ const res = await cnb.labels.repoLabel.list(repo2, {
44964
+ page,
44965
+ page_size: pageSize,
44966
+ keyword
44967
+ });
44968
+ ctx.forward(res);
44969
+ }).addTo(app);
44970
+ app.route({
44971
+ path: "cnb",
44972
+ key: "create-repo-label",
44973
+ description: "创建仓库标签",
44974
+ middleware: ["auth"],
44975
+ metadata: {
44976
+ tags: ["opencode"],
44977
+ ...createSkill({
44978
+ skill: "create-repo-label",
44979
+ title: "创建仓库标签",
44980
+ summary: "创建一个仓库标签",
44981
+ args: {
44982
+ repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
44983
+ name: tool.schema.string().describe("标签名称"),
44984
+ color: tool.schema.string().describe("标签颜色,十六进制颜色码,不含 # 前缀"),
44985
+ description: tool.schema.string().optional().describe("标签描述")
44986
+ }
44987
+ })
44988
+ }
44989
+ }).define(async (ctx) => {
44990
+ const cnb = await cnbManager.getContext(ctx);
44991
+ const repo2 = ctx.query?.repo;
44992
+ const name15 = ctx.query?.name;
44993
+ const color = ctx.query?.color;
44994
+ const description = ctx.query?.description;
44995
+ if (!repo2 || !name15 || !color) {
44996
+ ctx.throw(400, "缺少参数 repo, name 或 color");
44997
+ }
44998
+ const res = await cnb.labels.repoLabel.create(repo2, {
44999
+ name: name15,
45000
+ color,
45001
+ description
45002
+ });
45003
+ ctx.forward(res);
45004
+ }).addTo(app);
45005
+ app.route({
45006
+ path: "cnb",
45007
+ key: "update-repo-label",
45008
+ description: "更新仓库标签",
45009
+ middleware: ["auth"],
45010
+ metadata: {
45011
+ tags: ["opencode"],
45012
+ ...createSkill({
45013
+ skill: "update-repo-label",
45014
+ title: "更新仓库标签",
45015
+ summary: "更新仓库标签信息",
45016
+ args: {
45017
+ repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
45018
+ name: tool.schema.string().describe("标签名称"),
45019
+ color: tool.schema.string().optional().describe("标签颜色,十六进制颜色码,不含 # 前缀"),
45020
+ description: tool.schema.string().optional().describe("标签描述"),
45021
+ newName: tool.schema.string().optional().describe("新标签名称")
45022
+ }
45023
+ })
45024
+ }
45025
+ }).define(async (ctx) => {
45026
+ const cnb = await cnbManager.getContext(ctx);
45027
+ const repo2 = ctx.query?.repo;
45028
+ const name15 = ctx.query?.name;
45029
+ const color = ctx.query?.color;
45030
+ const description = ctx.query?.description;
45031
+ const newName = ctx.query?.newName;
45032
+ if (!repo2 || !name15) {
45033
+ ctx.throw(400, "缺少参数 repo 或 name");
45034
+ }
45035
+ const res = await cnb.labels.repoLabel.update(repo2, name15, {
45036
+ color,
45037
+ description,
45038
+ new_name: newName
45039
+ });
45040
+ ctx.forward(res);
45041
+ }).addTo(app);
45042
+ app.route({
45043
+ path: "cnb",
45044
+ key: "delete-repo-label",
45045
+ description: "删除仓库标签",
45046
+ middleware: ["auth"],
45047
+ metadata: {
45048
+ tags: ["opencode"],
45049
+ ...createSkill({
45050
+ skill: "delete-repo-label",
45051
+ title: "删除仓库标签",
45052
+ summary: "删除指定的仓库标签",
45053
+ args: {
45054
+ repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
45055
+ name: tool.schema.string().describe("标签名称")
45056
+ }
45057
+ })
45058
+ }
45059
+ }).define(async (ctx) => {
45060
+ const cnb = await cnbManager.getContext(ctx);
45061
+ const repo2 = ctx.query?.repo;
45062
+ const name15 = ctx.query?.name;
45063
+ if (!repo2 || !name15) {
45064
+ ctx.throw(400, "缺少参数 repo 或 name");
45065
+ }
45066
+ const res = await cnb.labels.repoLabel.remove(repo2, name15);
45067
+ ctx.forward(res);
45068
+ }).addTo(app);
44768
45069
 
44769
45070
  // agent/routes/workspace/skills.ts
44770
45071
  app.route({
@@ -45855,7 +46156,7 @@ app.route({
45855
46156
  let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
45856
46157
  const state = ctx.query?.state;
45857
46158
  const keyword = ctx.query?.keyword;
45858
- const labels = ctx.query?.labels;
46159
+ const labels2 = ctx.query?.labels;
45859
46160
  const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
45860
46161
  const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
45861
46162
  const order_by = ctx.query?.order_by;
@@ -45867,8 +46168,8 @@ app.route({
45867
46168
  params.state = state;
45868
46169
  if (keyword)
45869
46170
  params.keyword = keyword;
45870
- if (labels)
45871
- params.labels = labels;
46171
+ if (labels2)
46172
+ params.labels = labels2;
45872
46173
  if (page)
45873
46174
  params.page = page;
45874
46175
  if (page_size)
@@ -45937,7 +46238,7 @@ app.route({
45937
46238
  const title = ctx.query?.title;
45938
46239
  const body = ctx.query?.body;
45939
46240
  const assignees = ctx.query?.assignees;
45940
- const labels = ctx.query?.labels;
46241
+ const labels2 = ctx.query?.labels;
45941
46242
  const priority = ctx.query?.priority;
45942
46243
  if (!repo2 || !title) {
45943
46244
  ctx.throw(400, "缺少参数 repo 或 title");
@@ -45946,7 +46247,7 @@ app.route({
45946
46247
  title,
45947
46248
  body,
45948
46249
  assignees,
45949
- labels,
46250
+ labels: labels2,
45950
46251
  priority
45951
46252
  });
45952
46253
  ctx.forward(res);
@@ -46203,7 +46504,7 @@ var getLiveMdContent = (opts) => {
46203
46504
  2. Opencode web访问说明
46204
46505
  Opencode打开web地址,需要在浏览器输入用户名和密码,用户名固定为root,密码为CNB_TOKEN的值. 纯连接打开包含账号密码,第一次点击后,需要把账号密码清理掉才能访问,opencode的bug导致的。
46205
46506
  `;
46206
- const labels = [
46507
+ const labels2 = [
46207
46508
  {
46208
46509
  key: "vscodeWebUrl",
46209
46510
  title: "VSCode Web 地址",
@@ -46260,11 +46561,11 @@ Opencode打开web地址,需要在浏览器输入用户名和密码,用户名
46260
46561
  }
46261
46562
  ];
46262
46563
  const osInfoList = createOSInfo(more);
46263
- labels.push(...osInfoList);
46264
- return labels;
46564
+ labels2.push(...osInfoList);
46565
+ return labels2;
46265
46566
  };
46266
46567
  var createOSInfo = (more = false) => {
46267
- const labels = [];
46568
+ const labels2 = [];
46268
46569
  const startTimer = useKey("CNB_BUILD_START_TIME") || "";
46269
46570
  const cpus = os2.cpus();
46270
46571
  let totalIdle = 0;
@@ -46324,7 +46625,7 @@ var createOSInfo = (more = false) => {
46324
46625
  } catch (e) {
46325
46626
  diskUsage = "获取失败";
46326
46627
  }
46327
- labels.push({
46628
+ labels2.push({
46328
46629
  key: "cpuUsage",
46329
46630
  title: "CPU 使用率",
46330
46631
  value: `${cpuUsage}%`,
@@ -46366,7 +46667,7 @@ var createOSInfo = (more = false) => {
46366
46667
  const buildUptime = Date.now() - buildStartTimestamp;
46367
46668
  const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
46368
46669
  const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
46369
- labels.push({
46670
+ labels2.push({
46370
46671
  key: "buildStartTime",
46371
46672
  title: "构建启动时间",
46372
46673
  value: buildStartTime,
@@ -46385,13 +46686,13 @@ var createOSInfo = (more = false) => {
46385
46686
  timeTo4 = today4am.add(1, "day").valueOf() - now.valueOf();
46386
46687
  }
46387
46688
  const timeTo4Str = `[距离晚上4点重启时间: ${formatUptime(Math.floor(timeTo4 / 1000))}]`;
46388
- labels.push({
46689
+ labels2.push({
46389
46690
  key: "buildMaxRunTime",
46390
46691
  title: "最大运行时间",
46391
46692
  value: formatUptime(Math.floor(maxRunTime / 1000)),
46392
46693
  description: "构建最大运行时间(限制时间)"
46393
46694
  });
46394
- labels.unshift({
46695
+ labels2.unshift({
46395
46696
  key: "remainingTime",
46396
46697
  title: "剩余时间",
46397
46698
  value: maxRunTime - buildUptime,
@@ -46401,7 +46702,7 @@ var createOSInfo = (more = false) => {
46401
46702
  }
46402
46703
  if (more) {
46403
46704
  const loadavg = os2.loadavg();
46404
- labels.push({
46705
+ labels2.push({
46405
46706
  key: "hostname",
46406
46707
  title: "主机名",
46407
46708
  value: os2.hostname(),
@@ -46438,7 +46739,7 @@ var createOSInfo = (more = false) => {
46438
46739
  description: "系统负载 (15分钟)"
46439
46740
  });
46440
46741
  }
46441
- return labels;
46742
+ return labels2;
46442
46743
  };
46443
46744
 
46444
46745
  // agent/routes/cnb-board/cnb-dev-env.ts
@@ -46475,7 +46776,7 @@ app.route({
46475
46776
  if (notCNBCheck(ctx))
46476
46777
  return;
46477
46778
  const repoNameFromSlug = repoSlug.split("/").pop() || "";
46478
- const labels = [
46779
+ const labels2 = [
46479
46780
  {
46480
46781
  title: "CNB_REPO_SLUG",
46481
46782
  value: repoSlug,
@@ -46509,7 +46810,7 @@ app.route({
46509
46810
  ];
46510
46811
  ctx.body = {
46511
46812
  title: "CNB_BOARD_LIVE_REPO_INFO",
46512
- list: labels
46813
+ list: labels2
46513
46814
  };
46514
46815
  }).addTo(app);
46515
46816
  app.route({
@@ -46520,7 +46821,7 @@ app.route({
46520
46821
  }).define(async (ctx) => {
46521
46822
  if (notCNBCheck(ctx))
46522
46823
  return;
46523
- const labels = [
46824
+ const labels2 = [
46524
46825
  {
46525
46826
  title: "CNB_BUILD_ID",
46526
46827
  value: useKey("CNB_BUILD_ID") || "",
@@ -46654,7 +46955,7 @@ app.route({
46654
46955
  ];
46655
46956
  ctx.body = {
46656
46957
  title: "CNB_BOARD_LIVE_BUILD_INFO",
46657
- list: labels
46958
+ list: labels2
46658
46959
  };
46659
46960
  }).addTo(app);
46660
46961
  app.route({
@@ -46663,7 +46964,7 @@ app.route({
46663
46964
  description: "获取cnb-board live的PR信息",
46664
46965
  middleware: ["auth-admin"]
46665
46966
  }).define(async (ctx) => {
46666
- const labels = [
46967
+ const labels2 = [
46667
46968
  {
46668
46969
  title: "CNB_PULL_REQUEST",
46669
46970
  value: useKey("CNB_PULL_REQUEST") || "",
@@ -46752,7 +47053,7 @@ app.route({
46752
47053
  ];
46753
47054
  ctx.body = {
46754
47055
  title: "CNB_BOARD_LIVE_PULL_INFO",
46755
- list: labels
47056
+ list: labels2
46756
47057
  };
46757
47058
  }).addTo(app);
46758
47059
  app.route({
@@ -46763,7 +47064,7 @@ app.route({
46763
47064
  }).define(async (ctx) => {
46764
47065
  if (notCNBCheck(ctx))
46765
47066
  return;
46766
- const labels = [
47067
+ const labels2 = [
46767
47068
  {
46768
47069
  title: "CNB_NPC_SLUG",
46769
47070
  value: useKey("CNB_NPC_SLUG") || "",
@@ -46797,7 +47098,7 @@ app.route({
46797
47098
  ];
46798
47099
  ctx.body = {
46799
47100
  title: "CNB_BOARD_LIVE_NPC_INFO",
46800
- list: labels
47101
+ list: labels2
46801
47102
  };
46802
47103
  }).addTo(app);
46803
47104
  app.route({
@@ -46808,7 +47109,7 @@ app.route({
46808
47109
  }).define(async (ctx) => {
46809
47110
  if (notCNBCheck(ctx))
46810
47111
  return;
46811
- const labels = [
47112
+ const labels2 = [
46812
47113
  {
46813
47114
  title: "CNB_COMMENT_ID",
46814
47115
  value: useKey("CNB_COMMENT_ID") || "",
@@ -46842,7 +47143,7 @@ app.route({
46842
47143
  ];
46843
47144
  ctx.body = {
46844
47145
  title: "CNB_BOARD_LIVE_COMMENT_INFO",
46845
- list: labels
47146
+ list: labels2
46846
47147
  };
46847
47148
  }).addTo(app);
46848
47149
 
@@ -52981,6 +53282,44 @@ app.route({
52981
53282
  ctx.body = result;
52982
53283
  }).addTo(app);
52983
53284
 
53285
+ // agent/routes/missions/list.ts
53286
+ app.route({
53287
+ path: "cnb",
53288
+ key: "missions-list",
53289
+ description: "查询missions列表",
53290
+ metadata: {
53291
+ args: {
53292
+ repo: zod_default.string().optional().describe("missions所在的仓库,例如 kevisual/projects"),
53293
+ selector: zod_default.array(zod_default.any()).optional().describe('查询条件,例如 [{field: "resource_type", operator: "contains", value: ["issues"]},…]')
53294
+ }
53295
+ }
53296
+ }).define(async (ctx) => {
53297
+ const cnb = await cnbManager.getContext(ctx);
53298
+ const repo2 = ctx.query?.repo || "kevisual/projects";
53299
+ const res = await cnb.mission.queryResources(repo2, ctx.query?.selector || [
53300
+ {
53301
+ field: "resource_type",
53302
+ operator: "contains",
53303
+ value: [
53304
+ "issues"
53305
+ ]
53306
+ },
53307
+ {
53308
+ field: "state",
53309
+ operator: "not_equals",
53310
+ value: [
53311
+ "closed"
53312
+ ]
53313
+ },
53314
+ {
53315
+ field: "label",
53316
+ operator: "contains",
53317
+ value: ["AICoding"]
53318
+ }
53319
+ ]);
53320
+ ctx.forward(res);
53321
+ }).addTo(app);
53322
+
52984
53323
  // agent/routes/index.ts
52985
53324
  var checkAppId = (ctx, appId) => {
52986
53325
  const _appId = ctx?.app?.appId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "basename": "/root/cnb",
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import { Build } from "./build/index.ts";
7
7
  import { Issue } from "./issue/index.ts";
8
8
  import { Mission } from "./mission/index.ts";
9
9
  import { AiBase } from "./ai/index.ts";
10
+ import { RepoLabel, IssueLabel } from "./labels/index.ts";
10
11
 
11
12
  type CNBOptions = CNBCoreOptions<{
12
13
  }>;
@@ -20,6 +21,10 @@ export class CNB extends CNBCore {
20
21
  issue!: Issue;
21
22
  mission!: Mission;
22
23
  ai!: AiBase;
24
+ labels!: {
25
+ repoLabel: RepoLabel;
26
+ issueLabel: IssueLabel;
27
+ };
23
28
  constructor(options: CNBOptions) {
24
29
  super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
25
30
  this.init(options);
@@ -38,6 +43,10 @@ export class CNB extends CNBCore {
38
43
  this.issue = new Issue(options);
39
44
  this.mission = new Mission(options);
40
45
  this.ai = new AiBase(options);
46
+ this.labels = {
47
+ repoLabel: new RepoLabel(options),
48
+ issueLabel: new IssueLabel(options),
49
+ };
41
50
  }
42
51
  setToken(token: string) {
43
52
  this.token = token;
@@ -47,6 +56,8 @@ export class CNB extends CNBCore {
47
56
  this.build.token = token;
48
57
  this.issue.token = token;
49
58
  this.mission.token = token;
59
+ this.labels.repoLabel.token = token;
60
+ this.labels.issueLabel.token = token;
50
61
  }
51
62
  setCookie(cookie: string) {
52
63
  this.cookie = cookie;
@@ -56,7 +67,10 @@ export class CNB extends CNBCore {
56
67
  this.build.cookie = cookie;
57
68
  this.issue.cookie = cookie;
58
69
  this.mission.cookie = cookie;
70
+ this.labels.repoLabel.cookie = cookie;
71
+ this.labels.issueLabel.cookie = cookie;
59
72
  }
73
+ getCNBVersion = getCNBVersion
60
74
  }
61
75
 
62
76
  export * from './workspace/index.ts'
@@ -80,4 +94,5 @@ type VersionInfo = {
80
94
  hash: string;
81
95
  }
82
96
 
83
- export * from './issue/npc/env.ts'
97
+ export * from './issue/npc/env.ts'
98
+ export * from './labels/index.ts'
@@ -5,7 +5,7 @@ export type IssueAssignee = {
5
5
  nickname: string;
6
6
  username: string;
7
7
  };
8
- export type IssueLabel = {
8
+ export type IssueLabelItem = {
9
9
  color: string;
10
10
  description: string;
11
11
  id: string;
@@ -56,7 +56,7 @@ export type IssueComment = {
56
56
  export type IssueItem = {
57
57
  assignees: IssueAssignee[];
58
58
  author: IssueAuthor;
59
- labels: IssueLabel[];
59
+ labels: IssueLabelItem[];
60
60
 
61
61
  body: string;
62
62
  last_acted_at: string;
@@ -0,0 +1 @@
1
+ export * from './repo-label.ts';