@kevisual/cli 0.1.9 → 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.
@@ -62905,7 +62905,7 @@ var useKey = (envKey, initKey = "context") => {
62905
62905
  return null;
62906
62906
  };
62907
62907
 
62908
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router.js
62908
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router.js
62909
62909
  import { createRequire as createRequire2 } from "node:module";
62910
62910
  import { webcrypto as crypto2 } from "node:crypto";
62911
62911
  import http from "node:http";
@@ -79825,6 +79825,7 @@ class QueryRouter {
79825
79825
  const maxNextRoute = this.maxNextRoute;
79826
79826
  ctx = ctx || {};
79827
79827
  ctx.currentPath = path;
79828
+ ctx.currentId = route?.id;
79828
79829
  ctx.currentKey = key;
79829
79830
  ctx.currentRoute = route;
79830
79831
  ctx.index = (ctx.index || 0) + 1;
@@ -79838,7 +79839,7 @@ class QueryRouter {
79838
79839
  ctx.code = 500;
79839
79840
  ctx.message = "Too many nextRoute";
79840
79841
  ctx.body = null;
79841
- return;
79842
+ return ctx;
79842
79843
  }
79843
79844
  if (route && route.middleware && route.middleware.length > 0) {
79844
79845
  const errorMiddleware = [];
@@ -79913,7 +79914,9 @@ class QueryRouter {
79913
79914
  }
79914
79915
  return ctx;
79915
79916
  }
79916
- if (ctx.end) {}
79917
+ if (ctx.end) {
79918
+ return ctx;
79919
+ }
79917
79920
  }
79918
79921
  }
79919
79922
  }
