@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/agent/npc.ts +2 -2
- package/agent/routes/index.ts +1 -0
- package/agent/routes/missions/index.ts +1 -0
- package/agent/routes/missions/list.ts +39 -0
- package/agent/routes/repo/index.ts +2 -1
- package/agent/routes/repo/repo-label.ts +152 -0
- package/agent/routes/repo/repo.ts +28 -0
- package/dist/cli.js +446 -69
- package/dist/npc.js +448 -71
- package/dist/opencode.js +367 -28
- package/dist/routes.d.ts +242 -2
- package/dist/routes.js +366 -27
- package/package.json +1 -1
- package/src/index.ts +16 -1
- package/src/issue/index.ts +2 -2
- package/src/labels/index.ts +1 -0
- package/src/labels/repo-label.ts +208 -0
- package/src/mission/index.ts +10 -0
- package/src/mission/modules/fields.ts +164 -0
- package/src/mission/modules/resources.ts +41 -0
package/dist/npc.js
CHANGED
|
@@ -4432,7 +4432,7 @@ var require_commander = __commonJS((exports) => {
|
|
|
4432
4432
|
exports.InvalidOptionArgumentError = InvalidArgumentError3;
|
|
4433
4433
|
});
|
|
4434
4434
|
|
|
4435
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.1.
|
|
4435
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.1.6/node_modules/@kevisual/router/dist/router.js
|
|
4436
4436
|
import { createRequire as createRequire2 } from "node:module";
|
|
4437
4437
|
import { webcrypto as crypto } from "node:crypto";
|
|
4438
4438
|
import url2 from "node:url";
|
|
@@ -21947,7 +21947,7 @@ class QueryRouter {
|
|
|
21947
21947
|
console.error("=====debug====:", e);
|
|
21948
21948
|
console.error("=====debug====:[path:key]:", `${route.path}-${route.key}`);
|
|
21949
21949
|
}
|
|
21950
|
-
if (e instanceof CustomError) {
|
|
21950
|
+
if (e instanceof CustomError || e?.code) {
|
|
21951
21951
|
ctx.code = e.code;
|
|
21952
21952
|
ctx.message = e.message;
|
|
21953
21953
|
} else {
|
|
@@ -22210,6 +22210,39 @@ class QueryRouterServer extends QueryRouter {
|
|
|
22210
22210
|
const { path, key, id } = api2;
|
|
22211
22211
|
return this.run({ path, key, id, payload }, ctx);
|
|
22212
22212
|
}
|
|
22213
|
+
async createAuth(fun) {
|
|
22214
|
+
this.route({
|
|
22215
|
+
path: "auth",
|
|
22216
|
+
key: "auth",
|
|
22217
|
+
id: "auth",
|
|
22218
|
+
description: "token验证"
|
|
22219
|
+
}).define(async (ctx) => {
|
|
22220
|
+
if (fun) {
|
|
22221
|
+
await fun(ctx, "auth");
|
|
22222
|
+
}
|
|
22223
|
+
}).addTo(this, { overwrite: false });
|
|
22224
|
+
this.route({
|
|
22225
|
+
path: "auth-admin",
|
|
22226
|
+
key: "auth-admin",
|
|
22227
|
+
id: "auth-admin",
|
|
22228
|
+
description: "admin token验证",
|
|
22229
|
+
middleware: ["auth"]
|
|
22230
|
+
}).define(async (ctx) => {
|
|
22231
|
+
if (fun) {
|
|
22232
|
+
await fun(ctx, "auth-admin");
|
|
22233
|
+
}
|
|
22234
|
+
}).addTo(this, { overwrite: false });
|
|
22235
|
+
this.route({
|
|
22236
|
+
path: "auth-can",
|
|
22237
|
+
key: "auth-can",
|
|
22238
|
+
id: "auth-can",
|
|
22239
|
+
description: "权限验证"
|
|
22240
|
+
}).define(async (ctx) => {
|
|
22241
|
+
if (fun) {
|
|
22242
|
+
await fun(ctx, "auth-can");
|
|
22243
|
+
}
|
|
22244
|
+
}).addTo(this, { overwrite: false });
|
|
22245
|
+
}
|
|
22213
22246
|
}
|
|
22214
22247
|
var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
22215
22248
|
var isBrowser2 = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
|
|
@@ -25054,6 +25087,22 @@ class Issue extends CNBCore {
|
|
|
25054
25087
|
}
|
|
25055
25088
|
}
|
|
25056
25089
|
|
|
25090
|
+
// src/mission/modules/resources.ts
|
|
25091
|
+
var queryResources = async (cnb, opts) => {
|
|
25092
|
+
const url3 = `${cnb.hackURL}/${opts?.repo || "kevisual/projects"}/-/mission-resource/resources`;
|
|
25093
|
+
return cnb.post({
|
|
25094
|
+
url: url3,
|
|
25095
|
+
data: {
|
|
25096
|
+
selectors: opts?.selectors,
|
|
25097
|
+
slugName: opts?.repo
|
|
25098
|
+
},
|
|
25099
|
+
headers: {
|
|
25100
|
+
Accept: "application/vnd.cnb.web+json"
|
|
25101
|
+
},
|
|
25102
|
+
useCookie: true
|
|
25103
|
+
});
|
|
25104
|
+
};
|
|
25105
|
+
|
|
25057
25106
|
// src/mission/index.ts
|
|
25058
25107
|
class Mission extends CNBCore {
|
|
25059
25108
|
constructor(options) {
|
|
@@ -25116,6 +25165,9 @@ class Mission extends CNBCore {
|
|
|
25116
25165
|
params: { visibility }
|
|
25117
25166
|
});
|
|
25118
25167
|
}
|
|
25168
|
+
queryResources(repo, selectors) {
|
|
25169
|
+
return queryResources(this, { repo, selectors });
|
|
25170
|
+
}
|
|
25119
25171
|
}
|
|
25120
25172
|
|
|
25121
25173
|
// src/ai/index.ts
|
|
@@ -25135,6 +25187,78 @@ class AiBase extends CNBCore {
|
|
|
25135
25187
|
}
|
|
25136
25188
|
}
|
|
25137
25189
|
|
|
25190
|
+
// src/labels/repo-label.ts
|
|
25191
|
+
class RepoLabel extends CNBCore {
|
|
25192
|
+
constructor(options) {
|
|
25193
|
+
super(options);
|
|
25194
|
+
}
|
|
25195
|
+
list(repo, params) {
|
|
25196
|
+
const url3 = `/${repo}/-/labels`;
|
|
25197
|
+
return this.get({
|
|
25198
|
+
url: url3,
|
|
25199
|
+
params,
|
|
25200
|
+
headers: {
|
|
25201
|
+
Accept: "application/vnd.cnb.api+json"
|
|
25202
|
+
}
|
|
25203
|
+
});
|
|
25204
|
+
}
|
|
25205
|
+
create(repo, data) {
|
|
25206
|
+
const url3 = `/${repo}/-/labels`;
|
|
25207
|
+
return this.post({
|
|
25208
|
+
url: url3,
|
|
25209
|
+
data
|
|
25210
|
+
});
|
|
25211
|
+
}
|
|
25212
|
+
update(repo, name, data) {
|
|
25213
|
+
const url3 = `/${repo}/-/labels/${encodeURIComponent(name)}`;
|
|
25214
|
+
return this.patch({
|
|
25215
|
+
url: url3,
|
|
25216
|
+
data
|
|
25217
|
+
});
|
|
25218
|
+
}
|
|
25219
|
+
remove(repo, name) {
|
|
25220
|
+
const url3 = `/${repo}/-/labels/${encodeURIComponent(name)}`;
|
|
25221
|
+
return this.delete({ url: url3 });
|
|
25222
|
+
}
|
|
25223
|
+
}
|
|
25224
|
+
|
|
25225
|
+
class IssueLabel extends CNBCore {
|
|
25226
|
+
constructor(options) {
|
|
25227
|
+
super(options);
|
|
25228
|
+
}
|
|
25229
|
+
list(repo, number4, params) {
|
|
25230
|
+
const url3 = `/${repo}/-/issues/${number4}/labels`;
|
|
25231
|
+
return this.get({
|
|
25232
|
+
url: url3,
|
|
25233
|
+
params,
|
|
25234
|
+
headers: {
|
|
25235
|
+
Accept: "application/vnd.cnb.api+json"
|
|
25236
|
+
}
|
|
25237
|
+
});
|
|
25238
|
+
}
|
|
25239
|
+
set(repo, number4, data) {
|
|
25240
|
+
const url3 = `/${repo}/-/issues/${number4}/labels`;
|
|
25241
|
+
return this.put({
|
|
25242
|
+
url: url3,
|
|
25243
|
+
data
|
|
25244
|
+
});
|
|
25245
|
+
}
|
|
25246
|
+
add(repo, number4, data) {
|
|
25247
|
+
const url3 = `/${repo}/-/issues/${number4}/labels`;
|
|
25248
|
+
return this.post({
|
|
25249
|
+
url: url3,
|
|
25250
|
+
data
|
|
25251
|
+
});
|
|
25252
|
+
}
|
|
25253
|
+
clear(repo, number4) {
|
|
25254
|
+
const url3 = `/${repo}/-/issues/${number4}/labels`;
|
|
25255
|
+
return this.delete({ url: url3 });
|
|
25256
|
+
}
|
|
25257
|
+
remove(repo, number4, name) {
|
|
25258
|
+
const url3 = `/${repo}/-/issues/${number4}/labels/${encodeURIComponent(name)}`;
|
|
25259
|
+
return this.delete({ url: url3 });
|
|
25260
|
+
}
|
|
25261
|
+
}
|
|
25138
25262
|
// src/index.ts
|
|
25139
25263
|
class CNB extends CNBCore {
|
|
25140
25264
|
workspace;
|
|
@@ -25145,6 +25269,7 @@ class CNB extends CNBCore {
|
|
|
25145
25269
|
issue;
|
|
25146
25270
|
mission;
|
|
25147
25271
|
ai;
|
|
25272
|
+
labels;
|
|
25148
25273
|
constructor(options) {
|
|
25149
25274
|
super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
|
|
25150
25275
|
this.init(options);
|
|
@@ -25163,6 +25288,10 @@ class CNB extends CNBCore {
|
|
|
25163
25288
|
this.issue = new Issue(options);
|
|
25164
25289
|
this.mission = new Mission(options);
|
|
25165
25290
|
this.ai = new AiBase(options);
|
|
25291
|
+
this.labels = {
|
|
25292
|
+
repoLabel: new RepoLabel(options),
|
|
25293
|
+
issueLabel: new IssueLabel(options)
|
|
25294
|
+
};
|
|
25166
25295
|
}
|
|
25167
25296
|
setToken(token) {
|
|
25168
25297
|
this.token = token;
|
|
@@ -25172,6 +25301,8 @@ class CNB extends CNBCore {
|
|
|
25172
25301
|
this.build.token = token;
|
|
25173
25302
|
this.issue.token = token;
|
|
25174
25303
|
this.mission.token = token;
|
|
25304
|
+
this.labels.repoLabel.token = token;
|
|
25305
|
+
this.labels.issueLabel.token = token;
|
|
25175
25306
|
}
|
|
25176
25307
|
setCookie(cookie) {
|
|
25177
25308
|
this.cookie = cookie;
|
|
@@ -25181,8 +25312,15 @@ class CNB extends CNBCore {
|
|
|
25181
25312
|
this.build.cookie = cookie;
|
|
25182
25313
|
this.issue.cookie = cookie;
|
|
25183
25314
|
this.mission.cookie = cookie;
|
|
25315
|
+
this.labels.repoLabel.cookie = cookie;
|
|
25316
|
+
this.labels.issueLabel.cookie = cookie;
|
|
25184
25317
|
}
|
|
25318
|
+
getCNBVersion = getCNBVersion;
|
|
25185
25319
|
}
|
|
25320
|
+
var getCNBVersion = () => {
|
|
25321
|
+
const url3 = "https://cnb.cool/api/version";
|
|
25322
|
+
return fetch(url3).then((res) => res.json());
|
|
25323
|
+
};
|
|
25186
25324
|
|
|
25187
25325
|
// ../../node_modules/.pnpm/@ai-sdk+provider@3.0.8/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
25188
25326
|
var marker = "vercel.ai.error";
|
|
@@ -46892,6 +47030,169 @@ app.route({
|
|
|
46892
47030
|
const res = await cnb.repo.updateRepoInfo(name15, { description, license, site, topics });
|
|
46893
47031
|
ctx.forward(res);
|
|
46894
47032
|
}).addTo(app);
|
|
47033
|
+
app.route({
|
|
47034
|
+
path: "cnb",
|
|
47035
|
+
key: "update-repo-visibility",
|
|
47036
|
+
description: "更新代码仓库的可见性, 参数name, visibility",
|
|
47037
|
+
middleware: ["auth"],
|
|
47038
|
+
metadata: {
|
|
47039
|
+
args: {
|
|
47040
|
+
name: tool.schema.string().describe("代码仓库名称"),
|
|
47041
|
+
visibility: tool.schema.string().describe("代码仓库可见性, public 或 private 或 protected")
|
|
47042
|
+
}
|
|
47043
|
+
}
|
|
47044
|
+
}).define(async (ctx) => {
|
|
47045
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
47046
|
+
const name15 = ctx.query?.name;
|
|
47047
|
+
const visibility = ctx.query?.visibility;
|
|
47048
|
+
if (!name15) {
|
|
47049
|
+
ctx.throw(400, "缺少参数 name");
|
|
47050
|
+
}
|
|
47051
|
+
if (!visibility) {
|
|
47052
|
+
ctx.throw(400, "缺少参数 visibility");
|
|
47053
|
+
}
|
|
47054
|
+
const res = await cnb.post({
|
|
47055
|
+
url: `/${name15}/-/settings/set_visibility`,
|
|
47056
|
+
data: { visibility }
|
|
47057
|
+
});
|
|
47058
|
+
ctx.forward(res);
|
|
47059
|
+
}).addTo(app);
|
|
47060
|
+
|
|
47061
|
+
// agent/routes/repo/repo-label.ts
|
|
47062
|
+
app.route({
|
|
47063
|
+
path: "cnb",
|
|
47064
|
+
key: "list-repo-labels",
|
|
47065
|
+
description: "查询仓库的标签列表",
|
|
47066
|
+
middleware: ["auth"],
|
|
47067
|
+
metadata: {
|
|
47068
|
+
tags: ["opencode"],
|
|
47069
|
+
...createSkill({
|
|
47070
|
+
skill: "list-repo-labels",
|
|
47071
|
+
title: "查询仓库标签列表",
|
|
47072
|
+
summary: "查询仓库的标签列表",
|
|
47073
|
+
args: {
|
|
47074
|
+
repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
47075
|
+
page: tool.schema.number().optional().describe("分页页码,默认 1"),
|
|
47076
|
+
pageSize: tool.schema.number().optional().describe("分页每页大小,默认 30"),
|
|
47077
|
+
keyword: tool.schema.string().optional().describe("标签搜索关键词")
|
|
47078
|
+
}
|
|
47079
|
+
})
|
|
47080
|
+
}
|
|
47081
|
+
}).define(async (ctx) => {
|
|
47082
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
47083
|
+
const repo2 = ctx.query?.repo;
|
|
47084
|
+
const page = ctx.query?.page;
|
|
47085
|
+
const pageSize = ctx.query?.pageSize;
|
|
47086
|
+
const keyword = ctx.query?.keyword;
|
|
47087
|
+
if (!repo2) {
|
|
47088
|
+
ctx.throw(400, "缺少参数 repo");
|
|
47089
|
+
}
|
|
47090
|
+
const res = await cnb.labels.repoLabel.list(repo2, {
|
|
47091
|
+
page,
|
|
47092
|
+
page_size: pageSize,
|
|
47093
|
+
keyword
|
|
47094
|
+
});
|
|
47095
|
+
ctx.forward(res);
|
|
47096
|
+
}).addTo(app);
|
|
47097
|
+
app.route({
|
|
47098
|
+
path: "cnb",
|
|
47099
|
+
key: "create-repo-label",
|
|
47100
|
+
description: "创建仓库标签",
|
|
47101
|
+
middleware: ["auth"],
|
|
47102
|
+
metadata: {
|
|
47103
|
+
tags: ["opencode"],
|
|
47104
|
+
...createSkill({
|
|
47105
|
+
skill: "create-repo-label",
|
|
47106
|
+
title: "创建仓库标签",
|
|
47107
|
+
summary: "创建一个仓库标签",
|
|
47108
|
+
args: {
|
|
47109
|
+
repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
47110
|
+
name: tool.schema.string().describe("标签名称"),
|
|
47111
|
+
color: tool.schema.string().describe("标签颜色,十六进制颜色码,不含 # 前缀"),
|
|
47112
|
+
description: tool.schema.string().optional().describe("标签描述")
|
|
47113
|
+
}
|
|
47114
|
+
})
|
|
47115
|
+
}
|
|
47116
|
+
}).define(async (ctx) => {
|
|
47117
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
47118
|
+
const repo2 = ctx.query?.repo;
|
|
47119
|
+
const name15 = ctx.query?.name;
|
|
47120
|
+
const color = ctx.query?.color;
|
|
47121
|
+
const description = ctx.query?.description;
|
|
47122
|
+
if (!repo2 || !name15 || !color) {
|
|
47123
|
+
ctx.throw(400, "缺少参数 repo, name 或 color");
|
|
47124
|
+
}
|
|
47125
|
+
const res = await cnb.labels.repoLabel.create(repo2, {
|
|
47126
|
+
name: name15,
|
|
47127
|
+
color,
|
|
47128
|
+
description
|
|
47129
|
+
});
|
|
47130
|
+
ctx.forward(res);
|
|
47131
|
+
}).addTo(app);
|
|
47132
|
+
app.route({
|
|
47133
|
+
path: "cnb",
|
|
47134
|
+
key: "update-repo-label",
|
|
47135
|
+
description: "更新仓库标签",
|
|
47136
|
+
middleware: ["auth"],
|
|
47137
|
+
metadata: {
|
|
47138
|
+
tags: ["opencode"],
|
|
47139
|
+
...createSkill({
|
|
47140
|
+
skill: "update-repo-label",
|
|
47141
|
+
title: "更新仓库标签",
|
|
47142
|
+
summary: "更新仓库标签信息",
|
|
47143
|
+
args: {
|
|
47144
|
+
repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
47145
|
+
name: tool.schema.string().describe("标签名称"),
|
|
47146
|
+
color: tool.schema.string().optional().describe("标签颜色,十六进制颜色码,不含 # 前缀"),
|
|
47147
|
+
description: tool.schema.string().optional().describe("标签描述"),
|
|
47148
|
+
newName: tool.schema.string().optional().describe("新标签名称")
|
|
47149
|
+
}
|
|
47150
|
+
})
|
|
47151
|
+
}
|
|
47152
|
+
}).define(async (ctx) => {
|
|
47153
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
47154
|
+
const repo2 = ctx.query?.repo;
|
|
47155
|
+
const name15 = ctx.query?.name;
|
|
47156
|
+
const color = ctx.query?.color;
|
|
47157
|
+
const description = ctx.query?.description;
|
|
47158
|
+
const newName = ctx.query?.newName;
|
|
47159
|
+
if (!repo2 || !name15) {
|
|
47160
|
+
ctx.throw(400, "缺少参数 repo 或 name");
|
|
47161
|
+
}
|
|
47162
|
+
const res = await cnb.labels.repoLabel.update(repo2, name15, {
|
|
47163
|
+
color,
|
|
47164
|
+
description,
|
|
47165
|
+
new_name: newName
|
|
47166
|
+
});
|
|
47167
|
+
ctx.forward(res);
|
|
47168
|
+
}).addTo(app);
|
|
47169
|
+
app.route({
|
|
47170
|
+
path: "cnb",
|
|
47171
|
+
key: "delete-repo-label",
|
|
47172
|
+
description: "删除仓库标签",
|
|
47173
|
+
middleware: ["auth"],
|
|
47174
|
+
metadata: {
|
|
47175
|
+
tags: ["opencode"],
|
|
47176
|
+
...createSkill({
|
|
47177
|
+
skill: "delete-repo-label",
|
|
47178
|
+
title: "删除仓库标签",
|
|
47179
|
+
summary: "删除指定的仓库标签",
|
|
47180
|
+
args: {
|
|
47181
|
+
repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
47182
|
+
name: tool.schema.string().describe("标签名称")
|
|
47183
|
+
}
|
|
47184
|
+
})
|
|
47185
|
+
}
|
|
47186
|
+
}).define(async (ctx) => {
|
|
47187
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
47188
|
+
const repo2 = ctx.query?.repo;
|
|
47189
|
+
const name15 = ctx.query?.name;
|
|
47190
|
+
if (!repo2 || !name15) {
|
|
47191
|
+
ctx.throw(400, "缺少参数 repo 或 name");
|
|
47192
|
+
}
|
|
47193
|
+
const res = await cnb.labels.repoLabel.remove(repo2, name15);
|
|
47194
|
+
ctx.forward(res);
|
|
47195
|
+
}).addTo(app);
|
|
46895
47196
|
|
|
46896
47197
|
// agent/routes/workspace/skills.ts
|
|
46897
47198
|
app.route({
|
|
@@ -47982,7 +48283,7 @@ app.route({
|
|
|
47982
48283
|
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
47983
48284
|
const state = ctx.query?.state;
|
|
47984
48285
|
const keyword = ctx.query?.keyword;
|
|
47985
|
-
const
|
|
48286
|
+
const labels2 = ctx.query?.labels;
|
|
47986
48287
|
const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
|
|
47987
48288
|
const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
|
|
47988
48289
|
const order_by = ctx.query?.order_by;
|
|
@@ -47994,8 +48295,8 @@ app.route({
|
|
|
47994
48295
|
params.state = state;
|
|
47995
48296
|
if (keyword)
|
|
47996
48297
|
params.keyword = keyword;
|
|
47997
|
-
if (
|
|
47998
|
-
params.labels =
|
|
48298
|
+
if (labels2)
|
|
48299
|
+
params.labels = labels2;
|
|
47999
48300
|
if (page)
|
|
48000
48301
|
params.page = page;
|
|
48001
48302
|
if (page_size)
|
|
@@ -48064,7 +48365,7 @@ app.route({
|
|
|
48064
48365
|
const title = ctx.query?.title;
|
|
48065
48366
|
const body = ctx.query?.body;
|
|
48066
48367
|
const assignees = ctx.query?.assignees;
|
|
48067
|
-
const
|
|
48368
|
+
const labels2 = ctx.query?.labels;
|
|
48068
48369
|
const priority = ctx.query?.priority;
|
|
48069
48370
|
if (!repo2 || !title) {
|
|
48070
48371
|
ctx.throw(400, "缺少参数 repo 或 title");
|
|
@@ -48073,7 +48374,7 @@ app.route({
|
|
|
48073
48374
|
title,
|
|
48074
48375
|
body,
|
|
48075
48376
|
assignees,
|
|
48076
|
-
labels,
|
|
48377
|
+
labels: labels2,
|
|
48077
48378
|
priority
|
|
48078
48379
|
});
|
|
48079
48380
|
ctx.forward(res);
|
|
@@ -48330,7 +48631,7 @@ var getLiveMdContent = (opts) => {
|
|
|
48330
48631
|
2. Opencode web访问说明
|
|
48331
48632
|
Opencode打开web地址,需要在浏览器输入用户名和密码,用户名固定为root,密码为CNB_TOKEN的值. 纯连接打开包含账号密码,第一次点击后,需要把账号密码清理掉才能访问,opencode的bug导致的。
|
|
48332
48633
|
`;
|
|
48333
|
-
const
|
|
48634
|
+
const labels2 = [
|
|
48334
48635
|
{
|
|
48335
48636
|
key: "vscodeWebUrl",
|
|
48336
48637
|
title: "VSCode Web 地址",
|
|
@@ -48387,11 +48688,11 @@ Opencode打开web地址,需要在浏览器输入用户名和密码,用户名
|
|
|
48387
48688
|
}
|
|
48388
48689
|
];
|
|
48389
48690
|
const osInfoList = createOSInfo(more);
|
|
48390
|
-
|
|
48391
|
-
return
|
|
48691
|
+
labels2.push(...osInfoList);
|
|
48692
|
+
return labels2;
|
|
48392
48693
|
};
|
|
48393
48694
|
var createOSInfo = (more = false) => {
|
|
48394
|
-
const
|
|
48695
|
+
const labels2 = [];
|
|
48395
48696
|
const startTimer = useKey("CNB_BUILD_START_TIME") || "";
|
|
48396
48697
|
const cpus = os2.cpus();
|
|
48397
48698
|
let totalIdle = 0;
|
|
@@ -48451,7 +48752,7 @@ var createOSInfo = (more = false) => {
|
|
|
48451
48752
|
} catch (e) {
|
|
48452
48753
|
diskUsage = "获取失败";
|
|
48453
48754
|
}
|
|
48454
|
-
|
|
48755
|
+
labels2.push({
|
|
48455
48756
|
key: "cpuUsage",
|
|
48456
48757
|
title: "CPU 使用率",
|
|
48457
48758
|
value: `${cpuUsage}%`,
|
|
@@ -48493,7 +48794,7 @@ var createOSInfo = (more = false) => {
|
|
|
48493
48794
|
const buildUptime = Date.now() - buildStartTimestamp;
|
|
48494
48795
|
const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
|
|
48495
48796
|
const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
|
|
48496
|
-
|
|
48797
|
+
labels2.push({
|
|
48497
48798
|
key: "buildStartTime",
|
|
48498
48799
|
title: "构建启动时间",
|
|
48499
48800
|
value: buildStartTime,
|
|
@@ -48512,13 +48813,13 @@ var createOSInfo = (more = false) => {
|
|
|
48512
48813
|
timeTo4 = today4am.add(1, "day").valueOf() - now.valueOf();
|
|
48513
48814
|
}
|
|
48514
48815
|
const timeTo4Str = `[距离晚上4点重启时间: ${formatUptime(Math.floor(timeTo4 / 1000))}]`;
|
|
48515
|
-
|
|
48816
|
+
labels2.push({
|
|
48516
48817
|
key: "buildMaxRunTime",
|
|
48517
48818
|
title: "最大运行时间",
|
|
48518
48819
|
value: formatUptime(Math.floor(maxRunTime / 1000)),
|
|
48519
48820
|
description: "构建最大运行时间(限制时间)"
|
|
48520
48821
|
});
|
|
48521
|
-
|
|
48822
|
+
labels2.unshift({
|
|
48522
48823
|
key: "remainingTime",
|
|
48523
48824
|
title: "剩余时间",
|
|
48524
48825
|
value: maxRunTime - buildUptime,
|
|
@@ -48528,7 +48829,7 @@ var createOSInfo = (more = false) => {
|
|
|
48528
48829
|
}
|
|
48529
48830
|
if (more) {
|
|
48530
48831
|
const loadavg = os2.loadavg();
|
|
48531
|
-
|
|
48832
|
+
labels2.push({
|
|
48532
48833
|
key: "hostname",
|
|
48533
48834
|
title: "主机名",
|
|
48534
48835
|
value: os2.hostname(),
|
|
@@ -48565,7 +48866,7 @@ var createOSInfo = (more = false) => {
|
|
|
48565
48866
|
description: "系统负载 (15分钟)"
|
|
48566
48867
|
});
|
|
48567
48868
|
}
|
|
48568
|
-
return
|
|
48869
|
+
return labels2;
|
|
48569
48870
|
};
|
|
48570
48871
|
|
|
48571
48872
|
// agent/routes/cnb-board/cnb-dev-env.ts
|
|
@@ -48602,7 +48903,7 @@ app.route({
|
|
|
48602
48903
|
if (notCNBCheck(ctx))
|
|
48603
48904
|
return;
|
|
48604
48905
|
const repoNameFromSlug = repoSlug.split("/").pop() || "";
|
|
48605
|
-
const
|
|
48906
|
+
const labels2 = [
|
|
48606
48907
|
{
|
|
48607
48908
|
title: "CNB_REPO_SLUG",
|
|
48608
48909
|
value: repoSlug,
|
|
@@ -48636,7 +48937,7 @@ app.route({
|
|
|
48636
48937
|
];
|
|
48637
48938
|
ctx.body = {
|
|
48638
48939
|
title: "CNB_BOARD_LIVE_REPO_INFO",
|
|
48639
|
-
list:
|
|
48940
|
+
list: labels2
|
|
48640
48941
|
};
|
|
48641
48942
|
}).addTo(app);
|
|
48642
48943
|
app.route({
|
|
@@ -48647,7 +48948,7 @@ app.route({
|
|
|
48647
48948
|
}).define(async (ctx) => {
|
|
48648
48949
|
if (notCNBCheck(ctx))
|
|
48649
48950
|
return;
|
|
48650
|
-
const
|
|
48951
|
+
const labels2 = [
|
|
48651
48952
|
{
|
|
48652
48953
|
title: "CNB_BUILD_ID",
|
|
48653
48954
|
value: useKey("CNB_BUILD_ID") || "",
|
|
@@ -48781,7 +49082,7 @@ app.route({
|
|
|
48781
49082
|
];
|
|
48782
49083
|
ctx.body = {
|
|
48783
49084
|
title: "CNB_BOARD_LIVE_BUILD_INFO",
|
|
48784
|
-
list:
|
|
49085
|
+
list: labels2
|
|
48785
49086
|
};
|
|
48786
49087
|
}).addTo(app);
|
|
48787
49088
|
app.route({
|
|
@@ -48790,7 +49091,7 @@ app.route({
|
|
|
48790
49091
|
description: "获取cnb-board live的PR信息",
|
|
48791
49092
|
middleware: ["auth-admin"]
|
|
48792
49093
|
}).define(async (ctx) => {
|
|
48793
|
-
const
|
|
49094
|
+
const labels2 = [
|
|
48794
49095
|
{
|
|
48795
49096
|
title: "CNB_PULL_REQUEST",
|
|
48796
49097
|
value: useKey("CNB_PULL_REQUEST") || "",
|
|
@@ -48879,7 +49180,7 @@ app.route({
|
|
|
48879
49180
|
];
|
|
48880
49181
|
ctx.body = {
|
|
48881
49182
|
title: "CNB_BOARD_LIVE_PULL_INFO",
|
|
48882
|
-
list:
|
|
49183
|
+
list: labels2
|
|
48883
49184
|
};
|
|
48884
49185
|
}).addTo(app);
|
|
48885
49186
|
app.route({
|
|
@@ -48890,7 +49191,7 @@ app.route({
|
|
|
48890
49191
|
}).define(async (ctx) => {
|
|
48891
49192
|
if (notCNBCheck(ctx))
|
|
48892
49193
|
return;
|
|
48893
|
-
const
|
|
49194
|
+
const labels2 = [
|
|
48894
49195
|
{
|
|
48895
49196
|
title: "CNB_NPC_SLUG",
|
|
48896
49197
|
value: useKey("CNB_NPC_SLUG") || "",
|
|
@@ -48924,7 +49225,7 @@ app.route({
|
|
|
48924
49225
|
];
|
|
48925
49226
|
ctx.body = {
|
|
48926
49227
|
title: "CNB_BOARD_LIVE_NPC_INFO",
|
|
48927
|
-
list:
|
|
49228
|
+
list: labels2
|
|
48928
49229
|
};
|
|
48929
49230
|
}).addTo(app);
|
|
48930
49231
|
app.route({
|
|
@@ -48935,7 +49236,7 @@ app.route({
|
|
|
48935
49236
|
}).define(async (ctx) => {
|
|
48936
49237
|
if (notCNBCheck(ctx))
|
|
48937
49238
|
return;
|
|
48938
|
-
const
|
|
49239
|
+
const labels2 = [
|
|
48939
49240
|
{
|
|
48940
49241
|
title: "CNB_COMMENT_ID",
|
|
48941
49242
|
value: useKey("CNB_COMMENT_ID") || "",
|
|
@@ -48969,7 +49270,7 @@ app.route({
|
|
|
48969
49270
|
];
|
|
48970
49271
|
ctx.body = {
|
|
48971
49272
|
title: "CNB_BOARD_LIVE_COMMENT_INFO",
|
|
48972
|
-
list:
|
|
49273
|
+
list: labels2
|
|
48973
49274
|
};
|
|
48974
49275
|
}).addTo(app);
|
|
48975
49276
|
|
|
@@ -55108,6 +55409,44 @@ app.route({
|
|
|
55108
55409
|
ctx.body = result;
|
|
55109
55410
|
}).addTo(app);
|
|
55110
55411
|
|
|
55412
|
+
// agent/routes/missions/list.ts
|
|
55413
|
+
app.route({
|
|
55414
|
+
path: "cnb",
|
|
55415
|
+
key: "missions-list",
|
|
55416
|
+
description: "查询missions列表",
|
|
55417
|
+
metadata: {
|
|
55418
|
+
args: {
|
|
55419
|
+
repo: zod_default.string().optional().describe("missions所在的仓库,例如 kevisual/projects"),
|
|
55420
|
+
selector: zod_default.array(zod_default.any()).optional().describe('查询条件,例如 [{field: "resource_type", operator: "contains", value: ["issues"]},…]')
|
|
55421
|
+
}
|
|
55422
|
+
}
|
|
55423
|
+
}).define(async (ctx) => {
|
|
55424
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
55425
|
+
const repo2 = ctx.query?.repo || "kevisual/projects";
|
|
55426
|
+
const res = await cnb.mission.queryResources(repo2, ctx.query?.selector || [
|
|
55427
|
+
{
|
|
55428
|
+
field: "resource_type",
|
|
55429
|
+
operator: "contains",
|
|
55430
|
+
value: [
|
|
55431
|
+
"issues"
|
|
55432
|
+
]
|
|
55433
|
+
},
|
|
55434
|
+
{
|
|
55435
|
+
field: "state",
|
|
55436
|
+
operator: "not_equals",
|
|
55437
|
+
value: [
|
|
55438
|
+
"closed"
|
|
55439
|
+
]
|
|
55440
|
+
},
|
|
55441
|
+
{
|
|
55442
|
+
field: "label",
|
|
55443
|
+
operator: "contains",
|
|
55444
|
+
value: ["AICoding"]
|
|
55445
|
+
}
|
|
55446
|
+
]);
|
|
55447
|
+
ctx.forward(res);
|
|
55448
|
+
}).addTo(app);
|
|
55449
|
+
|
|
55111
55450
|
// agent/routes/index.ts
|
|
55112
55451
|
var checkAppId = (ctx, appId) => {
|
|
55113
55452
|
const _appId = ctx?.app?.appId;
|
|
@@ -55159,7 +55498,7 @@ var {
|
|
|
55159
55498
|
Help
|
|
55160
55499
|
} = import__3.default;
|
|
55161
55500
|
|
|
55162
|
-
// ../../node_modules/.pnpm/@kevisual+remote-app@0.0.
|
|
55501
|
+
// ../../node_modules/.pnpm/@kevisual+remote-app@0.0.6/node_modules/@kevisual/remote-app/dist/app.js
|
|
55163
55502
|
var __create4 = Object.create;
|
|
55164
55503
|
var __getProtoOf4 = Object.getPrototypeOf;
|
|
55165
55504
|
var __defProp5 = Object.defineProperty;
|
|
@@ -55374,12 +55713,10 @@ class RemoteApp {
|
|
|
55374
55713
|
reconnectAttempts = 0;
|
|
55375
55714
|
reconnectTimer = null;
|
|
55376
55715
|
isManuallyClosed = false;
|
|
55377
|
-
isInitializing = false;
|
|
55378
|
-
initId = 0;
|
|
55379
55716
|
constructor(opts) {
|
|
55380
55717
|
this.mainApp = opts?.app;
|
|
55381
55718
|
const token2 = opts.token;
|
|
55382
|
-
const url4 = opts.url
|
|
55719
|
+
const url4 = opts.url;
|
|
55383
55720
|
const id = opts.id;
|
|
55384
55721
|
const username = opts.username;
|
|
55385
55722
|
this.username = username;
|
|
@@ -55445,17 +55782,10 @@ class RemoteApp {
|
|
|
55445
55782
|
return wsURL;
|
|
55446
55783
|
}
|
|
55447
55784
|
async init() {
|
|
55448
|
-
if (this.isInitializing) {
|
|
55449
|
-
return;
|
|
55450
|
-
}
|
|
55451
|
-
this.isInitializing = true;
|
|
55452
|
-
const currentInitId = ++this.initId;
|
|
55453
55785
|
if (!this.url) {
|
|
55454
|
-
this.isInitializing = false;
|
|
55455
55786
|
throw new Error("No url provided for remote app");
|
|
55456
55787
|
}
|
|
55457
55788
|
if (!this.id) {
|
|
55458
|
-
this.isInitializing = false;
|
|
55459
55789
|
throw new Error("No id provided for remote app");
|
|
55460
55790
|
}
|
|
55461
55791
|
this.isError = false;
|
|
@@ -55465,20 +55795,11 @@ class RemoteApp {
|
|
|
55465
55795
|
const ws = new WebSocket(this.getWsURL(this.url));
|
|
55466
55796
|
const that = this;
|
|
55467
55797
|
ws.onopen = function() {
|
|
55468
|
-
if (currentInitId !== that.initId) {
|
|
55469
|
-
ws.close();
|
|
55470
|
-
return;
|
|
55471
|
-
}
|
|
55472
55798
|
that.isConnected = true;
|
|
55473
|
-
that.isInitializing = false;
|
|
55474
55799
|
that.onOpen();
|
|
55475
55800
|
console.log("[remote-app] WebSocket connection opened");
|
|
55476
55801
|
};
|
|
55477
55802
|
ws.onclose = function() {
|
|
55478
|
-
if (currentInitId !== that.initId) {
|
|
55479
|
-
return;
|
|
55480
|
-
}
|
|
55481
|
-
that.isInitializing = false;
|
|
55482
55803
|
that.isConnected = false;
|
|
55483
55804
|
that.onClose();
|
|
55484
55805
|
};
|
|
@@ -55486,10 +55807,6 @@ class RemoteApp {
|
|
|
55486
55807
|
that.onMessage(event.data);
|
|
55487
55808
|
};
|
|
55488
55809
|
ws.onerror = function(error49) {
|
|
55489
|
-
if (currentInitId !== that.initId) {
|
|
55490
|
-
return;
|
|
55491
|
-
}
|
|
55492
|
-
that.isInitializing = false;
|
|
55493
55810
|
that.onError(error49);
|
|
55494
55811
|
};
|
|
55495
55812
|
this.ws = ws;
|
|
@@ -55643,7 +55960,7 @@ class RemoteApp {
|
|
|
55643
55960
|
}
|
|
55644
55961
|
}
|
|
55645
55962
|
|
|
55646
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.1.
|
|
55963
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.1.6/node_modules/@kevisual/router/src/commander.ts
|
|
55647
55964
|
var groupByPath = (routes) => {
|
|
55648
55965
|
return routes.reduce((acc, route) => {
|
|
55649
55966
|
const path3 = route.path || "default";
|
|
@@ -55763,23 +56080,7 @@ var parse8 = async (opts) => {
|
|
|
55763
56080
|
_program.version(version3);
|
|
55764
56081
|
}
|
|
55765
56082
|
app3.createRouteList();
|
|
55766
|
-
app3
|
|
55767
|
-
path: "cli",
|
|
55768
|
-
key: "list"
|
|
55769
|
-
}).define(async () => {
|
|
55770
|
-
const routes = app3.routes.map((route) => {
|
|
55771
|
-
return {
|
|
55772
|
-
path: route.path,
|
|
55773
|
-
key: route.key,
|
|
55774
|
-
description: route?.metadata?.summary || route.description || ""
|
|
55775
|
-
};
|
|
55776
|
-
});
|
|
55777
|
-
const table = routes.map((route) => {
|
|
55778
|
-
return `${route.path} ${route.key} - ${route.description}`;
|
|
55779
|
-
}).join(`
|
|
55780
|
-
`);
|
|
55781
|
-
console.log(table);
|
|
55782
|
-
}).addTo(app3, { overwrite: false });
|
|
56083
|
+
createCliList(app3);
|
|
55783
56084
|
createCommand2({ app: app3, program: _program });
|
|
55784
56085
|
if (opts.remote) {
|
|
55785
56086
|
const { token: token2, username, id } = opts.remote;
|
|
@@ -55802,6 +56103,82 @@ var parse8 = async (opts) => {
|
|
|
55802
56103
|
}
|
|
55803
56104
|
}
|
|
55804
56105
|
};
|
|
56106
|
+
var createCliList = (app3) => {
|
|
56107
|
+
app3.route({
|
|
56108
|
+
path: "cli",
|
|
56109
|
+
key: "list",
|
|
56110
|
+
description: "列出所有可用的命令",
|
|
56111
|
+
metadata: {
|
|
56112
|
+
summary: "列出所有可用的命令",
|
|
56113
|
+
args: {
|
|
56114
|
+
q: zod_default.string().optional().describe("查询关键词,支持模糊匹配命令"),
|
|
56115
|
+
path: zod_default.string().optional().describe("按路径前缀过滤,如 user、admin"),
|
|
56116
|
+
tags: zod_default.string().optional().describe("按标签过滤,多个标签用逗号分隔"),
|
|
56117
|
+
sort: zod_default.enum(["key", "path", "name"]).optional().describe("排序方式"),
|
|
56118
|
+
limit: zod_default.number().optional().describe("限制返回数量"),
|
|
56119
|
+
offset: zod_default.number().optional().describe("偏移量,用于分页"),
|
|
56120
|
+
format: zod_default.enum(["table", "simple", "json"]).optional().describe("输出格式")
|
|
56121
|
+
}
|
|
56122
|
+
}
|
|
56123
|
+
}).define(async (ctx) => {
|
|
56124
|
+
const { q, path: pathFilter, tags, sort, limit, offset, format } = ctx.query;
|
|
56125
|
+
let routes = app3.routes.map((route) => {
|
|
56126
|
+
return {
|
|
56127
|
+
path: route.path,
|
|
56128
|
+
key: route.key,
|
|
56129
|
+
description: route?.metadata?.summary || route.description || "",
|
|
56130
|
+
tags: route?.metadata?.tags || []
|
|
56131
|
+
};
|
|
56132
|
+
});
|
|
56133
|
+
if (pathFilter) {
|
|
56134
|
+
routes = routes.filter((route) => route.path.startsWith(pathFilter));
|
|
56135
|
+
}
|
|
56136
|
+
if (tags) {
|
|
56137
|
+
const tagList = tags.split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
|
|
56138
|
+
if (tagList.length > 0) {
|
|
56139
|
+
routes = routes.filter((route) => {
|
|
56140
|
+
const routeTags = Array.isArray(route.tags) ? route.tags.map((t) => String(t).toLowerCase()) : [];
|
|
56141
|
+
return tagList.some((tag) => routeTags.includes(tag));
|
|
56142
|
+
});
|
|
56143
|
+
}
|
|
56144
|
+
}
|
|
56145
|
+
if (q) {
|
|
56146
|
+
const keyword = q.toLowerCase();
|
|
56147
|
+
routes = routes.filter((route) => {
|
|
56148
|
+
return route.path.toLowerCase().includes(keyword) || route.key.toLowerCase().includes(keyword) || route.description.toLowerCase().includes(keyword);
|
|
56149
|
+
});
|
|
56150
|
+
}
|
|
56151
|
+
if (sort) {
|
|
56152
|
+
routes.sort((a, b) => {
|
|
56153
|
+
if (sort === "path")
|
|
56154
|
+
return a.path.localeCompare(b.path);
|
|
56155
|
+
if (sort === "key")
|
|
56156
|
+
return a.key.localeCompare(b.key);
|
|
56157
|
+
return a.key.localeCompare(b.key);
|
|
56158
|
+
});
|
|
56159
|
+
}
|
|
56160
|
+
const total = routes.length;
|
|
56161
|
+
const start = offset || 0;
|
|
56162
|
+
const end = limit ? start + limit : undefined;
|
|
56163
|
+
routes = routes.slice(start, end);
|
|
56164
|
+
const outputFormat = format || "table";
|
|
56165
|
+
if (outputFormat === "json") {
|
|
56166
|
+
console.log(JSON.stringify({ total, offset: start, limit, routes }, null, 2));
|
|
56167
|
+
return;
|
|
56168
|
+
}
|
|
56169
|
+
if (outputFormat === "simple") {
|
|
56170
|
+
routes.forEach((route) => {
|
|
56171
|
+
console.log(`${route.path} ${route.key}`);
|
|
56172
|
+
});
|
|
56173
|
+
return;
|
|
56174
|
+
}
|
|
56175
|
+
const table = routes.map((route) => {
|
|
56176
|
+
return `${route.path} ${route.key} - ${route.description}`;
|
|
56177
|
+
}).join(`
|
|
56178
|
+
`);
|
|
56179
|
+
console.log(table);
|
|
56180
|
+
}).addTo(app3, { overwrite: false });
|
|
56181
|
+
};
|
|
55805
56182
|
// ../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/pick.mjs
|
|
55806
56183
|
function pick4(obj, keys) {
|
|
55807
56184
|
const result = {};
|
|
@@ -55839,8 +56216,8 @@ var getIssuesLabels = async () => {
|
|
|
55839
56216
|
});
|
|
55840
56217
|
if (res.code === 200) {
|
|
55841
56218
|
const issueData = res.data;
|
|
55842
|
-
const
|
|
55843
|
-
return
|
|
56219
|
+
const labels2 = issueData.labels || [];
|
|
56220
|
+
return labels2;
|
|
55844
56221
|
}
|
|
55845
56222
|
console.error("获取 Issue 详情失败", res);
|
|
55846
56223
|
return [];
|