@mingxy/ocosay 1.1.30 → 1.1.32

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.
@@ -82,6 +82,7 @@ export async function installSystemPackages(packages, notifSvc) {
82
82
  execSync('sudo apt-get update', {
83
83
  timeout: 120000,
84
84
  encoding: 'utf8',
85
+ stdio: ['pipe', 'pipe', 'pipe'],
85
86
  });
86
87
  silentLog('info', 'apt-get update 完成');
87
88
  }
@@ -93,6 +94,7 @@ export async function installSystemPackages(packages, notifSvc) {
93
94
  const output = execSync(fullCommand, {
94
95
  timeout: 300000,
95
96
  encoding: 'utf8',
97
+ stdio: ['pipe', 'pipe', 'pipe'],
96
98
  });
97
99
  silentLog('info', `安装输出: ${output.substring(0, 500)}`);
98
100
  const verifiedPackages = [];
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/ocosay",
3
- "version": "1.1.29",
3
+ "version": "1.1.31",
4
4
  "description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",
package/dist/plugin.js CHANGED
@@ -2437,7 +2437,7 @@ var require_thread_stream = __commonJS({
2437
2437
  var require_transport = __commonJS({
2438
2438
  "node_modules/pino/lib/transport.js"(exports, module) {
2439
2439
  "use strict";
2440
- var { createRequire: createRequire3 } = __require("module");
2440
+ var { createRequire: createRequire2 } = __require("module");
2441
2441
  var { existsSync: existsSync8 } = __require("node:fs");
2442
2442
  var getCallers = require_caller();
2443
2443
  var { join: join9, isAbsolute, sep } = __require("node:path");
@@ -2640,7 +2640,7 @@ var require_transport = __commonJS({
2640
2640
  for (const filePath of callers) {
2641
2641
  try {
2642
2642
  const context = filePath === "node:repl" ? process.cwd() + sep : filePath;
2643
- fixTarget2 = createRequire3(context).resolve(origin);
2643
+ fixTarget2 = createRequire2(context).resolve(origin);
2644
2644
  break;
2645
2645
  } catch (err) {
2646
2646
  continue;
@@ -9901,358 +9901,8 @@ import { readFileSync as readFileSync2, existsSync as existsSync7, writeFileSync
9901
9901
  import { fileURLToPath } from "url";
9902
9902
  import { dirname as dirname2, join as join8 } from "path";
9903
9903
  import { homedir as homedir3 } from "os";
9904
- import { exec, execSync as execSync4 } from "child_process";
9905
- import { createRequire as createRequire2 } from "module";
9906
-
9907
- // src/core/dependency-detector.ts
9908
- import { execSync as execSync2 } from "child_process";
9909
- function parseMissingHeaders(errorOutput) {
9910
- const pattern = /fatal error:\s+([^:]+):\s+No such file or directory/g;
9911
- const headers = [];
9912
- let match = pattern.exec(errorOutput);
9913
- while (match !== null) {
9914
- headers.push(match[1]);
9915
- match = pattern.exec(errorOutput);
9916
- }
9917
- return headers;
9918
- }
9919
- function execCapture(cmd, cwd) {
9920
- try {
9921
- const stdout = execSync2(cmd, {
9922
- cwd,
9923
- encoding: "utf8",
9924
- stdio: ["pipe", "pipe", "pipe"]
9925
- });
9926
- return { success: true, stdout, stderr: "" };
9927
- } catch (err) {
9928
- const error = err;
9929
- return {
9930
- success: false,
9931
- stdout: error.stdout ? error.stdout.toString() : "",
9932
- stderr: error.stderr ? error.stderr.toString() : ""
9933
- };
9934
- }
9935
- }
9936
- function detectMissingDependencies(errorOutput) {
9937
- const missingHeaders = parseMissingHeaders(errorOutput);
9938
- return {
9939
- missingHeaders,
9940
- rawOutput: errorOutput
9941
- };
9942
- }
9943
-
9944
- // src/core/dependency-mapper.ts
9904
+ import { exec, execSync as execSync2 } from "child_process";
9945
9905
  import { createRequire } from "module";
9946
- var require2 = createRequire(import.meta.url);
9947
- var HEADER_TO_PACKAGE = [
9948
- // ALSA - Linux音频库
9949
- {
9950
- header: "alsa/asoundlib.h",
9951
- package: "libasound2-dev"
9952
- },
9953
- // PortAudio - 跨平台音频I/O库
9954
- {
9955
- header: "portaudio.h",
9956
- package: "libportaudio-dev",
9957
- packageMac: "portaudio",
9958
- packageWin: "portaudio"
9959
- },
9960
- // FFmpeg相关
9961
- {
9962
- header: "libavcodec/avcodec.h",
9963
- package: "libavcodec-dev",
9964
- packageMac: "ffmpeg",
9965
- packageWin: "ffmpeg"
9966
- },
9967
- {
9968
- header: "libavformat/avformat.h",
9969
- package: "libavformat-dev",
9970
- packageMac: "ffmpeg",
9971
- packageWin: "ffmpeg"
9972
- },
9973
- {
9974
- header: "libavutil/avutil.h",
9975
- package: "libavutil-dev",
9976
- packageMac: "ffmpeg",
9977
- packageWin: "ffmpeg"
9978
- },
9979
- {
9980
- header: "libswresample/swresample.h",
9981
- package: "libswresample-dev",
9982
- packageMac: "ffmpeg",
9983
- packageWin: "ffmpeg"
9984
- },
9985
- // OpenAL - 3D音频API
9986
- {
9987
- header: "AL/al.h",
9988
- package: "libopenal-dev",
9989
- packageMac: "openal",
9990
- packageWin: "openal"
9991
- },
9992
- // SDL - 多媒体库
9993
- {
9994
- header: "SDL2/SDL.h",
9995
- package: "libsdl2-dev",
9996
- packageMac: "sdl2",
9997
- packageWin: "sdl2"
9998
- },
9999
- // PulseAudio - Linux音频服务
10000
- {
10001
- header: "pulse/pulseaudio.h",
10002
- package: "libpulse-dev"
10003
- },
10004
- // CoreAudio - macOS音频框架 (无头文件,纯框架)
10005
- {
10006
- header: "CoreAudio/CoreAudio.h",
10007
- package: "\u81FA",
10008
- // macOS系统框架,无需安装包
10009
- packageMac: ""
10010
- },
10011
- // Windows特定
10012
- {
10013
- header: "windows.h",
10014
- package: "",
10015
- // Linux上不存在
10016
- packageWin: ""
10017
- // Windows SDK自带
10018
- }
10019
- ];
10020
- function detectPlatform() {
10021
- const platform = process.platform;
10022
- const isWsl3 = detectWsl();
10023
- let packageManager;
10024
- let installCommand;
10025
- if (platform === "linux" || isWsl3) {
10026
- packageManager = "apt-get";
10027
- installCommand = "sudo apt-get install -y";
10028
- } else if (platform === "darwin") {
10029
- packageManager = "brew";
10030
- installCommand = "brew install";
10031
- } else {
10032
- packageManager = "choco";
10033
- installCommand = "choco install -y";
10034
- }
10035
- return {
10036
- platform,
10037
- isWsl: isWsl3,
10038
- packageManager,
10039
- installCommand
10040
- };
10041
- }
10042
- function detectWsl() {
10043
- if (process.platform !== "linux") return false;
10044
- try {
10045
- return require2("fs").readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
10046
- } catch {
10047
- return false;
10048
- }
10049
- }
10050
- function getPackageForPlatform(mapping, platform, isWsl3) {
10051
- if (platform === "win32") {
10052
- if (isWsl3) {
10053
- return mapping.package || null;
10054
- }
10055
- return mapping.packageWin || mapping.package || null;
10056
- }
10057
- if (platform === "darwin") {
10058
- if (mapping.packageMac === "") return null;
10059
- return mapping.packageMac || mapping.package || null;
10060
- }
10061
- if (mapping.package === "") return null;
10062
- return mapping.package || null;
10063
- }
10064
- function mapHeaderToPackages(header, platform) {
10065
- const exactMatch = HEADER_TO_PACKAGE.find(
10066
- (m) => m.header.toLowerCase() === header.toLowerCase()
10067
- );
10068
- if (exactMatch) {
10069
- const pkg = getPackageForPlatform(exactMatch, platform, detectWsl());
10070
- if (pkg && pkg.length > 0 && pkg !== "\u81FA") {
10071
- return [pkg];
10072
- }
10073
- return [];
10074
- }
10075
- const headerBasename = header.split("/").pop()?.toLowerCase() || "";
10076
- const fuzzyMatch = HEADER_TO_PACKAGE.find((m) => {
10077
- const mappingBasename = m.header.split("/").pop()?.toLowerCase() || "";
10078
- return mappingBasename === headerBasename;
10079
- });
10080
- if (fuzzyMatch) {
10081
- const pkg = getPackageForPlatform(fuzzyMatch, platform, detectWsl());
10082
- if (pkg && pkg.length > 0 && pkg !== "\u81FA") {
10083
- return [pkg];
10084
- }
10085
- return [];
10086
- }
10087
- return [];
10088
- }
10089
- function mapHeadersToPackages(headers, platform) {
10090
- const packageSet = /* @__PURE__ */ new Set();
10091
- for (const header of headers) {
10092
- const packages = mapHeaderToPackages(header, platform);
10093
- for (const pkg of packages) {
10094
- if (pkg.length > 0) {
10095
- packageSet.add(pkg);
10096
- }
10097
- }
10098
- }
10099
- return Array.from(packageSet);
10100
- }
10101
-
10102
- // src/core/dependency-installer.ts
10103
- import { execSync as execSync3 } from "child_process";
10104
- var logger8 = createModuleLogger("DependencyInstaller");
10105
- function getInstallCommandPrefix() {
10106
- const { platform, isWsl: isWsl3 } = detectPlatform();
10107
- if (platform === "linux" || isWsl3) {
10108
- return "sudo apt-get install -y";
10109
- } else if (platform === "darwin") {
10110
- return "brew install";
10111
- }
10112
- return "choco install -y";
10113
- }
10114
- function getCheckCommand(packageName) {
10115
- const { platform, isWsl: isWsl3 } = detectPlatform();
10116
- if (platform === "linux" || isWsl3) {
10117
- return `dpkg -s ${packageName} 2>/dev/null | grep -q "Status: install ok installed"`;
10118
- } else if (platform === "darwin") {
10119
- return `brew list ${packageName} &>/dev/null`;
10120
- }
10121
- return `choco list --local-only ${packageName} &>/dev/null`;
10122
- }
10123
- function silentLog(level2, message, extra) {
10124
- switch (level2) {
10125
- case "info":
10126
- logger8.info(extra || {}, message);
10127
- break;
10128
- case "warn":
10129
- logger8.warn(extra || {}, message);
10130
- break;
10131
- case "error":
10132
- logger8.error(extra || {}, message);
10133
- break;
10134
- }
10135
- }
10136
- function canSudoWithoutPassword() {
10137
- try {
10138
- execSync3("sudo -n true 2>&1", { stdio: "pipe" });
10139
- return true;
10140
- } catch {
10141
- return false;
10142
- }
10143
- }
10144
- async function installSystemPackages(packages, notifSvc) {
10145
- const result = {
10146
- success: false,
10147
- installedPackages: [],
10148
- failedPackages: []
10149
- };
10150
- const validPackages = packages.filter((p) => p && p.length > 0 && p !== "\u81FA");
10151
- if (validPackages.length === 0) {
10152
- silentLog("info", "\u6CA1\u6709\u9700\u8981\u5B89\u88C5\u7684\u5305");
10153
- return { ...result, success: true };
10154
- }
10155
- silentLog("info", `\u5F00\u59CB\u5B89\u88C5\u7CFB\u7EDF\u4F9D\u8D56: ${validPackages.join(", ")}`, { packages: validPackages });
10156
- notifSvc?.info("\u6B63\u5728\u5B89\u88C5\u7CFB\u7EDF\u4F9D\u8D56...", "Ocosay", 3e3);
10157
- const installCommand = getInstallCommandPrefix();
10158
- const fullCommand = `${installCommand} ${validPackages.join(" ")}`;
10159
- silentLog("info", `\u6267\u884C\u5B89\u88C5\u547D\u4EE4: ${fullCommand}`);
10160
- if (!canSudoWithoutPassword()) {
10161
- const msg = "\u9700\u8981 sudo \u6743\u9650\uFF0C\u8BF7\u786E\u4FDD\u5DF2\u914D\u7F6E NOPASSWD";
10162
- result.error = msg;
10163
- notifSvc?.error("\u9700\u8981 sudo \u6743\u9650", "\u8BF7\u5728\u7EC8\u7AEF\u6267\u884C: sudo visudo \u6DFB\u52A0 NOPASSWD \u914D\u7F6E\uFF0C\u914D\u7F6E\u597D\u540E\u8BF7\u91CD\u542F OpenCode", 1e4);
10164
- silentLog("error", msg);
10165
- return result;
10166
- }
10167
- try {
10168
- const { platform, isWsl: isWsl3 } = detectPlatform();
10169
- if (platform === "linux" || isWsl3) {
10170
- notifSvc?.info("\u6B63\u5728\u66F4\u65B0\u5305\u5217\u8868...", "Ocosay", 3e3);
10171
- silentLog("info", "\u66F4\u65B0 apt \u5305\u5217\u8868");
10172
- try {
10173
- execSync3("sudo apt-get update", {
10174
- timeout: 12e4,
10175
- encoding: "utf8"
10176
- });
10177
- silentLog("info", "apt-get update \u5B8C\u6210");
10178
- } catch (updateErr) {
10179
- silentLog("warn", "apt-get update \u5931\u8D25\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\u5B89\u88C5", { error: String(updateErr) });
10180
- }
10181
- }
10182
- notifSvc?.info(`\u6B63\u5728\u5B89\u88C5 ${validPackages.length} \u4E2A\u5305...`, "Ocosay", 5e3);
10183
- const output = execSync3(fullCommand, {
10184
- timeout: 3e5,
10185
- encoding: "utf8"
10186
- });
10187
- silentLog("info", `\u5B89\u88C5\u8F93\u51FA: ${output.substring(0, 500)}`);
10188
- const verifiedPackages = [];
10189
- const failedPackages = [];
10190
- for (const pkg of validPackages) {
10191
- const isInstalled = await verifyInstallation([pkg]);
10192
- if (isInstalled) {
10193
- verifiedPackages.push(pkg);
10194
- silentLog("info", `\u5305 ${pkg} \u5B89\u88C5\u9A8C\u8BC1\u6210\u529F`);
10195
- } else {
10196
- failedPackages.push(pkg);
10197
- silentLog("warn", `\u5305 ${pkg} \u5B89\u88C5\u9A8C\u8BC1\u5931\u8D25`);
10198
- }
10199
- }
10200
- result.installedPackages = verifiedPackages;
10201
- result.failedPackages = failedPackages;
10202
- result.success = failedPackages.length === 0;
10203
- if (result.success) {
10204
- notifSvc?.success("\u7CFB\u7EDF\u4F9D\u8D56\u5B89\u88C5\u6210\u529F", verifiedPackages.join(", "), 5e3);
10205
- silentLog("info", `\u6240\u6709\u5305\u5B89\u88C5\u6210\u529F: ${verifiedPackages.join(", ")}`);
10206
- } else {
10207
- const errorMsg = failedPackages.length > 0 ? `\u4EE5\u4E0B\u5305\u5B89\u88C5\u5931\u8D25: ${failedPackages.join(", ")}` : "\u90E8\u5206\u5305\u5B89\u88C5\u5931\u8D25";
10208
- result.error = errorMsg;
10209
- notifSvc?.warning("\u90E8\u5206\u4F9D\u8D56\u5B89\u88C5\u5931\u8D25", errorMsg, 8e3);
10210
- silentLog("warn", errorMsg);
10211
- }
10212
- } catch (err) {
10213
- const errorMessage = err instanceof Error ? err.message : String(err);
10214
- silentLog("error", `\u5B89\u88C5\u547D\u4EE4\u6267\u884C\u5931\u8D25: ${errorMessage}`, { error: errorMessage });
10215
- if (errorMessage.includes("sudo") || errorMessage.toLowerCase().includes("password")) {
10216
- result.error = "\u9700\u8981 sudo \u6743\u9650\uFF0C\u8BF7\u786E\u4FDD\u5DF2\u914D\u7F6E NOPASSWD";
10217
- notifSvc?.error("\u9700\u8981 sudo \u6743\u9650", "\u8BF7\u5728\u7EC8\u7AEF\u6267\u884C: sudo visudo", 1e4);
10218
- } else if (errorMessage.includes("already") || errorMessage.includes("is already")) {
10219
- result.success = true;
10220
- result.installedPackages = validPackages;
10221
- notifSvc?.success("\u4F9D\u8D56\u5DF2\u5B58\u5728", "\u65E0\u9700\u91CD\u65B0\u5B89\u88C5", 3e3);
10222
- } else {
10223
- result.error = errorMessage;
10224
- notifSvc?.error("\u4F9D\u8D56\u5B89\u88C5\u5931\u8D25", errorMessage.substring(0, 200), 8e3);
10225
- }
10226
- }
10227
- return result;
10228
- }
10229
- async function verifyInstallation(packages) {
10230
- if (packages.length === 0) {
10231
- return true;
10232
- }
10233
- const validPackages = packages.filter((p) => p && p.length > 0 && p !== "\u81FA");
10234
- if (validPackages.length === 0) {
10235
- return true;
10236
- }
10237
- silentLog("info", `\u9A8C\u8BC1\u5305\u5B89\u88C5\u72B6\u6001: ${validPackages.join(", ")}`);
10238
- try {
10239
- for (const pkg of validPackages) {
10240
- const checkCmd = getCheckCommand(pkg);
10241
- const { success } = execCapture(checkCmd);
10242
- if (!success) {
10243
- silentLog("warn", `\u5305 ${pkg} \u9A8C\u8BC1\u5931\u8D25`);
10244
- return false;
10245
- }
10246
- }
10247
- silentLog("info", `\u6240\u6709\u5305\u9A8C\u8BC1\u901A\u8FC7: ${validPackages.join(", ")}`);
10248
- return true;
10249
- } catch (err) {
10250
- silentLog("error", `\u9A8C\u8BC1\u8FC7\u7A0B\u5F02\u5E38: ${String(err)}`);
10251
- return false;
10252
- }
10253
- }
10254
-
10255
- // src/plugin.ts
10256
9906
  function execAsync(cmd, cwd) {
10257
9907
  return new Promise((resolve) => {
10258
9908
  exec(cmd, { cwd, encoding: "utf8" }, (error, stdout, stderr) => {
@@ -10260,12 +9910,12 @@ function execAsync(cmd, cwd) {
10260
9910
  });
10261
9911
  });
10262
9912
  }
10263
- var logger9 = createModuleLogger("Plugin");
10264
- var require3 = createRequire2(import.meta.url);
10265
- var opencodeBinPath = execSync4("which opencode").toString().trim();
9913
+ var logger8 = createModuleLogger("Plugin");
9914
+ var require2 = createRequire(import.meta.url);
9915
+ var opencodeBinPath = execSync2("which opencode").toString().trim();
10266
9916
  var opencodeRoot = dirname2(dirname2(opencodeBinPath));
10267
9917
  var opencodeNodeModules = join8(opencodeRoot, "node_modules");
10268
- var pluginRequire = createRequire2(join8(opencodeNodeModules, "package.json"));
9918
+ var pluginRequire = createRequire(join8(opencodeNodeModules, "package.json"));
10269
9919
  function getSkipFilePath() {
10270
9920
  return join8(homedir3(), ".config", "opencode", ".naudiodon_skip");
10271
9921
  }
@@ -10284,38 +9934,38 @@ async function markNaudiodonSkipped() {
10284
9934
  }
10285
9935
  async function verifyNaudiodonLoad() {
10286
9936
  try {
10287
- require3("naudiodon");
10288
- logger9.info("naudiodon loaded successfully");
9937
+ require2("naudiodon");
9938
+ logger8.info("naudiodon loaded successfully");
10289
9939
  return true;
10290
9940
  } catch (err) {
10291
- logger9.warn({ err }, "naudiodon load failed after rebuild");
9941
+ logger8.warn({ err }, "naudiodon load failed after rebuild");
10292
9942
  return false;
10293
9943
  }
10294
9944
  }
10295
9945
  async function rebuildNaudiodonDependency(dep) {
10296
- const naudiodonPath = dirname2(require3.resolve("naudiodon"));
9946
+ const naudiodonPath = dirname2(require2.resolve("naudiodon"));
10297
9947
  notificationService.info(`\u6B63\u5728\u7F16\u8BD1 ${dep}...`, "Ocosay \u4F9D\u8D56", 4e3);
10298
9948
  const result = await execAsync(`npm rebuild ${dep}`, naudiodonPath);
10299
9949
  if (result.error) {
10300
- logger9.warn({ err: result.error }, `${dep} rebuild failed`);
9950
+ logger8.warn({ err: result.error }, `${dep} rebuild failed`);
10301
9951
  return false;
10302
9952
  }
10303
- logger9.info(`${dep} rebuilt successfully`);
9953
+ logger8.info(`${dep} rebuilt successfully`);
10304
9954
  return true;
10305
9955
  }
10306
9956
  async function fixNaudiodonDependencies(maxRetries = 5) {
10307
- const naudiodonPath = dirname2(require3.resolve("naudiodon"));
9957
+ const naudiodonPath = dirname2(require2.resolve("naudiodon"));
10308
9958
  const criticalDeps = ["segfault-handler", "bindings", "node-pre-gyp"];
10309
9959
  for (let attempt = 0; attempt < maxRetries; attempt++) {
10310
9960
  if (await verifyNaudiodonLoad()) {
10311
9961
  return true;
10312
9962
  }
10313
- logger9.info({ attempt }, "naudiodon not loadable, trying dependency rebuild");
9963
+ logger8.info({ attempt }, "naudiodon not loadable, trying dependency rebuild");
10314
9964
  notificationService.info(`\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56 (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
10315
9965
  let anySuccess = false;
10316
9966
  for (const dep of criticalDeps) {
10317
9967
  try {
10318
- require3.resolve(dep, { paths: [naudiodonPath] });
9968
+ require2.resolve(dep, { paths: [naudiodonPath] });
10319
9969
  if (await rebuildNaudiodonDependency(dep)) {
10320
9970
  anySuccess = true;
10321
9971
  }
@@ -10323,9 +9973,9 @@ async function fixNaudiodonDependencies(maxRetries = 5) {
10323
9973
  notificationService.info(`\u6B63\u5728\u5B89\u88C5 ${dep}...`, "Ocosay", 4e3);
10324
9974
  const installResult = await execAsync(`npm install ${dep}`, naudiodonPath);
10325
9975
  if (installResult.error) {
10326
- logger9.warn({ err: installResult.error }, `${dep} install failed`);
9976
+ logger8.warn({ err: installResult.error }, `${dep} install failed`);
10327
9977
  } else {
10328
- logger9.info(`${dep} installed successfully`);
9978
+ logger8.info(`${dep} installed successfully`);
10329
9979
  anySuccess = true;
10330
9980
  }
10331
9981
  }
@@ -10334,9 +9984,9 @@ async function fixNaudiodonDependencies(maxRetries = 5) {
10334
9984
  notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 4e3);
10335
9985
  const rebuildResult = await execAsync("npm rebuild naudiodon", naudiodonPath);
10336
9986
  if (rebuildResult.error) {
10337
- logger9.warn({ err: rebuildResult.error }, "naudiodon rebuild failed");
9987
+ logger8.warn({ err: rebuildResult.error }, "naudiodon rebuild failed");
10338
9988
  } else {
10339
- logger9.info("naudiodon rebuilt");
9989
+ logger8.info("naudiodon rebuilt");
10340
9990
  anySuccess = true;
10341
9991
  }
10342
9992
  }
@@ -10351,35 +10001,35 @@ async function fixNaudiodonDependencies(maxRetries = 5) {
10351
10001
  }
10352
10002
  async function ensureNaudiodonCompiled() {
10353
10003
  if (shouldSkipNaudiodon()) {
10354
- logger9.info("naudiodon skipped previously");
10004
+ logger8.info("naudiodon skipped previously");
10355
10005
  return;
10356
10006
  }
10357
10007
  try {
10358
- require3("naudiodon");
10359
- logger9.info("naudiodon already compiled");
10008
+ require2("naudiodon");
10009
+ logger8.info("naudiodon already compiled");
10360
10010
  return;
10361
10011
  } catch {
10362
- logger9.info("naudiodon not compiled, will attempt to compile");
10012
+ logger8.info("naudiodon not compiled, will attempt to compile");
10363
10013
  notificationService.info("\u6B63\u5728\u7F16\u8BD1 naudiodon...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
10364
10014
  }
10365
10015
  try {
10366
- const naudiodonPath = dirname2(require3.resolve("naudiodon"));
10367
- logger9.info({ naudiodonPath }, "found naudiodon, rebuilding");
10016
+ const naudiodonPath = dirname2(require2.resolve("naudiodon"));
10017
+ logger8.info({ naudiodonPath }, "found naudiodon, rebuilding");
10368
10018
  const rebuildResult = await execAsync("npm rebuild naudiodon", naudiodonPath);
10369
10019
  if (rebuildResult.error) {
10370
- logger9.warn({ err: rebuildResult.error }, "naudiodon rebuild failed, checking for PortAudio");
10020
+ logger8.warn({ err: rebuildResult.error }, "naudiodon rebuild failed, checking for PortAudio");
10371
10021
  notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...", 5e3);
10372
10022
  const installed = await installPortAudio();
10373
10023
  if (installed.success) {
10374
- const retryPath = dirname2(require3.resolve("naudiodon"));
10024
+ const retryPath = dirname2(require2.resolve("naudiodon"));
10375
10025
  notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
10376
10026
  const retryResult = await execAsync("npm rebuild naudiodon", retryPath);
10377
10027
  if (retryResult.error) {
10378
- logger9.error({ err: retryResult.error }, "naudiodon compile failed even after PortAudio install");
10028
+ logger8.error({ err: retryResult.error }, "naudiodon compile failed even after PortAudio install");
10379
10029
  notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
10380
10030
  markNaudiodonSkipped();
10381
10031
  } else {
10382
- logger9.info("naudiodon compiled successfully after PortAudio install");
10032
+ logger8.info("naudiodon compiled successfully after PortAudio install");
10383
10033
  const loadSuccess = await verifyNaudiodonLoad();
10384
10034
  if (loadSuccess) {
10385
10035
  notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
@@ -10394,12 +10044,12 @@ async function ensureNaudiodonCompiled() {
10394
10044
  }
10395
10045
  }
10396
10046
  } else {
10397
- logger9.error("PortAudio install failed");
10047
+ logger8.error("PortAudio install failed");
10398
10048
  notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
10399
10049
  markNaudiodonSkipped();
10400
10050
  }
10401
10051
  } else {
10402
- logger9.info("naudiodon compiled, verifying...");
10052
+ logger8.info("naudiodon compiled, verifying...");
10403
10053
  const loadSuccess = await verifyNaudiodonLoad();
10404
10054
  if (loadSuccess) {
10405
10055
  notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
@@ -10414,19 +10064,19 @@ async function ensureNaudiodonCompiled() {
10414
10064
  }
10415
10065
  }
10416
10066
  } catch (err) {
10417
- logger9.warn({ err }, "naudiodon rebuild failed, checking for PortAudio");
10067
+ logger8.warn({ err }, "naudiodon rebuild failed, checking for PortAudio");
10418
10068
  notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...", 5e3);
10419
10069
  const installed = await installPortAudio();
10420
10070
  if (installed.success) {
10421
- const retryPath = dirname2(require3.resolve("naudiodon"));
10071
+ const retryPath = dirname2(require2.resolve("naudiodon"));
10422
10072
  notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
10423
10073
  const retryResult = await execAsync("npm rebuild naudiodon", retryPath);
10424
10074
  if (retryResult.error) {
10425
- logger9.error({ err: retryResult.error }, "naudiodon compile failed even after PortAudio install");
10075
+ logger8.error({ err: retryResult.error }, "naudiodon compile failed even after PortAudio install");
10426
10076
  notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
10427
10077
  markNaudiodonSkipped();
10428
10078
  } else {
10429
- logger9.info("naudiodon compiled successfully after PortAudio install");
10079
+ logger8.info("naudiodon compiled successfully after PortAudio install");
10430
10080
  const loadSuccess = await verifyNaudiodonLoad();
10431
10081
  if (loadSuccess) {
10432
10082
  notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
@@ -10441,7 +10091,7 @@ async function ensureNaudiodonCompiled() {
10441
10091
  }
10442
10092
  }
10443
10093
  } else {
10444
- logger9.error("PortAudio install failed");
10094
+ logger8.error("PortAudio install failed");
10445
10095
  notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
10446
10096
  markNaudiodonSkipped();
10447
10097
  }
@@ -10458,87 +10108,34 @@ function isModuleInstalled(moduleName) {
10458
10108
  async function verifyModuleLoad(dep) {
10459
10109
  try {
10460
10110
  pluginRequire(dep);
10461
- logger9.info(`${dep} loaded successfully`);
10111
+ logger8.info(`${dep} loaded successfully`);
10462
10112
  return true;
10463
10113
  } catch (err) {
10464
- logger9.warn({ err }, `${dep} load failed`);
10114
+ logger8.warn({ err }, `${dep} load failed`);
10465
10115
  return false;
10466
10116
  }
10467
10117
  }
10468
- async function tryCompileSpeaker() {
10469
- const dep = "speaker";
10470
- const result = { success: false, stderr: "" };
10471
- if (isModuleInstalled(dep)) {
10472
- if (await verifyModuleLoad(dep)) {
10473
- result.success = true;
10474
- return result;
10475
- }
10476
- }
10477
- if (!isModuleInstalled(dep)) {
10478
- const installResult = await execAsync("npm install speaker", opencodeNodeModules);
10479
- if (installResult.error) {
10480
- logger9.warn({ err: installResult.error }, "speaker install failed");
10481
- }
10482
- }
10483
- const rebuildResult = await execAsync("npm rebuild speaker", opencodeNodeModules);
10484
- result.stderr = (rebuildResult.stdout || "") + "\n" + (rebuildResult.stderr || "");
10485
- if (rebuildResult.error) {
10486
- result.stderr += "\n" + (rebuildResult.error.message || "");
10487
- }
10488
- if (await verifyModuleLoad(dep)) {
10489
- result.success = true;
10490
- }
10491
- return result;
10492
- }
10493
- async function ensureSpeakerCompiledAsync() {
10494
- const compileResult = await tryCompileSpeaker();
10495
- if (compileResult.success) {
10496
- logger9.info("speaker compiled successfully");
10497
- return;
10498
- }
10499
- const detectResult = detectMissingDependencies(compileResult.stderr);
10500
- if (detectResult.missingHeaders.length === 0) {
10501
- logger9.info("speaker compile failed with unknown error");
10502
- return;
10503
- }
10504
- logger9.info({ missingHeaders: detectResult.missingHeaders }, "detected missing headers");
10505
- const platformInfo = detectPlatform();
10506
- const packages = mapHeadersToPackages(detectResult.missingHeaders, platformInfo.platform);
10507
- if (packages.length === 0) {
10508
- logger9.info("no known packages for missing headers");
10509
- return;
10510
- }
10511
- logger9.info({ packages }, "mapped headers to packages, installing");
10512
- await installSystemPackages(packages, notificationService);
10513
- const retryResult = await tryCompileSpeaker();
10514
- if (retryResult.success) {
10515
- logger9.info("speaker compiled successfully after installing dependencies");
10516
- } else {
10517
- logger9.warn("speaker compile still failed after dependency installation");
10518
- }
10519
- }
10520
10118
  async function ensureSpeakerInstalledAsync() {
10521
10119
  await ensurePlaySoundInstalled();
10522
10120
  }
10523
10121
  async function initAsync() {
10524
10122
  setTimeout(async () => {
10525
- await ensureSpeakerCompiledAsync();
10526
10123
  await ensureSpeakerInstalledAsync();
10527
10124
  }, 100);
10528
10125
  }
10529
10126
  async function ensurePlaySoundInstalled() {
10530
10127
  const dep = "play-sound";
10531
10128
  if (isModuleInstalled(dep)) {
10532
- logger9.info("play-sound already installed");
10129
+ logger8.info("play-sound already installed");
10533
10130
  if (await verifyModuleLoad(dep)) {
10534
10131
  return;
10535
10132
  }
10536
10133
  }
10537
- logger9.info("play-sound not found, installing");
10134
+ logger8.info("play-sound not found, installing");
10538
10135
  notificationService.info("\u6B63\u5728\u5B89\u88C5 play-sound...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
10539
10136
  const installResult = await execAsync("npm install play-sound", opencodeNodeModules);
10540
10137
  if (installResult.error) {
10541
- logger9.warn({ err: installResult.error }, "play-sound install failed");
10138
+ logger8.warn({ err: installResult.error }, "play-sound install failed");
10542
10139
  notificationService.warning(
10543
10140
  "play-sound \u5B89\u88C5\u5931\u8D25",
10544
10141
  "\u8BF7\u624B\u52A8\u8FD0\u884C: npm install play-sound",
@@ -10546,7 +10143,7 @@ async function ensurePlaySoundInstalled() {
10546
10143
  );
10547
10144
  return;
10548
10145
  }
10549
- logger9.info("play-sound installed");
10146
+ logger8.info("play-sound installed");
10550
10147
  if (await verifyModuleLoad(dep)) {
10551
10148
  notificationService.success("play-sound \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10552
10149
  } else {
@@ -10558,14 +10155,11 @@ async function ensurePlaySoundInstalled() {
10558
10155
  }
10559
10156
  }
10560
10157
  async function ensureOptionalDepsInstalled() {
10561
- ensureSpeakerCompiledAsync().catch((err) => {
10562
- logger9.warn({ err }, "ensureSpeakerCompiledAsync failed");
10563
- });
10564
10158
  await ensurePlaySoundInstalled();
10565
10159
  }
10566
10160
  function execCmd2(cmd) {
10567
10161
  try {
10568
- const output = execSync4(cmd, { stdio: "pipe", encoding: "utf8" });
10162
+ const output = execSync2(cmd, { stdio: "pipe", encoding: "utf8" });
10569
10163
  return { success: true, output };
10570
10164
  } catch (err) {
10571
10165
  return { success: false, output: err.message || "" };
@@ -10574,7 +10168,7 @@ function execCmd2(cmd) {
10574
10168
  function isWsl2() {
10575
10169
  if (process.platform !== "linux") return false;
10576
10170
  try {
10577
- return require3("fs").readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
10171
+ return require2("fs").readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
10578
10172
  } catch {
10579
10173
  return false;
10580
10174
  }
@@ -10611,9 +10205,9 @@ async function checkAudioEnvironmentForBackend() {
10611
10205
  async function installPortAudio() {
10612
10206
  const platform = process.platform;
10613
10207
  const wsl = isWsl2();
10614
- logger9.info({ platform, wsl }, "installing PortAudio");
10208
+ logger8.info({ platform, wsl }, "installing PortAudio");
10615
10209
  const runInstall = async (cmd, desc) => {
10616
- logger9.info(`Running: ${cmd}`);
10210
+ logger8.info(`Running: ${cmd}`);
10617
10211
  notificationService.info(desc, "\u6B63\u5728\u5B89\u88C5...", 5e3);
10618
10212
  const result = await execAsync(cmd);
10619
10213
  if (result.error) {
@@ -10624,15 +10218,15 @@ async function installPortAudio() {
10624
10218
  "# \u8BF7\u5728WSL\u7EC8\u7AEF\u6267\u884C\u4E00\u6B21\nsudo visudo\n# \u6DFB\u52A0\u884C\uFF1Ayour user name ALL=(ALL) NOPASSWD: ALL",
10625
10219
  1e4
10626
10220
  );
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");
10221
+ logger8.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");
10628
10222
  return false;
10629
10223
  }
10630
10224
  if (msg.includes("already") || msg.includes("is already")) {
10631
- logger9.info("already installed");
10225
+ logger8.info("already installed");
10632
10226
  return true;
10633
10227
  }
10634
10228
  notificationService.error(desc + " \u5931\u8D25", msg.substring(0, 100), 8e3);
10635
- logger9.error({ err: result.error }, `install failed: ${desc}`);
10229
+ logger8.error({ err: result.error }, `install failed: ${desc}`);
10636
10230
  return false;
10637
10231
  }
10638
10232
  return true;
@@ -10641,7 +10235,7 @@ async function installPortAudio() {
10641
10235
  notificationService.info("\u68C0\u6D4B ffmpeg...", "\u97F3\u9891\u540E\u7AEF", 5e3);
10642
10236
  const ffmpegCheck = execCmd2("which ffplay");
10643
10237
  if (ffmpegCheck.success) {
10644
- logger9.info("ffmpeg already available");
10238
+ logger8.info("ffmpeg already available");
10645
10239
  notificationService.success("ffmpeg \u5C31\u7EEA", "ffplay \u53EF\u7528\u4E8E\u65E0\u58F0\u5361\u64AD\u653E", 5e3);
10646
10240
  } else {
10647
10241
  notificationService.info("\u5B89\u88C5 ffmpeg...", "\u97F3\u9891\u540E\u7AEF", 5e3);
@@ -10657,7 +10251,7 @@ async function installPortAudio() {
10657
10251
  }
10658
10252
  notificationService.info("\u68C0\u6D4B\u97F3\u9891\u8BBE\u5907...", "\u97F3\u9891\u540E\u7AEF", 5e3);
10659
10253
  if (checkAlsa()) {
10660
- logger9.info("alsa-utils already available and working");
10254
+ logger8.info("alsa-utils already available and working");
10661
10255
  notificationService.success("alsa-utils \u5C31\u7EEA", "\u97F3\u9891\u540E\u7AEF\u5DF2\u53EF\u7528", 5e3);
10662
10256
  return { success: true, message: "alsa" };
10663
10257
  }
@@ -10848,7 +10442,7 @@ var server = (async (input, _options) => {
10848
10442
  });
10849
10443
  } catch (err) {
10850
10444
  initError = err instanceof Error ? err : new Error(String(err));
10851
- logger9.error({ error: initError }, "initialization failed");
10445
+ logger8.error({ error: initError }, "initialization failed");
10852
10446
  }
10853
10447
  initAsync();
10854
10448
  await ensureNaudiodonCompiled();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/ocosay",
3
- "version": "1.1.30",
3
+ "version": "1.1.32",
4
4
  "description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",