@@ -80107,7 +80110,7 @@ class QueryRouter {
80107
80110
  description: "列出当前应用下的所有的路由信息",
80108
80111
  middleware: opts?.middleware || [],
80109
80112
  run: async (ctx) => {
80110
- const tokenUser = ctx.state.tokenUser;
80113
+ const tokenUser = ctx.state;
80111
80114
  let isUser = !!tokenUser;
80112
80115
  const list = this.getList(opts?.filter).filter((item) => {
80113
80116
  if (item.id === "auth" || item.id === "auth-can" || item.id === "check-auth-admin" || item.id === "auth-admin") {
@@ -80137,6 +80140,56 @@ class QueryRouter {
80137
80140
  toJSONSchema = toJSONSchema3;
80138
80141
  fromJSONSchema = fromJSONSchema3;
80139
80142
  }
80143
+
80144
+ class QueryRouterServer extends QueryRouter {
80145
+ handle;
80146
+ constructor(opts) {
80147
+ super();
80148
+ const initHandle = opts?.initHandle ?? true;
80149
+ if (initHandle || opts?.handleFn) {
80150
+ this.handle = this.getHandle(this, opts?.handleFn, opts?.context);
80151
+ }
80152
+ this.setContext({ needSerialize: false, ...opts?.context });
80153
+ if (opts?.appId) {
80154
+ this.appId = opts.appId;
80155
+ } else {
80156
+ this.appId = randomId(16);
80157
+ }
80158
+ }
80159
+ setHandle(wrapperFn, ctx) {
80160
+ this.handle = this.getHandle(this, wrapperFn, ctx);
80161
+ }
80162
+ addRoute(route, opts) {
80163
+ this.add(route, opts);
80164
+ }
80165
+ Route = Route;
80166
+ route(...args) {
80167
+ const [path, key, opts] = args;
80168
+ if (typeof path === "object") {
80169
+ return new Route(path.path, path.key, path);
80170
+ }
80171
+ if (typeof path === "string") {
80172
+ if (opts) {
80173
+ return new Route(path, key, opts);
80174
+ }
80175
+ if (key && typeof key === "object") {
80176
+ return new Route(path, key?.key || "", key);
80177
+ }
80178
+ return new Route(path, key);
80179
+ }
80180
+ return new Route(path, key, opts);
80181
+ }
80182
+ prompt(description) {
80183
+ return new Route(undefined, undefined, { description });
80184
+ }
80185
+ async run(msg, ctx) {
80186
+ const handle = this.handle;
80187
+ if (handle) {
80188
+ return handle(msg, ctx);
80189
+ }
80190
+ return super.run(msg, ctx);
80191
+ }
80192
+ }
80140
80193
  var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
80141
80194
  var isBrowser3 = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
80142
80195
  var isDeno = typeof Deno !== "undefined" && typeof Deno.version === "object" && typeof Deno.version.deno === "string";
@@ -81004,11 +81057,11 @@ class BunServer extends ServerBase {
81004
81057
  }
81005
81058
  }
81006
81059
 
81007
- class App extends QueryRouter {
81060
+ class App extends QueryRouterServer {
81008
81061
  router;
81009
81062
  server;
81010
81063
  constructor(opts) {
81011
- super();
81064
+ super({ initHandle: false, context: { needSerialize: true, ...opts?.routerContext } });
81012
81065
  const router = this;
81013
81066
  let server = opts?.server;
81014
81067
  if (!server) {
@@ -81020,7 +81073,6 @@ class App extends QueryRouter {
81020
81073
  }
81021
81074
  }
81022
81075
  server.setHandle(router.getHandle(router, opts?.routerHandle, opts?.routerContext));
81023
- router.setContext({ needSerialize: true, ...opts?.routerContext });
81024
81076
  this.router = router;
81025
81077
  this.server = server;
81026
81078
  if (opts?.appId) {
@@ -81033,42 +81085,7 @@ class App extends QueryRouter {
81033
81085
  listen(...args) {
81034
81086
  this.server.listen(...args);
81035
81087
  }
81036
- addRoute(route, opts) {
81037
- super.add(route, opts);
81038
- }
81039
81088
  Route = Route;
81040
- route(...args) {
81041
- const [path, key, opts] = args;
81042
- if (typeof path === "object") {
81043
- return new Route(path.path, path.key, path);
81044
- }
81045
- if (typeof path === "string") {
81046
- if (opts) {
81047
- return new Route(path, key, opts);
81048
- }
81049
- if (key && typeof key === "object") {
81050
- return new Route(path, key?.key || "", key);
81051
- }
81052
- return new Route(path, key);
81053
- }
81054
- return new Route(path, key, opts);
81055
- }
81056
- prompt(...args) {
81057
- const [desc] = args;
81058
- let description = "";
81059
- if (typeof desc === "string") {
81060
- description = desc;
81061
- } else if (typeof desc === "function") {
81062
- description = desc() || "";
81063
- }
81064
- return new Route("", "", { description });
81065
- }
81066
- async call(message, ctx) {
81067
- return await super.call(message, ctx);
81068
- }
81069
- async run(msg, ctx) {
81070
- return await super.run(msg, ctx);
81071
- }
81072
81089
  static handleRequest(req, res) {
81073
81090
  return handleServer(req, res);
81074
81091
  }
@@ -81083,7 +81100,7 @@ class App extends QueryRouter {
81083
81100
  }
81084
81101
  }
81085
81102
 
81086
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router-simple.js
81103
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router-simple.js
81087
81104
  import url3 from "node:url";
81088
81105
  var __create3 = Object.create;
81089
81106
  var __getProtoOf3 = Object.getPrototypeOf;
@@ -92291,7 +92308,7 @@ class Query {
92291
92308
  }
92292
92309
  }
92293
92310
 
92294
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router-browser.js
92311
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router-browser.js
92295
92312
  var __create5 = Object.create;
92296
92313
  var __getProtoOf5 = Object.getPrototypeOf;
92297
92314
  var __defProp5 = Object.defineProperty;
@@ -122870,6 +122887,15 @@ var installDeps = async (opts) => {
122870
122887
  syncSpawn("npm", params, { cwd: appPath, stdio: "inherit", env: process.env, shell: true });
122871
122888
  }
122872
122889
  };
122890
+ var execCommand = (command, options = {}) => {
122891
+ const { cwd } = options;
122892
+ return spawnSync(command, {
122893
+ stdio: "inherit",
122894
+ shell: true,
122895
+ cwd,
122896
+ env: process.env
122897
+ });
122898
+ };
122873
122899
 
122874
122900
  // src/services/init/update-pkgs.ts
122875
122901
  var import_semver = __toESM(require_semver2(), 1);
@@ -123401,7 +123427,8 @@ app.route({
123401
123427
  title: "查看客户端 IP 地址",
123402
123428
  summary: "获取当前客户端的 IP 地址信息"
123403
123429
  })
123404
- }
123430
+ },
123431
+ middleware: ["auth-admin"]
123405
123432
  }).define(async (ctx) => {
123406
123433
  const networkInterfaces = os3.networkInterfaces();
123407
123434
  const ipAddresses = [];
@@ -124963,11 +124990,7 @@ app.route({
124963
124990
  message: "客户端重启命令已执行"
124964
124991
  };
124965
124992
  } catch (error54) {
124966
- ctx.status = 500;
124967
- ctx.body = {
124968
- message: "重启客户端失败",
124969
- error: error54.message
124970
- };
124993
+ ctx.throw(500, "重启客户端失败");
124971
124994
  }
124972
124995
  }).addTo(app);
124973
124996
 
@@ -125140,11 +125163,11 @@ app.route({
125140
125163
  })
125141
125164
  }
125142
125165
  }).define(async (ctx) => {
125143
- const { path: path18, key = "" } = ctx.query;
125166
+ const { path: path18, key = "" } = ctx.args;
125144
125167
  if (!path18) {
125145
125168
  ctx.throw("路径path不能为空");
125146
125169
  }
125147
- const res = await ctx.run({ path: path18, key, payload: ctx.query.payload || {} }, {
125170
+ const res = await ctx.run({ path: path18, key, payload: ctx.args.payload || {} }, {
125148
125171
  ...ctx
125149
125172
  });
125150
125173
  ctx.forward(res);
@@ -127033,27 +127056,32 @@ app.route({
127033
127056
  // src/routes/cnb-board/live/live-content.ts
127034
127057
  var import_dayjs = __toESM(require_dayjs_min(), 1);
127035
127058
  import os7 from "node:os";
127059
+ import { execSync as execSync3 } from "node:child_process";
127036
127060
  var getLiveMdContent = (opts) => {
127037
127061
  const more = opts?.more ?? false;
127038
127062
  const url4 = useKey("CNB_VSCODE_PROXY_URI") || "";
127039
127063
  const token = useKey("CNB_TOKEN") || "";
127040
127064
  const openclawPort = useKey("OPENCLAW_PORT") || "80";
127041
- const openclawUrl = url4?.replace("{{port}}", openclawPort);
127065
+ const openclawUrl = url4.replace("{{port}}", openclawPort);
127042
127066
  const openclawUrlSecret = openclawUrl + "/openclaw?token=" + token;
127043
127067
  const opencodePort = useKey("OPENCODE_PORT") || "100";
127044
- const opencodeUrl = url4?.replace("{{port}}", opencodePort);
127068
+ const opencodeUrl = url4.replace("{{port}}", opencodePort);
127045
127069
  const _opencodeURL = new URL(opencodeUrl);
127046
127070
  _opencodeURL.username = "root";
127047
127071
  _opencodeURL.password = token;
127048
127072
  const opencodeUrlSecret = _opencodeURL.toString();
127049
- const kevisualUrl = url4?.replace("{{port}}", "51515");
127073
+ const kevisualUrl = url4.replace("{{port}}", "51515");
127074
+ const openWebUrl = url4.replace("{{port}}", "200");
127050
127075
  const vscodeWebUrl = useKey("CNB_VSCODE_WEB_URL") || "";
127051
127076
  const TEMPLATE = `# 开发环境模式配置
127052
127077
 
127053
127078
  ### 服务访问地址
127054
127079
  #### nginx 反向代理访问(推荐)
127055
- - OpenClaw: ${openclawUrl}
127080
+ - OpenClaw: ${openclawUrl + "/openclaw"}
127056
127081
  - OpenCode: ${opencodeUrl}
127082
+ - VSCode Web: ${vscodeWebUrl}
127083
+ - OpenWebUI: ${openWebUrl}
127084
+ - Kevisual: ${kevisualUrl}
127057
127085
 
127058
127086
  ### 直接访问
127059
127087
  - Kevisual: ${kevisualUrl}
@@ -127077,7 +127105,7 @@ var getLiveMdContent = (opts) => {
127077
127105
  - wss: vscode web的websocket地址
127078
127106
  - cookie: vscode web的cookie,保持和浏览器一致
127079
127107
  - url: vscode web的访问地址,可以直接访问vscode web
127080
- 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技能即可)
127081
127109
 
127082
127110
  `;
127083
127111
  const labels = [
@@ -127096,6 +127124,11 @@ var getLiveMdContent = (opts) => {
127096
127124
  value: token,
127097
127125
  description: "CNB 临时 Token,保持和环境变量 CNB_TOKEN 一致"
127098
127126
  },
127127
+ {
127128
+ title: "openWebUrl",
127129
+ value: openWebUrl,
127130
+ description: "OpenWebUI 的访问地址,可以通过该地址访问 OpenWebUI 服务"
127131
+ },
127099
127132
  {
127100
127133
  title: "openclawUrl",
127101
127134
  value: openclawUrl,
@@ -127128,7 +127161,7 @@ var getLiveMdContent = (opts) => {
127128
127161
  };
127129
127162
  var createOSInfo = (more = false) => {
127130
127163
  const labels = [];
127131
- const startTimer = useKey("CNB_BUILD_START_TIME") || 0;
127164
+ const startTimer = useKey("CNB_BUILD_START_TIME") || "";
127132
127165
  const cpus = os7.cpus();
127133
127166
  let totalIdle = 0;
127134
127167
  let totalTick = 0;
@@ -127139,10 +127172,26 @@ var createOSInfo = (more = false) => {
127139
127172
  totalIdle += cpu.times.idle;
127140
127173
  });
127141
127174
  const cpuUsage = ((1 - totalIdle / totalTick) * 100).toFixed(2);
127142
- const totalMem = os7.totalmem();
127143
- const freeMem = os7.freemem();
127144
- const usedMem = totalMem - freeMem;
127145
- const memUsage = (usedMem / totalMem * 100).toFixed(2);
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";
127146
127195
  const formatBytes = (bytes) => {
127147
127196
  const sizes = ["B", "KB", "MB", "GB", "TB"];
127148
127197
  if (bytes === 0)
@@ -127151,8 +127200,6 @@ var createOSInfo = (more = false) => {
127151
127200
  return (bytes / Math.pow(1024, i)).toFixed(2) + " " + sizes[i];
127152
127201
  };
127153
127202
  const bootTime = os7.uptime();
127154
- const bootTimeDate = new Date(Date.now() - bootTime * 1000);
127155
- const bootTimeStr = import_dayjs.default(bootTimeDate).format("YYYY-MM-DD HH:mm:ss");
127156
127203
  const formatUptime = (seconds) => {
127157
127204
  const days = Math.floor(seconds / 86400);
127158
127205
  const hours = Math.floor(seconds % 86400 / 3600);
@@ -127160,7 +127207,13 @@ var createOSInfo = (more = false) => {
127160
127207
  const secs = Math.floor(seconds % 60);
127161
127208
  return `${days}天 ${hours}小时 ${minutes}分钟 ${secs}秒`;
127162
127209
  };
127163
- const diskInfo = "可通过 df -h 命令获取";
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
+ }
127164
127217
  labels.push({
127165
127218
  title: "cpuUsage",
127166
127219
  value: `${cpuUsage}%`,
@@ -127171,33 +127224,35 @@ var createOSInfo = (more = false) => {
127171
127224
  description: "CPU 核心数"
127172
127225
  }, {
127173
127226
  title: "memoryUsed",
127174
- value: formatBytes(usedMem),
127227
+ value: formatBytes(memUsed),
127175
127228
  description: "已使用内存"
127176
127229
  }, {
127177
127230
  title: "memoryTotal",
127178
- value: formatBytes(totalMem),
127231
+ value: formatBytes(memTotal),
127179
127232
  description: "总内存"
127233
+ }, {
127234
+ title: "memoryFree",
127235
+ value: formatBytes(memFree),
127236
+ description: "空闲内存"
127180
127237
  }, {
127181
127238
  title: "memoryUsage",
127182
127239
  value: `${memUsage}%`,
127183
127240
  description: "内存使用率"
127184
127241
  }, {
127185
- title: "diskInfo",
127186
- value: diskInfo,
127187
- description: "磁盘信息 (请使用 df -h 命令查看)"
127188
- }, {
127189
- title: "bootTime",
127190
- value: bootTimeStr,
127191
- description: "系统启动时间"
127242
+ title: "diskUsage",
127243
+ value: diskUsage,
127244
+ description: "当前目录磁盘使用情况"
127192
127245
  }, {
127193
127246
  title: "uptime",
127194
127247
  value: formatUptime(bootTime),
127195
127248
  description: "系统运行时间"
127196
127249
  });
127197
127250
  if (startTimer) {
127198
- const buildStartTime = import_dayjs.default(parseInt(startTimer)).format("YYYY-MM-DD HH:mm:ss");
127199
- const buildUptime = Date.now() - parseInt(startTimer);
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;
127200
127254
  const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
127255
+ const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
127201
127256
  labels.push({
127202
127257
  title: "buildStartTime",
127203
127258
  value: buildStartTime,
@@ -127207,6 +127262,25 @@ var createOSInfo = (more = false) => {
127207
127262
  value: buildUptimeStr,
127208
127263
  description: "构建已运行时间"
127209
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
+ }
127210
127284
  }
127211
127285
  if (more) {
127212
127286
  const loadavg = os7.loadavg();
@@ -127245,8 +127319,26 @@ var createOSInfo = (more = false) => {
127245
127319
 
127246
127320
  // src/routes/cnb-board/cnb-dev-env.ts
127247
127321
  app.route({
127248
- path: "cnb-board",
127249
- key: "live-repo-info",
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",
127250
127342
  description: "获取cnb-board live的repo信息",
127251
127343
  middleware: ["auth-admin"]
127252
127344
  }).define(async (ctx) => {
@@ -127293,8 +127385,8 @@ app.route({
127293
127385
  };
127294
127386
  }).addTo(app);
127295
127387
  app.route({
127296
- path: "cnb-board",
127297
- key: "live-build-info",
127388
+ path: "cnb_board",
127389
+ key: "live_build_info",
127298
127390
  description: "获取cnb-board live的构建信息",
127299
127391
  middleware: ["auth-admin"]
127300
127392
  }).define(async (ctx) => {
@@ -127436,8 +127528,8 @@ app.route({
127436
127528
  };
127437
127529
  }).addTo(app);
127438
127530
  app.route({
127439
- path: "cnb-board",
127440
- key: "live-pull-info",
127531
+ path: "cnb_board",
127532
+ key: "live_pull_info",
127441
127533
  description: "获取cnb-board live的PR信息",
127442
127534
  middleware: ["auth-admin"]
127443
127535
  }).define(async (ctx) => {
@@ -127534,8 +127626,8 @@ app.route({
127534
127626
  };
127535
127627
  }).addTo(app);
127536
127628
  app.route({
127537
- path: "cnb-board",
127538
- key: "live-npc-info",
127629
+ path: "cnb_board",
127630
+ key: "live_npc_info",
127539
127631
  description: "获取cnb-board live的NPC信息",
127540
127632
  middleware: ["auth-admin"]
127541
127633
  }).define(async (ctx) => {
@@ -127577,8 +127669,8 @@ app.route({
127577
127669
  };
127578
127670
  }).addTo(app);
127579
127671
  app.route({
127580
- path: "cnb-board",
127581
- key: "live-comment-info",
127672
+ path: "cnb_board",
127673
+ key: "live_comment_info",
127582
127674
  description: "获取cnb-board live的评论信息",
127583
127675
  middleware: ["auth-admin"]
127584
127676
  }).define(async (ctx) => {
@@ -127623,22 +127715,24 @@ app.route({
127623
127715
  // src/routes/cnb-board/index.ts
127624
127716
  app.route({
127625
127717
  path: "cnb-board",
127626
- key: "live",
127627
- description: "获取cnb-board live的mdContent内容",
127628
- middleware: ["auth-admin"],
127629
- metadata: {
127630
- args: {
127631
- more: zod_default.boolean().optional().describe("是否获取更多系统信息,默认false")
127632
- }
127633
- }
127718
+ key: "is-cnb-board",
127719
+ description: "检查是否是 cnb-board 环境",
127720
+ middleware: ["auth-admin"]
127634
127721
  }).define(async (ctx) => {
127635
- const more = ctx.query?.more ?? false;
127636
- const list4 = getLiveMdContent({ more });
127722
+ const isCNB = useKey("CNB");
127637
127723
  ctx.body = {
127638
- title: "开发环境模式配置",
127639
- list: list4
127724
+ isCNB: !!isCNB
127640
127725
  };
127641
127726
  }).addTo(app);
127727
+ app.route({
127728
+ path: "cnb-board",
127729
+ key: "exit",
127730
+ description: "cnb的工作环境退出程序",
127731
+ middleware: ["auth-admin"]
127732
+ }).define(async (ctx) => {
127733
+ const cmd = "kill 1";
127734
+ execCommand(cmd);
127735
+ }).addTo(app);
127642
127736
 
127643
127737
  // ../node_modules/.pnpm/lru-cache@11.2.6/node_modules/lru-cache/dist/esm/index.min.js
127644
127738
  var M = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
@@ -128738,11 +128832,17 @@ class LiveCode {
128738
128832
  }
128739
128833
  }
128740
128834
 
128835
+ // src/routes/cnb-board/modules/is-cnb.ts
128836
+ var isCnb = () => {
128837
+ const CNB = useKey("CNB");
128838
+ return !!CNB;
128839
+ };
128840
+
128741
128841
  // src/services/proxy/proxy-page-index.ts
128742
128842
  var localProxy = new LocalProxy({});
128743
128843
  localProxy.initFromAssistantConfig(assistantConfig2);
128744
128844
  var isOpenPath = (pathname) => {
128745
- const openPaths = ["/root/home", "/root/cli", "/root/login"];
128845
+ const openPaths = ["/root/home", "/root/cli", "/root/login", "/root/cli-center"];
128746
128846
  for (const openPath of openPaths) {
128747
128847
  if (pathname.startsWith(openPath)) {
128748
128848
  return true;
@@ -128801,11 +128901,22 @@ var authFilter = async (req, res) => {
128801
128901
  };
128802
128902
  var proxyRoute = async (req, res) => {
128803
128903
  const _assistantConfig = assistantConfig2.getCacheAssistantConfig();
128804
- const home = _assistantConfig?.home || "/root/home";
128904
+ let home = _assistantConfig?.home;
128805
128905
  const auth = _assistantConfig?.auth || {};
128806
128906
  let noAdmin = !auth.username;
128807
- const toSetting = () => {
128808
- res.writeHead(302, { Location: `/root/cli-center/` });
128907
+ if (!home) {
128908
+ if (isCnb()) {
128909
+ home = "/root/cli-center/cnb-board";
128910
+ } else {
128911
+ home = "/root/cli-center/";
128912
+ }
128913
+ } else {
128914
+ if (!home.startsWith("/")) {
128915
+ home = "/" + home;
128916
+ }
128917
+ }
128918
+ const toLogin = (redirect) => {
128919
+ res.writeHead(302, { Location: `/root/login/` + (redirect ? `?redirect=${encodeURIComponent(redirect)}` : "") });
128809
128920
  res.end();
128810
128921
  return true;
128811
128922
  };
@@ -128813,10 +128924,11 @@ var proxyRoute = async (req, res) => {
128813
128924
  const pathname = decodeURIComponent(url4.pathname);
128814
128925
  if (pathname === "/") {
128815
128926
  if (noAdmin) {
128816
- return toSetting();
128927
+ return toLogin(home + "/");
128817
128928
  }
128818
- res.writeHead(302, { Location: `${home}/` });
128819
- return res.end();
128929
+ res.writeHead(302, { Location: home });
128930
+ res.end();
128931
+ return;
128820
128932
  }
128821
128933
  if (pathname.startsWith("/favicon.ico")) {
128822
128934
  res.statusCode = 404;
@@ -128877,7 +128989,7 @@ var proxyRoute = async (req, res) => {
128877
128989
  const isOpen = isOpenPath(pathname);
128878
128990
  logger.debug("proxyRoute", { _user, _app, pathname, noAdmin, isOpen });
128879
128991
  if (noAdmin && !isOpen) {
128880
- return toSetting();
128992
+ return toLogin();
128881
128993
  }
128882
128994
  if (_app && urls.length === 3) {
128883
128995
  res.writeHead(302, { Location: `${req.url}/` });
@@ -129013,7 +129125,7 @@ var import_busboy = __toESM(require_lib2(), 1);
129013
129125
  import path20 from "path";
129014
129126
  import fs23 from "fs";
129015
129127
 
129016
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/src/server/cookie.ts
129128
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/src/server/cookie.ts
129017
129129
  var NullObject2 = /* @__PURE__ */ (() => {
129018
129130
  const C2 = function() {};
129019
129131
  C2.prototype = Object.create(null);
@@ -129361,7 +129473,7 @@ import path22 from "node:path";
129361
129473
  // src/module/get-bun-path.ts
129362
129474
  import fs24 from "node:fs";
129363
129475
  import path21 from "node:path";
129364
- import { execSync as execSync3 } from "node:child_process";
129476
+ import { execSync as execSync4 } from "node:child_process";
129365
129477
  var getBunPath = () => {
129366
129478
  const isWindows = process.platform === "win32";
129367
129479
  const bunExecutableName = isWindows ? "bun.exe" : "bun";
@@ -129370,14 +129482,14 @@ var getBunPath = () => {
129370
129482
  }
129371
129483
  if (isWindows) {
129372
129484
  try {
129373
- const globalNodeModules = execSync3("npm root -g", { encoding: "utf-8" }).trim();
129485
+ const globalNodeModules = execSync4("npm root -g", { encoding: "utf-8" }).trim();
129374
129486
  const bunExePath = path21.join(globalNodeModules, "bun", "bin", "bun.exe");
129375
129487
  if (fs24.existsSync(bunExePath)) {
129376
129488
  return bunExePath;
129377
129489
  }
129378
129490
  } catch (error54) {}
129379
129491
  try {
129380
- const bunPath = execSync3("where bun", { encoding: "utf-8" }).trim().split(`
129492
+ const bunPath = execSync4("where bun", { encoding: "utf-8" }).trim().split(`
129381
129493
  `)[0];
129382
129494
  if (bunPath && bunPath.endsWith(".exe")) {
129383
129495
  return bunPath;
@@ -129392,7 +129504,7 @@ var getBunPath = () => {
129392
129504
  } catch (error54) {}
129393
129505
  } else {
129394
129506
  try {
129395
- const bunPath = execSync3("which bun", { encoding: "utf-8" }).trim();
129507
+ const bunPath = execSync4("which bun", { encoding: "utf-8" }).trim();
129396
129508
  if (bunPath && fs24.existsSync(bunPath)) {
129397
129509
  return bunPath;
129398
129510
  }