@kevisual/cli 0.1.9 → 0.1.10

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.
@@ -23667,7 +23667,7 @@ var require_lib2 = __commonJS((exports, module) => {
23667
23667
  };
23668
23668
  });
23669
23669
 
23670
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router.js
23670
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router.js
23671
23671
  import { createRequire as createRequire2 } from "node:module";
23672
23672
  import { webcrypto as crypto2 } from "node:crypto";
23673
23673
  import http from "node:http";
@@ -40587,6 +40587,7 @@ class QueryRouter {
40587
40587
  const maxNextRoute = this.maxNextRoute;
40588
40588
  ctx = ctx || {};
40589
40589
  ctx.currentPath = path;
40590
+ ctx.currentId = route?.id;
40590
40591
  ctx.currentKey = key;
40591
40592
  ctx.currentRoute = route;
40592
40593
  ctx.index = (ctx.index || 0) + 1;
@@ -40600,7 +40601,7 @@ class QueryRouter {
40600
40601
  ctx.code = 500;
40601
40602
  ctx.message = "Too many nextRoute";
40602
40603
  ctx.body = null;
40603
- return;
40604
+ return ctx;
40604
40605
  }
40605
40606
  if (route && route.middleware && route.middleware.length > 0) {
40606
40607
  const errorMiddleware = [];
@@ -40675,7 +40676,9 @@ class QueryRouter {
40675
40676
  }
40676
40677
  return ctx;
40677
40678
  }
40678
- if (ctx.end) {}
40679
+ if (ctx.end) {
40680
+ return ctx;
40681
+ }
40679
40682
  }
40680
40683
  }
40681
40684
  }
