@kevisual/cli 0.1.10 → 0.1.11
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/assistant-opencode.js +104 -53
- package/dist/assistant-server.js +108 -57
- package/dist/envision.js +2 -2
- package/package.json +1 -1
|
@@ -100298,11 +100298,11 @@ app.route({
|
|
|
100298
100298
|
})
|
|
100299
100299
|
}
|
|
100300
100300
|
}).define(async (ctx) => {
|
|
100301
|
-
const { path: path14, key = "" } = ctx.
|
|
100301
|
+
const { path: path14, key = "" } = ctx.args;
|
|
100302
100302
|
if (!path14) {
|
|
100303
100303
|
ctx.throw("路径path不能为空");
|
|
100304
100304
|
}
|
|
100305
|
-
const res = await ctx.run({ path: path14, key, payload: ctx.
|
|
100305
|
+
const res = await ctx.run({ path: path14, key, payload: ctx.args.payload || {} }, {
|
|
100306
100306
|
...ctx
|
|
100307
100307
|
});
|
|
100308
100308
|
ctx.forward(res);
|
|
@@ -102169,20 +102169,22 @@ app.route({
|
|
|
102169
102169
|
// src/routes/cnb-board/live/live-content.ts
|
|
102170
102170
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
102171
102171
|
import os7 from "node:os";
|
|
102172
|
+
import { execSync as execSync3 } from "node:child_process";
|
|
102172
102173
|
var getLiveMdContent = (opts) => {
|
|
102173
102174
|
const more = opts?.more ?? false;
|
|
102174
102175
|
const url4 = useKey2("CNB_VSCODE_PROXY_URI") || "";
|
|
102175
102176
|
const token = useKey2("CNB_TOKEN") || "";
|
|
102176
102177
|
const openclawPort = useKey2("OPENCLAW_PORT") || "80";
|
|
102177
|
-
const openclawUrl = url4
|
|
102178
|
+
const openclawUrl = url4.replace("{{port}}", openclawPort);
|
|
102178
102179
|
const openclawUrlSecret = openclawUrl + "/openclaw?token=" + token;
|
|
102179
102180
|
const opencodePort = useKey2("OPENCODE_PORT") || "100";
|
|
102180
|
-
const opencodeUrl = url4
|
|
102181
|
+
const opencodeUrl = url4.replace("{{port}}", opencodePort);
|
|
102181
102182
|
const _opencodeURL = new URL(opencodeUrl);
|
|
102182
102183
|
_opencodeURL.username = "root";
|
|
102183
102184
|
_opencodeURL.password = token;
|
|
102184
102185
|
const opencodeUrlSecret = _opencodeURL.toString();
|
|
102185
|
-
const kevisualUrl = url4
|
|
102186
|
+
const kevisualUrl = url4.replace("{{port}}", "51515");
|
|
102187
|
+
const openWebUrl = url4.replace("{{port}}", "200");
|
|
102186
102188
|
const vscodeWebUrl = useKey2("CNB_VSCODE_WEB_URL") || "";
|
|
102187
102189
|
const TEMPLATE = `# 开发环境模式配置
|
|
102188
102190
|
|
|
@@ -102190,6 +102192,9 @@ var getLiveMdContent = (opts) => {
|
|
|
102190
102192
|
#### nginx 反向代理访问(推荐)
|
|
102191
102193
|
- OpenClaw: ${openclawUrl + "/openclaw"}
|
|
102192
102194
|
- OpenCode: ${opencodeUrl}
|
|
102195
|
+
- VSCode Web: ${vscodeWebUrl}
|
|
102196
|
+
- OpenWebUI: ${openWebUrl}
|
|
102197
|
+
- Kevisual: ${kevisualUrl}
|
|
102193
102198
|
|
|
102194
102199
|
### 直接访问
|
|
102195
102200
|
- Kevisual: ${kevisualUrl}
|
|
@@ -102213,7 +102218,7 @@ var getLiveMdContent = (opts) => {
|
|
|
102213
102218
|
- wss: vscode web的websocket地址
|
|
102214
102219
|
- cookie: vscode web的cookie,保持和浏览器一致
|
|
102215
102220
|
- url: vscode web的访问地址,可以直接访问vscode web
|
|
102216
|
-
4. 运行cli命令,ev cnb live -c /workspace/live/keep.json
|
|
102221
|
+
4. 运行cli命令,ev cnb live -c /workspace/live/keep.json.(直接对话opencode或者openclaw调用cnb-live技能即可)
|
|
102217
102222
|
|
|
102218
102223
|
`;
|
|
102219
102224
|
const labels = [
|
|
@@ -102232,6 +102237,11 @@ var getLiveMdContent = (opts) => {
|
|
|
102232
102237
|
value: token,
|
|
102233
102238
|
description: "CNB 临时 Token,保持和环境变量 CNB_TOKEN 一致"
|
|
102234
102239
|
},
|
|
102240
|
+
{
|
|
102241
|
+
title: "openWebUrl",
|
|
102242
|
+
value: openWebUrl,
|
|
102243
|
+
description: "OpenWebUI 的访问地址,可以通过该地址访问 OpenWebUI 服务"
|
|
102244
|
+
},
|
|
102235
102245
|
{
|
|
102236
102246
|
title: "openclawUrl",
|
|
102237
102247
|
value: openclawUrl,
|
|
@@ -102264,7 +102274,7 @@ var getLiveMdContent = (opts) => {
|
|
|
102264
102274
|
};
|
|
102265
102275
|
var createOSInfo = (more = false) => {
|
|
102266
102276
|
const labels = [];
|
|
102267
|
-
const startTimer = useKey2("CNB_BUILD_START_TIME") ||
|
|
102277
|
+
const startTimer = useKey2("CNB_BUILD_START_TIME") || "";
|
|
102268
102278
|
const cpus = os7.cpus();
|
|
102269
102279
|
let totalIdle = 0;
|
|
102270
102280
|
let totalTick = 0;
|
|
@@ -102275,10 +102285,26 @@ var createOSInfo = (more = false) => {
|
|
|
102275
102285
|
totalIdle += cpu.times.idle;
|
|
102276
102286
|
});
|
|
102277
102287
|
const cpuUsage = ((1 - totalIdle / totalTick) * 100).toFixed(2);
|
|
102278
|
-
|
|
102279
|
-
|
|
102280
|
-
|
|
102281
|
-
|
|
102288
|
+
let memUsed = 0;
|
|
102289
|
+
let memTotal = 0;
|
|
102290
|
+
let memFree = 0;
|
|
102291
|
+
try {
|
|
102292
|
+
const freeOutput = execSync3("free -b", { encoding: "utf-8" });
|
|
102293
|
+
const lines = freeOutput.trim().split(`
|
|
102294
|
+
`);
|
|
102295
|
+
const memLine = lines.find((line) => line.startsWith("Mem:"));
|
|
102296
|
+
if (memLine) {
|
|
102297
|
+
const parts = memLine.split(/\s+/);
|
|
102298
|
+
memTotal = parseInt(parts[1]);
|
|
102299
|
+
memUsed = parseInt(parts[2]);
|
|
102300
|
+
memFree = parseInt(parts[3]);
|
|
102301
|
+
}
|
|
102302
|
+
} catch (e) {
|
|
102303
|
+
memTotal = os7.totalmem();
|
|
102304
|
+
memFree = os7.freemem();
|
|
102305
|
+
memUsed = memTotal - memFree;
|
|
102306
|
+
}
|
|
102307
|
+
const memUsage = memTotal > 0 ? (memUsed / memTotal * 100).toFixed(2) : "0.00";
|
|
102282
102308
|
const formatBytes = (bytes) => {
|
|
102283
102309
|
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
102284
102310
|
if (bytes === 0)
|
|
@@ -102287,8 +102313,6 @@ var createOSInfo = (more = false) => {
|
|
|
102287
102313
|
return (bytes / Math.pow(1024, i)).toFixed(2) + " " + sizes[i];
|
|
102288
102314
|
};
|
|
102289
102315
|
const bootTime = os7.uptime();
|
|
102290
|
-
const bootTimeDate = new Date(Date.now() - bootTime * 1000);
|
|
102291
|
-
const bootTimeStr = import_dayjs.default(bootTimeDate).format("YYYY-MM-DD HH:mm:ss");
|
|
102292
102316
|
const formatUptime = (seconds) => {
|
|
102293
102317
|
const days = Math.floor(seconds / 86400);
|
|
102294
102318
|
const hours = Math.floor(seconds % 86400 / 3600);
|
|
@@ -102296,7 +102320,13 @@ var createOSInfo = (more = false) => {
|
|
|
102296
102320
|
const secs = Math.floor(seconds % 60);
|
|
102297
102321
|
return `${days}天 ${hours}小时 ${minutes}分钟 ${secs}秒`;
|
|
102298
102322
|
};
|
|
102299
|
-
|
|
102323
|
+
let diskUsage = "";
|
|
102324
|
+
try {
|
|
102325
|
+
const duOutput = execSync3("du -sh .", { encoding: "utf-8" });
|
|
102326
|
+
diskUsage = duOutput.trim().split("\t")[0];
|
|
102327
|
+
} catch (e) {
|
|
102328
|
+
diskUsage = "获取失败";
|
|
102329
|
+
}
|
|
102300
102330
|
labels.push({
|
|
102301
102331
|
title: "cpuUsage",
|
|
102302
102332
|
value: `${cpuUsage}%`,
|
|
@@ -102307,33 +102337,35 @@ var createOSInfo = (more = false) => {
|
|
|
102307
102337
|
description: "CPU 核心数"
|
|
102308
102338
|
}, {
|
|
102309
102339
|
title: "memoryUsed",
|
|
102310
|
-
value: formatBytes(
|
|
102340
|
+
value: formatBytes(memUsed),
|
|
102311
102341
|
description: "已使用内存"
|
|
102312
102342
|
}, {
|
|
102313
102343
|
title: "memoryTotal",
|
|
102314
|
-
value: formatBytes(
|
|
102344
|
+
value: formatBytes(memTotal),
|
|
102315
102345
|
description: "总内存"
|
|
102346
|
+
}, {
|
|
102347
|
+
title: "memoryFree",
|
|
102348
|
+
value: formatBytes(memFree),
|
|
102349
|
+
description: "空闲内存"
|
|
102316
102350
|
}, {
|
|
102317
102351
|
title: "memoryUsage",
|
|
102318
102352
|
value: `${memUsage}%`,
|
|
102319
102353
|
description: "内存使用率"
|
|
102320
102354
|
}, {
|
|
102321
|
-
title: "
|
|
102322
|
-
value:
|
|
102323
|
-
description: "
|
|
102324
|
-
}, {
|
|
102325
|
-
title: "bootTime",
|
|
102326
|
-
value: bootTimeStr,
|
|
102327
|
-
description: "系统启动时间"
|
|
102355
|
+
title: "diskUsage",
|
|
102356
|
+
value: diskUsage,
|
|
102357
|
+
description: "当前目录磁盘使用情况"
|
|
102328
102358
|
}, {
|
|
102329
102359
|
title: "uptime",
|
|
102330
102360
|
value: formatUptime(bootTime),
|
|
102331
102361
|
description: "系统运行时间"
|
|
102332
102362
|
});
|
|
102333
102363
|
if (startTimer) {
|
|
102334
|
-
const buildStartTime = import_dayjs.default(
|
|
102335
|
-
const
|
|
102364
|
+
const buildStartTime = import_dayjs.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
|
|
102365
|
+
const buildStartTimestamp = import_dayjs.default(startTimer).valueOf();
|
|
102366
|
+
const buildUptime = Date.now() - buildStartTimestamp;
|
|
102336
102367
|
const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
|
|
102368
|
+
const maxRunTime = useKey2("CNB_PIPELINE_MAX_RUN_TIME") || 0;
|
|
102337
102369
|
labels.push({
|
|
102338
102370
|
title: "buildStartTime",
|
|
102339
102371
|
value: buildStartTime,
|
|
@@ -102343,6 +102375,25 @@ var createOSInfo = (more = false) => {
|
|
|
102343
102375
|
value: buildUptimeStr,
|
|
102344
102376
|
description: "构建已运行时间"
|
|
102345
102377
|
});
|
|
102378
|
+
if (maxRunTime > 0) {
|
|
102379
|
+
const now = import_dayjs.default();
|
|
102380
|
+
const today4am = now.hour(4).minute(0).second(0).millisecond(0);
|
|
102381
|
+
let timeTo4 = today4am.valueOf() - now.valueOf();
|
|
102382
|
+
if (timeTo4 < 0) {
|
|
102383
|
+
timeTo4 = today4am.add(1, "day").valueOf() - now.valueOf();
|
|
102384
|
+
}
|
|
102385
|
+
const timeTo4Str = `[距离晚上4点重启时间: ${formatUptime(Math.floor(timeTo4 / 1000))}]`;
|
|
102386
|
+
labels.push({
|
|
102387
|
+
title: "buildMaxRunTime",
|
|
102388
|
+
value: formatUptime(Math.floor(maxRunTime / 1000)),
|
|
102389
|
+
description: "构建最大运行时间(限制时间)"
|
|
102390
|
+
});
|
|
102391
|
+
labels.unshift({
|
|
102392
|
+
title: "剩余时间",
|
|
102393
|
+
value: formatUptime(Math.floor((maxRunTime - buildUptime) / 1000)) + " " + timeTo4Str,
|
|
102394
|
+
description: "构建剩余时间"
|
|
102395
|
+
});
|
|
102396
|
+
}
|
|
102346
102397
|
}
|
|
102347
102398
|
if (more) {
|
|
102348
102399
|
const loadavg = os7.loadavg();
|
|
@@ -102381,8 +102432,26 @@ var createOSInfo = (more = false) => {
|
|
|
102381
102432
|
|
|
102382
102433
|
// src/routes/cnb-board/cnb-dev-env.ts
|
|
102383
102434
|
app.route({
|
|
102384
|
-
path: "
|
|
102385
|
-
key: "live
|
|
102435
|
+
path: "cnb_board",
|
|
102436
|
+
key: "live",
|
|
102437
|
+
description: "获取cnb-board live的mdContent内容",
|
|
102438
|
+
middleware: ["auth-admin"],
|
|
102439
|
+
metadata: {
|
|
102440
|
+
args: {
|
|
102441
|
+
more: zod_default.boolean().optional().describe("是否获取更多系统信息,默认false")
|
|
102442
|
+
}
|
|
102443
|
+
}
|
|
102444
|
+
}).define(async (ctx) => {
|
|
102445
|
+
const more = ctx.query?.more ?? false;
|
|
102446
|
+
const list4 = getLiveMdContent({ more });
|
|
102447
|
+
ctx.body = {
|
|
102448
|
+
title: "开发环境模式配置",
|
|
102449
|
+
list: list4
|
|
102450
|
+
};
|
|
102451
|
+
}).addTo(app);
|
|
102452
|
+
app.route({
|
|
102453
|
+
path: "cnb_board",
|
|
102454
|
+
key: "live_repo_info",
|
|
102386
102455
|
description: "获取cnb-board live的repo信息",
|
|
102387
102456
|
middleware: ["auth-admin"]
|
|
102388
102457
|
}).define(async (ctx) => {
|
|
@@ -102429,8 +102498,8 @@ app.route({
|
|
|
102429
102498
|
};
|
|
102430
102499
|
}).addTo(app);
|
|
102431
102500
|
app.route({
|
|
102432
|
-
path: "
|
|
102433
|
-
key: "
|
|
102501
|
+
path: "cnb_board",
|
|
102502
|
+
key: "live_build_info",
|
|
102434
102503
|
description: "获取cnb-board live的构建信息",
|
|
102435
102504
|
middleware: ["auth-admin"]
|
|
102436
102505
|
}).define(async (ctx) => {
|
|
@@ -102572,8 +102641,8 @@ app.route({
|
|
|
102572
102641
|
};
|
|
102573
102642
|
}).addTo(app);
|
|
102574
102643
|
app.route({
|
|
102575
|
-
path: "
|
|
102576
|
-
key: "
|
|
102644
|
+
path: "cnb_board",
|
|
102645
|
+
key: "live_pull_info",
|
|
102577
102646
|
description: "获取cnb-board live的PR信息",
|
|
102578
102647
|
middleware: ["auth-admin"]
|
|
102579
102648
|
}).define(async (ctx) => {
|
|
@@ -102670,8 +102739,8 @@ app.route({
|
|
|
102670
102739
|
};
|
|
102671
102740
|
}).addTo(app);
|
|
102672
102741
|
app.route({
|
|
102673
|
-
path: "
|
|
102674
|
-
key: "
|
|
102742
|
+
path: "cnb_board",
|
|
102743
|
+
key: "live_npc_info",
|
|
102675
102744
|
description: "获取cnb-board live的NPC信息",
|
|
102676
102745
|
middleware: ["auth-admin"]
|
|
102677
102746
|
}).define(async (ctx) => {
|
|
@@ -102713,8 +102782,8 @@ app.route({
|
|
|
102713
102782
|
};
|
|
102714
102783
|
}).addTo(app);
|
|
102715
102784
|
app.route({
|
|
102716
|
-
path: "
|
|
102717
|
-
key: "
|
|
102785
|
+
path: "cnb_board",
|
|
102786
|
+
key: "live_comment_info",
|
|
102718
102787
|
description: "获取cnb-board live的评论信息",
|
|
102719
102788
|
middleware: ["auth-admin"]
|
|
102720
102789
|
}).define(async (ctx) => {
|
|
@@ -102768,24 +102837,6 @@ app.route({
|
|
|
102768
102837
|
isCNB: !!isCNB
|
|
102769
102838
|
};
|
|
102770
102839
|
}).addTo(app);
|
|
102771
|
-
app.route({
|
|
102772
|
-
path: "cnb-board",
|
|
102773
|
-
key: "live",
|
|
102774
|
-
description: "获取cnb-board live的mdContent内容",
|
|
102775
|
-
middleware: ["auth-admin"],
|
|
102776
|
-
metadata: {
|
|
102777
|
-
args: {
|
|
102778
|
-
more: zod_default.boolean().optional().describe("是否获取更多系统信息,默认false")
|
|
102779
|
-
}
|
|
102780
|
-
}
|
|
102781
|
-
}).define(async (ctx) => {
|
|
102782
|
-
const more = ctx.query?.more ?? false;
|
|
102783
|
-
const list4 = getLiveMdContent({ more });
|
|
102784
|
-
ctx.body = {
|
|
102785
|
-
title: "开发环境模式配置",
|
|
102786
|
-
list: list4
|
|
102787
|
-
};
|
|
102788
|
-
}).addTo(app);
|
|
102789
102840
|
app.route({
|
|
102790
102841
|
path: "cnb-board",
|
|
102791
102842
|
key: "exit",
|
package/dist/assistant-server.js
CHANGED
|
@@ -125163,11 +125163,11 @@ app.route({
|
|
|
125163
125163
|
})
|
|
125164
125164
|
}
|
|
125165
125165
|
}).define(async (ctx) => {
|
|
125166
|
-
const { path: path18, key = "" } = ctx.
|
|
125166
|
+
const { path: path18, key = "" } = ctx.args;
|
|
125167
125167
|
if (!path18) {
|
|
125168
125168
|
ctx.throw("路径path不能为空");
|
|
125169
125169
|
}
|
|
125170
|
-
const res = await ctx.run({ path: path18, key, payload: ctx.
|
|
125170
|
+
const res = await ctx.run({ path: path18, key, payload: ctx.args.payload || {} }, {
|
|
125171
125171
|
...ctx
|
|
125172
125172
|
});
|
|
125173
125173
|
ctx.forward(res);
|
|
@@ -127056,20 +127056,22 @@ app.route({
|
|
|
127056
127056
|
// src/routes/cnb-board/live/live-content.ts
|
|
127057
127057
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
127058
127058
|
import os7 from "node:os";
|
|
127059
|
+
import { execSync as execSync3 } from "node:child_process";
|
|
127059
127060
|
var getLiveMdContent = (opts) => {
|
|
127060
127061
|
const more = opts?.more ?? false;
|
|
127061
127062
|
const url4 = useKey("CNB_VSCODE_PROXY_URI") || "";
|
|
127062
127063
|
const token = useKey("CNB_TOKEN") || "";
|
|
127063
127064
|
const openclawPort = useKey("OPENCLAW_PORT") || "80";
|
|
127064
|
-
const openclawUrl = url4
|
|
127065
|
+
const openclawUrl = url4.replace("{{port}}", openclawPort);
|
|
127065
127066
|
const openclawUrlSecret = openclawUrl + "/openclaw?token=" + token;
|
|
127066
127067
|
const opencodePort = useKey("OPENCODE_PORT") || "100";
|
|
127067
|
-
const opencodeUrl = url4
|
|
127068
|
+
const opencodeUrl = url4.replace("{{port}}", opencodePort);
|
|
127068
127069
|
const _opencodeURL = new URL(opencodeUrl);
|
|
127069
127070
|
_opencodeURL.username = "root";
|
|
127070
127071
|
_opencodeURL.password = token;
|
|
127071
127072
|
const opencodeUrlSecret = _opencodeURL.toString();
|
|
127072
|
-
const kevisualUrl = url4
|
|
127073
|
+
const kevisualUrl = url4.replace("{{port}}", "51515");
|
|
127074
|
+
const openWebUrl = url4.replace("{{port}}", "200");
|
|
127073
127075
|
const vscodeWebUrl = useKey("CNB_VSCODE_WEB_URL") || "";
|
|
127074
127076
|
const TEMPLATE = `# 开发环境模式配置
|
|
127075
127077
|
|
|
@@ -127077,6 +127079,9 @@ var getLiveMdContent = (opts) => {
|
|
|
127077
127079
|
#### nginx 反向代理访问(推荐)
|
|
127078
127080
|
- OpenClaw: ${openclawUrl + "/openclaw"}
|
|
127079
127081
|
- OpenCode: ${opencodeUrl}
|
|
127082
|
+
- VSCode Web: ${vscodeWebUrl}
|
|
127083
|
+
- OpenWebUI: ${openWebUrl}
|
|
127084
|
+
- Kevisual: ${kevisualUrl}
|
|
127080
127085
|
|
|
127081
127086
|
### 直接访问
|
|
127082
127087
|
- Kevisual: ${kevisualUrl}
|
|
@@ -127100,7 +127105,7 @@ var getLiveMdContent = (opts) => {
|
|
|
127100
127105
|
- wss: vscode web的websocket地址
|
|
127101
127106
|
- cookie: vscode web的cookie,保持和浏览器一致
|
|
127102
127107
|
- url: vscode web的访问地址,可以直接访问vscode web
|
|
127103
|
-
4. 运行cli命令,ev cnb live -c /workspace/live/keep.json
|
|
127108
|
+
4. 运行cli命令,ev cnb live -c /workspace/live/keep.json.(直接对话opencode或者openclaw调用cnb-live技能即可)
|
|
127104
127109
|
|
|
127105
127110
|
`;
|
|
127106
127111
|
const labels = [
|
|
@@ -127119,6 +127124,11 @@ var getLiveMdContent = (opts) => {
|
|
|
127119
127124
|
value: token,
|
|
127120
127125
|
description: "CNB 临时 Token,保持和环境变量 CNB_TOKEN 一致"
|
|
127121
127126
|
},
|
|
127127
|
+
{
|
|
127128
|
+
title: "openWebUrl",
|
|
127129
|
+
value: openWebUrl,
|
|
127130
|
+
description: "OpenWebUI 的访问地址,可以通过该地址访问 OpenWebUI 服务"
|
|
127131
|
+
},
|
|
127122
127132
|
{
|
|
127123
127133
|
title: "openclawUrl",
|
|
127124
127134
|
value: openclawUrl,
|
|
@@ -127151,7 +127161,7 @@ var getLiveMdContent = (opts) => {
|
|
|
127151
127161
|
};
|
|
127152
127162
|
var createOSInfo = (more = false) => {
|
|
127153
127163
|
const labels = [];
|
|
127154
|
-
const startTimer = useKey("CNB_BUILD_START_TIME") ||
|
|
127164
|
+
const startTimer = useKey("CNB_BUILD_START_TIME") || "";
|
|
127155
127165
|
const cpus = os7.cpus();
|
|
127156
127166
|
let totalIdle = 0;
|
|
127157
127167
|
let totalTick = 0;
|
|
@@ -127162,10 +127172,26 @@ var createOSInfo = (more = false) => {
|
|
|
127162
127172
|
totalIdle += cpu.times.idle;
|
|
127163
127173
|
});
|
|
127164
127174
|
const cpuUsage = ((1 - totalIdle / totalTick) * 100).toFixed(2);
|
|
127165
|
-
|
|
127166
|
-
|
|
127167
|
-
|
|
127168
|
-
|
|
127175
|
+
let memUsed = 0;
|
|
127176
|
+
let memTotal = 0;
|
|
127177
|
+
let memFree = 0;
|
|
127178
|
+
try {
|
|
127179
|
+
const freeOutput = execSync3("free -b", { encoding: "utf-8" });
|
|
127180
|
+
const lines = freeOutput.trim().split(`
|
|
127181
|
+
`);
|
|
127182
|
+
const memLine = lines.find((line) => line.startsWith("Mem:"));
|
|
127183
|
+
if (memLine) {
|
|
127184
|
+
const parts = memLine.split(/\s+/);
|
|
127185
|
+
memTotal = parseInt(parts[1]);
|
|
127186
|
+
memUsed = parseInt(parts[2]);
|
|
127187
|
+
memFree = parseInt(parts[3]);
|
|
127188
|
+
}
|
|
127189
|
+
} catch (e) {
|
|
127190
|
+
memTotal = os7.totalmem();
|
|
127191
|
+
memFree = os7.freemem();
|
|
127192
|
+
memUsed = memTotal - memFree;
|
|
127193
|
+
}
|
|
127194
|
+
const memUsage = memTotal > 0 ? (memUsed / memTotal * 100).toFixed(2) : "0.00";
|
|
127169
127195
|
const formatBytes = (bytes) => {
|
|
127170
127196
|
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
127171
127197
|
if (bytes === 0)
|
|
@@ -127174,8 +127200,6 @@ var createOSInfo = (more = false) => {
|
|
|
127174
127200
|
return (bytes / Math.pow(1024, i)).toFixed(2) + " " + sizes[i];
|
|
127175
127201
|
};
|
|
127176
127202
|
const bootTime = os7.uptime();
|
|
127177
|
-
const bootTimeDate = new Date(Date.now() - bootTime * 1000);
|
|
127178
|
-
const bootTimeStr = import_dayjs.default(bootTimeDate).format("YYYY-MM-DD HH:mm:ss");
|
|
127179
127203
|
const formatUptime = (seconds) => {
|
|
127180
127204
|
const days = Math.floor(seconds / 86400);
|
|
127181
127205
|
const hours = Math.floor(seconds % 86400 / 3600);
|
|
@@ -127183,7 +127207,13 @@ var createOSInfo = (more = false) => {
|
|
|
127183
127207
|
const secs = Math.floor(seconds % 60);
|
|
127184
127208
|
return `${days}天 ${hours}小时 ${minutes}分钟 ${secs}秒`;
|
|
127185
127209
|
};
|
|
127186
|
-
|
|
127210
|
+
let diskUsage = "";
|
|
127211
|
+
try {
|
|
127212
|
+
const duOutput = execSync3("du -sh .", { encoding: "utf-8" });
|
|
127213
|
+
diskUsage = duOutput.trim().split("\t")[0];
|
|
127214
|
+
} catch (e) {
|
|
127215
|
+
diskUsage = "获取失败";
|
|
127216
|
+
}
|
|
127187
127217
|
labels.push({
|
|
127188
127218
|
title: "cpuUsage",
|
|
127189
127219
|
value: `${cpuUsage}%`,
|
|
@@ -127194,33 +127224,35 @@ var createOSInfo = (more = false) => {
|
|
|
127194
127224
|
description: "CPU 核心数"
|
|
127195
127225
|
}, {
|
|
127196
127226
|
title: "memoryUsed",
|
|
127197
|
-
value: formatBytes(
|
|
127227
|
+
value: formatBytes(memUsed),
|
|
127198
127228
|
description: "已使用内存"
|
|
127199
127229
|
}, {
|
|
127200
127230
|
title: "memoryTotal",
|
|
127201
|
-
value: formatBytes(
|
|
127231
|
+
value: formatBytes(memTotal),
|
|
127202
127232
|
description: "总内存"
|
|
127233
|
+
}, {
|
|
127234
|
+
title: "memoryFree",
|
|
127235
|
+
value: formatBytes(memFree),
|
|
127236
|
+
description: "空闲内存"
|
|
127203
127237
|
}, {
|
|
127204
127238
|
title: "memoryUsage",
|
|
127205
127239
|
value: `${memUsage}%`,
|
|
127206
127240
|
description: "内存使用率"
|
|
127207
127241
|
}, {
|
|
127208
|
-
title: "
|
|
127209
|
-
value:
|
|
127210
|
-
description: "
|
|
127211
|
-
}, {
|
|
127212
|
-
title: "bootTime",
|
|
127213
|
-
value: bootTimeStr,
|
|
127214
|
-
description: "系统启动时间"
|
|
127242
|
+
title: "diskUsage",
|
|
127243
|
+
value: diskUsage,
|
|
127244
|
+
description: "当前目录磁盘使用情况"
|
|
127215
127245
|
}, {
|
|
127216
127246
|
title: "uptime",
|
|
127217
127247
|
value: formatUptime(bootTime),
|
|
127218
127248
|
description: "系统运行时间"
|
|
127219
127249
|
});
|
|
127220
127250
|
if (startTimer) {
|
|
127221
|
-
const buildStartTime = import_dayjs.default(
|
|
127222
|
-
const
|
|
127251
|
+
const buildStartTime = import_dayjs.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
|
|
127252
|
+
const buildStartTimestamp = import_dayjs.default(startTimer).valueOf();
|
|
127253
|
+
const buildUptime = Date.now() - buildStartTimestamp;
|
|
127223
127254
|
const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
|
|
127255
|
+
const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
|
|
127224
127256
|
labels.push({
|
|
127225
127257
|
title: "buildStartTime",
|
|
127226
127258
|
value: buildStartTime,
|
|
@@ -127230,6 +127262,25 @@ var createOSInfo = (more = false) => {
|
|
|
127230
127262
|
value: buildUptimeStr,
|
|
127231
127263
|
description: "构建已运行时间"
|
|
127232
127264
|
});
|
|
127265
|
+
if (maxRunTime > 0) {
|
|
127266
|
+
const now = import_dayjs.default();
|
|
127267
|
+
const today4am = now.hour(4).minute(0).second(0).millisecond(0);
|
|
127268
|
+
let timeTo4 = today4am.valueOf() - now.valueOf();
|
|
127269
|
+
if (timeTo4 < 0) {
|
|
127270
|
+
timeTo4 = today4am.add(1, "day").valueOf() - now.valueOf();
|
|
127271
|
+
}
|
|
127272
|
+
const timeTo4Str = `[距离晚上4点重启时间: ${formatUptime(Math.floor(timeTo4 / 1000))}]`;
|
|
127273
|
+
labels.push({
|
|
127274
|
+
title: "buildMaxRunTime",
|
|
127275
|
+
value: formatUptime(Math.floor(maxRunTime / 1000)),
|
|
127276
|
+
description: "构建最大运行时间(限制时间)"
|
|
127277
|
+
});
|
|
127278
|
+
labels.unshift({
|
|
127279
|
+
title: "剩余时间",
|
|
127280
|
+
value: formatUptime(Math.floor((maxRunTime - buildUptime) / 1000)) + " " + timeTo4Str,
|
|
127281
|
+
description: "构建剩余时间"
|
|
127282
|
+
});
|
|
127283
|
+
}
|
|
127233
127284
|
}
|
|
127234
127285
|
if (more) {
|
|
127235
127286
|
const loadavg = os7.loadavg();
|
|
@@ -127268,8 +127319,26 @@ var createOSInfo = (more = false) => {
|
|
|
127268
127319
|
|
|
127269
127320
|
// src/routes/cnb-board/cnb-dev-env.ts
|
|
127270
127321
|
app.route({
|
|
127271
|
-
path: "
|
|
127272
|
-
key: "live
|
|
127322
|
+
path: "cnb_board",
|
|
127323
|
+
key: "live",
|
|
127324
|
+
description: "获取cnb-board live的mdContent内容",
|
|
127325
|
+
middleware: ["auth-admin"],
|
|
127326
|
+
metadata: {
|
|
127327
|
+
args: {
|
|
127328
|
+
more: zod_default.boolean().optional().describe("是否获取更多系统信息,默认false")
|
|
127329
|
+
}
|
|
127330
|
+
}
|
|
127331
|
+
}).define(async (ctx) => {
|
|
127332
|
+
const more = ctx.query?.more ?? false;
|
|
127333
|
+
const list4 = getLiveMdContent({ more });
|
|
127334
|
+
ctx.body = {
|
|
127335
|
+
title: "开发环境模式配置",
|
|
127336
|
+
list: list4
|
|
127337
|
+
};
|
|
127338
|
+
}).addTo(app);
|
|
127339
|
+
app.route({
|
|
127340
|
+
path: "cnb_board",
|
|
127341
|
+
key: "live_repo_info",
|
|
127273
127342
|
description: "获取cnb-board live的repo信息",
|
|
127274
127343
|
middleware: ["auth-admin"]
|
|
127275
127344
|
}).define(async (ctx) => {
|
|
@@ -127316,8 +127385,8 @@ app.route({
|
|
|
127316
127385
|
};
|
|
127317
127386
|
}).addTo(app);
|
|
127318
127387
|
app.route({
|
|
127319
|
-
path: "
|
|
127320
|
-
key: "
|
|
127388
|
+
path: "cnb_board",
|
|
127389
|
+
key: "live_build_info",
|
|
127321
127390
|
description: "获取cnb-board live的构建信息",
|
|
127322
127391
|
middleware: ["auth-admin"]
|
|
127323
127392
|
}).define(async (ctx) => {
|
|
@@ -127459,8 +127528,8 @@ app.route({
|
|
|
127459
127528
|
};
|
|
127460
127529
|
}).addTo(app);
|
|
127461
127530
|
app.route({
|
|
127462
|
-
path: "
|
|
127463
|
-
key: "
|
|
127531
|
+
path: "cnb_board",
|
|
127532
|
+
key: "live_pull_info",
|
|
127464
127533
|
description: "获取cnb-board live的PR信息",
|
|
127465
127534
|
middleware: ["auth-admin"]
|
|
127466
127535
|
}).define(async (ctx) => {
|
|
@@ -127557,8 +127626,8 @@ app.route({
|
|
|
127557
127626
|
};
|
|
127558
127627
|
}).addTo(app);
|
|
127559
127628
|
app.route({
|
|
127560
|
-
path: "
|
|
127561
|
-
key: "
|
|
127629
|
+
path: "cnb_board",
|
|
127630
|
+
key: "live_npc_info",
|
|
127562
127631
|
description: "获取cnb-board live的NPC信息",
|
|
127563
127632
|
middleware: ["auth-admin"]
|
|
127564
127633
|
}).define(async (ctx) => {
|
|
@@ -127600,8 +127669,8 @@ app.route({
|
|
|
127600
127669
|
};
|
|
127601
127670
|
}).addTo(app);
|
|
127602
127671
|
app.route({
|
|
127603
|
-
path: "
|
|
127604
|
-
key: "
|
|
127672
|
+
path: "cnb_board",
|
|
127673
|
+
key: "live_comment_info",
|
|
127605
127674
|
description: "获取cnb-board live的评论信息",
|
|
127606
127675
|
middleware: ["auth-admin"]
|
|
127607
127676
|
}).define(async (ctx) => {
|
|
@@ -127655,24 +127724,6 @@ app.route({
|
|
|
127655
127724
|
isCNB: !!isCNB
|
|
127656
127725
|
};
|
|
127657
127726
|
}).addTo(app);
|
|
127658
|
-
app.route({
|
|
127659
|
-
path: "cnb-board",
|
|
127660
|
-
key: "live",
|
|
127661
|
-
description: "获取cnb-board live的mdContent内容",
|
|
127662
|
-
middleware: ["auth-admin"],
|
|
127663
|
-
metadata: {
|
|
127664
|
-
args: {
|
|
127665
|
-
more: zod_default.boolean().optional().describe("是否获取更多系统信息,默认false")
|
|
127666
|
-
}
|
|
127667
|
-
}
|
|
127668
|
-
}).define(async (ctx) => {
|
|
127669
|
-
const more = ctx.query?.more ?? false;
|
|
127670
|
-
const list4 = getLiveMdContent({ more });
|
|
127671
|
-
ctx.body = {
|
|
127672
|
-
title: "开发环境模式配置",
|
|
127673
|
-
list: list4
|
|
127674
|
-
};
|
|
127675
|
-
}).addTo(app);
|
|
127676
127727
|
app.route({
|
|
127677
127728
|
path: "cnb-board",
|
|
127678
127729
|
key: "exit",
|
|
@@ -129422,7 +129473,7 @@ import path22 from "node:path";
|
|
|
129422
129473
|
// src/module/get-bun-path.ts
|
|
129423
129474
|
import fs24 from "node:fs";
|
|
129424
129475
|
import path21 from "node:path";
|
|
129425
|
-
import { execSync as
|
|
129476
|
+
import { execSync as execSync4 } from "node:child_process";
|
|
129426
129477
|
var getBunPath = () => {
|
|
129427
129478
|
const isWindows = process.platform === "win32";
|
|
129428
129479
|
const bunExecutableName = isWindows ? "bun.exe" : "bun";
|
|
@@ -129431,14 +129482,14 @@ var getBunPath = () => {
|
|
|
129431
129482
|
}
|
|
129432
129483
|
if (isWindows) {
|
|
129433
129484
|
try {
|
|
129434
|
-
const globalNodeModules =
|
|
129485
|
+
const globalNodeModules = execSync4("npm root -g", { encoding: "utf-8" }).trim();
|
|
129435
129486
|
const bunExePath = path21.join(globalNodeModules, "bun", "bin", "bun.exe");
|
|
129436
129487
|
if (fs24.existsSync(bunExePath)) {
|
|
129437
129488
|
return bunExePath;
|
|
129438
129489
|
}
|
|
129439
129490
|
} catch (error54) {}
|
|
129440
129491
|
try {
|
|
129441
|
-
const bunPath =
|
|
129492
|
+
const bunPath = execSync4("where bun", { encoding: "utf-8" }).trim().split(`
|
|
129442
129493
|
`)[0];
|
|
129443
129494
|
if (bunPath && bunPath.endsWith(".exe")) {
|
|
129444
129495
|
return bunPath;
|
|
@@ -129453,7 +129504,7 @@ var getBunPath = () => {
|
|
|
129453
129504
|
} catch (error54) {}
|
|
129454
129505
|
} else {
|
|
129455
129506
|
try {
|
|
129456
|
-
const bunPath =
|
|
129507
|
+
const bunPath = execSync4("which bun", { encoding: "utf-8" }).trim();
|
|
129457
129508
|
if (bunPath && fs24.existsSync(bunPath)) {
|
|
129458
129509
|
return bunPath;
|
|
129459
129510
|
}
|
package/dist/envision.js
CHANGED
|
@@ -22312,8 +22312,8 @@ InitEnv.init();
|
|
|
22312
22312
|
var version = useContextKey("version", () => {
|
|
22313
22313
|
let version2 = "0.0.64";
|
|
22314
22314
|
try {
|
|
22315
|
-
if ("0.1.
|
|
22316
|
-
version2 = "0.1.
|
|
22315
|
+
if ("0.1.11")
|
|
22316
|
+
version2 = "0.1.11";
|
|
22317
22317
|
} catch (e) {}
|
|
22318
22318
|
return version2;
|
|
22319
22319
|
});
|