@kevisual/cnb 0.0.72 → 0.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/app.ts +2 -2
- package/dist/cli.js +49 -9
- package/dist/npc.js +49 -9
- package/dist/opencode.js +52 -12
- package/dist/routes.d.ts +6 -0
- package/dist/routes.js +49 -9
- package/package.json +4 -4
- package/src/user/index.ts +19 -1
package/agent/app.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryRouterServer as App } from '@kevisual/router'
|
|
2
|
-
import {
|
|
2
|
+
import { useTrimKey, useContextKey } from '@kevisual/context'
|
|
3
3
|
import { useKey } from '@kevisual/use-config'
|
|
4
4
|
import { CNB } from '../src/index.ts';
|
|
5
5
|
import { CNBManager } from './modules/cnb-manager.ts'
|
|
@@ -10,7 +10,7 @@ export const cnbManager = new CNBManager()
|
|
|
10
10
|
// CNB_TOKEN 是流水线自己就有的变量,但是权限比较小
|
|
11
11
|
const token = useKey('CNB_API_KEY') as string || useKey('CNB_TOKEN') as string
|
|
12
12
|
// cookie 变量是可选的
|
|
13
|
-
const cookie = useKey('CNB_COOKIE') as string
|
|
13
|
+
const cookie = useTrimKey(useKey('CNB_COOKIE') as string) as string
|
|
14
14
|
const aiRepo = useKey('CNB_AI_REPO') as string || useKey('CNB_REPO_SLUG_LOWERCASE') as string
|
|
15
15
|
try {
|
|
16
16
|
cnbManager.addCNB({
|
package/dist/cli.js
CHANGED
|
@@ -38346,7 +38346,7 @@ var import_sender = __toESM2(require_sender(), 1);
|
|
|
38346
38346
|
var import_websocket = __toESM2(require_websocket(), 1);
|
|
38347
38347
|
var import_websocket_server = __toESM2(require_websocket_server(), 1);
|
|
38348
38348
|
|
|
38349
|
-
// ../../node_modules/.pnpm/@kevisual+context@0.0.
|
|
38349
|
+
// ../../node_modules/.pnpm/@kevisual+context@0.0.10/node_modules/@kevisual/context/dist/app.js
|
|
38350
38350
|
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
38351
38351
|
var isBrowser22 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
38352
38352
|
function getDefaultExportFromCjs(x) {
|
|
@@ -38927,6 +38927,30 @@ var useKey = (envKey, initKey = "context") => {
|
|
|
38927
38927
|
}
|
|
38928
38928
|
return null;
|
|
38929
38929
|
};
|
|
38930
|
+
var useTrimKey = (value, opts) => {
|
|
38931
|
+
if (!value)
|
|
38932
|
+
return value;
|
|
38933
|
+
const trimed = value.trim();
|
|
38934
|
+
const trimQuotes = opts?.trimQuotes ?? true;
|
|
38935
|
+
const boolean4 = opts?.boolean ?? true;
|
|
38936
|
+
const number4 = opts?.number ?? true;
|
|
38937
|
+
if (trimQuotes && trimed.startsWith('"') && trimed.endsWith('"')) {
|
|
38938
|
+
value = trimed.slice(1, -1);
|
|
38939
|
+
}
|
|
38940
|
+
if (trimQuotes && trimed.startsWith("'") && trimed.endsWith("'")) {
|
|
38941
|
+
value = trimed.slice(1, -1);
|
|
38942
|
+
}
|
|
38943
|
+
if (boolean4 && trimed.toLowerCase() === "true") {
|
|
38944
|
+
return true;
|
|
38945
|
+
}
|
|
38946
|
+
if (boolean4 && trimed.toLowerCase() === "false") {
|
|
38947
|
+
return false;
|
|
38948
|
+
}
|
|
38949
|
+
if (number4 && !isNaN(Number(trimed))) {
|
|
38950
|
+
return Number(trimed);
|
|
38951
|
+
}
|
|
38952
|
+
return value;
|
|
38953
|
+
};
|
|
38930
38954
|
|
|
38931
38955
|
// ../../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.4.1/node_modules/@kevisual/use-config/dist/app.js
|
|
38932
38956
|
import { createRequire as createRequire3 } from "node:module";
|
|
@@ -40372,6 +40396,7 @@ class Repo extends CNBCore {
|
|
|
40372
40396
|
}
|
|
40373
40397
|
|
|
40374
40398
|
// src/user/index.ts
|
|
40399
|
+
var import_dayjs2 = __toESM(require_dayjs_min(), 1);
|
|
40375
40400
|
class User extends CNBCore {
|
|
40376
40401
|
constructor(options) {
|
|
40377
40402
|
super(options);
|
|
@@ -40386,11 +40411,26 @@ class User extends CNBCore {
|
|
|
40386
40411
|
async checkCookieValid() {
|
|
40387
40412
|
const user = await this.getCurrentUser();
|
|
40388
40413
|
if (user.code === 200) {
|
|
40389
|
-
|
|
40414
|
+
const cookieInfo = await this.getCookieInfo();
|
|
40415
|
+
const expiredAt = import_dayjs2.default(cookieInfo.expiredAt * 1000).format("YYYY-MM-DD HH:mm:ss");
|
|
40416
|
+
return { code: 200, message: "cookie valid", data: { expiredAt } };
|
|
40390
40417
|
} else {
|
|
40391
40418
|
return { code: 401, message: "cookie invalid" };
|
|
40392
40419
|
}
|
|
40393
40420
|
}
|
|
40421
|
+
async getCookieInfo() {
|
|
40422
|
+
const cookie = this.cookie;
|
|
40423
|
+
const cnbSession = cookie?.split(";").find((item) => item.trim().startsWith("CNBSESSION="));
|
|
40424
|
+
const csrfKey = cookie?.split(";").find((item) => item.trim().startsWith("csrfkey="));
|
|
40425
|
+
const firstPart = cnbSession?.split("=")[1].split(".")[0];
|
|
40426
|
+
const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60;
|
|
40427
|
+
return {
|
|
40428
|
+
cnbSession,
|
|
40429
|
+
csrfKey,
|
|
40430
|
+
firstPart,
|
|
40431
|
+
expiredAt
|
|
40432
|
+
};
|
|
40433
|
+
}
|
|
40394
40434
|
getUser() {
|
|
40395
40435
|
const url3 = "/user";
|
|
40396
40436
|
return this.get({ url: url3 });
|
|
@@ -62631,7 +62671,7 @@ class CNBManager {
|
|
|
62631
62671
|
// agent/app.ts
|
|
62632
62672
|
var cnbManager = new CNBManager;
|
|
62633
62673
|
var token = useKey2("CNB_API_KEY") || useKey2("CNB_TOKEN");
|
|
62634
|
-
var cookie = useKey2("CNB_COOKIE");
|
|
62674
|
+
var cookie = useTrimKey(useKey2("CNB_COOKIE"));
|
|
62635
62675
|
var aiRepo = useKey2("CNB_AI_REPO") || useKey2("CNB_REPO_SLUG_LOWERCASE");
|
|
62636
62676
|
try {
|
|
62637
62677
|
cnbManager.addCNB({
|
|
@@ -64542,7 +64582,7 @@ app.route({
|
|
|
64542
64582
|
}).addTo(app);
|
|
64543
64583
|
|
|
64544
64584
|
// agent/routes/cnb-board/live/live-content.ts
|
|
64545
|
-
var
|
|
64585
|
+
var import_dayjs3 = __toESM(require_dayjs_min(), 1);
|
|
64546
64586
|
import os2 from "node:os";
|
|
64547
64587
|
import { execSync as execSync2 } from "node:child_process";
|
|
64548
64588
|
var getLiveMdContent = (opts) => {
|
|
@@ -64756,8 +64796,8 @@ var createOSInfo = (more = false) => {
|
|
|
64756
64796
|
description: "当前目录磁盘使用情况"
|
|
64757
64797
|
});
|
|
64758
64798
|
if (startTimer) {
|
|
64759
|
-
const buildStartTime =
|
|
64760
|
-
const buildStartTimestamp =
|
|
64799
|
+
const buildStartTime = import_dayjs3.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
|
|
64800
|
+
const buildStartTimestamp = import_dayjs3.default(startTimer).valueOf();
|
|
64761
64801
|
const buildUptime = Date.now() - buildStartTimestamp;
|
|
64762
64802
|
const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
|
|
64763
64803
|
const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
|
|
@@ -64773,7 +64813,7 @@ var createOSInfo = (more = false) => {
|
|
|
64773
64813
|
description: `构建已运行时间: ${buildUptimeStr}`
|
|
64774
64814
|
});
|
|
64775
64815
|
if (maxRunTime > 0) {
|
|
64776
|
-
const now =
|
|
64816
|
+
const now = import_dayjs3.default();
|
|
64777
64817
|
const today4am = now.hour(4).minute(0).second(0).millisecond(0);
|
|
64778
64818
|
let timeTo4 = today4am.valueOf() - now.valueOf();
|
|
64779
64819
|
if (timeTo4 < 0) {
|
|
@@ -72229,7 +72269,7 @@ var import_fast_glob = __toESM(require_out4(), 1);
|
|
|
72229
72269
|
import fs4 from "node:fs";
|
|
72230
72270
|
|
|
72231
72271
|
// src/release/upload-release.ts
|
|
72232
|
-
var
|
|
72272
|
+
var import_dayjs4 = __toESM(require_dayjs_min(), 1);
|
|
72233
72273
|
import fs3 from "node:fs";
|
|
72234
72274
|
|
|
72235
72275
|
// src/upload/upload-base.ts
|
|
@@ -72314,7 +72354,7 @@ var getFileSize = (file3) => {
|
|
|
72314
72354
|
|
|
72315
72355
|
// src/release/upload-release.ts
|
|
72316
72356
|
var createBodyByFileItem = (files) => {
|
|
72317
|
-
const createdAt =
|
|
72357
|
+
const createdAt = import_dayjs4.default().format("YYYY-MM-DD HH:mm:ss");
|
|
72318
72358
|
const summary = `创建时间:${createdAt},文件数量:${files.length}`;
|
|
72319
72359
|
const header = `| name | type |
|
|
72320
72360
|
| --- | --- |`;
|
package/dist/npc.js
CHANGED
|
@@ -36253,7 +36253,7 @@ var import_sender = __toESM2(require_sender(), 1);
|
|
|
36253
36253
|
var import_websocket = __toESM2(require_websocket(), 1);
|
|
36254
36254
|
var import_websocket_server = __toESM2(require_websocket_server(), 1);
|
|
36255
36255
|
|
|
36256
|
-
// ../../node_modules/.pnpm/@kevisual+context@0.0.
|
|
36256
|
+
// ../../node_modules/.pnpm/@kevisual+context@0.0.10/node_modules/@kevisual/context/dist/app.js
|
|
36257
36257
|
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
36258
36258
|
var isBrowser22 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
36259
36259
|
function getDefaultExportFromCjs(x) {
|
|
@@ -36834,6 +36834,30 @@ var useKey = (envKey, initKey = "context") => {
|
|
|
36834
36834
|
}
|
|
36835
36835
|
return null;
|
|
36836
36836
|
};
|
|
36837
|
+
var useTrimKey = (value, opts) => {
|
|
36838
|
+
if (!value)
|
|
36839
|
+
return value;
|
|
36840
|
+
const trimed = value.trim();
|
|
36841
|
+
const trimQuotes = opts?.trimQuotes ?? true;
|
|
36842
|
+
const boolean4 = opts?.boolean ?? true;
|
|
36843
|
+
const number4 = opts?.number ?? true;
|
|
36844
|
+
if (trimQuotes && trimed.startsWith('"') && trimed.endsWith('"')) {
|
|
36845
|
+
value = trimed.slice(1, -1);
|
|
36846
|
+
}
|
|
36847
|
+
if (trimQuotes && trimed.startsWith("'") && trimed.endsWith("'")) {
|
|
36848
|
+
value = trimed.slice(1, -1);
|
|
36849
|
+
}
|
|
36850
|
+
if (boolean4 && trimed.toLowerCase() === "true") {
|
|
36851
|
+
return true;
|
|
36852
|
+
}
|
|
36853
|
+
if (boolean4 && trimed.toLowerCase() === "false") {
|
|
36854
|
+
return false;
|
|
36855
|
+
}
|
|
36856
|
+
if (number4 && !isNaN(Number(trimed))) {
|
|
36857
|
+
return Number(trimed);
|
|
36858
|
+
}
|
|
36859
|
+
return value;
|
|
36860
|
+
};
|
|
36837
36861
|
|
|
36838
36862
|
// ../../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.4.1/node_modules/@kevisual/use-config/dist/app.js
|
|
36839
36863
|
import { createRequire as createRequire3 } from "node:module";
|
|
@@ -38279,6 +38303,7 @@ class Repo extends CNBCore {
|
|
|
38279
38303
|
}
|
|
38280
38304
|
|
|
38281
38305
|
// src/user/index.ts
|
|
38306
|
+
var import_dayjs2 = __toESM(require_dayjs_min(), 1);
|
|
38282
38307
|
class User extends CNBCore {
|
|
38283
38308
|
constructor(options) {
|
|
38284
38309
|
super(options);
|
|
@@ -38293,11 +38318,26 @@ class User extends CNBCore {
|
|
|
38293
38318
|
async checkCookieValid() {
|
|
38294
38319
|
const user = await this.getCurrentUser();
|
|
38295
38320
|
if (user.code === 200) {
|
|
38296
|
-
|
|
38321
|
+
const cookieInfo = await this.getCookieInfo();
|
|
38322
|
+
const expiredAt = import_dayjs2.default(cookieInfo.expiredAt * 1000).format("YYYY-MM-DD HH:mm:ss");
|
|
38323
|
+
return { code: 200, message: "cookie valid", data: { expiredAt } };
|
|
38297
38324
|
} else {
|
|
38298
38325
|
return { code: 401, message: "cookie invalid" };
|
|
38299
38326
|
}
|
|
38300
38327
|
}
|
|
38328
|
+
async getCookieInfo() {
|
|
38329
|
+
const cookie = this.cookie;
|
|
38330
|
+
const cnbSession = cookie?.split(";").find((item) => item.trim().startsWith("CNBSESSION="));
|
|
38331
|
+
const csrfKey = cookie?.split(";").find((item) => item.trim().startsWith("csrfkey="));
|
|
38332
|
+
const firstPart = cnbSession?.split("=")[1].split(".")[0];
|
|
38333
|
+
const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60;
|
|
38334
|
+
return {
|
|
38335
|
+
cnbSession,
|
|
38336
|
+
csrfKey,
|
|
38337
|
+
firstPart,
|
|
38338
|
+
expiredAt
|
|
38339
|
+
};
|
|
38340
|
+
}
|
|
38301
38341
|
getUser() {
|
|
38302
38342
|
const url3 = "/user";
|
|
38303
38343
|
return this.get({ url: url3 });
|
|
@@ -60572,7 +60612,7 @@ class CNBManager {
|
|
|
60572
60612
|
// agent/app.ts
|
|
60573
60613
|
var cnbManager = new CNBManager;
|
|
60574
60614
|
var token = useKey2("CNB_API_KEY") || useKey2("CNB_TOKEN");
|
|
60575
|
-
var cookie = useKey2("CNB_COOKIE");
|
|
60615
|
+
var cookie = useTrimKey(useKey2("CNB_COOKIE"));
|
|
60576
60616
|
var aiRepo = useKey2("CNB_AI_REPO") || useKey2("CNB_REPO_SLUG_LOWERCASE");
|
|
60577
60617
|
try {
|
|
60578
60618
|
cnbManager.addCNB({
|
|
@@ -62483,7 +62523,7 @@ app.route({
|
|
|
62483
62523
|
}).addTo(app);
|
|
62484
62524
|
|
|
62485
62525
|
// agent/routes/cnb-board/live/live-content.ts
|
|
62486
|
-
var
|
|
62526
|
+
var import_dayjs3 = __toESM(require_dayjs_min(), 1);
|
|
62487
62527
|
import os2 from "node:os";
|
|
62488
62528
|
import { execSync as execSync2 } from "node:child_process";
|
|
62489
62529
|
var getLiveMdContent = (opts) => {
|
|
@@ -62697,8 +62737,8 @@ var createOSInfo = (more = false) => {
|
|
|
62697
62737
|
description: "当前目录磁盘使用情况"
|
|
62698
62738
|
});
|
|
62699
62739
|
if (startTimer) {
|
|
62700
|
-
const buildStartTime =
|
|
62701
|
-
const buildStartTimestamp =
|
|
62740
|
+
const buildStartTime = import_dayjs3.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
|
|
62741
|
+
const buildStartTimestamp = import_dayjs3.default(startTimer).valueOf();
|
|
62702
62742
|
const buildUptime = Date.now() - buildStartTimestamp;
|
|
62703
62743
|
const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
|
|
62704
62744
|
const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
|
|
@@ -62714,7 +62754,7 @@ var createOSInfo = (more = false) => {
|
|
|
62714
62754
|
description: `构建已运行时间: ${buildUptimeStr}`
|
|
62715
62755
|
});
|
|
62716
62756
|
if (maxRunTime > 0) {
|
|
62717
|
-
const now =
|
|
62757
|
+
const now = import_dayjs3.default();
|
|
62718
62758
|
const today4am = now.hour(4).minute(0).second(0).millisecond(0);
|
|
62719
62759
|
let timeTo4 = today4am.valueOf() - now.valueOf();
|
|
62720
62760
|
if (timeTo4 < 0) {
|
|
@@ -70170,7 +70210,7 @@ var import_fast_glob = __toESM(require_out4(), 1);
|
|
|
70170
70210
|
import fs4 from "node:fs";
|
|
70171
70211
|
|
|
70172
70212
|
// src/release/upload-release.ts
|
|
70173
|
-
var
|
|
70213
|
+
var import_dayjs4 = __toESM(require_dayjs_min(), 1);
|
|
70174
70214
|
import fs3 from "node:fs";
|
|
70175
70215
|
|
|
70176
70216
|
// src/upload/upload-base.ts
|
|
@@ -70255,7 +70295,7 @@ var getFileSize = (file3) => {
|
|
|
70255
70295
|
|
|
70256
70296
|
// src/release/upload-release.ts
|
|
70257
70297
|
var createBodyByFileItem = (files) => {
|
|
70258
|
-
const createdAt =
|
|
70298
|
+
const createdAt = import_dayjs4.default().format("YYYY-MM-DD HH:mm:ss");
|
|
70259
70299
|
const summary = `创建时间:${createdAt},文件数量:${files.length}`;
|
|
70260
70300
|
const header = `| name | type |
|
|
70261
70301
|
| --- | --- |`;
|
package/dist/opencode.js
CHANGED
|
@@ -36253,7 +36253,7 @@ var import_sender = __toESM2(require_sender(), 1);
|
|
|
36253
36253
|
var import_websocket = __toESM2(require_websocket(), 1);
|
|
36254
36254
|
var import_websocket_server = __toESM2(require_websocket_server(), 1);
|
|
36255
36255
|
|
|
36256
|
-
// ../../node_modules/.pnpm/@kevisual+context@0.0.
|
|
36256
|
+
// ../../node_modules/.pnpm/@kevisual+context@0.0.10/node_modules/@kevisual/context/dist/app.js
|
|
36257
36257
|
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
36258
36258
|
var isBrowser22 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
36259
36259
|
function getDefaultExportFromCjs(x) {
|
|
@@ -36834,6 +36834,30 @@ var useKey = (envKey, initKey = "context") => {
|
|
|
36834
36834
|
}
|
|
36835
36835
|
return null;
|
|
36836
36836
|
};
|
|
36837
|
+
var useTrimKey = (value, opts) => {
|
|
36838
|
+
if (!value)
|
|
36839
|
+
return value;
|
|
36840
|
+
const trimed = value.trim();
|
|
36841
|
+
const trimQuotes = opts?.trimQuotes ?? true;
|
|
36842
|
+
const boolean4 = opts?.boolean ?? true;
|
|
36843
|
+
const number4 = opts?.number ?? true;
|
|
36844
|
+
if (trimQuotes && trimed.startsWith('"') && trimed.endsWith('"')) {
|
|
36845
|
+
value = trimed.slice(1, -1);
|
|
36846
|
+
}
|
|
36847
|
+
if (trimQuotes && trimed.startsWith("'") && trimed.endsWith("'")) {
|
|
36848
|
+
value = trimed.slice(1, -1);
|
|
36849
|
+
}
|
|
36850
|
+
if (boolean4 && trimed.toLowerCase() === "true") {
|
|
36851
|
+
return true;
|
|
36852
|
+
}
|
|
36853
|
+
if (boolean4 && trimed.toLowerCase() === "false") {
|
|
36854
|
+
return false;
|
|
36855
|
+
}
|
|
36856
|
+
if (number4 && !isNaN(Number(trimed))) {
|
|
36857
|
+
return Number(trimed);
|
|
36858
|
+
}
|
|
36859
|
+
return value;
|
|
36860
|
+
};
|
|
36837
36861
|
|
|
36838
36862
|
// ../../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.4.1/node_modules/@kevisual/use-config/dist/app.js
|
|
36839
36863
|
import { createRequire as createRequire3 } from "node:module";
|
|
@@ -38279,6 +38303,7 @@ class Repo extends CNBCore {
|
|
|
38279
38303
|
}
|
|
38280
38304
|
|
|
38281
38305
|
// src/user/index.ts
|
|
38306
|
+
var import_dayjs2 = __toESM(require_dayjs_min(), 1);
|
|
38282
38307
|
class User extends CNBCore {
|
|
38283
38308
|
constructor(options) {
|
|
38284
38309
|
super(options);
|
|
@@ -38293,11 +38318,26 @@ class User extends CNBCore {
|
|
|
38293
38318
|
async checkCookieValid() {
|
|
38294
38319
|
const user = await this.getCurrentUser();
|
|
38295
38320
|
if (user.code === 200) {
|
|
38296
|
-
|
|
38321
|
+
const cookieInfo = await this.getCookieInfo();
|
|
38322
|
+
const expiredAt = import_dayjs2.default(cookieInfo.expiredAt * 1000).format("YYYY-MM-DD HH:mm:ss");
|
|
38323
|
+
return { code: 200, message: "cookie valid", data: { expiredAt } };
|
|
38297
38324
|
} else {
|
|
38298
38325
|
return { code: 401, message: "cookie invalid" };
|
|
38299
38326
|
}
|
|
38300
38327
|
}
|
|
38328
|
+
async getCookieInfo() {
|
|
38329
|
+
const cookie = this.cookie;
|
|
38330
|
+
const cnbSession = cookie?.split(";").find((item) => item.trim().startsWith("CNBSESSION="));
|
|
38331
|
+
const csrfKey = cookie?.split(";").find((item) => item.trim().startsWith("csrfkey="));
|
|
38332
|
+
const firstPart = cnbSession?.split("=")[1].split(".")[0];
|
|
38333
|
+
const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60;
|
|
38334
|
+
return {
|
|
38335
|
+
cnbSession,
|
|
38336
|
+
csrfKey,
|
|
38337
|
+
firstPart,
|
|
38338
|
+
expiredAt
|
|
38339
|
+
};
|
|
38340
|
+
}
|
|
38301
38341
|
getUser() {
|
|
38302
38342
|
const url3 = "/user";
|
|
38303
38343
|
return this.get({ url: url3 });
|
|
@@ -60538,7 +60578,7 @@ class CNBManager {
|
|
|
60538
60578
|
// agent/app.ts
|
|
60539
60579
|
var cnbManager = new CNBManager;
|
|
60540
60580
|
var token = useKey2("CNB_API_KEY") || useKey2("CNB_TOKEN");
|
|
60541
|
-
var cookie = useKey2("CNB_COOKIE");
|
|
60581
|
+
var cookie = useTrimKey(useKey2("CNB_COOKIE"));
|
|
60542
60582
|
var aiRepo = useKey2("CNB_AI_REPO") || useKey2("CNB_REPO_SLUG_LOWERCASE");
|
|
60543
60583
|
try {
|
|
60544
60584
|
cnbManager.addCNB({
|
|
@@ -62449,7 +62489,7 @@ app.route({
|
|
|
62449
62489
|
}).addTo(app);
|
|
62450
62490
|
|
|
62451
62491
|
// agent/routes/cnb-board/live/live-content.ts
|
|
62452
|
-
var
|
|
62492
|
+
var import_dayjs3 = __toESM(require_dayjs_min(), 1);
|
|
62453
62493
|
import os2 from "node:os";
|
|
62454
62494
|
import { execSync as execSync2 } from "node:child_process";
|
|
62455
62495
|
var getLiveMdContent = (opts) => {
|
|
@@ -62663,8 +62703,8 @@ var createOSInfo = (more = false) => {
|
|
|
62663
62703
|
description: "当前目录磁盘使用情况"
|
|
62664
62704
|
});
|
|
62665
62705
|
if (startTimer) {
|
|
62666
|
-
const buildStartTime =
|
|
62667
|
-
const buildStartTimestamp =
|
|
62706
|
+
const buildStartTime = import_dayjs3.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
|
|
62707
|
+
const buildStartTimestamp = import_dayjs3.default(startTimer).valueOf();
|
|
62668
62708
|
const buildUptime = Date.now() - buildStartTimestamp;
|
|
62669
62709
|
const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
|
|
62670
62710
|
const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
|
|
@@ -62680,7 +62720,7 @@ var createOSInfo = (more = false) => {
|
|
|
62680
62720
|
description: `构建已运行时间: ${buildUptimeStr}`
|
|
62681
62721
|
});
|
|
62682
62722
|
if (maxRunTime > 0) {
|
|
62683
|
-
const now =
|
|
62723
|
+
const now = import_dayjs3.default();
|
|
62684
62724
|
const today4am = now.hour(4).minute(0).second(0).millisecond(0);
|
|
62685
62725
|
let timeTo4 = today4am.valueOf() - now.valueOf();
|
|
62686
62726
|
if (timeTo4 < 0) {
|
|
@@ -70136,7 +70176,7 @@ var import_fast_glob = __toESM(require_out4(), 1);
|
|
|
70136
70176
|
import fs4 from "node:fs";
|
|
70137
70177
|
|
|
70138
70178
|
// src/release/upload-release.ts
|
|
70139
|
-
var
|
|
70179
|
+
var import_dayjs4 = __toESM(require_dayjs_min(), 1);
|
|
70140
70180
|
import fs3 from "node:fs";
|
|
70141
70181
|
|
|
70142
70182
|
// src/upload/upload-base.ts
|
|
@@ -70221,7 +70261,7 @@ var getFileSize = (file3) => {
|
|
|
70221
70261
|
|
|
70222
70262
|
// src/release/upload-release.ts
|
|
70223
70263
|
var createBodyByFileItem = (files) => {
|
|
70224
|
-
const createdAt =
|
|
70264
|
+
const createdAt = import_dayjs4.default().format("YYYY-MM-DD HH:mm:ss");
|
|
70225
70265
|
const summary = `创建时间:${createdAt},文件数量:${files.length}`;
|
|
70226
70266
|
const header = `| name | type |
|
|
70227
70267
|
| --- | --- |`;
|
|
@@ -71676,7 +71716,7 @@ var useContextKey3 = (key, init, opts) => {
|
|
|
71676
71716
|
}
|
|
71677
71717
|
return useEnvKey3(key, init, "context", opts);
|
|
71678
71718
|
};
|
|
71679
|
-
var
|
|
71719
|
+
var use3 = useContextKey3;
|
|
71680
71720
|
var useConfigKey3 = (key, init, opts) => {
|
|
71681
71721
|
if (opts?.isNew) {
|
|
71682
71722
|
return useEnvKeyNew3(key, "config", { getNew: true, init, ...opts });
|
|
@@ -71694,8 +71734,8 @@ class InitEnv3 {
|
|
|
71694
71734
|
InitEnv3.isInit = true;
|
|
71695
71735
|
gt3.useConfigKey = useConfigKey3;
|
|
71696
71736
|
gt3.useContextKey = useContextKey3;
|
|
71697
|
-
gt3.use =
|
|
71698
|
-
gt3.webEnv = { useConfigKey: useConfigKey3, useContextKey: useContextKey3, use:
|
|
71737
|
+
gt3.use = use3;
|
|
71738
|
+
gt3.webEnv = { useConfigKey: useConfigKey3, useContextKey: useContextKey3, use: use3 };
|
|
71699
71739
|
load && (gt3.Load = BaseLoad3);
|
|
71700
71740
|
}
|
|
71701
71741
|
}
|
package/dist/routes.d.ts
CHANGED
|
@@ -514,6 +514,12 @@ declare class User extends CNBCore {
|
|
|
514
514
|
* @returns
|
|
515
515
|
*/
|
|
516
516
|
checkCookieValid(): Promise<Result$2>;
|
|
517
|
+
getCookieInfo(): Promise<{
|
|
518
|
+
cnbSession: string;
|
|
519
|
+
csrfKey: string;
|
|
520
|
+
firstPart: string;
|
|
521
|
+
expiredAt: number;
|
|
522
|
+
}>;
|
|
517
523
|
/**
|
|
518
524
|
* 使用 Token 获取用户信息
|
|
519
525
|
* @returns
|
package/dist/routes.js
CHANGED
|
@@ -36253,7 +36253,7 @@ var import_sender = __toESM2(require_sender(), 1);
|
|
|
36253
36253
|
var import_websocket = __toESM2(require_websocket(), 1);
|
|
36254
36254
|
var import_websocket_server = __toESM2(require_websocket_server(), 1);
|
|
36255
36255
|
|
|
36256
|
-
// ../../node_modules/.pnpm/@kevisual+context@0.0.
|
|
36256
|
+
// ../../node_modules/.pnpm/@kevisual+context@0.0.10/node_modules/@kevisual/context/dist/app.js
|
|
36257
36257
|
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
36258
36258
|
var isBrowser22 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
36259
36259
|
function getDefaultExportFromCjs(x) {
|
|
@@ -36834,6 +36834,30 @@ var useKey = (envKey, initKey = "context") => {
|
|
|
36834
36834
|
}
|
|
36835
36835
|
return null;
|
|
36836
36836
|
};
|
|
36837
|
+
var useTrimKey = (value, opts) => {
|
|
36838
|
+
if (!value)
|
|
36839
|
+
return value;
|
|
36840
|
+
const trimed = value.trim();
|
|
36841
|
+
const trimQuotes = opts?.trimQuotes ?? true;
|
|
36842
|
+
const boolean4 = opts?.boolean ?? true;
|
|
36843
|
+
const number4 = opts?.number ?? true;
|
|
36844
|
+
if (trimQuotes && trimed.startsWith('"') && trimed.endsWith('"')) {
|
|
36845
|
+
value = trimed.slice(1, -1);
|
|
36846
|
+
}
|
|
36847
|
+
if (trimQuotes && trimed.startsWith("'") && trimed.endsWith("'")) {
|
|
36848
|
+
value = trimed.slice(1, -1);
|
|
36849
|
+
}
|
|
36850
|
+
if (boolean4 && trimed.toLowerCase() === "true") {
|
|
36851
|
+
return true;
|
|
36852
|
+
}
|
|
36853
|
+
if (boolean4 && trimed.toLowerCase() === "false") {
|
|
36854
|
+
return false;
|
|
36855
|
+
}
|
|
36856
|
+
if (number4 && !isNaN(Number(trimed))) {
|
|
36857
|
+
return Number(trimed);
|
|
36858
|
+
}
|
|
36859
|
+
return value;
|
|
36860
|
+
};
|
|
36837
36861
|
|
|
36838
36862
|
// ../../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.4.1/node_modules/@kevisual/use-config/dist/app.js
|
|
36839
36863
|
import { createRequire as createRequire3 } from "node:module";
|
|
@@ -38279,6 +38303,7 @@ class Repo extends CNBCore {
|
|
|
38279
38303
|
}
|
|
38280
38304
|
|
|
38281
38305
|
// src/user/index.ts
|
|
38306
|
+
var import_dayjs2 = __toESM(require_dayjs_min(), 1);
|
|
38282
38307
|
class User extends CNBCore {
|
|
38283
38308
|
constructor(options) {
|
|
38284
38309
|
super(options);
|
|
@@ -38293,11 +38318,26 @@ class User extends CNBCore {
|
|
|
38293
38318
|
async checkCookieValid() {
|
|
38294
38319
|
const user = await this.getCurrentUser();
|
|
38295
38320
|
if (user.code === 200) {
|
|
38296
|
-
|
|
38321
|
+
const cookieInfo = await this.getCookieInfo();
|
|
38322
|
+
const expiredAt = import_dayjs2.default(cookieInfo.expiredAt * 1000).format("YYYY-MM-DD HH:mm:ss");
|
|
38323
|
+
return { code: 200, message: "cookie valid", data: { expiredAt } };
|
|
38297
38324
|
} else {
|
|
38298
38325
|
return { code: 401, message: "cookie invalid" };
|
|
38299
38326
|
}
|
|
38300
38327
|
}
|
|
38328
|
+
async getCookieInfo() {
|
|
38329
|
+
const cookie = this.cookie;
|
|
38330
|
+
const cnbSession = cookie?.split(";").find((item) => item.trim().startsWith("CNBSESSION="));
|
|
38331
|
+
const csrfKey = cookie?.split(";").find((item) => item.trim().startsWith("csrfkey="));
|
|
38332
|
+
const firstPart = cnbSession?.split("=")[1].split(".")[0];
|
|
38333
|
+
const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60;
|
|
38334
|
+
return {
|
|
38335
|
+
cnbSession,
|
|
38336
|
+
csrfKey,
|
|
38337
|
+
firstPart,
|
|
38338
|
+
expiredAt
|
|
38339
|
+
};
|
|
38340
|
+
}
|
|
38301
38341
|
getUser() {
|
|
38302
38342
|
const url3 = "/user";
|
|
38303
38343
|
return this.get({ url: url3 });
|
|
@@ -60538,7 +60578,7 @@ class CNBManager {
|
|
|
60538
60578
|
// agent/app.ts
|
|
60539
60579
|
var cnbManager = new CNBManager;
|
|
60540
60580
|
var token = useKey2("CNB_API_KEY") || useKey2("CNB_TOKEN");
|
|
60541
|
-
var cookie = useKey2("CNB_COOKIE");
|
|
60581
|
+
var cookie = useTrimKey(useKey2("CNB_COOKIE"));
|
|
60542
60582
|
var aiRepo = useKey2("CNB_AI_REPO") || useKey2("CNB_REPO_SLUG_LOWERCASE");
|
|
60543
60583
|
try {
|
|
60544
60584
|
cnbManager.addCNB({
|
|
@@ -62449,7 +62489,7 @@ app.route({
|
|
|
62449
62489
|
}).addTo(app);
|
|
62450
62490
|
|
|
62451
62491
|
// agent/routes/cnb-board/live/live-content.ts
|
|
62452
|
-
var
|
|
62492
|
+
var import_dayjs3 = __toESM(require_dayjs_min(), 1);
|
|
62453
62493
|
import os2 from "node:os";
|
|
62454
62494
|
import { execSync as execSync2 } from "node:child_process";
|
|
62455
62495
|
var getLiveMdContent = (opts) => {
|
|
@@ -62663,8 +62703,8 @@ var createOSInfo = (more = false) => {
|
|
|
62663
62703
|
description: "当前目录磁盘使用情况"
|
|
62664
62704
|
});
|
|
62665
62705
|
if (startTimer) {
|
|
62666
|
-
const buildStartTime =
|
|
62667
|
-
const buildStartTimestamp =
|
|
62706
|
+
const buildStartTime = import_dayjs3.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
|
|
62707
|
+
const buildStartTimestamp = import_dayjs3.default(startTimer).valueOf();
|
|
62668
62708
|
const buildUptime = Date.now() - buildStartTimestamp;
|
|
62669
62709
|
const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
|
|
62670
62710
|
const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
|
|
@@ -62680,7 +62720,7 @@ var createOSInfo = (more = false) => {
|
|
|
62680
62720
|
description: `构建已运行时间: ${buildUptimeStr}`
|
|
62681
62721
|
});
|
|
62682
62722
|
if (maxRunTime > 0) {
|
|
62683
|
-
const now =
|
|
62723
|
+
const now = import_dayjs3.default();
|
|
62684
62724
|
const today4am = now.hour(4).minute(0).second(0).millisecond(0);
|
|
62685
62725
|
let timeTo4 = today4am.valueOf() - now.valueOf();
|
|
62686
62726
|
if (timeTo4 < 0) {
|
|
@@ -70136,7 +70176,7 @@ var import_fast_glob = __toESM(require_out4(), 1);
|
|
|
70136
70176
|
import fs4 from "node:fs";
|
|
70137
70177
|
|
|
70138
70178
|
// src/release/upload-release.ts
|
|
70139
|
-
var
|
|
70179
|
+
var import_dayjs4 = __toESM(require_dayjs_min(), 1);
|
|
70140
70180
|
import fs3 from "node:fs";
|
|
70141
70181
|
|
|
70142
70182
|
// src/upload/upload-base.ts
|
|
@@ -70221,7 +70261,7 @@ var getFileSize = (file3) => {
|
|
|
70221
70261
|
|
|
70222
70262
|
// src/release/upload-release.ts
|
|
70223
70263
|
var createBodyByFileItem = (files) => {
|
|
70224
|
-
const createdAt =
|
|
70264
|
+
const createdAt = import_dayjs4.default().format("YYYY-MM-DD HH:mm:ss");
|
|
70225
70265
|
const summary = `创建时间:${createdAt},文件数量:${files.length}`;
|
|
70226
70266
|
const header = `| name | type |
|
|
70227
70267
|
| --- | --- |`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/cnb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.74",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"basename": "/root/cnb",
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"@kevisual/ai": "^0.0.30",
|
|
38
38
|
"@kevisual/api": "^0.0.67",
|
|
39
39
|
"@kevisual/code-builder": "^0.0.7",
|
|
40
|
-
"@kevisual/context": "^0.0.
|
|
40
|
+
"@kevisual/context": "^0.0.10",
|
|
41
41
|
"@kevisual/dts": "^0.0.4",
|
|
42
42
|
"@kevisual/remote-app": "^0.0.7",
|
|
43
43
|
"@kevisual/types": "^0.0.14",
|
|
44
44
|
"@opencode-ai/plugin": "^1.4.3",
|
|
45
|
-
"@types/bun": "^1.3.
|
|
45
|
+
"@types/bun": "^1.3.12",
|
|
46
46
|
"@types/node": "^25.6.0",
|
|
47
47
|
"@types/ws": "^8.18.1",
|
|
48
|
-
"ai": "^6.0.
|
|
48
|
+
"ai": "^6.0.158",
|
|
49
49
|
"commander": "^14.0.3",
|
|
50
50
|
"dayjs": "^1.11.20",
|
|
51
51
|
"dotenv": "^17.4.1",
|
package/src/user/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
1
2
|
import { CNBCore, CNBCoreOptions } from "../cnb-core.ts";
|
|
2
3
|
import { Result } from "@kevisual/query";
|
|
3
4
|
export class User extends CNBCore {
|
|
@@ -23,11 +24,28 @@ export class User extends CNBCore {
|
|
|
23
24
|
async checkCookieValid(): Promise<Result> {
|
|
24
25
|
const user = await this.getCurrentUser();
|
|
25
26
|
if (user.code === 200) {
|
|
26
|
-
|
|
27
|
+
const cookieInfo = await this.getCookieInfo();
|
|
28
|
+
const expiredAt = dayjs(cookieInfo.expiredAt * 1000).format('YYYY-MM-DD HH:mm:ss');
|
|
29
|
+
return { code: 200, message: 'cookie valid', data: { expiredAt: expiredAt } };
|
|
27
30
|
} else {
|
|
28
31
|
return { code: 401, message: 'cookie invalid' };
|
|
29
32
|
}
|
|
30
33
|
}
|
|
34
|
+
async getCookieInfo() {
|
|
35
|
+
// CNBSESSION=1775638499.1935321989751226368.23c2313b832a6ca869c15e5257d6b16deb341dea4633bbd76c8d91c77d65fda5; csrfkey=1619226679
|
|
36
|
+
const cookie = this.cookie;
|
|
37
|
+
// 解析 CNBSESSION
|
|
38
|
+
const cnbSession = cookie?.split(';').find(item => item.trim().startsWith('CNBSESSION='));
|
|
39
|
+
const csrfKey = cookie?.split(';').find(item => item.trim().startsWith('csrfkey='));
|
|
40
|
+
const firstPart = cnbSession?.split('=')[1].split('.')[0];
|
|
41
|
+
const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60; // CNBSESSION 的过期时间为7* 24 小时
|
|
42
|
+
return {
|
|
43
|
+
cnbSession,
|
|
44
|
+
csrfKey,
|
|
45
|
+
firstPart,
|
|
46
|
+
expiredAt,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
31
49
|
/**
|
|
32
50
|
* 使用 Token 获取用户信息
|
|
33
51
|
* @returns
|