@mingxy/ocosay 1.1.26 → 1.1.28
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/package.json +1 -1
- package/dist/plugin.js +91 -112
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -10295,15 +10295,14 @@ async function verifyNaudiodonLoad() {
|
|
|
10295
10295
|
}
|
|
10296
10296
|
async function rebuildNaudiodonDependency(dep) {
|
|
10297
10297
|
const naudiodonPath = dirname2(require3.resolve("naudiodon"));
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
logger9.
|
|
10302
|
-
return true;
|
|
10303
|
-
} catch (err) {
|
|
10304
|
-
logger9.warn({ err }, `${dep} rebuild failed`);
|
|
10298
|
+
notificationService.info(`\u6B63\u5728\u7F16\u8BD1 ${dep}...`, "Ocosay \u4F9D\u8D56", 4e3);
|
|
10299
|
+
const result = await execAsync(`npm rebuild ${dep}`, naudiodonPath);
|
|
10300
|
+
if (result.error) {
|
|
10301
|
+
logger9.warn({ err: result.error }, `${dep} rebuild failed`);
|
|
10305
10302
|
return false;
|
|
10306
10303
|
}
|
|
10304
|
+
logger9.info(`${dep} rebuilt successfully`);
|
|
10305
|
+
return true;
|
|
10307
10306
|
}
|
|
10308
10307
|
async function fixNaudiodonDependencies(maxRetries = 5) {
|
|
10309
10308
|
const naudiodonPath = dirname2(require3.resolve("naudiodon"));
|
|
@@ -10322,24 +10321,24 @@ async function fixNaudiodonDependencies(maxRetries = 5) {
|
|
|
10322
10321
|
anySuccess = true;
|
|
10323
10322
|
}
|
|
10324
10323
|
} catch {
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10324
|
+
notificationService.info(`\u6B63\u5728\u5B89\u88C5 ${dep}...`, "Ocosay", 4e3);
|
|
10325
|
+
const installResult = await execAsync(`npm install ${dep}`, naudiodonPath);
|
|
10326
|
+
if (installResult.error) {
|
|
10327
|
+
logger9.warn({ err: installResult.error }, `${dep} install failed`);
|
|
10328
|
+
} else {
|
|
10328
10329
|
logger9.info(`${dep} installed successfully`);
|
|
10329
10330
|
anySuccess = true;
|
|
10330
|
-
} catch (installErr) {
|
|
10331
|
-
logger9.warn({ err: installErr }, `${dep} install failed`);
|
|
10332
10331
|
}
|
|
10333
10332
|
}
|
|
10334
10333
|
}
|
|
10335
10334
|
if (!anySuccess || !await verifyNaudiodonLoad()) {
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
|
|
10335
|
+
notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 4e3);
|
|
10336
|
+
const rebuildResult = await execAsync("npm rebuild naudiodon", naudiodonPath);
|
|
10337
|
+
if (rebuildResult.error) {
|
|
10338
|
+
logger9.warn({ err: rebuildResult.error }, "naudiodon rebuild failed");
|
|
10339
|
+
} else {
|
|
10339
10340
|
logger9.info("naudiodon rebuilt");
|
|
10340
10341
|
anySuccess = true;
|
|
10341
|
-
} catch (err) {
|
|
10342
|
-
logger9.warn({ err }, "naudiodon rebuild failed");
|
|
10343
10342
|
}
|
|
10344
10343
|
}
|
|
10345
10344
|
if (await verifyNaudiodonLoad()) {
|
|
@@ -10367,18 +10366,52 @@ async function ensureNaudiodonCompiled() {
|
|
|
10367
10366
|
try {
|
|
10368
10367
|
const naudiodonPath = dirname2(require3.resolve("naudiodon"));
|
|
10369
10368
|
logger9.info({ naudiodonPath }, "found naudiodon, rebuilding");
|
|
10370
|
-
await execAsync("npm rebuild naudiodon", naudiodonPath);
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10369
|
+
const rebuildResult = await execAsync("npm rebuild naudiodon", naudiodonPath);
|
|
10370
|
+
if (rebuildResult.error) {
|
|
10371
|
+
logger9.warn({ err: rebuildResult.error }, "naudiodon rebuild failed, checking for PortAudio");
|
|
10372
|
+
notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...", 5e3);
|
|
10373
|
+
const installed = await installPortAudio();
|
|
10374
|
+
if (installed.success) {
|
|
10375
|
+
const retryPath = dirname2(require3.resolve("naudiodon"));
|
|
10376
|
+
notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
|
|
10377
|
+
const retryResult = await execAsync("npm rebuild naudiodon", retryPath);
|
|
10378
|
+
if (retryResult.error) {
|
|
10379
|
+
logger9.error({ err: retryResult.error }, "naudiodon compile failed even after PortAudio install");
|
|
10380
|
+
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
|
|
10381
|
+
markNaudiodonSkipped();
|
|
10382
|
+
} else {
|
|
10383
|
+
logger9.info("naudiodon compiled successfully after PortAudio install");
|
|
10384
|
+
const loadSuccess = await verifyNaudiodonLoad();
|
|
10385
|
+
if (loadSuccess) {
|
|
10386
|
+
notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10387
|
+
} else {
|
|
10388
|
+
notificationService.warning("naudiodon \u52A0\u8F7D\u5931\u8D25", "\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56...", 5e3);
|
|
10389
|
+
const fixed = await fixNaudiodonDependencies();
|
|
10390
|
+
if (fixed) {
|
|
10391
|
+
notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10392
|
+
} else {
|
|
10393
|
+
markNaudiodonSkipped();
|
|
10394
|
+
}
|
|
10395
|
+
}
|
|
10396
|
+
}
|
|
10397
|
+
} else {
|
|
10398
|
+
logger9.error("PortAudio install failed");
|
|
10399
|
+
notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
|
|
10400
|
+
markNaudiodonSkipped();
|
|
10401
|
+
}
|
|
10375
10402
|
} else {
|
|
10376
|
-
|
|
10377
|
-
const
|
|
10378
|
-
if (
|
|
10379
|
-
notificationService.success("naudiodon \
|
|
10403
|
+
logger9.info("naudiodon compiled, verifying...");
|
|
10404
|
+
const loadSuccess = await verifyNaudiodonLoad();
|
|
10405
|
+
if (loadSuccess) {
|
|
10406
|
+
notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10380
10407
|
} else {
|
|
10381
|
-
|
|
10408
|
+
notificationService.warning("naudiodon \u52A0\u8F7D\u5931\u8D25", "\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56...", 5e3);
|
|
10409
|
+
const fixed = await fixNaudiodonDependencies();
|
|
10410
|
+
if (fixed) {
|
|
10411
|
+
notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10412
|
+
} else {
|
|
10413
|
+
markNaudiodonSkipped();
|
|
10414
|
+
}
|
|
10382
10415
|
}
|
|
10383
10416
|
}
|
|
10384
10417
|
} catch (err) {
|
|
@@ -10386,10 +10419,14 @@ async function ensureNaudiodonCompiled() {
|
|
|
10386
10419
|
notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...", 5e3);
|
|
10387
10420
|
const installed = await installPortAudio();
|
|
10388
10421
|
if (installed.success) {
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10422
|
+
const retryPath = dirname2(require3.resolve("naudiodon"));
|
|
10423
|
+
notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
|
|
10424
|
+
const retryResult = await execAsync("npm rebuild naudiodon", retryPath);
|
|
10425
|
+
if (retryResult.error) {
|
|
10426
|
+
logger9.error({ err: retryResult.error }, "naudiodon compile failed even after PortAudio install");
|
|
10427
|
+
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
|
|
10428
|
+
markNaudiodonSkipped();
|
|
10429
|
+
} else {
|
|
10393
10430
|
logger9.info("naudiodon compiled successfully after PortAudio install");
|
|
10394
10431
|
const loadSuccess = await verifyNaudiodonLoad();
|
|
10395
10432
|
if (loadSuccess) {
|
|
@@ -10400,13 +10437,9 @@ async function ensureNaudiodonCompiled() {
|
|
|
10400
10437
|
if (fixed) {
|
|
10401
10438
|
notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10402
10439
|
} else {
|
|
10403
|
-
|
|
10440
|
+
markNaudiodonSkipped();
|
|
10404
10441
|
}
|
|
10405
10442
|
}
|
|
10406
|
-
} catch (retryErr) {
|
|
10407
|
-
logger9.error({ err: retryErr }, "naudiodon compile failed even after PortAudio install");
|
|
10408
|
-
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
|
|
10409
|
-
markNaudiodonSkipped();
|
|
10410
10443
|
}
|
|
10411
10444
|
} else {
|
|
10412
10445
|
logger9.error("PortAudio install failed");
|
|
@@ -10443,18 +10476,17 @@ async function tryCompileSpeaker() {
|
|
|
10443
10476
|
}
|
|
10444
10477
|
}
|
|
10445
10478
|
if (!isModuleInstalled(dep)) {
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10479
|
+
const installResult = await execAsync("npm install speaker", opencodeNodeModules);
|
|
10480
|
+
if (installResult.error) {
|
|
10481
|
+
logger9.warn({ err: installResult.error }, "speaker install failed");
|
|
10449
10482
|
}
|
|
10450
10483
|
}
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
result.stderr = err.stderr?.toString() || err.message || "";
|
|
10484
|
+
const rebuildResult = await execAsync("npm rebuild speaker", opencodeNodeModules);
|
|
10485
|
+
if (rebuildResult.error) {
|
|
10486
|
+
result.stderr = rebuildResult.stderr || rebuildResult.error.message || "";
|
|
10487
|
+
}
|
|
10488
|
+
if (await verifyModuleLoad(dep)) {
|
|
10489
|
+
result.success = true;
|
|
10458
10490
|
}
|
|
10459
10491
|
return result;
|
|
10460
10492
|
}
|
|
@@ -10494,59 +10526,6 @@ async function initAsync() {
|
|
|
10494
10526
|
await ensureSpeakerInstalledAsync();
|
|
10495
10527
|
}, 100);
|
|
10496
10528
|
}
|
|
10497
|
-
async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
10498
|
-
const dep = "speaker";
|
|
10499
|
-
if (isModuleInstalled(dep)) {
|
|
10500
|
-
logger9.info("speaker already installed");
|
|
10501
|
-
if (await verifyModuleLoad(dep)) {
|
|
10502
|
-
return;
|
|
10503
|
-
}
|
|
10504
|
-
logger9.info("speaker installed but not loadable, rebuilding");
|
|
10505
|
-
notificationService.info("\u6B63\u5728\u7F16\u8BD1 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10506
|
-
try {
|
|
10507
|
-
await execAsync("npm rebuild speaker", opencodeNodeModules);
|
|
10508
|
-
logger9.info("speaker rebuilt");
|
|
10509
|
-
} catch (err) {
|
|
10510
|
-
logger9.warn({ err }, "speaker rebuild failed");
|
|
10511
|
-
}
|
|
10512
|
-
if (await verifyModuleLoad(dep)) {
|
|
10513
|
-
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10514
|
-
return;
|
|
10515
|
-
}
|
|
10516
|
-
} else {
|
|
10517
|
-
logger9.info("speaker not found, installing");
|
|
10518
|
-
notificationService.info("\u6B63\u5728\u5B89\u88C5 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10519
|
-
try {
|
|
10520
|
-
await execAsync("npm install speaker", opencodeNodeModules);
|
|
10521
|
-
logger9.info("speaker installed");
|
|
10522
|
-
} catch (err) {
|
|
10523
|
-
logger9.warn({ err }, "speaker install failed");
|
|
10524
|
-
}
|
|
10525
|
-
}
|
|
10526
|
-
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
10527
|
-
if (await verifyModuleLoad(dep)) {
|
|
10528
|
-
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10529
|
-
return;
|
|
10530
|
-
}
|
|
10531
|
-
logger9.info({ attempt, dep }, "speaker not loadable, trying rebuild");
|
|
10532
|
-
notificationService.info(`\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 speaker (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
|
|
10533
|
-
try {
|
|
10534
|
-
await execAsync("npm rebuild speaker", opencodeNodeModules);
|
|
10535
|
-
logger9.info("speaker rebuilt");
|
|
10536
|
-
} catch (err) {
|
|
10537
|
-
logger9.warn({ err }, "speaker rebuild failed");
|
|
10538
|
-
}
|
|
10539
|
-
if (await verifyModuleLoad(dep)) {
|
|
10540
|
-
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10541
|
-
return;
|
|
10542
|
-
}
|
|
10543
|
-
if (attempt < maxRetries - 1) {
|
|
10544
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
10545
|
-
}
|
|
10546
|
-
}
|
|
10547
|
-
logger9.error({ dep }, "speaker could not be compiled");
|
|
10548
|
-
notificationService.error("speaker \u7F16\u8BD1\u5931\u8D25", "\u8BF7\u624B\u52A8\u8FD0\u884C: npm install speaker && npm rebuild speaker", 8e3);
|
|
10549
|
-
}
|
|
10550
10529
|
async function ensurePlaySoundInstalled() {
|
|
10551
10530
|
const dep = "play-sound";
|
|
10552
10531
|
if (isModuleInstalled(dep)) {
|
|
@@ -10557,11 +10536,9 @@ async function ensurePlaySoundInstalled() {
|
|
|
10557
10536
|
}
|
|
10558
10537
|
logger9.info("play-sound not found, installing");
|
|
10559
10538
|
notificationService.info("\u6B63\u5728\u5B89\u88C5 play-sound...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
logger9.
|
|
10563
|
-
} catch (err) {
|
|
10564
|
-
logger9.warn({ err }, "play-sound install failed");
|
|
10539
|
+
const installResult = await execAsync("npm install play-sound", opencodeNodeModules);
|
|
10540
|
+
if (installResult.error) {
|
|
10541
|
+
logger9.warn({ err: installResult.error }, "play-sound install failed");
|
|
10565
10542
|
notificationService.warning(
|
|
10566
10543
|
"play-sound \u5B89\u88C5\u5931\u8D25",
|
|
10567
10544
|
"\u8BF7\u624B\u52A8\u8FD0\u884C: npm install play-sound",
|
|
@@ -10569,6 +10546,7 @@ async function ensurePlaySoundInstalled() {
|
|
|
10569
10546
|
);
|
|
10570
10547
|
return;
|
|
10571
10548
|
}
|
|
10549
|
+
logger9.info("play-sound installed");
|
|
10572
10550
|
if (await verifyModuleLoad(dep)) {
|
|
10573
10551
|
notificationService.success("play-sound \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10574
10552
|
} else {
|
|
@@ -10580,7 +10558,9 @@ async function ensurePlaySoundInstalled() {
|
|
|
10580
10558
|
}
|
|
10581
10559
|
}
|
|
10582
10560
|
async function ensureOptionalDepsInstalled() {
|
|
10583
|
-
|
|
10561
|
+
ensureSpeakerCompiledAsync().catch((err) => {
|
|
10562
|
+
logger9.warn({ err }, "ensureSpeakerCompiledAsync failed");
|
|
10563
|
+
});
|
|
10584
10564
|
await ensurePlaySoundInstalled();
|
|
10585
10565
|
}
|
|
10586
10566
|
function execCmd2(cmd) {
|
|
@@ -10635,18 +10615,16 @@ async function installPortAudio() {
|
|
|
10635
10615
|
const runInstall = async (cmd, desc) => {
|
|
10636
10616
|
logger9.info(`Running: ${cmd}`);
|
|
10637
10617
|
notificationService.info(desc, "\u6B63\u5728\u5B89\u88C5...", 5e3);
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
} catch (err) {
|
|
10642
|
-
const msg = err.message || "";
|
|
10618
|
+
const result = await execAsync(cmd);
|
|
10619
|
+
if (result.error) {
|
|
10620
|
+
const msg = result.error.message || "";
|
|
10643
10621
|
if (msg.includes("sudo") || msg.includes("password") || msg.includes("Password")) {
|
|
10644
10622
|
notificationService.error(
|
|
10645
10623
|
"\u9700\u8981 sudo \u6743\u9650",
|
|
10646
10624
|
"# \u8BF7\u5728WSL\u7EC8\u7AEF\u6267\u884C\u4E00\u6B21\nsudo visudo\n# \u6DFB\u52A0\u884C\uFF1Ayour user name ALL=(ALL) NOPASSWD: ALL",
|
|
10647
10625
|
1e4
|
|
10648
10626
|
);
|
|
10649
|
-
logger9.error({ err }, "\u9700\u8981 sudo \u6743\u9650 \u8BF7\u5728WSL\u7EC8\u7AEF\u6267\u884C\u4E00\u6B21sudo visudo # \u6DFB\u52A0\u884C\uFF1Ayour user name ALL=(ALL) NOPASSWD: ALL");
|
|
10627
|
+
logger9.error({ err: result.error }, "\u9700\u8981 sudo \u6743\u9650 \u8BF7\u5728WSL\u7EC8\u7AEF\u6267\u884C\u4E00\u6B21sudo visudo # \u6DFB\u52A0\u884C\uFF1Ayour user name ALL=(ALL) NOPASSWD: ALL");
|
|
10650
10628
|
return false;
|
|
10651
10629
|
}
|
|
10652
10630
|
if (msg.includes("already") || msg.includes("is already")) {
|
|
@@ -10654,9 +10632,10 @@ async function installPortAudio() {
|
|
|
10654
10632
|
return true;
|
|
10655
10633
|
}
|
|
10656
10634
|
notificationService.error(desc + " \u5931\u8D25", msg.substring(0, 100), 8e3);
|
|
10657
|
-
logger9.error({ err }, `install failed: ${desc}`);
|
|
10635
|
+
logger9.error({ err: result.error }, `install failed: ${desc}`);
|
|
10658
10636
|
return false;
|
|
10659
10637
|
}
|
|
10638
|
+
return true;
|
|
10660
10639
|
};
|
|
10661
10640
|
if (platform === "linux" || wsl) {
|
|
10662
10641
|
notificationService.info("\u68C0\u6D4B ffmpeg...", "\u97F3\u9891\u540E\u7AEF", 5e3);
|