@mingxy/ocosay 1.1.20 → 1.1.22
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/core/backends/speaker-backend.js +10 -1
- package/dist/package.json +1 -1
- package/dist/plugin.js +15 -9
- package/package.json +1 -1
|
@@ -3,7 +3,16 @@
|
|
|
3
3
|
* 使用 speaker npm 包直接输出 PCM 到 ALSA/PulseAudio
|
|
4
4
|
* 支持流式播放,但需要完整的音频头信息
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import { logger } from '../../utils/logger.js';
|
|
7
|
+
// 动态加载 speaker 模块
|
|
8
|
+
let Speaker;
|
|
9
|
+
try {
|
|
10
|
+
Speaker = require('speaker');
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
logger.warn({ err }, 'speaker not available');
|
|
14
|
+
Speaker = null;
|
|
15
|
+
}
|
|
7
16
|
/**
|
|
8
17
|
* SpeakerBackend - 使用 speaker 包的后端
|
|
9
18
|
* speaker 直接将 PCM 数据输出到系统音频设备
|
package/dist/package.json
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -7621,7 +7621,13 @@ var PlaySoundBackend = class {
|
|
|
7621
7621
|
};
|
|
7622
7622
|
|
|
7623
7623
|
// src/core/backends/speaker-backend.ts
|
|
7624
|
-
|
|
7624
|
+
var Speaker;
|
|
7625
|
+
try {
|
|
7626
|
+
Speaker = __require("speaker");
|
|
7627
|
+
} catch (err) {
|
|
7628
|
+
logger.warn({ err }, "speaker not available");
|
|
7629
|
+
Speaker = null;
|
|
7630
|
+
}
|
|
7625
7631
|
var SpeakerBackend = class {
|
|
7626
7632
|
name = "speaker";
|
|
7627
7633
|
supportsStreaming = true;
|
|
@@ -9899,6 +9905,8 @@ import { execSync as execSync2 } from "child_process";
|
|
|
9899
9905
|
import { createRequire } from "module";
|
|
9900
9906
|
var logger8 = createModuleLogger("Plugin");
|
|
9901
9907
|
var require2 = createRequire(import.meta.url);
|
|
9908
|
+
var opencodeNodeModules = join8(dirname2(require2.resolve("@opencode-ai/plugin")), "..", "..");
|
|
9909
|
+
var pluginRequire = createRequire(join8(opencodeNodeModules, "package.json"));
|
|
9902
9910
|
function getSkipFilePath() {
|
|
9903
9911
|
return join8(homedir3(), ".config", "opencode", ".naudiodon_skip");
|
|
9904
9912
|
}
|
|
@@ -10064,7 +10072,7 @@ async function ensureNaudiodonCompiled() {
|
|
|
10064
10072
|
}
|
|
10065
10073
|
function isModuleInstalled(moduleName) {
|
|
10066
10074
|
try {
|
|
10067
|
-
|
|
10075
|
+
pluginRequire.resolve(moduleName);
|
|
10068
10076
|
return true;
|
|
10069
10077
|
} catch {
|
|
10070
10078
|
return false;
|
|
@@ -10072,7 +10080,7 @@ function isModuleInstalled(moduleName) {
|
|
|
10072
10080
|
}
|
|
10073
10081
|
async function verifyModuleLoad(dep) {
|
|
10074
10082
|
try {
|
|
10075
|
-
|
|
10083
|
+
pluginRequire(dep);
|
|
10076
10084
|
logger8.info(`${dep} loaded successfully`);
|
|
10077
10085
|
return true;
|
|
10078
10086
|
} catch (err) {
|
|
@@ -10082,7 +10090,6 @@ async function verifyModuleLoad(dep) {
|
|
|
10082
10090
|
}
|
|
10083
10091
|
async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
10084
10092
|
const dep = "speaker";
|
|
10085
|
-
const basePath = dirname2(require2.resolve("./package.json"));
|
|
10086
10093
|
if (isModuleInstalled(dep)) {
|
|
10087
10094
|
logger8.info("speaker already installed");
|
|
10088
10095
|
if (await verifyModuleLoad(dep)) {
|
|
@@ -10092,7 +10099,7 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
|
10092
10099
|
notificationService.info("\u6B63\u5728\u7F16\u8BD1 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10093
10100
|
try {
|
|
10094
10101
|
execSync2("npm rebuild speaker", {
|
|
10095
|
-
cwd:
|
|
10102
|
+
cwd: opencodeNodeModules,
|
|
10096
10103
|
stdio: "inherit"
|
|
10097
10104
|
});
|
|
10098
10105
|
logger8.info("speaker rebuilt");
|
|
@@ -10108,7 +10115,7 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
|
10108
10115
|
notificationService.info("\u6B63\u5728\u5B89\u88C5 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10109
10116
|
try {
|
|
10110
10117
|
execSync2("npm install speaker", {
|
|
10111
|
-
cwd:
|
|
10118
|
+
cwd: opencodeNodeModules,
|
|
10112
10119
|
stdio: "inherit"
|
|
10113
10120
|
});
|
|
10114
10121
|
logger8.info("speaker installed");
|
|
@@ -10125,7 +10132,7 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
|
10125
10132
|
notificationService.info(`\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 speaker (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
|
|
10126
10133
|
try {
|
|
10127
10134
|
execSync2("npm rebuild speaker", {
|
|
10128
|
-
cwd:
|
|
10135
|
+
cwd: opencodeNodeModules,
|
|
10129
10136
|
stdio: "inherit"
|
|
10130
10137
|
});
|
|
10131
10138
|
logger8.info("speaker rebuilt");
|
|
@@ -10145,7 +10152,6 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
|
10145
10152
|
}
|
|
10146
10153
|
async function ensurePlaySoundInstalled() {
|
|
10147
10154
|
const dep = "play-sound";
|
|
10148
|
-
const basePath = dirname2(require2.resolve("./package.json"));
|
|
10149
10155
|
if (isModuleInstalled(dep)) {
|
|
10150
10156
|
logger8.info("play-sound already installed");
|
|
10151
10157
|
if (await verifyModuleLoad(dep)) {
|
|
@@ -10156,7 +10162,7 @@ async function ensurePlaySoundInstalled() {
|
|
|
10156
10162
|
notificationService.info("\u6B63\u5728\u5B89\u88C5 play-sound...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10157
10163
|
try {
|
|
10158
10164
|
execSync2("npm install play-sound", {
|
|
10159
|
-
cwd:
|
|
10165
|
+
cwd: opencodeNodeModules,
|
|
10160
10166
|
stdio: "inherit"
|
|
10161
10167
|
});
|
|
10162
10168
|
logger8.info("play-sound installed");
|