@aight-cool/aight-utils 0.1.18 → 0.1.20
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/index.js +35 -64
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2998,12 +2998,12 @@ function registerPush(api, _config) {
|
|
|
2998
2998
|
}
|
|
2999
2999
|
const deviceId = params.deviceId;
|
|
3000
3000
|
const pushToken = params.pushToken;
|
|
3001
|
-
const
|
|
3001
|
+
const platform = params.platform;
|
|
3002
3002
|
const sandbox = !!params.sandbox;
|
|
3003
3003
|
registerToken({
|
|
3004
3004
|
deviceId,
|
|
3005
3005
|
pushToken,
|
|
3006
|
-
platform
|
|
3006
|
+
platform,
|
|
3007
3007
|
sandbox,
|
|
3008
3008
|
registeredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3009
3009
|
});
|
|
@@ -3014,7 +3014,7 @@ function registerPush(api, _config) {
|
|
|
3014
3014
|
registerToken({
|
|
3015
3015
|
deviceId,
|
|
3016
3016
|
pushToken,
|
|
3017
|
-
platform
|
|
3017
|
+
platform,
|
|
3018
3018
|
sandbox,
|
|
3019
3019
|
sendKey,
|
|
3020
3020
|
registeredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3392,9 +3392,10 @@ function registerBootstrap(api) {
|
|
|
3392
3392
|
// src/groups.ts
|
|
3393
3393
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
3394
3394
|
import { join as join3 } from "path";
|
|
3395
|
+
import { homedir as homedir3 } from "os";
|
|
3395
3396
|
var FILENAME = "group-names.json";
|
|
3396
3397
|
function filePath(api) {
|
|
3397
|
-
const dir = api.dataDir ?? join3(
|
|
3398
|
+
const dir = api.dataDir ?? join3(homedir3(), ".openclaw", "plugin-data", "aight-utils");
|
|
3398
3399
|
mkdirSync3(dir, { recursive: true });
|
|
3399
3400
|
return join3(dir, FILENAME);
|
|
3400
3401
|
}
|
|
@@ -3625,59 +3626,35 @@ function registerPushHook(api) {
|
|
|
3625
3626
|
}
|
|
3626
3627
|
|
|
3627
3628
|
// src/health.ts
|
|
3628
|
-
import
|
|
3629
|
-
import
|
|
3629
|
+
import * as os4 from "os";
|
|
3630
|
+
import * as fs4 from "fs";
|
|
3630
3631
|
function getStats() {
|
|
3631
|
-
const os4 = platform();
|
|
3632
3632
|
let memory = null;
|
|
3633
3633
|
let cpu = null;
|
|
3634
3634
|
let disk = null;
|
|
3635
3635
|
try {
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
const usedGB = (totalKB - availKB) * 1024 / 1073741824;
|
|
3659
|
-
memory = {
|
|
3660
|
-
usedGB: Math.round(usedGB * 10) / 10,
|
|
3661
|
-
totalGB: Math.round(totalGB * 10) / 10,
|
|
3662
|
-
percent: Math.round(usedGB / totalGB * 100)
|
|
3663
|
-
};
|
|
3664
|
-
const loadavg = execSync("cat /proc/loadavg", { encoding: "utf8", timeout: 5e3 });
|
|
3665
|
-
const load1m = parseFloat(loadavg.split(" ")[0]);
|
|
3666
|
-
const cores = parseInt(execSync("nproc", { encoding: "utf8", timeout: 5e3 }).trim());
|
|
3667
|
-
cpu = { percent: Math.round(Math.min(load1m / cores * 100, 100)) };
|
|
3668
|
-
}
|
|
3669
|
-
const df = execSync("df -k /", { encoding: "utf8", timeout: 5e3 });
|
|
3670
|
-
const dfLine = df.split("\n")[1];
|
|
3671
|
-
const dfParts = dfLine?.split(/\s+/);
|
|
3672
|
-
if (dfParts && dfParts.length >= 4) {
|
|
3673
|
-
const totalKB = parseInt(dfParts[1]);
|
|
3674
|
-
const usedKB = parseInt(dfParts[2]);
|
|
3675
|
-
disk = {
|
|
3676
|
-
totalGB: Math.round(totalKB / 1048576),
|
|
3677
|
-
usedGB: Math.round(usedKB / 1048576),
|
|
3678
|
-
percent: Math.round(usedKB / totalKB * 100)
|
|
3679
|
-
};
|
|
3680
|
-
}
|
|
3636
|
+
const totalBytes = os4.totalmem();
|
|
3637
|
+
const freeBytes = os4.freemem();
|
|
3638
|
+
const usedBytes = totalBytes - freeBytes;
|
|
3639
|
+
const totalGB = totalBytes / 1073741824;
|
|
3640
|
+
const usedGB = usedBytes / 1073741824;
|
|
3641
|
+
memory = {
|
|
3642
|
+
usedGB: Math.round(usedGB * 10) / 10,
|
|
3643
|
+
totalGB: Math.round(totalGB * 10) / 10,
|
|
3644
|
+
percent: Math.round(usedGB / totalGB * 100)
|
|
3645
|
+
};
|
|
3646
|
+
const load1m = os4.loadavg()[0];
|
|
3647
|
+
const cores = os4.cpus().length;
|
|
3648
|
+
cpu = { percent: Math.round(Math.min(load1m / cores * 100, 100)) };
|
|
3649
|
+
const stat = fs4.statfsSync("/");
|
|
3650
|
+
const totalDiskBytes = stat.blocks * stat.bsize;
|
|
3651
|
+
const freeDiskBytes = stat.bfree * stat.bsize;
|
|
3652
|
+
const usedDiskBytes = totalDiskBytes - freeDiskBytes;
|
|
3653
|
+
disk = {
|
|
3654
|
+
totalGB: Math.round(totalDiskBytes / 1073741824),
|
|
3655
|
+
usedGB: Math.round(usedDiskBytes / 1073741824),
|
|
3656
|
+
percent: Math.round(usedDiskBytes / totalDiskBytes * 100)
|
|
3657
|
+
};
|
|
3681
3658
|
} catch {
|
|
3682
3659
|
}
|
|
3683
3660
|
return { memory, cpu, disk };
|
|
@@ -3696,7 +3673,6 @@ function registerHealth(api) {
|
|
|
3696
3673
|
}
|
|
3697
3674
|
|
|
3698
3675
|
// src/version.ts
|
|
3699
|
-
import { execSync as execSync2 } from "child_process";
|
|
3700
3676
|
import { createRequire } from "module";
|
|
3701
3677
|
import { readFileSync as readFileSync5 } from "fs";
|
|
3702
3678
|
import { join as join5, dirname } from "path";
|
|
@@ -3718,18 +3694,13 @@ var cachedGatewayVersion = null;
|
|
|
3718
3694
|
function getGatewayVersion() {
|
|
3719
3695
|
if (cachedGatewayVersion) return cachedGatewayVersion;
|
|
3720
3696
|
try {
|
|
3721
|
-
const
|
|
3722
|
-
|
|
3697
|
+
const require_ = createRequire(import.meta.url);
|
|
3698
|
+
const resolved = require_.resolve("openclaw");
|
|
3699
|
+
const pkgPath = join5(dirname(resolved), "package.json");
|
|
3700
|
+
const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
|
|
3701
|
+
cachedGatewayVersion = pkg.version ?? "unknown";
|
|
3723
3702
|
} catch {
|
|
3724
|
-
|
|
3725
|
-
const require_ = createRequire(import.meta.url);
|
|
3726
|
-
const resolved = require_.resolve("openclaw");
|
|
3727
|
-
const pkgPath = join5(dirname(resolved), "package.json");
|
|
3728
|
-
const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
|
|
3729
|
-
cachedGatewayVersion = pkg.version ?? "unknown";
|
|
3730
|
-
} catch {
|
|
3731
|
-
cachedGatewayVersion = "unknown";
|
|
3732
|
-
}
|
|
3703
|
+
cachedGatewayVersion = "unknown";
|
|
3733
3704
|
}
|
|
3734
3705
|
return cachedGatewayVersion;
|
|
3735
3706
|
}
|