@mingxy/ocosay 1.0.29 → 1.0.31
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/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 +118 -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;
|
|
@@ -7604,32 +7604,46 @@ import { homedir } from "os";
|
|
|
7604
7604
|
import { join as join5 } from "path";
|
|
7605
7605
|
import { existsSync as existsSync4, mkdirSync } from "fs";
|
|
7606
7606
|
var logDir = join5(homedir(), ".ocosay");
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
}
|
|
7607
|
+
var logFile = join5(logDir, "ocosay.log");
|
|
7608
|
+
if (!existsSync4(logDir)) {
|
|
7609
|
+
try {
|
|
7610
|
+
mkdirSync(logDir, { recursive: true });
|
|
7611
|
+
} catch {
|
|
7613
7612
|
}
|
|
7614
7613
|
}
|
|
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";
|
|
7614
|
+
var streams = [
|
|
7615
|
+
{ stream: process.stdout }
|
|
7616
|
+
];
|
|
7617
|
+
try {
|
|
7618
|
+
streams.push({ stream: import_pino.default.destination({ dest: logFile, mkdir: true }) });
|
|
7619
|
+
} catch {
|
|
7630
7620
|
}
|
|
7621
|
+
var level = process.env.NODE_ENV !== "production" ? "debug" : process.env.OCOSAY_LOG_LEVEL || "info";
|
|
7622
|
+
var logger = (0, import_pino.default)(
|
|
7623
|
+
{
|
|
7624
|
+
level,
|
|
7625
|
+
base: { service: "ocosay" },
|
|
7626
|
+
timestamp: import_pino.default.stdTimeFunctions.isoTime
|
|
7627
|
+
},
|
|
7628
|
+
import_pino.default.multistream(streams)
|
|
7629
|
+
);
|
|
7631
7630
|
|
|
7632
7631
|
// src/core/speaker.ts
|
|
7632
|
+
function toast(options) {
|
|
7633
|
+
const tui = global.__opencode_tui__;
|
|
7634
|
+
if (tui?.showToast) {
|
|
7635
|
+
try {
|
|
7636
|
+
tui.showToast({
|
|
7637
|
+
title: options.title,
|
|
7638
|
+
message: options.body,
|
|
7639
|
+
variant: options.type,
|
|
7640
|
+
duration: 3e3
|
|
7641
|
+
});
|
|
7642
|
+
} catch (err) {
|
|
7643
|
+
logger.warn({ err }, "toast call failed");
|
|
7644
|
+
}
|
|
7645
|
+
}
|
|
7646
|
+
}
|
|
7633
7647
|
var Speaker = class extends EventEmitter2 {
|
|
7634
7648
|
constructor(options = {}) {
|
|
7635
7649
|
super();
|
|
@@ -7639,21 +7653,11 @@ var Speaker = class extends EventEmitter2 {
|
|
|
7639
7653
|
onEnd: () => {
|
|
7640
7654
|
this.isSpeaking = false;
|
|
7641
7655
|
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
|
-
}
|
|
7656
|
+
toast({
|
|
7657
|
+
title: "TTS playback success",
|
|
7658
|
+
body: "Audio generated and playing",
|
|
7659
|
+
type: "info"
|
|
7660
|
+
});
|
|
7657
7661
|
},
|
|
7658
7662
|
onError: (error) => this.emit("error", error),
|
|
7659
7663
|
onPause: () => {
|
|
@@ -7696,21 +7700,6 @@ var Speaker = class extends EventEmitter2 {
|
|
|
7696
7700
|
}
|
|
7697
7701
|
this.isSpeaking = true;
|
|
7698
7702
|
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
7703
|
try {
|
|
7715
7704
|
const providerName = options.provider || this.options.defaultProvider || "minimax";
|
|
7716
7705
|
if (!hasProvider(providerName)) {
|
|
@@ -7735,21 +7724,12 @@ var Speaker = class extends EventEmitter2 {
|
|
|
7735
7724
|
}
|
|
7736
7725
|
} catch (error) {
|
|
7737
7726
|
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
|
-
}
|
|
7727
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
7728
|
+
toast({
|
|
7729
|
+
title: "TTS playback error",
|
|
7730
|
+
body: errorMessage,
|
|
7731
|
+
type: "error"
|
|
7732
|
+
});
|
|
7753
7733
|
if (error instanceof TTSError) {
|
|
7754
7734
|
this.emit("error", error);
|
|
7755
7735
|
throw error;
|
|
@@ -7879,17 +7859,17 @@ function extractTextArg(args) {
|
|
|
7879
7859
|
const text7 = argObj.text7;
|
|
7880
7860
|
if (text7 !== null && text7 !== void 0) {
|
|
7881
7861
|
if (typeof text7 === "string" && text7.trim().length > 0) {
|
|
7882
|
-
|
|
7862
|
+
logger.warn("received text7 instead of text from OpenCode framework");
|
|
7883
7863
|
return text7.trim();
|
|
7884
7864
|
}
|
|
7885
7865
|
if (typeof text7 === "object" && "content" in text7) {
|
|
7886
7866
|
const content = text7.content;
|
|
7887
7867
|
if (typeof content === "string" && content.trim().length > 0) {
|
|
7888
|
-
|
|
7868
|
+
logger.warn("text7 is an object with content field");
|
|
7889
7869
|
return content.trim();
|
|
7890
7870
|
}
|
|
7891
7871
|
}
|
|
7892
|
-
|
|
7872
|
+
logger.warn({ type: typeof text7 }, "text7 is not a valid string or object with content");
|
|
7893
7873
|
}
|
|
7894
7874
|
for (const key of Object.keys(argObj)) {
|
|
7895
7875
|
if (key.startsWith("text") && key !== "text" && key !== "text7") {
|
|
@@ -7900,7 +7880,7 @@ function extractTextArg(args) {
|
|
|
7900
7880
|
}
|
|
7901
7881
|
}
|
|
7902
7882
|
if (text !== void 0) {
|
|
7903
|
-
|
|
7883
|
+
logger.warn({ type: typeof text }, "text arg is not a valid string");
|
|
7904
7884
|
}
|
|
7905
7885
|
return void 0;
|
|
7906
7886
|
}
|
|
@@ -7962,7 +7942,7 @@ async function handleToolCall(toolName, args) {
|
|
|
7962
7942
|
streamReader2.start();
|
|
7963
7943
|
const textArg = extractTextArg(args);
|
|
7964
7944
|
if (textArg && typeof textArg === "string" && textArg.trim().length > 0) {
|
|
7965
|
-
|
|
7945
|
+
logger.info({ text: textArg.substring(0, 50) + "..." }, "synthesizing text");
|
|
7966
7946
|
synthesizer.synthesize(textArg);
|
|
7967
7947
|
}
|
|
7968
7948
|
return { success: true, message: "Stream speak started" };
|
|
@@ -8917,7 +8897,7 @@ function initializeStreamComponents(config) {
|
|
|
8917
8897
|
},
|
|
8918
8898
|
onProgress: (bytesWritten) => {
|
|
8919
8899
|
},
|
|
8920
|
-
onError: (error) =>
|
|
8900
|
+
onError: (error) => logger.error({ error }, "stream player error"),
|
|
8921
8901
|
onStop: () => {
|
|
8922
8902
|
}
|
|
8923
8903
|
};
|
|
@@ -8931,7 +8911,7 @@ function initializeStreamComponents(config) {
|
|
|
8931
8911
|
try {
|
|
8932
8912
|
await streamingSynthesizer?.synthesize(text);
|
|
8933
8913
|
} catch (error) {
|
|
8934
|
-
|
|
8914
|
+
logger.error({ error }, "synthesize error");
|
|
8935
8915
|
}
|
|
8936
8916
|
}
|
|
8937
8917
|
isSynthesizing = false;
|
|
@@ -9108,7 +9088,7 @@ function loadOrCreateConfig() {
|
|
|
9108
9088
|
}
|
|
9109
9089
|
}
|
|
9110
9090
|
if (!fs2.existsSync(CONFIG_PATH)) {
|
|
9111
|
-
|
|
9091
|
+
logger.info("config file not found, creating default config");
|
|
9112
9092
|
const defaultConfig = generateDefaultConfig();
|
|
9113
9093
|
const configContent = JSON.stringify(defaultConfig, null, 2);
|
|
9114
9094
|
try {
|
|
@@ -9116,13 +9096,13 @@ function loadOrCreateConfig() {
|
|
|
9116
9096
|
try {
|
|
9117
9097
|
fs2.chmodSync(CONFIG_PATH, 384);
|
|
9118
9098
|
} catch (err) {
|
|
9119
|
-
|
|
9099
|
+
logger.warn({ err }, "failed to set config file permissions");
|
|
9120
9100
|
}
|
|
9121
9101
|
} catch (err) {
|
|
9122
|
-
throw new Error(`[ocosay]
|
|
9102
|
+
throw new Error(`[ocosay] cannot write config file ${CONFIG_PATH}: ${err}`);
|
|
9123
9103
|
}
|
|
9124
|
-
|
|
9125
|
-
|
|
9104
|
+
logger.info({ path: CONFIG_PATH }, "config file created");
|
|
9105
|
+
logger.info("please edit config file to add API Key and Base URL");
|
|
9126
9106
|
return defaultConfig;
|
|
9127
9107
|
}
|
|
9128
9108
|
try {
|
|
@@ -9144,7 +9124,7 @@ function loadOrCreateConfig() {
|
|
|
9144
9124
|
}
|
|
9145
9125
|
};
|
|
9146
9126
|
} catch (error) {
|
|
9147
|
-
|
|
9127
|
+
logger.error({ error }, "config file read failed, using default config");
|
|
9148
9128
|
return generateDefaultConfig();
|
|
9149
9129
|
}
|
|
9150
9130
|
}
|
|
@@ -9163,15 +9143,9 @@ try {
|
|
|
9163
9143
|
} catch {
|
|
9164
9144
|
}
|
|
9165
9145
|
var ttsSpeakTool = tool({
|
|
9166
|
-
description: "\u5C06\u6587\u672C\u8F6C\u6362\u4E3A\u8BED\u97F3\u5E76\u64AD\u653E",
|
|
9146
|
+
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
9147
|
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")
|
|
9148
|
+
text: tool.schema.string().describe("\u8981\u8F6C\u6362\u7684\u6587\u672C\u5185\u5BB9")
|
|
9175
9149
|
},
|
|
9176
9150
|
execute: async (args) => {
|
|
9177
9151
|
const result = await handleToolCall("tts_speak", args);
|
|
@@ -9215,10 +9189,8 @@ var ttsResumeTool = tool({
|
|
|
9215
9189
|
}
|
|
9216
9190
|
});
|
|
9217
9191
|
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
|
-
},
|
|
9192
|
+
description: "\u5217\u51FA\u53EF\u7528\u7684\u97F3\u8272\uFF08\u4F7F\u7528\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u9ED8\u8BA4\u63D0\u4F9B\u5546\uFF09",
|
|
9193
|
+
args: {},
|
|
9222
9194
|
execute: async (args) => {
|
|
9223
9195
|
const result = await handleToolCall("tts_list_voices", args);
|
|
9224
9196
|
if (result.success === false) {
|
|
@@ -9250,11 +9222,9 @@ var ttsStatusTool = tool({
|
|
|
9250
9222
|
}
|
|
9251
9223
|
});
|
|
9252
9224
|
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",
|
|
9225
|
+
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
9226
|
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")
|
|
9227
|
+
text: tool.schema.string().optional().describe("\u521D\u59CB\u6587\u672C\uFF08\u53EF\u9009\uFF09")
|
|
9258
9228
|
},
|
|
9259
9229
|
execute: async (args) => {
|
|
9260
9230
|
const result = await handleToolCall("tts_stream_speak", args);
|
|
@@ -9302,7 +9272,7 @@ var server = (async (input, _options) => {
|
|
|
9302
9272
|
});
|
|
9303
9273
|
} catch (err) {
|
|
9304
9274
|
initError = err instanceof Error ? err : new Error(String(err));
|
|
9305
|
-
|
|
9275
|
+
logger.error({ error: initError }, "initialization failed");
|
|
9306
9276
|
}
|
|
9307
9277
|
const opencodeTui = input.client?.tui;
|
|
9308
9278
|
global.__opencode_tui__ = opencodeTui;
|