@mingxy/ocosay 1.1.27 → 1.1.29
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 +9 -59
- package/dist/utils/logger.js +5 -5
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -6774,14 +6774,15 @@ var createFormatStream = () => new Transform({
|
|
|
6774
6774
|
callback();
|
|
6775
6775
|
}
|
|
6776
6776
|
});
|
|
6777
|
-
var stdoutStream = createFormatStream();
|
|
6778
|
-
stdoutStream.pipe(process.stdout);
|
|
6779
6777
|
var fileStream = null;
|
|
6780
6778
|
try {
|
|
6781
6779
|
const fileDest = import_pino.default.destination({ dest: logFile, mkdir: true });
|
|
6782
6780
|
fileStream = createFormatStream();
|
|
6783
6781
|
fileStream.pipe(fileDest);
|
|
6784
6782
|
} catch {
|
|
6783
|
+
const stdoutStream = createFormatStream();
|
|
6784
|
+
stdoutStream.pipe(process.stdout);
|
|
6785
|
+
fileStream = stdoutStream;
|
|
6785
6786
|
}
|
|
6786
6787
|
var logger = (0, import_pino.default)(
|
|
6787
6788
|
{
|
|
@@ -6793,8 +6794,7 @@ var logger = (0, import_pino.default)(
|
|
|
6793
6794
|
}
|
|
6794
6795
|
},
|
|
6795
6796
|
import_pino.default.multistream([
|
|
6796
|
-
{ stream:
|
|
6797
|
-
...fileStream ? [{ stream: fileStream }] : []
|
|
6797
|
+
{ stream: fileStream }
|
|
6798
6798
|
])
|
|
6799
6799
|
);
|
|
6800
6800
|
function createModuleLogger(module) {
|
|
@@ -10482,8 +10482,9 @@ async function tryCompileSpeaker() {
|
|
|
10482
10482
|
}
|
|
10483
10483
|
}
|
|
10484
10484
|
const rebuildResult = await execAsync("npm rebuild speaker", opencodeNodeModules);
|
|
10485
|
+
result.stderr = (rebuildResult.stdout || "") + "\n" + (rebuildResult.stderr || "");
|
|
10485
10486
|
if (rebuildResult.error) {
|
|
10486
|
-
result.stderr
|
|
10487
|
+
result.stderr += "\n" + (rebuildResult.error.message || "");
|
|
10487
10488
|
}
|
|
10488
10489
|
if (await verifyModuleLoad(dep)) {
|
|
10489
10490
|
result.success = true;
|
|
@@ -10526,59 +10527,6 @@ async function initAsync() {
|
|
|
10526
10527
|
await ensureSpeakerInstalledAsync();
|
|
10527
10528
|
}, 100);
|
|
10528
10529
|
}
|
|
10529
|
-
async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
10530
|
-
const dep = "speaker";
|
|
10531
|
-
if (isModuleInstalled(dep)) {
|
|
10532
|
-
logger9.info("speaker already installed");
|
|
10533
|
-
if (await verifyModuleLoad(dep)) {
|
|
10534
|
-
return;
|
|
10535
|
-
}
|
|
10536
|
-
logger9.info("speaker installed but not loadable, rebuilding");
|
|
10537
|
-
notificationService.info("\u6B63\u5728\u7F16\u8BD1 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10538
|
-
const rebuildResult = await execAsync("npm rebuild speaker", opencodeNodeModules);
|
|
10539
|
-
if (rebuildResult.error) {
|
|
10540
|
-
logger9.warn({ err: rebuildResult.error }, "speaker rebuild failed");
|
|
10541
|
-
} else {
|
|
10542
|
-
logger9.info("speaker rebuilt");
|
|
10543
|
-
}
|
|
10544
|
-
if (await verifyModuleLoad(dep)) {
|
|
10545
|
-
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10546
|
-
return;
|
|
10547
|
-
}
|
|
10548
|
-
} else {
|
|
10549
|
-
logger9.info("speaker not found, installing");
|
|
10550
|
-
notificationService.info("\u6B63\u5728\u5B89\u88C5 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10551
|
-
const installResult = await execAsync("npm install speaker", opencodeNodeModules);
|
|
10552
|
-
if (installResult.error) {
|
|
10553
|
-
logger9.warn({ err: installResult.error }, "speaker install failed");
|
|
10554
|
-
} else {
|
|
10555
|
-
logger9.info("speaker installed");
|
|
10556
|
-
}
|
|
10557
|
-
}
|
|
10558
|
-
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
10559
|
-
if (await verifyModuleLoad(dep)) {
|
|
10560
|
-
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10561
|
-
return;
|
|
10562
|
-
}
|
|
10563
|
-
logger9.info({ attempt, dep }, "speaker not loadable, trying rebuild");
|
|
10564
|
-
notificationService.info(`\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 speaker (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
|
|
10565
|
-
const rebuildResult = await execAsync("npm rebuild speaker", opencodeNodeModules);
|
|
10566
|
-
if (rebuildResult.error) {
|
|
10567
|
-
logger9.warn({ err: rebuildResult.error }, "speaker rebuild failed");
|
|
10568
|
-
} else {
|
|
10569
|
-
logger9.info("speaker rebuilt");
|
|
10570
|
-
}
|
|
10571
|
-
if (await verifyModuleLoad(dep)) {
|
|
10572
|
-
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10573
|
-
return;
|
|
10574
|
-
}
|
|
10575
|
-
if (attempt < maxRetries - 1) {
|
|
10576
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
10577
|
-
}
|
|
10578
|
-
}
|
|
10579
|
-
logger9.error({ dep }, "speaker could not be compiled");
|
|
10580
|
-
notificationService.error("speaker \u7F16\u8BD1\u5931\u8D25", "\u8BF7\u624B\u52A8\u8FD0\u884C: npm install speaker && npm rebuild speaker", 8e3);
|
|
10581
|
-
}
|
|
10582
10530
|
async function ensurePlaySoundInstalled() {
|
|
10583
10531
|
const dep = "play-sound";
|
|
10584
10532
|
if (isModuleInstalled(dep)) {
|
|
@@ -10611,7 +10559,9 @@ async function ensurePlaySoundInstalled() {
|
|
|
10611
10559
|
}
|
|
10612
10560
|
}
|
|
10613
10561
|
async function ensureOptionalDepsInstalled() {
|
|
10614
|
-
|
|
10562
|
+
ensureSpeakerCompiledAsync().catch((err) => {
|
|
10563
|
+
logger9.warn({ err }, "ensureSpeakerCompiledAsync failed");
|
|
10564
|
+
});
|
|
10615
10565
|
await ensurePlaySoundInstalled();
|
|
10616
10566
|
}
|
|
10617
10567
|
function execCmd2(cmd) {
|
package/dist/utils/logger.js
CHANGED
|
@@ -33,8 +33,6 @@ const createFormatStream = () => new Transform({
|
|
|
33
33
|
callback();
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
const stdoutStream = createFormatStream();
|
|
37
|
-
stdoutStream.pipe(process.stdout);
|
|
38
36
|
let fileStream = null;
|
|
39
37
|
try {
|
|
40
38
|
const fileDest = pino.destination({ dest: logFile, mkdir: true });
|
|
@@ -42,7 +40,10 @@ try {
|
|
|
42
40
|
fileStream.pipe(fileDest);
|
|
43
41
|
}
|
|
44
42
|
catch {
|
|
45
|
-
// fallback
|
|
43
|
+
// fallback: 如果文件流创建失败,使用 stdout
|
|
44
|
+
const stdoutStream = createFormatStream();
|
|
45
|
+
stdoutStream.pipe(process.stdout);
|
|
46
|
+
fileStream = stdoutStream;
|
|
46
47
|
}
|
|
47
48
|
export const logger = pino({
|
|
48
49
|
level,
|
|
@@ -52,8 +53,7 @@ export const logger = pino({
|
|
|
52
53
|
level: (label) => ({ level: label }),
|
|
53
54
|
},
|
|
54
55
|
}, pino.multistream([
|
|
55
|
-
{ stream:
|
|
56
|
-
...(fileStream ? [{ stream: fileStream }] : [])
|
|
56
|
+
{ stream: fileStream }
|
|
57
57
|
]));
|
|
58
58
|
/**
|
|
59
59
|
* 创建带模块后缀的logger
|