@yoooclaw/phone-notifications 1.11.2-beta.3 → 1.11.2
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.cjs +139 -36
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,19 @@ function expandUserPath(value) {
|
|
|
56
56
|
}
|
|
57
57
|
return value;
|
|
58
58
|
}
|
|
59
|
+
function detectHostKindFromPath(value) {
|
|
60
|
+
if (!value) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
const normalized = value.replace(/\\/g, "/").toLowerCase();
|
|
64
|
+
if (normalized.endsWith("/.qclaw") || normalized.includes("/.qclaw/") || normalized.endsWith("/.qclow") || normalized.includes("/.qclow/")) {
|
|
65
|
+
return "qclaw";
|
|
66
|
+
}
|
|
67
|
+
if (normalized.endsWith("/.openclaw") || normalized.includes("/.openclaw/")) {
|
|
68
|
+
return "openclaw";
|
|
69
|
+
}
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
59
72
|
function candidateMetaPaths() {
|
|
60
73
|
const home = homeDir();
|
|
61
74
|
return [
|
|
@@ -97,6 +110,22 @@ function hasOpenClawMarkers() {
|
|
|
97
110
|
(0, import_node_path4.join)(baseDir, "extensions")
|
|
98
111
|
].some((candidate) => (0, import_node_fs5.existsSync)(candidate));
|
|
99
112
|
}
|
|
113
|
+
function detectHostKind() {
|
|
114
|
+
if (trimToUndefined(process.env.QCLAW_STATE_DIR) || trimToUndefined(process.env.QCLAW_CONFIG_PATH) || trimToUndefined(process.env.QCLAW_HOME)) {
|
|
115
|
+
return "qclaw";
|
|
116
|
+
}
|
|
117
|
+
const pathHintKind = detectHostKindFromPath(resolveStateDirFromEnv()) ?? detectHostKindFromPath(resolveConfigPathFromEnv());
|
|
118
|
+
if (pathHintKind) {
|
|
119
|
+
return pathHintKind;
|
|
120
|
+
}
|
|
121
|
+
if (hasOpenClawMarkers()) {
|
|
122
|
+
return "openclaw";
|
|
123
|
+
}
|
|
124
|
+
if (loadQClawMeta()) {
|
|
125
|
+
return "qclaw";
|
|
126
|
+
}
|
|
127
|
+
return "openclaw";
|
|
128
|
+
}
|
|
100
129
|
function resolveStateDir() {
|
|
101
130
|
const envDir = resolveStateDirFromEnv();
|
|
102
131
|
if (envDir) {
|
|
@@ -233,11 +262,16 @@ function readDotEnv() {
|
|
|
233
262
|
})
|
|
234
263
|
);
|
|
235
264
|
}
|
|
265
|
+
function readPersistedEnvName() {
|
|
266
|
+
const fromDotEnv = readDotEnv()["PHONE_NOTIFICATIONS_ENV"]?.trim();
|
|
267
|
+
if (fromDotEnv && VALID_ENVS.has(fromDotEnv)) return fromDotEnv;
|
|
268
|
+
return void 0;
|
|
269
|
+
}
|
|
236
270
|
function loadEnvName() {
|
|
237
271
|
const fromEnvVar = process.env.PHONE_NOTIFICATIONS_ENV?.trim();
|
|
238
272
|
if (fromEnvVar && VALID_ENVS.has(fromEnvVar)) return fromEnvVar;
|
|
239
|
-
const fromDotEnv =
|
|
240
|
-
if (fromDotEnv
|
|
273
|
+
const fromDotEnv = readPersistedEnvName();
|
|
274
|
+
if (fromDotEnv) return fromDotEnv;
|
|
241
275
|
const { env } = readCredentials();
|
|
242
276
|
if (env && VALID_ENVS.has(env)) return env;
|
|
243
277
|
return "production";
|
|
@@ -692,7 +726,7 @@ function findWhisperBinary(dataDir, logger) {
|
|
|
692
726
|
for (const name of pathNames) {
|
|
693
727
|
try {
|
|
694
728
|
const cmd = (0, import_node_os4.platform)() === "win32" ? "where" : "which";
|
|
695
|
-
const result = (0,
|
|
729
|
+
const result = (0, import_node_child_process3.execSync)(`${cmd} ${name}`, { encoding: "utf-8", stdio: "pipe" }).trim();
|
|
696
730
|
if (result) {
|
|
697
731
|
logger.info(`[whisper-local] \u627E\u5230\u7CFB\u7EDF PATH \u4E8C\u8FDB\u5236: ${result}`);
|
|
698
732
|
return result.split("\n")[0].trim();
|
|
@@ -762,7 +796,7 @@ async function transcribeWithWhisperLocal(audioFilePath, localConfig, dataDir, l
|
|
|
762
796
|
const startMs = Date.now();
|
|
763
797
|
let result;
|
|
764
798
|
try {
|
|
765
|
-
result = (0,
|
|
799
|
+
result = (0, import_node_child_process3.spawnSync)(whisperBin, args, {
|
|
766
800
|
encoding: "utf-8",
|
|
767
801
|
timeout: 60 * 60 * 1e3,
|
|
768
802
|
// 1 小时超时(5 小时录音)
|
|
@@ -817,14 +851,14 @@ function getWhisperLocalStatus(dataDir, logger) {
|
|
|
817
851
|
}
|
|
818
852
|
function detectCuda(logger) {
|
|
819
853
|
try {
|
|
820
|
-
(0,
|
|
854
|
+
(0, import_node_child_process3.execSync)("nvidia-smi", { encoding: "utf-8", stdio: "pipe", timeout: 5e3 });
|
|
821
855
|
logger.info("[whisper-local] \u68C0\u6D4B\u5230 NVIDIA GPU (nvidia-smi)");
|
|
822
856
|
return true;
|
|
823
857
|
} catch {
|
|
824
858
|
}
|
|
825
859
|
if ((0, import_node_os4.platform)() === "linux") {
|
|
826
860
|
try {
|
|
827
|
-
const ldconfig = (0,
|
|
861
|
+
const ldconfig = (0, import_node_child_process3.execSync)("ldconfig -p 2>/dev/null | grep libcudart", {
|
|
828
862
|
encoding: "utf-8",
|
|
829
863
|
stdio: "pipe",
|
|
830
864
|
timeout: 5e3
|
|
@@ -841,7 +875,7 @@ function detectCuda(logger) {
|
|
|
841
875
|
function getAvailableMemoryGB(backend, logger) {
|
|
842
876
|
if (backend === "cuda") {
|
|
843
877
|
try {
|
|
844
|
-
const output2 = (0,
|
|
878
|
+
const output2 = (0, import_node_child_process3.execSync)(
|
|
845
879
|
"nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits",
|
|
846
880
|
{ encoding: "utf-8", stdio: "pipe", timeout: 5e3 }
|
|
847
881
|
);
|
|
@@ -889,7 +923,7 @@ function detectAudioFormat(filePath) {
|
|
|
889
923
|
}
|
|
890
924
|
function convertToWav(inputPath, outputPath, actualFmt, logger) {
|
|
891
925
|
try {
|
|
892
|
-
const ffmpegResult = (0,
|
|
926
|
+
const ffmpegResult = (0, import_node_child_process3.spawnSync)("ffmpeg", [
|
|
893
927
|
"-y",
|
|
894
928
|
"-i",
|
|
895
929
|
inputPath,
|
|
@@ -913,7 +947,7 @@ function convertToWav(inputPath, outputPath, actualFmt, logger) {
|
|
|
913
947
|
}
|
|
914
948
|
if (actualFmt === ".ogg") {
|
|
915
949
|
try {
|
|
916
|
-
const opusResult = (0,
|
|
950
|
+
const opusResult = (0, import_node_child_process3.spawnSync)(
|
|
917
951
|
"opusdec",
|
|
918
952
|
["--rate", "16000", "--mono", inputPath, outputPath],
|
|
919
953
|
{ encoding: "utf-8", timeout: 12e4, stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -942,7 +976,7 @@ function convertToWav(inputPath, outputPath, actualFmt, logger) {
|
|
|
942
976
|
}
|
|
943
977
|
}
|
|
944
978
|
try {
|
|
945
|
-
const afResult = (0,
|
|
979
|
+
const afResult = (0, import_node_child_process3.spawnSync)("afconvert", [
|
|
946
980
|
"-f",
|
|
947
981
|
"WAVE",
|
|
948
982
|
"-d",
|
|
@@ -1070,11 +1104,11 @@ function formatBytes2(bytes) {
|
|
|
1070
1104
|
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
1071
1105
|
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)}GB`;
|
|
1072
1106
|
}
|
|
1073
|
-
var
|
|
1107
|
+
var import_node_child_process3, import_node_fs25, import_node_path21, import_promises3, import_node_stream2, import_node_os4, WHISPER_MODELS_DIR, WHISPER_BIN_DIR, HF_MODEL_URL_TEMPLATE, MODELSCOPE_MODEL_URL_TEMPLATE, PROBE_TIMEOUT_MS, MODEL_FILENAMES, MODEL_DISK_SIZES;
|
|
1074
1108
|
var init_whisper_local = __esm({
|
|
1075
1109
|
"src/recording/whisper-local.ts"() {
|
|
1076
1110
|
"use strict";
|
|
1077
|
-
|
|
1111
|
+
import_node_child_process3 = require("child_process");
|
|
1078
1112
|
import_node_fs25 = require("fs");
|
|
1079
1113
|
import_node_path21 = require("path");
|
|
1080
1114
|
import_promises3 = require("stream/promises");
|
|
@@ -5438,7 +5472,7 @@ function readBuildInjectedVersion() {
|
|
|
5438
5472
|
if (false) {
|
|
5439
5473
|
return void 0;
|
|
5440
5474
|
}
|
|
5441
|
-
const version = "1.11.2
|
|
5475
|
+
const version = "1.11.2".trim();
|
|
5442
5476
|
return version || void 0;
|
|
5443
5477
|
}
|
|
5444
5478
|
function readPluginVersionFromPackageJson() {
|
|
@@ -8539,21 +8573,98 @@ function registerLogSearch(ntf, ctx) {
|
|
|
8539
8573
|
}
|
|
8540
8574
|
|
|
8541
8575
|
// src/cli/env.ts
|
|
8576
|
+
var import_node_child_process = require("child_process");
|
|
8542
8577
|
init_env();
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8578
|
+
init_host();
|
|
8579
|
+
var GATEWAY_RESTART_TIMEOUT_MS = 3e4;
|
|
8580
|
+
var NOOP_LOGGER = {
|
|
8581
|
+
info() {
|
|
8582
|
+
},
|
|
8583
|
+
warn() {
|
|
8584
|
+
},
|
|
8585
|
+
error() {
|
|
8586
|
+
}
|
|
8587
|
+
};
|
|
8588
|
+
function buildEnvShowPayload(deps = {}) {
|
|
8589
|
+
const persistedEnv = deps.readPersistedEnvName?.() ?? readPersistedEnvName();
|
|
8590
|
+
const env = persistedEnv ?? "production";
|
|
8591
|
+
const urls = getEnvUrls(env);
|
|
8592
|
+
return {
|
|
8593
|
+
ok: true,
|
|
8594
|
+
env,
|
|
8595
|
+
source: persistedEnv ? ".env" : "default",
|
|
8596
|
+
lightApiUrl: urls.lightApiUrl,
|
|
8597
|
+
relayTunnelUrl: urls.relayTunnelUrl,
|
|
8598
|
+
availableEnvs: getAvailableEnvs()
|
|
8599
|
+
};
|
|
8600
|
+
}
|
|
8601
|
+
function triggerGatewayReloadAfterEnvSwitch(deps = {}) {
|
|
8602
|
+
const scheduleRestart = deps.scheduleGatewayRestart ?? (() => scheduleGatewayRestart(NOOP_LOGGER));
|
|
8603
|
+
const scheduled = scheduleRestart();
|
|
8604
|
+
if (scheduled.scheduled) {
|
|
8605
|
+
return {
|
|
8606
|
+
attempted: true,
|
|
8549
8607
|
ok: true,
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8608
|
+
method: "signal",
|
|
8609
|
+
message: "\u5DF2\u81EA\u52A8\u89E6\u53D1 gateway \u8FDB\u7A0B\u5185\u91CD\u8F7D"
|
|
8610
|
+
};
|
|
8611
|
+
}
|
|
8612
|
+
const hostKind = deps.detectHostKind?.() ?? detectHostKind();
|
|
8613
|
+
if (hostKind === "qclaw") {
|
|
8614
|
+
return {
|
|
8615
|
+
attempted: false,
|
|
8616
|
+
ok: false,
|
|
8617
|
+
method: "skipped",
|
|
8618
|
+
message: "\u5F53\u524D\u5BBF\u4E3B\u4E3A QClaw\uFF0C\u8BF7\u91CD\u542F QClaw \u684C\u9762\u5E94\u7528\u540E\u4F7F\u73AF\u5883\u5207\u6362\u751F\u6548"
|
|
8619
|
+
};
|
|
8620
|
+
}
|
|
8621
|
+
const hostCli = deps.hostCli?.trim() || process.env.HOST_CLI?.trim() || "openclaw";
|
|
8622
|
+
const command = `${hostCli} gateway restart`;
|
|
8623
|
+
const run = deps.spawnSync ?? import_node_child_process.spawnSync;
|
|
8624
|
+
const result = run(hostCli, ["gateway", "restart"], {
|
|
8625
|
+
encoding: "utf-8",
|
|
8626
|
+
stdio: "pipe",
|
|
8627
|
+
timeout: GATEWAY_RESTART_TIMEOUT_MS
|
|
8628
|
+
});
|
|
8629
|
+
if (!result.error && result.status === 0) {
|
|
8630
|
+
return {
|
|
8631
|
+
attempted: true,
|
|
8632
|
+
ok: true,
|
|
8633
|
+
method: "cli",
|
|
8634
|
+
command,
|
|
8635
|
+
message: `\u5DF2\u81EA\u52A8\u89E6\u53D1 ${command}`
|
|
8636
|
+
};
|
|
8637
|
+
}
|
|
8638
|
+
const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
|
|
8639
|
+
const errorMessage = result.error?.message?.trim();
|
|
8640
|
+
return {
|
|
8641
|
+
attempted: true,
|
|
8642
|
+
ok: false,
|
|
8643
|
+
method: "cli",
|
|
8644
|
+
command,
|
|
8645
|
+
message: `\u5DF2\u5207\u6362\u73AF\u5883\uFF0C\u4F46\u81EA\u52A8\u91CD\u8F7D\u672A\u5B8C\u6210\uFF0C\u8BF7\u624B\u52A8\u8FD0\u884C: ${command}`,
|
|
8646
|
+
detail: stderr || errorMessage || (typeof result.status === "number" ? `exit status=${result.status}` : void 0)
|
|
8647
|
+
};
|
|
8648
|
+
}
|
|
8649
|
+
function buildEnvSwitchPayload(envName, deps = {}) {
|
|
8650
|
+
saveEnvName(envName);
|
|
8651
|
+
const urls = getEnvUrls(envName);
|
|
8652
|
+
const reload = triggerGatewayReloadAfterEnvSwitch(deps);
|
|
8653
|
+
return {
|
|
8654
|
+
ok: true,
|
|
8655
|
+
message: reload.ok ? `\u5DF2\u5207\u6362\u5230 ${envName} \u73AF\u5883\uFF0C\u5E76\u5DF2\u89E6\u53D1\u91CD\u8F7D` : `\u5DF2\u5207\u6362\u5230 ${envName} \u73AF\u5883`,
|
|
8656
|
+
env: envName,
|
|
8657
|
+
lightApiUrl: urls.lightApiUrl,
|
|
8658
|
+
relayTunnelUrl: urls.relayTunnelUrl,
|
|
8659
|
+
reload
|
|
8660
|
+
};
|
|
8661
|
+
}
|
|
8662
|
+
function registerEnvCli(ntf, deps = {}) {
|
|
8663
|
+
const env = ntf.command("env").description("\u73AF\u5883\u7BA1\u7406\uFF08\u5207\u6362 test / production\uFF09");
|
|
8664
|
+
env.command("show").description("\u663E\u793A\u5F53\u524D\u73AF\u5883\u53CA\u5BF9\u5E94\u7684\u63A5\u53E3\u5730\u5740").action(() => {
|
|
8665
|
+
output(buildEnvShowPayload(deps));
|
|
8555
8666
|
});
|
|
8556
|
-
env.command("switch <env>").description("\u5207\u6362\u73AF\u5883\
|
|
8667
|
+
env.command("switch <env>").description("\u5207\u6362\u73AF\u5883\uFF08test / production\uFF09").action((envName) => {
|
|
8557
8668
|
const available = getAvailableEnvs();
|
|
8558
8669
|
if (!available.includes(envName)) {
|
|
8559
8670
|
exitError(
|
|
@@ -8561,15 +8672,7 @@ function registerEnvCli(ntf) {
|
|
|
8561
8672
|
`\u65E0\u6548\u7684\u73AF\u5883\u540D\u79F0: ${envName}\uFF0C\u53EF\u9009\u503C: ${available.join(", ")}`
|
|
8562
8673
|
);
|
|
8563
8674
|
}
|
|
8564
|
-
|
|
8565
|
-
const urls = getEnvUrls(envName);
|
|
8566
|
-
output({
|
|
8567
|
-
ok: true,
|
|
8568
|
-
message: `\u5DF2\u5207\u6362\u5230 ${envName} \u73AF\u5883`,
|
|
8569
|
-
env: envName,
|
|
8570
|
-
lightApiUrl: urls.lightApiUrl,
|
|
8571
|
-
relayTunnelUrl: urls.relayTunnelUrl
|
|
8572
|
-
});
|
|
8675
|
+
output(buildEnvSwitchPayload(envName, deps));
|
|
8573
8676
|
});
|
|
8574
8677
|
}
|
|
8575
8678
|
|
|
@@ -9156,7 +9259,7 @@ function registerRecSetup(rec, ctx) {
|
|
|
9156
9259
|
}
|
|
9157
9260
|
|
|
9158
9261
|
// src/cli/update.ts
|
|
9159
|
-
var
|
|
9262
|
+
var import_node_child_process2 = require("child_process");
|
|
9160
9263
|
var import_node_fs20 = require("fs");
|
|
9161
9264
|
var import_node_path15 = require("path");
|
|
9162
9265
|
var import_node_os3 = __toESM(require("os"), 1);
|
|
@@ -9231,7 +9334,7 @@ async function runUpdate(ctx, opts) {
|
|
|
9231
9334
|
process.exit(1);
|
|
9232
9335
|
}
|
|
9233
9336
|
const stateDir = ctx.stateDir ?? resolveStateDir();
|
|
9234
|
-
const result = (0,
|
|
9337
|
+
const result = (0, import_node_child_process2.spawnSync)(
|
|
9235
9338
|
process.execPath,
|
|
9236
9339
|
[tmpScript, "--version", latest, "--state-dir", stateDir],
|
|
9237
9340
|
{ stdio: "inherit" }
|