@kevisual/cli 0.1.11 → 0.1.13
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 +151 -103
- package/dist/assistant-server.js +1222 -1553
- package/dist/assistant.js +54 -56
- package/dist/envision.js +50 -59
- package/package.json +5 -5
|
@@ -42679,6 +42679,13 @@ var envKevisualDir = process.env.ASSISTANT_CONFIG_DIR;
|
|
|
42679
42679
|
if (envKevisualDir) {
|
|
42680
42680
|
kevisualDir = envKevisualDir;
|
|
42681
42681
|
logger.debug("使用环境变量 ASSISTANT_CONFIG_DIR 作为 kevisual 目录:", kevisualDir);
|
|
42682
|
+
} else {
|
|
42683
|
+
if (!kevisualDir) {
|
|
42684
|
+
const isCNB = process.env.CNB_GROUP_SLUG;
|
|
42685
|
+
if (isCNB) {
|
|
42686
|
+
kevisualDir = path.join("/workspace/kevisual");
|
|
42687
|
+
}
|
|
42688
|
+
}
|
|
42682
42689
|
}
|
|
42683
42690
|
var HomeConfigDir = path.join(kevisualDir, "assistant-app");
|
|
42684
42691
|
function parseArgs(args) {
|
|
@@ -44002,6 +44009,7 @@ class AssistantConfig {
|
|
|
44002
44009
|
}
|
|
44003
44010
|
getDefaultInitAssistantConfig() {
|
|
44004
44011
|
const id = randomId2();
|
|
44012
|
+
const isCNB = !!useKey("CNB");
|
|
44005
44013
|
return {
|
|
44006
44014
|
app: {
|
|
44007
44015
|
url: "https://kevisual.cn",
|
|
@@ -44009,7 +44017,7 @@ class AssistantConfig {
|
|
|
44009
44017
|
},
|
|
44010
44018
|
description: "助手配置文件",
|
|
44011
44019
|
docs: "https://kevisual.cn/root/cli/docs/",
|
|
44012
|
-
home: "/root/home",
|
|
44020
|
+
home: isCNB ? "/root/cli-center" : "/root/home",
|
|
44013
44021
|
proxy: [],
|
|
44014
44022
|
share: {
|
|
44015
44023
|
enabled: true,
|
|
@@ -51956,7 +51964,7 @@ class RemoteApp {
|
|
|
51956
51964
|
this.emitter.emit("message", data);
|
|
51957
51965
|
}
|
|
51958
51966
|
onError(error49) {
|
|
51959
|
-
console.error(
|
|
51967
|
+
console.error(`[remote-app] 远程应用错误: ${this.id}`, error49);
|
|
51960
51968
|
this.isError = true;
|
|
51961
51969
|
this.emitter.emit("error", error49);
|
|
51962
51970
|
}
|
|
@@ -52026,7 +52034,7 @@ class RemoteApp {
|
|
|
52026
52034
|
}
|
|
52027
52035
|
}
|
|
52028
52036
|
|
|
52029
|
-
// ../node_modules/.pnpm/@kevisual+query@0.0.
|
|
52037
|
+
// ../node_modules/.pnpm/@kevisual+query@0.0.52/node_modules/@kevisual/query/dist/query-browser.js
|
|
52030
52038
|
var isTextForContentType = (contentType) => {
|
|
52031
52039
|
if (!contentType)
|
|
52032
52040
|
return false;
|
|
@@ -66321,7 +66329,7 @@ function filter(data, query) {
|
|
|
66321
66329
|
return executor.execute(ast, data);
|
|
66322
66330
|
}
|
|
66323
66331
|
|
|
66324
|
-
// ../node_modules/.pnpm/@kevisual+api@0.0.
|
|
66332
|
+
// ../node_modules/.pnpm/@kevisual+api@0.0.60_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-proxy/router-api-proxy.ts
|
|
66325
66333
|
var initApi = async (opts) => {
|
|
66326
66334
|
const router = opts?.router;
|
|
66327
66335
|
const item = opts?.item;
|
|
@@ -80962,7 +80970,7 @@ class AssistantApp extends Manager2 {
|
|
|
80962
80970
|
app: this.mainApp,
|
|
80963
80971
|
autoReconnect: true,
|
|
80964
80972
|
reconnectDelay: 5000,
|
|
80965
|
-
maxReconnectAttempts:
|
|
80973
|
+
maxReconnectAttempts: 50,
|
|
80966
80974
|
enableBackoff: true
|
|
80967
80975
|
});
|
|
80968
80976
|
remoteApp.isConnect();
|
|
@@ -80982,7 +80990,7 @@ class AssistantApp extends Manager2 {
|
|
|
80982
80990
|
logger.info("[remote-app] 远程连接已关闭,自动重连机制正在处理...");
|
|
80983
80991
|
});
|
|
80984
80992
|
remoteApp.on("maxReconnectAttemptsReached", () => {
|
|
80985
|
-
logger.error("远程应用重连达到最大次数,停止重连");
|
|
80993
|
+
logger.error("[remote-app] 远程应用重连达到最大次数,停止重连");
|
|
80986
80994
|
});
|
|
80987
80995
|
this.remoteApp = remoteApp;
|
|
80988
80996
|
} else {
|
|
@@ -81148,7 +81156,7 @@ var checkLocalUser = async (opts) => {
|
|
|
81148
81156
|
}
|
|
81149
81157
|
}
|
|
81150
81158
|
};
|
|
81151
|
-
// ../node_modules/.pnpm/@kevisual+query@0.0.
|
|
81159
|
+
// ../node_modules/.pnpm/@kevisual+query@0.0.52/node_modules/@kevisual/query/dist/query.js
|
|
81152
81160
|
var isTextForContentType2 = (contentType) => {
|
|
81153
81161
|
if (!contentType)
|
|
81154
81162
|
return false;
|
|
@@ -81436,7 +81444,7 @@ class Query2 {
|
|
|
81436
81444
|
}
|
|
81437
81445
|
}
|
|
81438
81446
|
|
|
81439
|
-
// ../node_modules/.pnpm/@kevisual+api@0.0.
|
|
81447
|
+
// ../node_modules/.pnpm/@kevisual+api@0.0.60_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/dist/query-login-node.js
|
|
81440
81448
|
import { homedir as homedir2 } from "node:os";
|
|
81441
81449
|
import { join, dirname } from "node:path";
|
|
81442
81450
|
import fs13 from "node:fs";
|
|
@@ -81752,6 +81760,15 @@ class BaseQuery {
|
|
|
81752
81760
|
return this.query.get(data, options);
|
|
81753
81761
|
}
|
|
81754
81762
|
}
|
|
81763
|
+
var defaultCacheData = {
|
|
81764
|
+
loginUsers: [],
|
|
81765
|
+
user: undefined,
|
|
81766
|
+
id: undefined,
|
|
81767
|
+
accessToken: undefined,
|
|
81768
|
+
refreshToken: undefined,
|
|
81769
|
+
accessTokenExpiresIn: undefined,
|
|
81770
|
+
createdAt: undefined
|
|
81771
|
+
};
|
|
81755
81772
|
|
|
81756
81773
|
class LoginCacheStore {
|
|
81757
81774
|
cache;
|
|
@@ -81762,13 +81779,7 @@ class LoginCacheStore {
|
|
|
81762
81779
|
throw new Error("cache is required");
|
|
81763
81780
|
}
|
|
81764
81781
|
this.cache = opts.cache;
|
|
81765
|
-
this.cacheData = {
|
|
81766
|
-
loginUsers: [],
|
|
81767
|
-
user: undefined,
|
|
81768
|
-
id: undefined,
|
|
81769
|
-
accessToken: undefined,
|
|
81770
|
-
refreshToken: undefined
|
|
81771
|
-
};
|
|
81782
|
+
this.cacheData = { ...defaultCacheData };
|
|
81772
81783
|
this.name = opts.name;
|
|
81773
81784
|
}
|
|
81774
81785
|
async setValue(value) {
|
|
@@ -81778,27 +81789,13 @@ class LoginCacheStore {
|
|
|
81778
81789
|
}
|
|
81779
81790
|
async delValue() {
|
|
81780
81791
|
await this.cache.del();
|
|
81781
|
-
this.cacheData = {
|
|
81782
|
-
loginUsers: [],
|
|
81783
|
-
user: undefined,
|
|
81784
|
-
id: undefined,
|
|
81785
|
-
accessToken: undefined,
|
|
81786
|
-
refreshToken: undefined
|
|
81787
|
-
};
|
|
81792
|
+
this.cacheData = { ...defaultCacheData };
|
|
81788
81793
|
}
|
|
81789
81794
|
getValue() {
|
|
81790
81795
|
return this.cache.get(this.name);
|
|
81791
81796
|
}
|
|
81792
81797
|
async init() {
|
|
81793
|
-
const defaultData = {
|
|
81794
|
-
loginUsers: [],
|
|
81795
|
-
user: undefined,
|
|
81796
|
-
id: undefined,
|
|
81797
|
-
accessToken: undefined,
|
|
81798
|
-
refreshToken: undefined,
|
|
81799
|
-
accessTokenExpiresIn: undefined,
|
|
81800
|
-
createdAt: undefined
|
|
81801
|
-
};
|
|
81798
|
+
const defaultData = { ...this.cacheData };
|
|
81802
81799
|
if (this.cache.init) {
|
|
81803
81800
|
try {
|
|
81804
81801
|
const cacheData = await this.cache.init();
|
|
@@ -81811,18 +81808,18 @@ class LoginCacheStore {
|
|
|
81811
81808
|
}
|
|
81812
81809
|
return this.cacheData;
|
|
81813
81810
|
}
|
|
81814
|
-
async setLoginUser(
|
|
81815
|
-
const has = this.cacheData.loginUsers.find((u) => u.id ===
|
|
81811
|
+
async setLoginUser(loginUser) {
|
|
81812
|
+
const has = this.cacheData.loginUsers.find((u) => u.id === loginUser.id);
|
|
81816
81813
|
if (has) {
|
|
81817
|
-
this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((u) => u?.id && u.id !==
|
|
81818
|
-
}
|
|
81819
|
-
this.cacheData.loginUsers.push(
|
|
81820
|
-
this.cacheData.user =
|
|
81821
|
-
this.cacheData.id =
|
|
81822
|
-
this.cacheData.accessToken =
|
|
81823
|
-
this.cacheData.refreshToken =
|
|
81824
|
-
this.cacheData.accessTokenExpiresIn =
|
|
81825
|
-
this.cacheData.createdAt =
|
|
81814
|
+
this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((u) => u?.id && u.id !== loginUser.id);
|
|
81815
|
+
}
|
|
81816
|
+
this.cacheData.loginUsers.push(loginUser);
|
|
81817
|
+
this.cacheData.user = loginUser.user;
|
|
81818
|
+
this.cacheData.id = loginUser.id;
|
|
81819
|
+
this.cacheData.accessToken = loginUser.accessToken;
|
|
81820
|
+
this.cacheData.refreshToken = loginUser.refreshToken;
|
|
81821
|
+
this.cacheData.accessTokenExpiresIn = loginUser.accessTokenExpiresIn;
|
|
81822
|
+
this.cacheData.createdAt = loginUser.createdAt;
|
|
81826
81823
|
await this.setValue(this.cacheData);
|
|
81827
81824
|
}
|
|
81828
81825
|
getCurrentUser() {
|
|
@@ -81858,22 +81855,22 @@ class LoginCacheStore {
|
|
|
81858
81855
|
if (has) {
|
|
81859
81856
|
this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((u) => u?.id && u.id !== user.id);
|
|
81860
81857
|
}
|
|
81861
|
-
this.cacheData.
|
|
81862
|
-
this.cacheData.
|
|
81863
|
-
|
|
81864
|
-
|
|
81865
|
-
|
|
81866
|
-
|
|
81858
|
+
const hasOther = this.cacheData.loginUsers.length > 0;
|
|
81859
|
+
const current = this.cacheData.loginUsers[this.cacheData.loginUsers.length - 1];
|
|
81860
|
+
if (hasOther && current) {
|
|
81861
|
+
this.cacheData.user = current.user;
|
|
81862
|
+
this.cacheData.id = current.id;
|
|
81863
|
+
this.cacheData.accessToken = current.accessToken;
|
|
81864
|
+
this.cacheData.refreshToken = current.refreshToken;
|
|
81865
|
+
this.cacheData.accessTokenExpiresIn = current.accessTokenExpiresIn;
|
|
81866
|
+
this.cacheData.createdAt = current.createdAt;
|
|
81867
|
+
} else {
|
|
81868
|
+
this.cacheData = { ...defaultCacheData };
|
|
81869
|
+
}
|
|
81867
81870
|
await this.setValue(this.cacheData);
|
|
81868
81871
|
}
|
|
81869
81872
|
async clearAll() {
|
|
81870
|
-
this.cacheData
|
|
81871
|
-
this.cacheData.user = undefined;
|
|
81872
|
-
this.cacheData.id = undefined;
|
|
81873
|
-
this.cacheData.accessToken = undefined;
|
|
81874
|
-
this.cacheData.refreshToken = undefined;
|
|
81875
|
-
this.cacheData.accessTokenExpiresIn = undefined;
|
|
81876
|
-
this.cacheData.createdAt = undefined;
|
|
81873
|
+
this.cacheData = { ...defaultCacheData };
|
|
81877
81874
|
await this.setValue(this.cacheData);
|
|
81878
81875
|
}
|
|
81879
81876
|
}
|
|
@@ -82461,7 +82458,7 @@ class QueryLogin extends BaseQuery {
|
|
|
82461
82458
|
async queryRefreshToken(opts) {
|
|
82462
82459
|
const refreshToken = opts?.refreshToken;
|
|
82463
82460
|
let accessToken = opts?.accessToken;
|
|
82464
|
-
const _refreshToken = refreshToken
|
|
82461
|
+
const _refreshToken = refreshToken ?? await this.cacheStore.getRefreshToken();
|
|
82465
82462
|
let data = {};
|
|
82466
82463
|
if (accessToken) {
|
|
82467
82464
|
data.accessToken = accessToken;
|
|
@@ -82572,6 +82569,7 @@ class QueryLogin extends BaseQuery {
|
|
|
82572
82569
|
}
|
|
82573
82570
|
const isExpired = await this.cacheStore.getIsExpired();
|
|
82574
82571
|
if (isExpired) {
|
|
82572
|
+
console.log("token过期,正在刷新token", this.cacheStore.cacheData);
|
|
82575
82573
|
const res = await this.refreshLoginUser();
|
|
82576
82574
|
if (res.code === 200) {
|
|
82577
82575
|
return res.data?.accessToken || null;
|
|
@@ -100309,7 +100307,7 @@ app.route({
|
|
|
100309
100307
|
}).addTo(app, {
|
|
100310
100308
|
overwrite: false
|
|
100311
100309
|
});
|
|
100312
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100310
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/core/serverSentEvents.gen.js
|
|
100313
100311
|
var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url4, ...options }) => {
|
|
100314
100312
|
let lastEventId;
|
|
100315
100313
|
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
@@ -100418,7 +100416,7 @@ var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseVa
|
|
|
100418
100416
|
return { stream: stream2 };
|
|
100419
100417
|
};
|
|
100420
100418
|
|
|
100421
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100419
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/core/auth.gen.js
|
|
100422
100420
|
var getAuthToken = async (auth, callback) => {
|
|
100423
100421
|
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
100424
100422
|
if (!token) {
|
|
@@ -100433,12 +100431,12 @@ var getAuthToken = async (auth, callback) => {
|
|
|
100433
100431
|
return token;
|
|
100434
100432
|
};
|
|
100435
100433
|
|
|
100436
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100434
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/core/bodySerializer.gen.js
|
|
100437
100435
|
var jsonBodySerializer = {
|
|
100438
100436
|
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
100439
100437
|
};
|
|
100440
100438
|
|
|
100441
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100439
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/core/pathSerializer.gen.js
|
|
100442
100440
|
var separatorArrayExplode = (style) => {
|
|
100443
100441
|
switch (style) {
|
|
100444
100442
|
case "label":
|
|
@@ -100541,7 +100539,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
|
|
|
100541
100539
|
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
100542
100540
|
};
|
|
100543
100541
|
|
|
100544
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100542
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
|
|
100545
100543
|
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
100546
100544
|
var defaultPathSerializer = ({ path: path14, url: _url5 }) => {
|
|
100547
100545
|
let url4 = _url5;
|
|
@@ -100609,7 +100607,7 @@ var getUrl = ({ baseUrl, path: path14, query: query2, querySerializer, url: _url
|
|
|
100609
100607
|
return url4;
|
|
100610
100608
|
};
|
|
100611
100609
|
|
|
100612
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100610
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/client/utils.gen.js
|
|
100613
100611
|
var createQuerySerializer = ({ allowReserved, array: array6, object: object5 } = {}) => {
|
|
100614
100612
|
const querySerializer = (queryParams) => {
|
|
100615
100613
|
const search = [];
|
|
@@ -100817,7 +100815,7 @@ var createConfig = (override = {}) => ({
|
|
|
100817
100815
|
...override
|
|
100818
100816
|
});
|
|
100819
100817
|
|
|
100820
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100818
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/client/client.gen.js
|
|
100821
100819
|
var createClient = (config7 = {}) => {
|
|
100822
100820
|
let _config = mergeConfigs(createConfig(), config7);
|
|
100823
100821
|
const getConfig2 = () => ({ ..._config });
|
|
@@ -100964,7 +100962,7 @@ var createClient = (config7 = {}) => {
|
|
|
100964
100962
|
trace: makeMethod("TRACE")
|
|
100965
100963
|
};
|
|
100966
100964
|
};
|
|
100967
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100965
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/core/params.gen.js
|
|
100968
100966
|
var extraPrefixesMap = {
|
|
100969
100967
|
$body_: "body",
|
|
100970
100968
|
$headers_: "headers",
|
|
@@ -100972,12 +100970,12 @@ var extraPrefixesMap = {
|
|
|
100972
100970
|
$query_: "query"
|
|
100973
100971
|
};
|
|
100974
100972
|
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
100975
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100973
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/client.gen.js
|
|
100976
100974
|
var client = createClient(createConfig({
|
|
100977
100975
|
baseUrl: "http://localhost:4096"
|
|
100978
100976
|
}));
|
|
100979
100977
|
|
|
100980
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
100978
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/gen/sdk.gen.js
|
|
100981
100979
|
class _HeyApiClient {
|
|
100982
100980
|
_client = client;
|
|
100983
100981
|
constructor(args2) {
|
|
@@ -101647,7 +101645,7 @@ class OpencodeClient extends _HeyApiClient {
|
|
|
101647
101645
|
event = new Event({ client: this._client });
|
|
101648
101646
|
}
|
|
101649
101647
|
|
|
101650
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
101648
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/client.js
|
|
101651
101649
|
function createOpencodeClient(config7) {
|
|
101652
101650
|
if (!config7?.fetch) {
|
|
101653
101651
|
const customFetch = (req) => {
|
|
@@ -101668,7 +101666,7 @@ function createOpencodeClient(config7) {
|
|
|
101668
101666
|
const client2 = createClient(config7);
|
|
101669
101667
|
return new OpencodeClient({ client: client2 });
|
|
101670
101668
|
}
|
|
101671
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
101669
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/server.js
|
|
101672
101670
|
import { spawn as spawn3 } from "node:child_process";
|
|
101673
101671
|
async function createOpencodeServer(options) {
|
|
101674
101672
|
options = Object.assign({
|
|
@@ -101737,7 +101735,7 @@ Server output: ${output}`;
|
|
|
101737
101735
|
}
|
|
101738
101736
|
};
|
|
101739
101737
|
}
|
|
101740
|
-
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.
|
|
101738
|
+
// ../node_modules/.pnpm/@opencode-ai+sdk@1.2.14/node_modules/@opencode-ai/sdk/dist/index.js
|
|
101741
101739
|
async function createOpencode(options) {
|
|
101742
101740
|
const server2 = await createOpencodeServer({
|
|
101743
101741
|
...options
|
|
@@ -102223,47 +102221,56 @@ var getLiveMdContent = (opts) => {
|
|
|
102223
102221
|
`;
|
|
102224
102222
|
const labels = [
|
|
102225
102223
|
{
|
|
102226
|
-
|
|
102224
|
+
key: "vscodeWebUrl",
|
|
102225
|
+
title: "VSCode Web 地址",
|
|
102227
102226
|
value: vscodeWebUrl,
|
|
102228
102227
|
description: "VSCode Web 的访问地址"
|
|
102229
102228
|
},
|
|
102230
102229
|
{
|
|
102231
|
-
|
|
102230
|
+
key: "kevisualUrl",
|
|
102231
|
+
title: "Kevisual 地址",
|
|
102232
102232
|
value: kevisualUrl,
|
|
102233
102233
|
description: "Kevisual 的访问地址,可以通过该地址访问 Kevisual 服务"
|
|
102234
102234
|
},
|
|
102235
102235
|
{
|
|
102236
|
-
|
|
102236
|
+
key: "cnbTempToken",
|
|
102237
|
+
title: "CNB Token",
|
|
102237
102238
|
value: token,
|
|
102238
102239
|
description: "CNB 临时 Token,保持和环境变量 CNB_TOKEN 一致"
|
|
102239
102240
|
},
|
|
102240
102241
|
{
|
|
102241
|
-
|
|
102242
|
+
key: "openWebUrl",
|
|
102243
|
+
title: "OpenWebUI 地址",
|
|
102242
102244
|
value: openWebUrl,
|
|
102243
102245
|
description: "OpenWebUI 的访问地址,可以通过该地址访问 OpenWebUI 服务"
|
|
102244
102246
|
},
|
|
102245
102247
|
{
|
|
102246
|
-
|
|
102247
|
-
|
|
102248
|
+
key: "openclawUrl",
|
|
102249
|
+
title: "OpenClaw 地址",
|
|
102250
|
+
value: openclawUrl + "/openclaw",
|
|
102248
102251
|
description: "OpenClaw 的访问地址,可以通过该地址访问 OpenClaw 服务"
|
|
102249
102252
|
},
|
|
102250
102253
|
{
|
|
102251
|
-
|
|
102254
|
+
key: "openclawUrlSecret",
|
|
102255
|
+
title: "OpenClaw 访问地址(含 Token)",
|
|
102252
102256
|
value: openclawUrlSecret,
|
|
102253
102257
|
description: "OpenClaw 的访问地址,包含 token 参数,可以直接访问 OpenClaw 服务"
|
|
102254
102258
|
},
|
|
102255
102259
|
{
|
|
102256
|
-
|
|
102260
|
+
key: "opencodeUrl",
|
|
102261
|
+
title: "OpenCode 地址",
|
|
102257
102262
|
value: opencodeUrl,
|
|
102258
102263
|
description: "OpenCode 的访问地址,可以通过该地址访问 OpenCode 服务"
|
|
102259
102264
|
},
|
|
102260
102265
|
{
|
|
102261
|
-
|
|
102266
|
+
key: "opencodeUrlSecret",
|
|
102267
|
+
title: "OpenCode 访问地址(含 Token)",
|
|
102262
102268
|
value: opencodeUrlSecret,
|
|
102263
102269
|
description: "OpenCode 的访问地址,包含 token 参数,可以直接访问 OpenCode 服务"
|
|
102264
102270
|
},
|
|
102265
102271
|
{
|
|
102266
|
-
|
|
102272
|
+
key: "docs",
|
|
102273
|
+
title: "配置说明文档",
|
|
102267
102274
|
value: TEMPLATE,
|
|
102268
102275
|
description: "开发环境模式配置说明文档"
|
|
102269
102276
|
}
|
|
@@ -102312,13 +102319,19 @@ var createOSInfo = (more = false) => {
|
|
|
102312
102319
|
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
102313
102320
|
return (bytes / Math.pow(1024, i)).toFixed(2) + " " + sizes[i];
|
|
102314
102321
|
};
|
|
102315
|
-
const bootTime = os7.uptime();
|
|
102316
102322
|
const formatUptime = (seconds) => {
|
|
102317
102323
|
const days = Math.floor(seconds / 86400);
|
|
102318
102324
|
const hours = Math.floor(seconds % 86400 / 3600);
|
|
102319
102325
|
const minutes = Math.floor(seconds % 3600 / 60);
|
|
102320
102326
|
const secs = Math.floor(seconds % 60);
|
|
102321
|
-
|
|
102327
|
+
let uptimeStr = "";
|
|
102328
|
+
if (days > 0)
|
|
102329
|
+
uptimeStr += `${days}天 `;
|
|
102330
|
+
if (hours > 0)
|
|
102331
|
+
uptimeStr += `${hours}小时 `;
|
|
102332
|
+
if (minutes > 0)
|
|
102333
|
+
uptimeStr += `${minutes}分钟 `;
|
|
102334
|
+
return `${uptimeStr}${secs}秒`;
|
|
102322
102335
|
};
|
|
102323
102336
|
let diskUsage = "";
|
|
102324
102337
|
try {
|
|
@@ -102328,37 +102341,40 @@ var createOSInfo = (more = false) => {
|
|
|
102328
102341
|
diskUsage = "获取失败";
|
|
102329
102342
|
}
|
|
102330
102343
|
labels.push({
|
|
102331
|
-
|
|
102344
|
+
key: "cpuUsage",
|
|
102345
|
+
title: "CPU 使用率",
|
|
102332
102346
|
value: `${cpuUsage}%`,
|
|
102333
102347
|
description: "CPU 使用率"
|
|
102334
102348
|
}, {
|
|
102335
|
-
|
|
102349
|
+
key: "cpuCores",
|
|
102350
|
+
title: "CPU 核心数",
|
|
102336
102351
|
value: `${cpus.length}`,
|
|
102337
102352
|
description: "CPU 核心数"
|
|
102338
102353
|
}, {
|
|
102339
|
-
|
|
102354
|
+
key: "memoryUsed",
|
|
102355
|
+
title: "已使用内存",
|
|
102340
102356
|
value: formatBytes(memUsed),
|
|
102341
102357
|
description: "已使用内存"
|
|
102342
102358
|
}, {
|
|
102343
|
-
|
|
102359
|
+
key: "memoryTotal",
|
|
102360
|
+
title: "总内存",
|
|
102344
102361
|
value: formatBytes(memTotal),
|
|
102345
102362
|
description: "总内存"
|
|
102346
102363
|
}, {
|
|
102347
|
-
|
|
102364
|
+
key: "memoryFree",
|
|
102365
|
+
title: "空闲内存",
|
|
102348
102366
|
value: formatBytes(memFree),
|
|
102349
102367
|
description: "空闲内存"
|
|
102350
102368
|
}, {
|
|
102351
|
-
|
|
102369
|
+
key: "memoryUsage",
|
|
102370
|
+
title: "内存使用率",
|
|
102352
102371
|
value: `${memUsage}%`,
|
|
102353
102372
|
description: "内存使用率"
|
|
102354
102373
|
}, {
|
|
102355
|
-
|
|
102374
|
+
key: "diskUsage",
|
|
102375
|
+
title: "磁盘使用",
|
|
102356
102376
|
value: diskUsage,
|
|
102357
102377
|
description: "当前目录磁盘使用情况"
|
|
102358
|
-
}, {
|
|
102359
|
-
title: "uptime",
|
|
102360
|
-
value: formatUptime(bootTime),
|
|
102361
|
-
description: "系统运行时间"
|
|
102362
102378
|
});
|
|
102363
102379
|
if (startTimer) {
|
|
102364
102380
|
const buildStartTime = import_dayjs.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
|
|
@@ -102367,11 +102383,13 @@ var createOSInfo = (more = false) => {
|
|
|
102367
102383
|
const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
|
|
102368
102384
|
const maxRunTime = useKey2("CNB_PIPELINE_MAX_RUN_TIME") || 0;
|
|
102369
102385
|
labels.push({
|
|
102370
|
-
|
|
102386
|
+
key: "buildStartTime",
|
|
102387
|
+
title: "构建启动时间",
|
|
102371
102388
|
value: buildStartTime,
|
|
102372
102389
|
description: "构建启动时间"
|
|
102373
102390
|
}, {
|
|
102374
|
-
|
|
102391
|
+
key: "buildUptime",
|
|
102392
|
+
title: "构建已运行时间",
|
|
102375
102393
|
value: buildUptimeStr,
|
|
102376
102394
|
description: "构建已运行时间"
|
|
102377
102395
|
});
|
|
@@ -102384,11 +102402,13 @@ var createOSInfo = (more = false) => {
|
|
|
102384
102402
|
}
|
|
102385
102403
|
const timeTo4Str = `[距离晚上4点重启时间: ${formatUptime(Math.floor(timeTo4 / 1000))}]`;
|
|
102386
102404
|
labels.push({
|
|
102387
|
-
|
|
102405
|
+
key: "buildMaxRunTime",
|
|
102406
|
+
title: "最大运行时间",
|
|
102388
102407
|
value: formatUptime(Math.floor(maxRunTime / 1000)),
|
|
102389
102408
|
description: "构建最大运行时间(限制时间)"
|
|
102390
102409
|
});
|
|
102391
102410
|
labels.unshift({
|
|
102411
|
+
key: "remainingTime",
|
|
102392
102412
|
title: "剩余时间",
|
|
102393
102413
|
value: formatUptime(Math.floor((maxRunTime - buildUptime) / 1000)) + " " + timeTo4Str,
|
|
102394
102414
|
description: "构建剩余时间"
|
|
@@ -102398,31 +102418,38 @@ var createOSInfo = (more = false) => {
|
|
|
102398
102418
|
if (more) {
|
|
102399
102419
|
const loadavg = os7.loadavg();
|
|
102400
102420
|
labels.push({
|
|
102401
|
-
|
|
102421
|
+
key: "hostname",
|
|
102422
|
+
title: "主机名",
|
|
102402
102423
|
value: os7.hostname(),
|
|
102403
102424
|
description: "主机名"
|
|
102404
102425
|
}, {
|
|
102405
|
-
|
|
102426
|
+
key: "platform",
|
|
102427
|
+
title: "运行平台",
|
|
102406
102428
|
value: os7.platform(),
|
|
102407
102429
|
description: "运行平台"
|
|
102408
102430
|
}, {
|
|
102409
|
-
|
|
102431
|
+
key: "arch",
|
|
102432
|
+
title: "系统架构",
|
|
102410
102433
|
value: os7.arch(),
|
|
102411
102434
|
description: "系统架构"
|
|
102412
102435
|
}, {
|
|
102413
|
-
|
|
102436
|
+
key: "osType",
|
|
102437
|
+
title: "操作系统类型",
|
|
102414
102438
|
value: os7.type(),
|
|
102415
102439
|
description: "操作系统类型"
|
|
102416
102440
|
}, {
|
|
102417
|
-
|
|
102441
|
+
key: "loadavg1m",
|
|
102442
|
+
title: "系统负载 (1分钟)",
|
|
102418
102443
|
value: loadavg[0].toFixed(2),
|
|
102419
102444
|
description: "系统负载 (1分钟)"
|
|
102420
102445
|
}, {
|
|
102421
|
-
|
|
102446
|
+
key: "loadavg5m",
|
|
102447
|
+
title: "系统负载 (5分钟)",
|
|
102422
102448
|
value: loadavg[1].toFixed(2),
|
|
102423
102449
|
description: "系统负载 (5分钟)"
|
|
102424
102450
|
}, {
|
|
102425
|
-
|
|
102451
|
+
key: "loadavg15m",
|
|
102452
|
+
title: "系统负载 (15分钟)",
|
|
102426
102453
|
value: loadavg[2].toFixed(2),
|
|
102427
102454
|
description: "系统负载 (15分钟)"
|
|
102428
102455
|
});
|
|
@@ -102431,6 +102458,17 @@ var createOSInfo = (more = false) => {
|
|
|
102431
102458
|
};
|
|
102432
102459
|
|
|
102433
102460
|
// src/routes/cnb-board/cnb-dev-env.ts
|
|
102461
|
+
var notCNBCheck = (ctx) => {
|
|
102462
|
+
const isCNB = useKey2("CNB");
|
|
102463
|
+
if (!isCNB) {
|
|
102464
|
+
ctx.body = {
|
|
102465
|
+
title: "非 cnb-board 环境",
|
|
102466
|
+
list: []
|
|
102467
|
+
};
|
|
102468
|
+
return true;
|
|
102469
|
+
}
|
|
102470
|
+
return false;
|
|
102471
|
+
};
|
|
102434
102472
|
app.route({
|
|
102435
102473
|
path: "cnb_board",
|
|
102436
102474
|
key: "live",
|
|
@@ -102443,6 +102481,8 @@ app.route({
|
|
|
102443
102481
|
}
|
|
102444
102482
|
}).define(async (ctx) => {
|
|
102445
102483
|
const more = ctx.query?.more ?? false;
|
|
102484
|
+
if (notCNBCheck(ctx))
|
|
102485
|
+
return;
|
|
102446
102486
|
const list4 = getLiveMdContent({ more });
|
|
102447
102487
|
ctx.body = {
|
|
102448
102488
|
title: "开发环境模式配置",
|
|
@@ -102458,7 +102498,9 @@ app.route({
|
|
|
102458
102498
|
const repoSlug = useKey2("CNB_REPO_SLUG") || "";
|
|
102459
102499
|
const repoName = useKey2("CNB_REPO_NAME") || "";
|
|
102460
102500
|
const repoId = useKey2("CNB_REPO_ID") || "";
|
|
102461
|
-
const repoUrlHttps = useKey2("
|
|
102501
|
+
const repoUrlHttps = useKey2("CNB_REPO_UR if (notCNBCheck(ctx)) return;L_HTTPS") || "";
|
|
102502
|
+
if (notCNBCheck(ctx))
|
|
102503
|
+
return;
|
|
102462
102504
|
const repoNameFromSlug = repoSlug.split("/").pop() || "";
|
|
102463
102505
|
const labels = [
|
|
102464
102506
|
{
|
|
@@ -102503,6 +102545,8 @@ app.route({
|
|
|
102503
102545
|
description: "获取cnb-board live的构建信息",
|
|
102504
102546
|
middleware: ["auth-admin"]
|
|
102505
102547
|
}).define(async (ctx) => {
|
|
102548
|
+
if (notCNBCheck(ctx))
|
|
102549
|
+
return;
|
|
102506
102550
|
const labels = [
|
|
102507
102551
|
{
|
|
102508
102552
|
title: "CNB_BUILD_ID",
|
|
@@ -102744,6 +102788,8 @@ app.route({
|
|
|
102744
102788
|
description: "获取cnb-board live的NPC信息",
|
|
102745
102789
|
middleware: ["auth-admin"]
|
|
102746
102790
|
}).define(async (ctx) => {
|
|
102791
|
+
if (notCNBCheck(ctx))
|
|
102792
|
+
return;
|
|
102747
102793
|
const labels = [
|
|
102748
102794
|
{
|
|
102749
102795
|
title: "CNB_NPC_SLUG",
|
|
@@ -102787,6 +102833,8 @@ app.route({
|
|
|
102787
102833
|
description: "获取cnb-board live的评论信息",
|
|
102788
102834
|
middleware: ["auth-admin"]
|
|
102789
102835
|
}).define(async (ctx) => {
|
|
102836
|
+
if (notCNBCheck(ctx))
|
|
102837
|
+
return;
|
|
102790
102838
|
const labels = [
|
|
102791
102839
|
{
|
|
102792
102840
|
title: "CNB_COMMENT_ID",
|