@mingxy/ocosay 1.0.29 → 1.0.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.
- package/.idea/UniappTool.xml +10 -0
- package/.idea/modules.xml +8 -0
- package/.idea/ocosay.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +34 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -6
- package/dist/config.js.map +1 -1
- package/dist/core/backends/powershell-backend.d.ts.map +1 -1
- package/dist/core/backends/powershell-backend.js +9 -0
- package/dist/core/backends/powershell-backend.js.map +1 -1
- package/dist/core/speaker.d.ts.map +1 -1
- package/dist/core/speaker.js +34 -49
- package/dist/core/speaker.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +124 -148
- package/dist/plugin.js.map +3 -3
- package/dist/tools/tts.d.ts +0 -18
- package/dist/tools/tts.d.ts.map +1 -1
- package/dist/tools/tts.js +7 -16
- package/dist/tools/tts.js.map +1 -1
- package/dist/utils/logger.d.ts +0 -4
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +21 -31
- package/dist/utils/logger.js.map +1 -1
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -4902,10 +4902,10 @@ var require_tools = __commonJS({
|
|
|
4902
4902
|
var asString = nodeMajor >= 25 ? (str) => JSON.stringify(str) : _asString;
|
|
4903
4903
|
function noop() {
|
|
4904
4904
|
}
|
|
4905
|
-
function genLog(
|
|
4905
|
+
function genLog(level2, hook) {
|
|
4906
4906
|
if (!hook) return LOG;
|
|
4907
4907
|
return function hookWrappedLog(...args) {
|
|
4908
|
-
hook.call(this, args, LOG,
|
|
4908
|
+
hook.call(this, args, LOG, level2);
|
|
4909
4909
|
};
|
|
4910
4910
|
function LOG(o, ...n) {
|
|
4911
4911
|
if (typeof o === "object") {
|
|
@@ -4927,13 +4927,13 @@ var require_tools = __commonJS({
|
|
|
4927
4927
|
if (typeof this[msgPrefixSym] === "string" && msg !== void 0 && msg !== null) {
|
|
4928
4928
|
msg = this[msgPrefixSym] + msg;
|
|
4929
4929
|
}
|
|
4930
|
-
this[writeSym](o, format(msg, formatParams, this[formatOptsSym]),
|
|
4930
|
+
this[writeSym](o, format(msg, formatParams, this[formatOptsSym]), level2);
|
|
4931
4931
|
} else {
|
|
4932
4932
|
let msg = o === void 0 ? n.shift() : o;
|
|
4933
4933
|
if (typeof this[msgPrefixSym] === "string" && msg !== void 0 && msg !== null) {
|
|
4934
4934
|
msg = this[msgPrefixSym] + msg;
|
|
4935
4935
|
}
|
|
4936
|
-
this[writeSym](null, format(msg, n, this[formatOptsSym]),
|
|
4936
|
+
this[writeSym](null, format(msg, n, this[formatOptsSym]), level2);
|
|
4937
4937
|
}
|
|
4938
4938
|
}
|
|
4939
4939
|
}
|
|
@@ -5166,9 +5166,9 @@ var require_tools = __commonJS({
|
|
|
5166
5166
|
}
|
|
5167
5167
|
}
|
|
5168
5168
|
}
|
|
5169
|
-
function buildFormatters(
|
|
5169
|
+
function buildFormatters(level2, bindings, log) {
|
|
5170
5170
|
return {
|
|
5171
|
-
level,
|
|
5171
|
+
level: level2,
|
|
5172
5172
|
bindings,
|
|
5173
5173
|
log
|
|
5174
5174
|
};
|
|
@@ -5267,17 +5267,17 @@ var require_levels = __commonJS({
|
|
|
5267
5267
|
const { labels } = instance.levels;
|
|
5268
5268
|
const cache = {};
|
|
5269
5269
|
for (const label in labels) {
|
|
5270
|
-
const
|
|
5271
|
-
cache[label] = JSON.stringify(
|
|
5270
|
+
const level2 = formatter(labels[label], Number(label));
|
|
5271
|
+
cache[label] = JSON.stringify(level2).slice(0, -1);
|
|
5272
5272
|
}
|
|
5273
5273
|
instance[lsCacheSym] = cache;
|
|
5274
5274
|
return instance;
|
|
5275
5275
|
}
|
|
5276
|
-
function isStandardLevel(
|
|
5276
|
+
function isStandardLevel(level2, useOnlyCustomLevels) {
|
|
5277
5277
|
if (useOnlyCustomLevels) {
|
|
5278
5278
|
return false;
|
|
5279
5279
|
}
|
|
5280
|
-
switch (
|
|
5280
|
+
switch (level2) {
|
|
5281
5281
|
case "fatal":
|
|
5282
5282
|
case "error":
|
|
5283
5283
|
case "warn":
|
|
@@ -5289,15 +5289,15 @@ var require_levels = __commonJS({
|
|
|
5289
5289
|
return false;
|
|
5290
5290
|
}
|
|
5291
5291
|
}
|
|
5292
|
-
function setLevel(
|
|
5292
|
+
function setLevel(level2) {
|
|
5293
5293
|
const { labels, values } = this.levels;
|
|
5294
|
-
if (typeof
|
|
5295
|
-
if (labels[
|
|
5296
|
-
|
|
5294
|
+
if (typeof level2 === "number") {
|
|
5295
|
+
if (labels[level2] === void 0) throw Error("unknown level value" + level2);
|
|
5296
|
+
level2 = labels[level2];
|
|
5297
5297
|
}
|
|
5298
|
-
if (values[
|
|
5298
|
+
if (values[level2] === void 0) throw Error("unknown level " + level2);
|
|
5299
5299
|
const preLevelVal = this[levelValSym];
|
|
5300
|
-
const levelVal = this[levelValSym] = values[
|
|
5300
|
+
const levelVal = this[levelValSym] = values[level2];
|
|
5301
5301
|
const useOnlyCustomLevelsVal = this[useOnlyCustomLevelsSym];
|
|
5302
5302
|
const levelComparison = this[levelCompSym];
|
|
5303
5303
|
const hook = this[hooksSym].logMethod;
|
|
@@ -5310,14 +5310,14 @@ var require_levels = __commonJS({
|
|
|
5310
5310
|
}
|
|
5311
5311
|
this.emit(
|
|
5312
5312
|
"level-change",
|
|
5313
|
-
|
|
5313
|
+
level2,
|
|
5314
5314
|
levelVal,
|
|
5315
5315
|
labels[preLevelVal],
|
|
5316
5316
|
preLevelVal,
|
|
5317
5317
|
this
|
|
5318
5318
|
);
|
|
5319
5319
|
}
|
|
5320
|
-
function getLevel(
|
|
5320
|
+
function getLevel(level2) {
|
|
5321
5321
|
const { levels, levelVal } = this;
|
|
5322
5322
|
return levels && levels.labels ? levels.labels[levelVal] : "";
|
|
5323
5323
|
}
|
|
@@ -5359,7 +5359,7 @@ var require_levels = __commonJS({
|
|
|
5359
5359
|
if (typeof defaultLevel === "number") {
|
|
5360
5360
|
const values = [].concat(
|
|
5361
5361
|
Object.keys(customLevels || {}).map((key) => customLevels[key]),
|
|
5362
|
-
useOnlyCustomLevels ? [] : Object.keys(nums).map((
|
|
5362
|
+
useOnlyCustomLevels ? [] : Object.keys(nums).map((level2) => +level2),
|
|
5363
5363
|
Infinity
|
|
5364
5364
|
);
|
|
5365
5365
|
if (!values.includes(defaultLevel)) {
|
|
@@ -5551,9 +5551,9 @@ var require_proto = __commonJS({
|
|
|
5551
5551
|
}
|
|
5552
5552
|
} else instance[serializersSym] = serializers;
|
|
5553
5553
|
if (options.hasOwnProperty("formatters")) {
|
|
5554
|
-
const { level, bindings: chindings, log } = options.formatters;
|
|
5554
|
+
const { level: level2, bindings: chindings, log } = options.formatters;
|
|
5555
5555
|
instance[formattersSym] = buildFormatters(
|
|
5556
|
-
|
|
5556
|
+
level2 || formatters.level,
|
|
5557
5557
|
chindings || resetChildingsFormatter,
|
|
5558
5558
|
log || formatters.log
|
|
5559
5559
|
);
|
|
@@ -6286,20 +6286,20 @@ var require_multistream = __commonJS({
|
|
|
6286
6286
|
return res;
|
|
6287
6287
|
function write(data) {
|
|
6288
6288
|
let dest;
|
|
6289
|
-
const
|
|
6290
|
-
const { streams } = this;
|
|
6289
|
+
const level2 = this.lastLevel;
|
|
6290
|
+
const { streams: streams2 } = this;
|
|
6291
6291
|
let recordedLevel = 0;
|
|
6292
6292
|
let stream;
|
|
6293
|
-
for (let i = initLoopVar(
|
|
6294
|
-
dest =
|
|
6295
|
-
if (dest.level <=
|
|
6293
|
+
for (let i = initLoopVar(streams2.length, opts.dedupe); checkLoopVar(i, streams2.length, opts.dedupe); i = adjustLoopVar(i, opts.dedupe)) {
|
|
6294
|
+
dest = streams2[i];
|
|
6295
|
+
if (dest.level <= level2) {
|
|
6296
6296
|
if (recordedLevel !== 0 && recordedLevel !== dest.level) {
|
|
6297
6297
|
break;
|
|
6298
6298
|
}
|
|
6299
6299
|
stream = dest.stream;
|
|
6300
6300
|
if (stream[metadata]) {
|
|
6301
6301
|
const { lastTime, lastMsg, lastObj, lastLogger } = this;
|
|
6302
|
-
stream.lastLevel =
|
|
6302
|
+
stream.lastLevel = level2;
|
|
6303
6303
|
stream.lastTime = lastTime;
|
|
6304
6304
|
stream.lastMsg = lastMsg;
|
|
6305
6305
|
stream.lastObj = lastObj;
|
|
@@ -6337,35 +6337,35 @@ var require_multistream = __commonJS({
|
|
|
6337
6337
|
if (!isStream) {
|
|
6338
6338
|
throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");
|
|
6339
6339
|
}
|
|
6340
|
-
const { streams, streamLevels: streamLevels2 } = this;
|
|
6341
|
-
let
|
|
6340
|
+
const { streams: streams2, streamLevels: streamLevels2 } = this;
|
|
6341
|
+
let level2;
|
|
6342
6342
|
if (typeof dest.levelVal === "number") {
|
|
6343
|
-
|
|
6343
|
+
level2 = dest.levelVal;
|
|
6344
6344
|
} else if (typeof dest.level === "string") {
|
|
6345
|
-
|
|
6345
|
+
level2 = streamLevels2[dest.level];
|
|
6346
6346
|
} else if (typeof dest.level === "number") {
|
|
6347
|
-
|
|
6347
|
+
level2 = dest.level;
|
|
6348
6348
|
} else {
|
|
6349
|
-
|
|
6349
|
+
level2 = DEFAULT_INFO_LEVEL;
|
|
6350
6350
|
}
|
|
6351
6351
|
const dest_ = {
|
|
6352
6352
|
stream: stream_,
|
|
6353
|
-
level,
|
|
6353
|
+
level: level2,
|
|
6354
6354
|
levelVal: void 0,
|
|
6355
6355
|
id: ++res.lastId
|
|
6356
6356
|
};
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
this.minLevel =
|
|
6357
|
+
streams2.unshift(dest_);
|
|
6358
|
+
streams2.sort(compareByLevel);
|
|
6359
|
+
this.minLevel = streams2[0].level;
|
|
6360
6360
|
return res;
|
|
6361
6361
|
}
|
|
6362
6362
|
function remove(id2) {
|
|
6363
|
-
const { streams } = this;
|
|
6364
|
-
const index =
|
|
6363
|
+
const { streams: streams2 } = this;
|
|
6364
|
+
const index = streams2.findIndex((s) => s.id === id2);
|
|
6365
6365
|
if (index >= 0) {
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
this.minLevel =
|
|
6366
|
+
streams2.splice(index, 1);
|
|
6367
|
+
streams2.sort(compareByLevel);
|
|
6368
|
+
this.minLevel = streams2.length > 0 ? streams2[0].level : -1;
|
|
6369
6369
|
}
|
|
6370
6370
|
return res;
|
|
6371
6371
|
}
|
|
@@ -6377,11 +6377,11 @@ var require_multistream = __commonJS({
|
|
|
6377
6377
|
stream.end();
|
|
6378
6378
|
}
|
|
6379
6379
|
}
|
|
6380
|
-
function clone(
|
|
6381
|
-
const
|
|
6382
|
-
for (let i = 0; i <
|
|
6383
|
-
|
|
6384
|
-
level,
|
|
6380
|
+
function clone(level2) {
|
|
6381
|
+
const streams2 = new Array(this.streams.length);
|
|
6382
|
+
for (let i = 0; i < streams2.length; i++) {
|
|
6383
|
+
streams2[i] = {
|
|
6384
|
+
level: level2,
|
|
6385
6385
|
stream: this.streams[i].stream
|
|
6386
6386
|
};
|
|
6387
6387
|
}
|
|
@@ -6389,8 +6389,8 @@ var require_multistream = __commonJS({
|
|
|
6389
6389
|
write,
|
|
6390
6390
|
add,
|
|
6391
6391
|
remove,
|
|
6392
|
-
minLevel:
|
|
6393
|
-
streams,
|
|
6392
|
+
minLevel: level2,
|
|
6393
|
+
streams: streams2,
|
|
6394
6394
|
clone,
|
|
6395
6395
|
emit,
|
|
6396
6396
|
flushSync,
|
|
@@ -6515,7 +6515,7 @@ var require_pino = __commonJS({
|
|
|
6515
6515
|
nestedKey,
|
|
6516
6516
|
base,
|
|
6517
6517
|
name,
|
|
6518
|
-
level,
|
|
6518
|
+
level: level2,
|
|
6519
6519
|
customLevels,
|
|
6520
6520
|
levelComparison,
|
|
6521
6521
|
mixin,
|
|
@@ -6564,7 +6564,7 @@ var require_pino = __commonJS({
|
|
|
6564
6564
|
if (useOnlyCustomLevels && !customLevels) throw Error("customLevels is required if useOnlyCustomLevels is set true");
|
|
6565
6565
|
if (mixin && typeof mixin !== "function") throw Error(`Unknown mixin type "${typeof mixin}" - expected "function"`);
|
|
6566
6566
|
if (msgPrefix && typeof msgPrefix !== "string") throw Error(`Unknown msgPrefix type "${typeof msgPrefix}" - expected "string"`);
|
|
6567
|
-
assertDefaultLevelFound(
|
|
6567
|
+
assertDefaultLevelFound(level2, customLevels, useOnlyCustomLevels);
|
|
6568
6568
|
const levels = mappings(customLevels, useOnlyCustomLevels);
|
|
6569
6569
|
if (typeof stream.emit === "function") {
|
|
6570
6570
|
stream.emit("message", { code: "PINO_CONFIG", config: { levels, messageKey, errorKey } });
|
|
@@ -6600,7 +6600,7 @@ var require_pino = __commonJS({
|
|
|
6600
6600
|
});
|
|
6601
6601
|
Object.setPrototypeOf(instance, proto());
|
|
6602
6602
|
genLsCache(instance);
|
|
6603
|
-
instance[setLevelSym](
|
|
6603
|
+
instance[setLevelSym](level2);
|
|
6604
6604
|
return instance;
|
|
6605
6605
|
}
|
|
6606
6606
|
module.exports = pino2;
|
|
@@ -7089,6 +7089,12 @@ import { join as join3 } from "path";
|
|
|
7089
7089
|
import { writeFileSync as writeFileSync3, unlinkSync as unlinkSync3, existsSync as existsSync3 } from "fs";
|
|
7090
7090
|
var SAFE_PATH_REGEX3 = /^[\w\:\\_.]+$/i;
|
|
7091
7091
|
function wslPathToWindows(wslPath) {
|
|
7092
|
+
if (wslPath.startsWith("/tmp/")) {
|
|
7093
|
+
return "\\\\wsl$\\Ubuntu\\tmp\\" + wslPath.slice(5).replace(/\//g, "\\");
|
|
7094
|
+
}
|
|
7095
|
+
if (wslPath.startsWith("/var/tmp/")) {
|
|
7096
|
+
return "\\\\wsl$\\Ubuntu\\var\\tmp\\" + wslPath.slice(9).replace(/\//g, "\\");
|
|
7097
|
+
}
|
|
7092
7098
|
return wslPath.replace(/^\/mnt\/([a-z])\//, "$1:/").replace(/\//g, "\\");
|
|
7093
7099
|
}
|
|
7094
7100
|
var UnsupportedError2 = class extends Error {
|
|
@@ -7604,32 +7610,46 @@ import { homedir } from "os";
|
|
|
7604
7610
|
import { join as join5 } from "path";
|
|
7605
7611
|
import { existsSync as existsSync4, mkdirSync } from "fs";
|
|
7606
7612
|
var logDir = join5(homedir(), ".ocosay");
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
}
|
|
7613
|
+
var logFile = join5(logDir, "ocosay.log");
|
|
7614
|
+
if (!existsSync4(logDir)) {
|
|
7615
|
+
try {
|
|
7616
|
+
mkdirSync(logDir, { recursive: true });
|
|
7617
|
+
} catch {
|
|
7613
7618
|
}
|
|
7614
7619
|
}
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
target: "pino/file",
|
|
7622
|
-
options: { destination: join5(logDir, "ocosay.log"), mkdir: false },
|
|
7623
|
-
level: "info"
|
|
7624
|
-
}
|
|
7625
|
-
]
|
|
7626
|
-
}
|
|
7627
|
-
});
|
|
7628
|
-
if (process.env.NODE_ENV !== "production") {
|
|
7629
|
-
logger.level = "debug";
|
|
7620
|
+
var streams = [
|
|
7621
|
+
{ stream: process.stdout }
|
|
7622
|
+
];
|
|
7623
|
+
try {
|
|
7624
|
+
streams.push({ stream: import_pino.default.destination({ dest: logFile, mkdir: true }) });
|
|
7625
|
+
} catch {
|
|
7630
7626
|
}
|
|
7627
|
+
var level = process.env.NODE_ENV !== "production" ? "debug" : process.env.OCOSAY_LOG_LEVEL || "info";
|
|
7628
|
+
var logger = (0, import_pino.default)(
|
|
7629
|
+
{
|
|
7630
|
+
level,
|
|
7631
|
+
base: { service: "ocosay" },
|
|
7632
|
+
timestamp: import_pino.default.stdTimeFunctions.isoTime
|
|
7633
|
+
},
|
|
7634
|
+
import_pino.default.multistream(streams)
|
|
7635
|
+
);
|
|
7631
7636
|
|
|
7632
7637
|
// src/core/speaker.ts
|
|
7638
|
+
function toast(options) {
|
|
7639
|
+
const tui = global.__opencode_tui__;
|
|
7640
|
+
if (tui?.showToast) {
|
|
7641
|
+
try {
|
|
7642
|
+
tui.showToast({
|
|
7643
|
+
title: options.title,
|
|
7644
|
+
message: options.body,
|
|
7645
|
+
variant: options.type,
|
|
7646
|
+
duration: 3e3
|
|
7647
|
+
});
|
|
7648
|
+
} catch (err) {
|
|
7649
|
+
logger.warn({ err }, "toast call failed");
|
|
7650
|
+
}
|
|
7651
|
+
}
|
|
7652
|
+
}
|
|
7633
7653
|
var Speaker = class extends EventEmitter2 {
|
|
7634
7654
|
constructor(options = {}) {
|
|
7635
7655
|
super();
|
|
@@ -7639,21 +7659,11 @@ var Speaker = class extends EventEmitter2 {
|
|
|
7639
7659
|
onEnd: () => {
|
|
7640
7660
|
this.isSpeaking = false;
|
|
7641
7661
|
this.emit("end", this.currentText);
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
title: "\u{1F399}\uFE0F TTS",
|
|
7648
|
-
message: "Playback completed",
|
|
7649
|
-
variant: "success",
|
|
7650
|
-
duration: 3e3
|
|
7651
|
-
}
|
|
7652
|
-
});
|
|
7653
|
-
} catch (err) {
|
|
7654
|
-
console.warn("[Speaker] Toast playback completed failed:", err);
|
|
7655
|
-
}
|
|
7656
|
-
}
|
|
7662
|
+
toast({
|
|
7663
|
+
title: "TTS playback success",
|
|
7664
|
+
body: "Audio generated and playing",
|
|
7665
|
+
type: "info"
|
|
7666
|
+
});
|
|
7657
7667
|
},
|
|
7658
7668
|
onError: (error) => this.emit("error", error),
|
|
7659
7669
|
onPause: () => {
|
|
@@ -7696,21 +7706,6 @@ var Speaker = class extends EventEmitter2 {
|
|
|
7696
7706
|
}
|
|
7697
7707
|
this.isSpeaking = true;
|
|
7698
7708
|
this.currentText = text;
|
|
7699
|
-
const showToastFn = global.__opencode_tui__?.showToast;
|
|
7700
|
-
if (showToastFn) {
|
|
7701
|
-
try {
|
|
7702
|
-
showToastFn({
|
|
7703
|
-
body: {
|
|
7704
|
-
title: "\u{1F399}\uFE0F TTS",
|
|
7705
|
-
message: `Playing: ${text.substring(0, 30)}...`,
|
|
7706
|
-
variant: "info",
|
|
7707
|
-
duration: 3e3
|
|
7708
|
-
}
|
|
7709
|
-
});
|
|
7710
|
-
} catch (err) {
|
|
7711
|
-
console.warn("[Speaker] Toast playback start failed:", err);
|
|
7712
|
-
}
|
|
7713
|
-
}
|
|
7714
7709
|
try {
|
|
7715
7710
|
const providerName = options.provider || this.options.defaultProvider || "minimax";
|
|
7716
7711
|
if (!hasProvider(providerName)) {
|
|
@@ -7735,21 +7730,12 @@ var Speaker = class extends EventEmitter2 {
|
|
|
7735
7730
|
}
|
|
7736
7731
|
} catch (error) {
|
|
7737
7732
|
this.isSpeaking = false;
|
|
7738
|
-
const
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
message: "Playback failed, please check config",
|
|
7745
|
-
variant: "error",
|
|
7746
|
-
duration: 3e3
|
|
7747
|
-
}
|
|
7748
|
-
});
|
|
7749
|
-
} catch (err) {
|
|
7750
|
-
console.warn("[Speaker] Toast playback failed:", err);
|
|
7751
|
-
}
|
|
7752
|
-
}
|
|
7733
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
7734
|
+
toast({
|
|
7735
|
+
title: "TTS playback error",
|
|
7736
|
+
body: errorMessage,
|
|
7737
|
+
type: "error"
|
|
7738
|
+
});
|
|
7753
7739
|
if (error instanceof TTSError) {
|
|
7754
7740
|
this.emit("error", error);
|
|
7755
7741
|
throw error;
|
|
@@ -7879,17 +7865,17 @@ function extractTextArg(args) {
|
|
|
7879
7865
|
const text7 = argObj.text7;
|
|
7880
7866
|
if (text7 !== null && text7 !== void 0) {
|
|
7881
7867
|
if (typeof text7 === "string" && text7.trim().length > 0) {
|
|
7882
|
-
|
|
7868
|
+
logger.warn("received text7 instead of text from OpenCode framework");
|
|
7883
7869
|
return text7.trim();
|
|
7884
7870
|
}
|
|
7885
7871
|
if (typeof text7 === "object" && "content" in text7) {
|
|
7886
7872
|
const content = text7.content;
|
|
7887
7873
|
if (typeof content === "string" && content.trim().length > 0) {
|
|
7888
|
-
|
|
7874
|
+
logger.warn("text7 is an object with content field");
|
|
7889
7875
|
return content.trim();
|
|
7890
7876
|
}
|
|
7891
7877
|
}
|
|
7892
|
-
|
|
7878
|
+
logger.warn({ type: typeof text7 }, "text7 is not a valid string or object with content");
|
|
7893
7879
|
}
|
|
7894
7880
|
for (const key of Object.keys(argObj)) {
|
|
7895
7881
|
if (key.startsWith("text") && key !== "text" && key !== "text7") {
|
|
@@ -7900,7 +7886,7 @@ function extractTextArg(args) {
|
|
|
7900
7886
|
}
|
|
7901
7887
|
}
|
|
7902
7888
|
if (text !== void 0) {
|
|
7903
|
-
|
|
7889
|
+
logger.warn({ type: typeof text }, "text arg is not a valid string");
|
|
7904
7890
|
}
|
|
7905
7891
|
return void 0;
|
|
7906
7892
|
}
|
|
@@ -7962,7 +7948,7 @@ async function handleToolCall(toolName, args) {
|
|
|
7962
7948
|
streamReader2.start();
|
|
7963
7949
|
const textArg = extractTextArg(args);
|
|
7964
7950
|
if (textArg && typeof textArg === "string" && textArg.trim().length > 0) {
|
|
7965
|
-
|
|
7951
|
+
logger.info({ text: textArg.substring(0, 50) + "..." }, "synthesizing text");
|
|
7966
7952
|
synthesizer.synthesize(textArg);
|
|
7967
7953
|
}
|
|
7968
7954
|
return { success: true, message: "Stream speak started" };
|
|
@@ -8917,7 +8903,7 @@ function initializeStreamComponents(config) {
|
|
|
8917
8903
|
},
|
|
8918
8904
|
onProgress: (bytesWritten) => {
|
|
8919
8905
|
},
|
|
8920
|
-
onError: (error) =>
|
|
8906
|
+
onError: (error) => logger.error({ error }, "stream player error"),
|
|
8921
8907
|
onStop: () => {
|
|
8922
8908
|
}
|
|
8923
8909
|
};
|
|
@@ -8931,7 +8917,7 @@ function initializeStreamComponents(config) {
|
|
|
8931
8917
|
try {
|
|
8932
8918
|
await streamingSynthesizer?.synthesize(text);
|
|
8933
8919
|
} catch (error) {
|
|
8934
|
-
|
|
8920
|
+
logger.error({ error }, "synthesize error");
|
|
8935
8921
|
}
|
|
8936
8922
|
}
|
|
8937
8923
|
isSynthesizing = false;
|
|
@@ -9108,7 +9094,7 @@ function loadOrCreateConfig() {
|
|
|
9108
9094
|
}
|
|
9109
9095
|
}
|
|
9110
9096
|
if (!fs2.existsSync(CONFIG_PATH)) {
|
|
9111
|
-
|
|
9097
|
+
logger.info("config file not found, creating default config");
|
|
9112
9098
|
const defaultConfig = generateDefaultConfig();
|
|
9113
9099
|
const configContent = JSON.stringify(defaultConfig, null, 2);
|
|
9114
9100
|
try {
|
|
@@ -9116,13 +9102,13 @@ function loadOrCreateConfig() {
|
|
|
9116
9102
|
try {
|
|
9117
9103
|
fs2.chmodSync(CONFIG_PATH, 384);
|
|
9118
9104
|
} catch (err) {
|
|
9119
|
-
|
|
9105
|
+
logger.warn({ err }, "failed to set config file permissions");
|
|
9120
9106
|
}
|
|
9121
9107
|
} catch (err) {
|
|
9122
|
-
throw new Error(`[ocosay]
|
|
9108
|
+
throw new Error(`[ocosay] cannot write config file ${CONFIG_PATH}: ${err}`);
|
|
9123
9109
|
}
|
|
9124
|
-
|
|
9125
|
-
|
|
9110
|
+
logger.info({ path: CONFIG_PATH }, "config file created");
|
|
9111
|
+
logger.info("please edit config file to add API Key and Base URL");
|
|
9126
9112
|
return defaultConfig;
|
|
9127
9113
|
}
|
|
9128
9114
|
try {
|
|
@@ -9144,7 +9130,7 @@ function loadOrCreateConfig() {
|
|
|
9144
9130
|
}
|
|
9145
9131
|
};
|
|
9146
9132
|
} catch (error) {
|
|
9147
|
-
|
|
9133
|
+
logger.error({ error }, "config file read failed, using default config");
|
|
9148
9134
|
return generateDefaultConfig();
|
|
9149
9135
|
}
|
|
9150
9136
|
}
|
|
@@ -9163,15 +9149,9 @@ try {
|
|
|
9163
9149
|
} catch {
|
|
9164
9150
|
}
|
|
9165
9151
|
var ttsSpeakTool = tool({
|
|
9166
|
-
description: "\u5C06\u6587\u672C\u8F6C\u6362\u4E3A\u8BED\u97F3\u5E76\u64AD\u653E",
|
|
9152
|
+
description: "\u5C06\u6587\u672C\u8F6C\u6362\u4E3A\u8BED\u97F3\u5E76\u64AD\u653E\uFF08\u4F7F\u7528\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u9ED8\u8BA4\u97F3\u8272\u548C\u6A21\u578B\uFF09",
|
|
9167
9153
|
args: {
|
|
9168
|
-
text: tool.schema.string().describe("\u8981\u8F6C\u6362\u7684\u6587\u672C\u5185\u5BB9")
|
|
9169
|
-
provider: tool.schema.string().optional().describe("TTS \u63D0\u4F9B\u5546\u540D\u79F0"),
|
|
9170
|
-
voice: tool.schema.string().optional().describe("\u97F3\u8272 ID"),
|
|
9171
|
-
model: tool.schema.enum(["sync", "async", "stream"]).optional().describe("\u5408\u6210\u6A21\u5F0F"),
|
|
9172
|
-
speed: tool.schema.number().optional().describe("\u8BED\u901F 0.5-2.0"),
|
|
9173
|
-
volume: tool.schema.number().optional().describe("\u97F3\u91CF 0-100"),
|
|
9174
|
-
pitch: tool.schema.number().optional().describe("\u97F3\u8C03 0.5-2.0")
|
|
9154
|
+
text: tool.schema.string().describe("\u8981\u8F6C\u6362\u7684\u6587\u672C\u5185\u5BB9")
|
|
9175
9155
|
},
|
|
9176
9156
|
execute: async (args) => {
|
|
9177
9157
|
const result = await handleToolCall("tts_speak", args);
|
|
@@ -9215,10 +9195,8 @@ var ttsResumeTool = tool({
|
|
|
9215
9195
|
}
|
|
9216
9196
|
});
|
|
9217
9197
|
var ttsListVoicesTool = tool({
|
|
9218
|
-
description: "\u5217\u51FA\u53EF\u7528\u7684\u97F3\u8272",
|
|
9219
|
-
args: {
|
|
9220
|
-
provider: tool.schema.string().optional().describe("TTS \u63D0\u4F9B\u5546\u540D\u79F0")
|
|
9221
|
-
},
|
|
9198
|
+
description: "\u5217\u51FA\u53EF\u7528\u7684\u97F3\u8272\uFF08\u4F7F\u7528\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u9ED8\u8BA4\u63D0\u4F9B\u5546\uFF09",
|
|
9199
|
+
args: {},
|
|
9222
9200
|
execute: async (args) => {
|
|
9223
9201
|
const result = await handleToolCall("tts_list_voices", args);
|
|
9224
9202
|
if (result.success === false) {
|
|
@@ -9250,11 +9228,9 @@ var ttsStatusTool = tool({
|
|
|
9250
9228
|
}
|
|
9251
9229
|
});
|
|
9252
9230
|
var ttsStreamSpeakTool = tool({
|
|
9253
|
-
description: "\u542F\u52A8\u6D41\u5F0F\u6717\u8BFB\uFF08\u8C46\u5305\u6A21\u5F0F\uFF09\uFF0C\u8BA2\u9605AI\u56DE\u590D\u5E76\u8FB9\u751F\u6210\u8FB9\u6717\u8BFB",
|
|
9231
|
+
description: "\u542F\u52A8\u6D41\u5F0F\u6717\u8BFB\uFF08\u8C46\u5305\u6A21\u5F0F\uFF09\uFF0C\u8BA2\u9605AI\u56DE\u590D\u5E76\u8FB9\u751F\u6210\u8FB9\u6717\u8BFB\uFF08\u4F7F\u7528\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u9ED8\u8BA4\u97F3\u8272\uFF09",
|
|
9254
9232
|
args: {
|
|
9255
|
-
text: tool.schema.string().optional().describe("\u521D\u59CB\u6587\u672C\uFF08\u53EF\u9009\uFF09")
|
|
9256
|
-
voice: tool.schema.string().optional().describe("\u97F3\u8272ID"),
|
|
9257
|
-
model: tool.schema.enum(["sync", "async", "stream"]).optional().describe("\u5408\u6210\u6A21\u5F0F")
|
|
9233
|
+
text: tool.schema.string().optional().describe("\u521D\u59CB\u6587\u672C\uFF08\u53EF\u9009\uFF09")
|
|
9258
9234
|
},
|
|
9259
9235
|
execute: async (args) => {
|
|
9260
9236
|
const result = await handleToolCall("tts_stream_speak", args);
|
|
@@ -9302,7 +9278,7 @@ var server = (async (input, _options) => {
|
|
|
9302
9278
|
});
|
|
9303
9279
|
} catch (err) {
|
|
9304
9280
|
initError = err instanceof Error ? err : new Error(String(err));
|
|
9305
|
-
|
|
9281
|
+
logger.error({ error: initError }, "initialization failed");
|
|
9306
9282
|
}
|
|
9307
9283
|
const opencodeTui = input.client?.tui;
|
|
9308
9284
|
global.__opencode_tui__ = opencodeTui;
|