@@ -40869,7 +40872,7 @@ class QueryRouter {
40869
40872
  description: "列出当前应用下的所有的路由信息",
40870
40873
  middleware: opts?.middleware || [],
40871
40874
  run: async (ctx) => {
40872
- const tokenUser = ctx.state.tokenUser;
40875
+ const tokenUser = ctx.state;
40873
40876
  let isUser = !!tokenUser;
40874
40877
  const list = this.getList(opts?.filter).filter((item) => {
40875
40878
  if (item.id === "auth" || item.id === "auth-can" || item.id === "check-auth-admin" || item.id === "auth-admin") {
@@ -40899,6 +40902,56 @@ class QueryRouter {
40899
40902
  toJSONSchema = toJSONSchema3;
40900
40903
  fromJSONSchema = fromJSONSchema3;
40901
40904
  }
40905
+
40906
+ class QueryRouterServer extends QueryRouter {
40907
+ handle;
40908
+ constructor(opts) {
40909
+ super();
40910
+ const initHandle = opts?.initHandle ?? true;
40911
+ if (initHandle || opts?.handleFn) {
40912
+ this.handle = this.getHandle(this, opts?.handleFn, opts?.context);
40913
+ }
40914
+ this.setContext({ needSerialize: false, ...opts?.context });
40915
+ if (opts?.appId) {
40916
+ this.appId = opts.appId;
40917
+ } else {
40918
+ this.appId = randomId(16);
40919
+ }
40920
+ }
40921
+ setHandle(wrapperFn, ctx) {
40922
+ this.handle = this.getHandle(this, wrapperFn, ctx);
40923
+ }
40924
+ addRoute(route, opts) {
40925
+ this.add(route, opts);
40926
+ }
40927
+ Route = Route;
40928
+ route(...args) {
40929
+ const [path, key, opts] = args;
40930
+ if (typeof path === "object") {
40931
+ return new Route(path.path, path.key, path);
40932
+ }
40933
+ if (typeof path === "string") {
40934
+ if (opts) {
40935
+ return new Route(path, key, opts);
40936
+ }
40937
+ if (key && typeof key === "object") {
40938
+ return new Route(path, key?.key || "", key);
40939
+ }
40940
+ return new Route(path, key);
40941
+ }
40942
+ return new Route(path, key, opts);
40943
+ }
40944
+ prompt(description) {
40945
+ return new Route(undefined, undefined, { description });
40946
+ }
40947
+ async run(msg, ctx) {
40948
+ const handle = this.handle;
40949
+ if (handle) {
40950
+ return handle(msg, ctx);
40951
+ }
40952
+ return super.run(msg, ctx);
40953
+ }
40954
+ }
40902
40955
  var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
40903
40956
  var isBrowser = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
40904
40957
  var isDeno = typeof Deno !== "undefined" && typeof Deno.version === "object" && typeof Deno.version.deno === "string";
@@ -41766,11 +41819,11 @@ class BunServer extends ServerBase {
41766
41819
  }
41767
41820
  }
41768
41821
 
41769
- class App extends QueryRouter {
41822
+ class App extends QueryRouterServer {
41770
41823
  router;
41771
41824
  server;
41772
41825
  constructor(opts) {
41773
- super();
41826
+ super({ initHandle: false, context: { needSerialize: true, ...opts?.routerContext } });
41774
41827
  const router = this;
41775
41828
  let server = opts?.server;
41776
41829
  if (!server) {
@@ -41782,7 +41835,6 @@ class App extends QueryRouter {
41782
41835
  }
41783
41836
  }
41784
41837
  server.setHandle(router.getHandle(router, opts?.routerHandle, opts?.routerContext));
41785
- router.setContext({ needSerialize: true, ...opts?.routerContext });
41786
41838
  this.router = router;
41787
41839
  this.server = server;
41788
41840
  if (opts?.appId) {
@@ -41795,42 +41847,7 @@ class App extends QueryRouter {
41795
41847
  listen(...args) {
41796
41848
  this.server.listen(...args);
41797
41849
  }
41798
- addRoute(route, opts) {
41799
- super.add(route, opts);
41800
- }
41801
41850
  Route = Route;
41802
- route(...args) {
41803
- const [path, key, opts] = args;
41804
- if (typeof path === "object") {
41805
- return new Route(path.path, path.key, path);
41806
- }
41807
- if (typeof path === "string") {
41808
- if (opts) {
41809
- return new Route(path, key, opts);
41810
- }
41811
- if (key && typeof key === "object") {
41812
- return new Route(path, key?.key || "", key);
41813
- }
41814
- return new Route(path, key);
41815
- }
41816
- return new Route(path, key, opts);
41817
- }
41818
- prompt(...args) {
41819
- const [desc] = args;
41820
- let description = "";
41821
- if (typeof desc === "string") {
41822
- description = desc;
41823
- } else if (typeof desc === "function") {
41824
- description = desc() || "";
41825
- }
41826
- return new Route("", "", { description });
41827
- }
41828
- async call(message, ctx) {
41829
- return await super.call(message, ctx);
41830
- }
41831
- async run(msg, ctx) {
41832
- return await super.run(msg, ctx);
41833
- }
41834
41851
  static handleRequest(req, res) {
41835
41852
  return handleServer(req, res);
41836
41853
  }
@@ -41845,7 +41862,7 @@ class App extends QueryRouter {
41845
41862
  }
41846
41863
  }
41847
41864
 
41848
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router-simple.js
41865
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router-simple.js
41849
41866
  import url3 from "node:url";
41850
41867
  var __create3 = Object.create;
41851
41868
  var __getProtoOf3 = Object.getPrototypeOf;
@@ -52297,7 +52314,7 @@ class Query {
52297
52314
  }
52298
52315
  }
52299
52316
 
52300
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router-browser.js
52317
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router-browser.js
52301
52318
  var __create5 = Object.create;
52302
52319
  var __getProtoOf5 = Object.getPrototypeOf;
52303
52320
  var __defProp5 = Object.defineProperty;
@@ -83457,6 +83474,15 @@ var installDeps = async (opts) => {
83457
83474
  syncSpawn("npm", params, { cwd: appPath, stdio: "inherit", env: process.env, shell: true });
83458
83475
  }
83459
83476
  };
83477
+ var execCommand = (command, options = {}) => {
83478
+ const { cwd } = options;
83479
+ return spawnSync(command, {
83480
+ stdio: "inherit",
83481
+ shell: true,
83482
+ cwd,
83483
+ env: process.env
83484
+ });
83485
+ };
83460
83486
 
83461
83487
  // src/services/init/update-pkgs.ts
83462
83488
  var import_semver = __toESM(require_semver2(), 1);
@@ -83740,7 +83766,7 @@ var simpleRouter = useContextKey("simpleRouter", () => {
83740
83766
  });
83741
83767
  app.createRouteList();
83742
83768
 
83743
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/opencode.js
83769
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/opencode.js
83744
83770
  import { webcrypto as crypto4 } from "node:crypto";
83745
83771
  var __create6 = Object.create;
83746
83772
  var __getProtoOf6 = Object.getPrototypeOf;
@@ -98339,7 +98365,7 @@ var addCallFn = (app2) => {
98339
98365
  path: "call",
98340
98366
  key: "",
98341
98367
  description: "调用",
98342
- middleware: ["auth"],
98368
+ middleware: ["auth-admin"],
98343
98369
  metadata: {
98344
98370
  tags: ["opencode"],
98345
98371
  ...createSkill2({
@@ -98353,7 +98379,7 @@ var addCallFn = (app2) => {
98353
98379
  args: {
98354
98380
  path: tool2.schema.string().describe("应用路径,例如 cnb"),
98355
98381
  key: tool2.schema.string().optional().describe("应用key,例如 list-repos"),
98356
- payload: tool2.schema.object({}).optional().describe("调用参数")
98382
+ payload: tool2.schema.object({}).optional().describe('调用参数, 为对象, 例如 { "query": "javascript" }')
98357
98383
  }
98358
98384
  })
98359
98385
  }
@@ -98381,8 +98407,13 @@ var createRouterAgentPluginFn = (opts) => {
98381
98407
  if (!router.hasRoute("call", "")) {
98382
98408
  addCallFn(router);
98383
98409
  }
98384
- if (!router.hasRoute("auth", "")) {
98385
- router.route({ path: "auth", key: "", id: "auth", description: "认证" }).define(async (ctx) => {}).addTo(router);
98410
+ if (router) {
98411
+ router.route({ path: "auth", key: "", id: "auth", description: "认证" }).define(async (ctx) => {}).addTo(router, {
98412
+ overwrite: false
98413
+ });
98414
+ router.route({ path: "auth-admin", key: "", id: "auth-admin", description: "认证" }).define(async (ctx) => {}).addTo(router, {
98415
+ overwrite: false
98416
+ });
98386
98417
  }
98387
98418
  const _routes = filter2(router.routes, opts?.query || "");
98388
98419
  const routes = _routes.filter((r) => {
@@ -98396,7 +98427,7 @@ var createRouterAgentPluginFn = (opts) => {
98396
98427
  return false;
98397
98428
  });
98398
98429
  const AgentPlugin = async (pluginInput) => {
98399
- useContextKey3("plugin-input", () => pluginInput, true);
98430
+ useContextKey3("plugin-input", () => pluginInput, { isNew: true });
98400
98431
  const hooks = opts?.hooks ? await opts.hooks(pluginInput) : {};
98401
98432
  return {
98402
98433
  ...hooks,
@@ -98531,7 +98562,8 @@ app.route({
98531
98562
  title: "查看客户端 IP 地址",
98532
98563
  summary: "获取当前客户端的 IP 地址信息"
98533
98564
  })
98534
- }
98565
+ },
98566
+ middleware: ["auth-admin"]
98535
98567
  }).define(async (ctx) => {
98536
98568
  const networkInterfaces = os3.networkInterfaces();
98537
98569
  const ipAddresses = [];
@@ -100093,11 +100125,7 @@ app.route({
100093
100125
  message: "客户端重启命令已执行"
100094
100126
  };
100095
100127
  } catch (error111) {
100096
- ctx.status = 500;
100097
- ctx.body = {
100098
- message: "重启客户端失败",
100099
- error: error111.message
100100
- };
100128
+ ctx.throw(500, "重启客户端失败");
100101
100129
  }
100102
100130
  }).addTo(app);
100103
100131
 
@@ -102160,7 +102188,7 @@ var getLiveMdContent = (opts) => {
102160
102188
 
102161
102189
  ### 服务访问地址
102162
102190
  #### nginx 反向代理访问(推荐)
102163
- - OpenClaw: ${openclawUrl}
102191
+ - OpenClaw: ${openclawUrl + "/openclaw"}
102164
102192
  - OpenCode: ${opencodeUrl}
102165
102193
 
102166
102194
  ### 直接访问
@@ -102729,6 +102757,17 @@ app.route({
102729
102757
  }).addTo(app);
102730
102758
 
102731
102759
  // src/routes/cnb-board/index.ts
102760
+ app.route({
102761
+ path: "cnb-board",
102762
+ key: "is-cnb-board",
102763
+ description: "检查是否是 cnb-board 环境",
102764
+ middleware: ["auth-admin"]
102765
+ }).define(async (ctx) => {
102766
+ const isCNB = useKey2("CNB");
102767
+ ctx.body = {
102768
+ isCNB: !!isCNB
102769
+ };
102770
+ }).addTo(app);
102732
102771
  app.route({
102733
102772
  path: "cnb-board",
102734
102773
  key: "live",
@@ -102747,6 +102786,15 @@ app.route({
102747
102786
  list: list4
102748
102787
  };
102749
102788
  }).addTo(app);
102789
+ app.route({
102790
+ path: "cnb-board",
102791
+ key: "exit",
102792
+ description: "cnb的工作环境退出程序",
102793
+ middleware: ["auth-admin"]
102794
+ }).define(async (ctx) => {
102795
+ const cmd = "kill 1";
102796
+ execCommand(cmd);
102797
+ }).addTo(app);
102750
102798
 
102751
102799
  // ../node_modules/.pnpm/lru-cache@11.2.6/node_modules/lru-cache/dist/esm/index.min.js
102752
102800
  var M = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
@@ -103462,7 +103510,7 @@ var import_busboy = __toESM(require_lib2(), 1);
103462
103510
  import path16 from "path";
103463
103511
  import fs19 from "fs";
103464
103512
 
103465
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/src/server/cookie.ts
103513
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/src/server/cookie.ts
103466
103514
  var NullObject2 = /* @__PURE__ */ (() => {
103467
103515
  const C2 = function() {};
103468
103516
  C2.prototype = Object.create(null);
@@ -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
 
@@ -127052,7 +127075,7 @@ var getLiveMdContent = (opts) => {
127052
127075
 
127053
127076
  ### 服务访问地址
127054
127077
  #### nginx 反向代理访问(推荐)
127055
- - OpenClaw: ${openclawUrl}
127078
+ - OpenClaw: ${openclawUrl + "/openclaw"}
127056
127079
  - OpenCode: ${opencodeUrl}
127057
127080
 
127058
127081
  ### 直接访问
@@ -127621,6 +127644,17 @@ app.route({
127621
127644
  }).addTo(app);
127622
127645
 
127623
127646
  // src/routes/cnb-board/index.ts
127647
+ app.route({
127648
+ path: "cnb-board",
127649
+ key: "is-cnb-board",
127650
+ description: "检查是否是 cnb-board 环境",
127651
+ middleware: ["auth-admin"]
127652
+ }).define(async (ctx) => {
127653
+ const isCNB = useKey("CNB");
127654
+ ctx.body = {
127655
+ isCNB: !!isCNB
127656
+ };
127657
+ }).addTo(app);
127624
127658
  app.route({
127625
127659
  path: "cnb-board",
127626
127660
  key: "live",
@@ -127639,6 +127673,15 @@ app.route({
127639
127673
  list: list4
127640
127674
  };
127641
127675
  }).addTo(app);
127676
+ app.route({
127677
+ path: "cnb-board",
127678
+ key: "exit",
127679
+ description: "cnb的工作环境退出程序",
127680
+ middleware: ["auth-admin"]
127681
+ }).define(async (ctx) => {
127682
+ const cmd = "kill 1";
127683
+ execCommand(cmd);
127684
+ }).addTo(app);
127642
127685
 
127643
127686
  // ../node_modules/.pnpm/lru-cache@11.2.6/node_modules/lru-cache/dist/esm/index.min.js
127644
127687
  var M = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
@@ -128738,11 +128781,17 @@ class LiveCode {
128738
128781
  }
128739
128782
  }
128740
128783
 
128784
+ // src/routes/cnb-board/modules/is-cnb.ts
128785
+ var isCnb = () => {
128786
+ const CNB = useKey("CNB");
128787
+ return !!CNB;
128788
+ };
128789
+
128741
128790
  // src/services/proxy/proxy-page-index.ts
128742
128791
  var localProxy = new LocalProxy({});
128743
128792
  localProxy.initFromAssistantConfig(assistantConfig2);
128744
128793
  var isOpenPath = (pathname) => {
128745
- const openPaths = ["/root/home", "/root/cli", "/root/login"];
128794
+ const openPaths = ["/root/home", "/root/cli", "/root/login", "/root/cli-center"];
128746
128795
  for (const openPath of openPaths) {
128747
128796
  if (pathname.startsWith(openPath)) {
128748
128797
  return true;
@@ -128801,11 +128850,22 @@ var authFilter = async (req, res) => {
128801
128850
  };
128802
128851
  var proxyRoute = async (req, res) => {
128803
128852
  const _assistantConfig = assistantConfig2.getCacheAssistantConfig();
128804
- const home = _assistantConfig?.home || "/root/home";
128853
+ let home = _assistantConfig?.home;
128805
128854
  const auth = _assistantConfig?.auth || {};
128806
128855
  let noAdmin = !auth.username;
128807
- const toSetting = () => {
128808
- res.writeHead(302, { Location: `/root/cli-center/` });
128856
+ if (!home) {
128857
+ if (isCnb()) {
128858
+ home = "/root/cli-center/cnb-board";
128859
+ } else {
128860
+ home = "/root/cli-center/";
128861
+ }
128862
+ } else {
128863
+ if (!home.startsWith("/")) {
128864
+ home = "/" + home;
128865
+ }
128866
+ }
128867
+ const toLogin = (redirect) => {
128868
+ res.writeHead(302, { Location: `/root/login/` + (redirect ? `?redirect=${encodeURIComponent(redirect)}` : "") });
128809
128869
  res.end();
128810
128870
  return true;
128811
128871
  };
@@ -128813,10 +128873,11 @@ var proxyRoute = async (req, res) => {
128813
128873
  const pathname = decodeURIComponent(url4.pathname);
128814
128874
  if (pathname === "/") {
128815
128875
  if (noAdmin) {
128816
- return toSetting();
128876
+ return toLogin(home + "/");
128817
128877
  }
128818
- res.writeHead(302, { Location: `${home}/` });
128819
- return res.end();
128878
+ res.writeHead(302, { Location: home });
128879
+ res.end();
128880
+ return;
128820
128881
  }
128821
128882
  if (pathname.startsWith("/favicon.ico")) {
128822
128883
  res.statusCode = 404;
@@ -128877,7 +128938,7 @@ var proxyRoute = async (req, res) => {
128877
128938
  const isOpen = isOpenPath(pathname);
128878
128939
  logger.debug("proxyRoute", { _user, _app, pathname, noAdmin, isOpen });
128879
128940
  if (noAdmin && !isOpen) {
128880
- return toSetting();
128941
+ return toLogin();
128881
128942
  }
128882
128943
  if (_app && urls.length === 3) {
128883
128944
  res.writeHead(302, { Location: `${req.url}/` });
@@ -129013,7 +129074,7 @@ var import_busboy = __toESM(require_lib2(), 1);
129013
129074
  import path20 from "path";
129014
129075
  import fs23 from "fs";
129015
129076
 
129016
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/src/server/cookie.ts
129077
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/src/server/cookie.ts
129017
129078
  var NullObject2 = /* @__PURE__ */ (() => {
129018
129079
  const C2 = function() {};
129019
129080
  C2.prototype = Object.create(null);
package/dist/assistant.js CHANGED
@@ -37099,7 +37099,7 @@ class Query {
37099
37099
  }
37100
37100
  }
37101
37101
 
37102
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router-browser.js
37102
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router-browser.js
37103
37103
  var __create3 = Object.create;
37104
37104
  var __getProtoOf3 = Object.getPrototypeOf;
37105
37105
  var __defProp3 = Object.defineProperty;
@@ -51291,7 +51291,7 @@ var getStringHash = (str) => {
51291
51291
  return crypto2.createHash("md5").update(str).digest("hex");
51292
51292
  };
51293
51293
 
51294
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router.js
51294
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router.js
51295
51295
  import { createRequire as createRequire3 } from "node:module";
51296
51296
  import { webcrypto as crypto3 } from "node:crypto";
51297
51297
  import http from "node:http";
@@ -68195,6 +68195,7 @@ class QueryRouter {
68195
68195
  const maxNextRoute = this.maxNextRoute;
68196
68196
  ctx = ctx || {};
68197
68197
  ctx.currentPath = path7;
68198
+ ctx.currentId = route?.id;
68198
68199
  ctx.currentKey = key;
68199
68200
  ctx.currentRoute = route;
68200
68201
  ctx.index = (ctx.index || 0) + 1;
@@ -68208,7 +68209,7 @@ class QueryRouter {
68208
68209
  ctx.code = 500;
68209
68210
  ctx.message = "Too many nextRoute";
68210
68211
  ctx.body = null;
68211
- return;
68212
+ return ctx;
68212
68213
  }
68213
68214
  if (route && route.middleware && route.middleware.length > 0) {
68214
68215
  const errorMiddleware = [];
@@ -68283,7 +68284,9 @@ class QueryRouter {
68283
68284
  }
68284
68285
  return ctx;
68285
68286
  }
68286
- if (ctx.end) {}
68287
+ if (ctx.end) {
68288
+ return ctx;
68289
+ }
68287
68290
  }
68288
68291
  }
68289
68292
  }
@@ -68477,7 +68480,7 @@ class QueryRouter {
68477
68480
  description: "列出当前应用下的所有的路由信息",
68478
68481
  middleware: opts?.middleware || [],
68479
68482
  run: async (ctx) => {
68480
- const tokenUser = ctx.state.tokenUser;
68483
+ const tokenUser = ctx.state;
68481
68484
  let isUser = !!tokenUser;
68482
68485
  const list4 = this.getList(opts?.filter).filter((item) => {
68483
68486
  if (item.id === "auth" || item.id === "auth-can" || item.id === "check-auth-admin" || item.id === "auth-admin") {
@@ -68507,6 +68510,56 @@ class QueryRouter {
68507
68510
  toJSONSchema = toJSONSchema32;
68508
68511
  fromJSONSchema = fromJSONSchema32;
68509
68512
  }
68513
+
68514
+ class QueryRouterServer2 extends QueryRouter {
68515
+ handle;
68516
+ constructor(opts) {
68517
+ super();
68518
+ const initHandle = opts?.initHandle ?? true;
68519
+ if (initHandle || opts?.handleFn) {
68520
+ this.handle = this.getHandle(this, opts?.handleFn, opts?.context);
68521
+ }
68522
+ this.setContext({ needSerialize: false, ...opts?.context });
68523
+ if (opts?.appId) {
68524
+ this.appId = opts.appId;
68525
+ } else {
68526
+ this.appId = randomId2(16);
68527
+ }
68528
+ }
68529
+ setHandle(wrapperFn, ctx) {
68530
+ this.handle = this.getHandle(this, wrapperFn, ctx);
68531
+ }
68532
+ addRoute(route, opts) {
68533
+ this.add(route, opts);
68534
+ }
68535
+ Route = Route;
68536
+ route(...args2) {
68537
+ const [path7, key, opts] = args2;
68538
+ if (typeof path7 === "object") {
68539
+ return new Route(path7.path, path7.key, path7);
68540
+ }
68541
+ if (typeof path7 === "string") {
68542
+ if (opts) {
68543
+ return new Route(path7, key, opts);
68544
+ }
68545
+ if (key && typeof key === "object") {
68546
+ return new Route(path7, key?.key || "", key);
68547
+ }
68548
+ return new Route(path7, key);
68549
+ }
68550
+ return new Route(path7, key, opts);
68551
+ }
68552
+ prompt(description) {
68553
+ return new Route(undefined, undefined, { description });
68554
+ }
68555
+ async run(msg, ctx) {
68556
+ const handle = this.handle;
68557
+ if (handle) {
68558
+ return handle(msg, ctx);
68559
+ }
68560
+ return super.run(msg, ctx);
68561
+ }
68562
+ }
68510
68563
  var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
68511
68564
  var isBrowser3 = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
68512
68565
  var isDeno2 = typeof Deno !== "undefined" && typeof Deno.version === "object" && typeof Deno.version.deno === "string";
@@ -69374,11 +69427,11 @@ class BunServer extends ServerBase {
69374
69427
  }
69375
69428
  }
69376
69429
 
69377
- class App extends QueryRouter {
69430
+ class App extends QueryRouterServer2 {
69378
69431
  router;
69379
69432
  server;
69380
69433
  constructor(opts) {
69381
- super();
69434
+ super({ initHandle: false, context: { needSerialize: true, ...opts?.routerContext } });
69382
69435
  const router = this;
69383
69436
  let server = opts?.server;
69384
69437
  if (!server) {
@@ -69390,7 +69443,6 @@ class App extends QueryRouter {
69390
69443
  }
69391
69444
  }
69392
69445
  server.setHandle(router.getHandle(router, opts?.routerHandle, opts?.routerContext));
69393
- router.setContext({ needSerialize: true, ...opts?.routerContext });
69394
69446
  this.router = router;
69395
69447
  this.server = server;
69396
69448
  if (opts?.appId) {
@@ -69403,42 +69455,7 @@ class App extends QueryRouter {
69403
69455
  listen(...args2) {
69404
69456
  this.server.listen(...args2);
69405
69457
  }
69406
- addRoute(route, opts) {
69407
- super.add(route, opts);
69408
- }
69409
69458
  Route = Route;
69410
- route(...args2) {
69411
- const [path7, key, opts] = args2;
69412
- if (typeof path7 === "object") {
69413
- return new Route(path7.path, path7.key, path7);
69414
- }
69415
- if (typeof path7 === "string") {
69416
- if (opts) {
69417
- return new Route(path7, key, opts);
69418
- }
69419
- if (key && typeof key === "object") {
69420
- return new Route(path7, key?.key || "", key);
69421
- }
69422
- return new Route(path7, key);
69423
- }
69424
- return new Route(path7, key, opts);
69425
- }
69426
- prompt(...args2) {
69427
- const [desc] = args2;
69428
- let description = "";
69429
- if (typeof desc === "string") {
69430
- description = desc;
69431
- } else if (typeof desc === "function") {
69432
- description = desc() || "";
69433
- }
69434
- return new Route("", "", { description });
69435
- }
69436
- async call(message, ctx) {
69437
- return await super.call(message, ctx);
69438
- }
69439
- async run(msg, ctx) {
69440
- return await super.run(msg, ctx);
69441
- }
69442
69459
  static handleRequest(req, res) {
69443
69460
  return handleServer(req, res);
69444
69461
  }
@@ -69453,7 +69470,7 @@ class App extends QueryRouter {
69453
69470
  }
69454
69471
  }
69455
69472
 
69456
- // ../node_modules/.pnpm/@kevisual+router@0.0.83/node_modules/@kevisual/router/dist/router-simple.js
69473
+ // ../node_modules/.pnpm/@kevisual+router@0.0.84/node_modules/@kevisual/router/dist/router-simple.js
69457
69474
  import url5 from "node:url";
69458
69475
  var __create5 = Object.create;
69459
69476
  var __getProtoOf5 = Object.getPrototypeOf;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "envision 命令行工具",
5
5
  "type": "module",
6
6
  "basename": "/root/cli",