@mingxy/ocosay 1.1.2 → 1.1.4
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 +2 -5
- package/dist/plugin.js +97 -8
- package/package.json +3 -5
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mingxy/ocosay",
|
|
3
|
-
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.js",
|
|
@@ -29,9 +29,7 @@
|
|
|
29
29
|
"build:plugin": "esbuild src/plugin.ts --bundle --platform=node --format=esm --outdir=dist --sourcemap --external:@opencode-ai/plugin --external:axios --external:ws --external:zod",
|
|
30
30
|
"watch": "tsc --watch",
|
|
31
31
|
"test": "jest",
|
|
32
|
-
"lint": "eslint src --ext .ts"
|
|
33
|
-
"install-deps": "node scripts/install-native-deps.js",
|
|
34
|
-
"postinstall": "node scripts/verify-audio.js"
|
|
32
|
+
"lint": "eslint src --ext .ts"
|
|
35
33
|
},
|
|
36
34
|
"keywords": [
|
|
37
35
|
"tts",
|
|
@@ -50,7 +48,6 @@
|
|
|
50
48
|
"zod": "^4.3.6"
|
|
51
49
|
},
|
|
52
50
|
"optionalDependencies": {
|
|
53
|
-
"bindings": "^1.5.0",
|
|
54
51
|
"naudiodon": "^1.0.0"
|
|
55
52
|
},
|
|
56
53
|
"devDependencies": {
|
package/dist/plugin.js
CHANGED
|
@@ -4649,8 +4649,8 @@ var require_thread_stream = __commonJS({
|
|
|
4649
4649
|
var require_transport = __commonJS({
|
|
4650
4650
|
"node_modules/pino/lib/transport.js"(exports, module) {
|
|
4651
4651
|
"use strict";
|
|
4652
|
-
var { createRequire } = __require("module");
|
|
4653
|
-
var { existsSync:
|
|
4652
|
+
var { createRequire: createRequire2 } = __require("module");
|
|
4653
|
+
var { existsSync: existsSync7 } = __require("node:fs");
|
|
4654
4654
|
var getCallers = require_caller();
|
|
4655
4655
|
var { join: join8, isAbsolute, sep } = __require("node:path");
|
|
4656
4656
|
var { fileURLToPath: fileURLToPath2 } = __require("node:url");
|
|
@@ -4724,7 +4724,7 @@ var require_transport = __commonJS({
|
|
|
4724
4724
|
return false;
|
|
4725
4725
|
}
|
|
4726
4726
|
}
|
|
4727
|
-
return isAbsolute(path2) && !
|
|
4727
|
+
return isAbsolute(path2) && !existsSync7(path2);
|
|
4728
4728
|
}
|
|
4729
4729
|
function stripQuotes(value) {
|
|
4730
4730
|
const first = value[0];
|
|
@@ -4852,7 +4852,7 @@ var require_transport = __commonJS({
|
|
|
4852
4852
|
for (const filePath of callers) {
|
|
4853
4853
|
try {
|
|
4854
4854
|
const context = filePath === "node:repl" ? process.cwd() + sep : filePath;
|
|
4855
|
-
fixTarget2 =
|
|
4855
|
+
fixTarget2 = createRequire2(context).resolve(origin);
|
|
4856
4856
|
break;
|
|
4857
4857
|
} catch (err) {
|
|
4858
4858
|
continue;
|
|
@@ -9551,10 +9551,98 @@ function loadOrCreateConfig() {
|
|
|
9551
9551
|
}
|
|
9552
9552
|
|
|
9553
9553
|
// src/plugin.ts
|
|
9554
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
9554
|
+
import { readFileSync as readFileSync2, existsSync as existsSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
9555
9555
|
import { fileURLToPath } from "url";
|
|
9556
9556
|
import { dirname as dirname2, join as join7 } from "path";
|
|
9557
|
+
import { homedir as homedir3 } from "os";
|
|
9558
|
+
import { execSync } from "child_process";
|
|
9559
|
+
import { createRequire } from "module";
|
|
9557
9560
|
var logger7 = createModuleLogger("Plugin");
|
|
9561
|
+
var require2 = createRequire(import.meta.url);
|
|
9562
|
+
function getSkipFilePath() {
|
|
9563
|
+
return join7(homedir3(), ".config", "opencode", ".naudiodon_skip");
|
|
9564
|
+
}
|
|
9565
|
+
function shouldSkipNaudiodon() {
|
|
9566
|
+
return existsSync6(getSkipFilePath());
|
|
9567
|
+
}
|
|
9568
|
+
function markNaudiodonSkipped() {
|
|
9569
|
+
try {
|
|
9570
|
+
const dir = join7(homedir3(), ".config", "opencode");
|
|
9571
|
+
if (!existsSync6(dir)) {
|
|
9572
|
+
execSync("mkdir -p", { cwd: dir });
|
|
9573
|
+
}
|
|
9574
|
+
writeFileSync5(getSkipFilePath(), Date.now().toString(), "utf-8");
|
|
9575
|
+
} catch {
|
|
9576
|
+
}
|
|
9577
|
+
}
|
|
9578
|
+
async function ensureNaudiodonCompiled() {
|
|
9579
|
+
if (shouldSkipNaudiodon()) {
|
|
9580
|
+
logger7.info("naudiodon skipped previously, skipping compile attempt");
|
|
9581
|
+
return;
|
|
9582
|
+
}
|
|
9583
|
+
try {
|
|
9584
|
+
require2("naudiodon");
|
|
9585
|
+
logger7.info("naudiodon already compiled");
|
|
9586
|
+
return;
|
|
9587
|
+
} catch {
|
|
9588
|
+
logger7.info("naudiodon not compiled, attempting to compile...");
|
|
9589
|
+
}
|
|
9590
|
+
try {
|
|
9591
|
+
const naudiodonPath = dirname2(require2.resolve("naudiodon"));
|
|
9592
|
+
logger7.info({ naudiodonPath }, "found naudiodon at");
|
|
9593
|
+
notificationService.info("\u6B63\u5728\u7F16\u8BD1 naudiodon...", "Ocosay \u97F3\u9891\u540E\u7AEF");
|
|
9594
|
+
execSync("npm rebuild naudiodon", {
|
|
9595
|
+
cwd: naudiodonPath,
|
|
9596
|
+
stdio: "inherit"
|
|
9597
|
+
});
|
|
9598
|
+
logger7.info("naudiodon compiled successfully");
|
|
9599
|
+
notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA");
|
|
9600
|
+
} catch (err) {
|
|
9601
|
+
logger7.warn({ err }, "naudiodon rebuild failed, checking for PortAudio...");
|
|
9602
|
+
notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...");
|
|
9603
|
+
const installed = installPortAudio();
|
|
9604
|
+
if (installed) {
|
|
9605
|
+
try {
|
|
9606
|
+
const naudiodonPath = dirname2(require2.resolve("naudiodon"));
|
|
9607
|
+
notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay");
|
|
9608
|
+
execSync("npm rebuild naudiodon", {
|
|
9609
|
+
cwd: naudiodonPath,
|
|
9610
|
+
stdio: "inherit"
|
|
9611
|
+
});
|
|
9612
|
+
logger7.info("naudiodon compiled successfully after PortAudio install");
|
|
9613
|
+
notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA");
|
|
9614
|
+
} catch (retryErr) {
|
|
9615
|
+
logger7.error({ err: retryErr }, "failed to compile naudiodon even after PortAudio install");
|
|
9616
|
+
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u5DF2\u8DF3\u8FC7\uFF0C\u4E4B\u540E\u4E0D\u518D\u91CD\u8BD5");
|
|
9617
|
+
markNaudiodonSkipped();
|
|
9618
|
+
}
|
|
9619
|
+
} else {
|
|
9620
|
+
notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u5DF2\u8DF3\u8FC7\uFF0C\u4E4B\u540E\u4E0D\u518D\u91CD\u8BD5");
|
|
9621
|
+
markNaudiodonSkipped();
|
|
9622
|
+
}
|
|
9623
|
+
}
|
|
9624
|
+
}
|
|
9625
|
+
function installPortAudio() {
|
|
9626
|
+
const platform = process.platform;
|
|
9627
|
+
logger7.info({ platform }, "installing PortAudio for platform");
|
|
9628
|
+
notificationService.info("\u6B63\u5728\u5B89\u88C5 PortAudio...", `\u5E73\u53F0: ${platform}`);
|
|
9629
|
+
try {
|
|
9630
|
+
if (platform === "linux") {
|
|
9631
|
+
execSync("sudo apt-get update && sudo apt-get install -y libportaudio-dev portaudio", { stdio: "inherit" });
|
|
9632
|
+
} else if (platform === "darwin") {
|
|
9633
|
+
execSync("brew install portaudio", { stdio: "inherit" });
|
|
9634
|
+
} else if (platform === "win32") {
|
|
9635
|
+
execSync("choco install portaudio -y", { stdio: "inherit" });
|
|
9636
|
+
} else {
|
|
9637
|
+
logger7.warn("unsupported platform for automatic PortAudio install");
|
|
9638
|
+
return false;
|
|
9639
|
+
}
|
|
9640
|
+
return true;
|
|
9641
|
+
} catch (err) {
|
|
9642
|
+
logger7.error({ err }, "failed to install PortAudio automatically");
|
|
9643
|
+
return false;
|
|
9644
|
+
}
|
|
9645
|
+
}
|
|
9558
9646
|
var __filename = fileURLToPath(import.meta.url);
|
|
9559
9647
|
var __dirname2 = dirname2(__filename);
|
|
9560
9648
|
var id = "ocosay";
|
|
@@ -9680,6 +9768,10 @@ var ttsStreamStatusTool = tool({
|
|
|
9680
9768
|
});
|
|
9681
9769
|
var initError = null;
|
|
9682
9770
|
var server = (async (input, _options) => {
|
|
9771
|
+
const opencodeTui = input.client?.tui;
|
|
9772
|
+
global.__opencode_tui__ = opencodeTui;
|
|
9773
|
+
notificationService.setTui(opencodeTui);
|
|
9774
|
+
await ensureNaudiodonCompiled();
|
|
9683
9775
|
const config = loadOrCreateConfig();
|
|
9684
9776
|
try {
|
|
9685
9777
|
await initialize({
|
|
@@ -9696,9 +9788,6 @@ var server = (async (input, _options) => {
|
|
|
9696
9788
|
initError = err instanceof Error ? err : new Error(String(err));
|
|
9697
9789
|
logger7.error({ error: initError }, "initialization failed");
|
|
9698
9790
|
}
|
|
9699
|
-
const opencodeTui = input.client?.tui;
|
|
9700
|
-
global.__opencode_tui__ = opencodeTui;
|
|
9701
|
-
notificationService.setTui(opencodeTui);
|
|
9702
9791
|
setTimeout(() => {
|
|
9703
9792
|
if (initError) {
|
|
9704
9793
|
notificationService.error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mingxy/ocosay",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.js",
|
|
@@ -29,9 +29,7 @@
|
|
|
29
29
|
"build:plugin": "esbuild src/plugin.ts --bundle --platform=node --format=esm --outdir=dist --sourcemap --external:@opencode-ai/plugin --external:axios --external:ws --external:zod",
|
|
30
30
|
"watch": "tsc --watch",
|
|
31
31
|
"test": "jest",
|
|
32
|
-
"lint": "eslint src --ext .ts"
|
|
33
|
-
"install": "node scripts/install-portaudio.cjs && node scripts/compile-native.cjs",
|
|
34
|
-
"install:portaudio": "node scripts/install-portaudio.cjs"
|
|
32
|
+
"lint": "eslint src --ext .ts"
|
|
35
33
|
},
|
|
36
34
|
"keywords": [
|
|
37
35
|
"tts",
|
|
@@ -50,7 +48,7 @@
|
|
|
50
48
|
"zod": "^4.3.6"
|
|
51
49
|
},
|
|
52
50
|
"optionalDependencies": {
|
|
53
|
-
"naudiodon": "^
|
|
51
|
+
"naudiodon": "^1.0.0"
|
|
54
52
|
},
|
|
55
53
|
"devDependencies": {
|
|
56
54
|
"@types/howler": "^2.2.12",
|