@ducci/jarvis 1.0.93 → 1.0.95
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/package.json
CHANGED
|
@@ -697,7 +697,6 @@ export async function startTelegramChannel(config) {
|
|
|
697
697
|
await sendMessage(api, chatId, displayText, result.sessionId);
|
|
698
698
|
console.log(`[telegram] response sent chat_id=${chatId} slot=${slot} length=${displayText.length}`);
|
|
699
699
|
// TTS: send audio summary if voice is enabled (config.voiceEnabled checked live, updated by /voice toggle)
|
|
700
|
-
await api.sendMessage(chatId, `[TTS debug] voiceEnabled=${config.voiceEnabled} hasKey=${!!config.fishAudioApiKey}`).catch(() => {});
|
|
701
700
|
if (config.voiceEnabled && config.fishAudioApiKey) {
|
|
702
701
|
try {
|
|
703
702
|
// If the response is a raw JSON blob (format_error recovery), extract the actual text
|
|
@@ -709,12 +708,8 @@ export async function startTelegramChannel(config) {
|
|
|
709
708
|
const plain = toPlainText(ttsSource);
|
|
710
709
|
if (plain) {
|
|
711
710
|
const ttsText = await generateTtsSummary(plain, config);
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
await api.sendMessage(chatId, `[TTS debug] summary="${ttsText}" finalLen=${finalTtsText.length}`).catch(() => {});
|
|
715
|
-
if (finalTtsText) {
|
|
716
|
-
const audioBuffer = await textToSpeech(finalTtsText, config);
|
|
717
|
-
await api.sendMessage(chatId, `[TTS debug] audio bytes: ${audioBuffer.length}`).catch(() => {});
|
|
711
|
+
if (ttsText) {
|
|
712
|
+
const audioBuffer = await textToSpeech(ttsText, config);
|
|
718
713
|
await api.sendAudio(chatId, new InputFile(audioBuffer, 'response.mp3'));
|
|
719
714
|
console.log(`[telegram] voice sent chat_id=${chatId} slot=${slot} tts_chars=${ttsText.length}`);
|
|
720
715
|
}
|
package/src/server/agent.js
CHANGED
|
@@ -131,6 +131,18 @@ function extractApiError(err, model) {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
// Extract the most specific error description available.
|
|
135
|
+
// Provider-specific APIs (e.g. z.ai) return a code + message in err.error;
|
|
136
|
+
// the OpenAI SDK sets err.message to the body message but sometimes prepends
|
|
137
|
+
// the HTTP status code, making it less readable. Prefer err.error.message + code.
|
|
138
|
+
function describeApiError(err) {
|
|
139
|
+
const bodyMsg = err?.error?.message;
|
|
140
|
+
const bodyCode = err?.error?.code;
|
|
141
|
+
if (bodyMsg && bodyCode) return `${bodyMsg} (code: ${bodyCode})`;
|
|
142
|
+
if (bodyMsg) return bodyMsg;
|
|
143
|
+
return err?.message ?? String(err);
|
|
144
|
+
}
|
|
145
|
+
|
|
134
146
|
async function callModelWithFallback(client, config, messages, tools) {
|
|
135
147
|
let primaryErr = null;
|
|
136
148
|
try {
|
|
@@ -141,9 +153,21 @@ async function callModelWithFallback(client, config, messages, tools) {
|
|
|
141
153
|
try {
|
|
142
154
|
return await callModel(client, config.fallbackModel, messages, tools);
|
|
143
155
|
} catch (fallbackErr) {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
const primaryDesc = describeApiError(primaryErr);
|
|
157
|
+
const fallbackDesc = describeApiError(fallbackErr);
|
|
158
|
+
const sameModel = config.selectedModel === config.fallbackModel;
|
|
159
|
+
const sameError = primaryDesc === fallbackDesc;
|
|
160
|
+
|
|
161
|
+
let msg;
|
|
162
|
+
if (sameModel && sameError) {
|
|
163
|
+
msg = `Model (${config.selectedModel}) failed: ${fallbackDesc}`;
|
|
164
|
+
} else if (sameModel) {
|
|
165
|
+
msg = `Model (${config.selectedModel}) failed. Primary: ${primaryDesc} | Fallback: ${fallbackDesc}`;
|
|
166
|
+
} else {
|
|
167
|
+
msg = `Both primary (${config.selectedModel}) and fallback (${config.fallbackModel}) models failed. Primary: ${primaryDesc} | Fallback: ${fallbackDesc}`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const combined = new Error(msg);
|
|
147
171
|
combined.apiErrors = {
|
|
148
172
|
primary: extractApiError(primaryErr, config.selectedModel),
|
|
149
173
|
fallback: extractApiError(fallbackErr, config.fallbackModel),
|