thaddeus 1.0.12 → 1.0.13
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/bin/thaddeus.js +2 -4
- package/package.json +1 -1
- package/src/services/elevenlabsTTS.ts +36 -4
package/bin/thaddeus.js
CHANGED
|
@@ -59,10 +59,8 @@ env.THADDEUS_USE_XAI = 'true';
|
|
|
59
59
|
env.THADDEUS_USE_PROXY = 'true'; // Route through Render backend (has xAI/ElevenLabs/Twilio keys)
|
|
60
60
|
env.CLAUBBIT = '1';
|
|
61
61
|
|
|
62
|
-
// Auth token — set via env var
|
|
63
|
-
|
|
64
|
-
env.THADDEUS_AUTH_TOKEN = 'thd_8afadf66c4da726e27628871f7c3c635c567d3bae7d6246ade13a3a452110605';
|
|
65
|
-
}
|
|
62
|
+
// Auth token — set via THADDEUS_AUTH_TOKEN env var, .env file, or ~/.thaddeus/auth.json
|
|
63
|
+
// Do NOT hardcode tokens here — npm package is public
|
|
66
64
|
|
|
67
65
|
// Remove conflicting auth from other installs
|
|
68
66
|
delete env.ANTHROPIC_API_KEY;
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import { unlink, writeFile } from 'fs/promises'
|
|
|
11
11
|
import { tmpdir } from 'os'
|
|
12
12
|
import { join } from 'path'
|
|
13
13
|
import { logError } from '../utils/log.js'
|
|
14
|
+
import { getAuthToken, getBackendUrl } from './thaddeusAuth.js'
|
|
14
15
|
|
|
15
16
|
// ─── Configuration ──────────────────────────────────────────────────
|
|
16
17
|
|
|
@@ -59,9 +60,10 @@ export function stop(): void {
|
|
|
59
60
|
export async function speak(text: string): Promise<void> {
|
|
60
61
|
if (!ttsEnabled) return
|
|
61
62
|
|
|
63
|
+
const useProxy = process.env.THADDEUS_USE_PROXY === 'true' || process.env.THADDEUS_USE_PROXY === '1'
|
|
62
64
|
const apiKey = process.env.ELEVENLABS_API_KEY
|
|
63
|
-
if (!apiKey) {
|
|
64
|
-
logError(new Error('[elevenlabsTTS] ELEVENLABS_API_KEY not set'))
|
|
65
|
+
if (!apiKey && !useProxy) {
|
|
66
|
+
logError(new Error('[elevenlabsTTS] ELEVENLABS_API_KEY not set and proxy not enabled'))
|
|
65
67
|
return
|
|
66
68
|
}
|
|
67
69
|
|
|
@@ -113,10 +115,40 @@ export async function speak(text: string): Promise<void> {
|
|
|
113
115
|
// ─── Internal: API call ─────────────────────────────────────────────
|
|
114
116
|
|
|
115
117
|
async function fetchTTSAudio(
|
|
116
|
-
apiKey: string,
|
|
118
|
+
apiKey: string | undefined,
|
|
117
119
|
text: string,
|
|
118
120
|
signal: AbortSignal,
|
|
119
121
|
): Promise<ArrayBuffer | null> {
|
|
122
|
+
const useProxy = process.env.THADDEUS_USE_PROXY === 'true' || process.env.THADDEUS_USE_PROXY === '1'
|
|
123
|
+
|
|
124
|
+
// Route through Render proxy — backend holds the ElevenLabs key
|
|
125
|
+
if (useProxy) {
|
|
126
|
+
const authToken = getAuthToken()
|
|
127
|
+
const proxyUrl = `${getBackendUrl()}/api/thaddeus/tts`
|
|
128
|
+
const response = await fetch(proxyUrl, {
|
|
129
|
+
method: 'POST',
|
|
130
|
+
headers: {
|
|
131
|
+
'Content-Type': 'application/json',
|
|
132
|
+
Accept: 'audio/mpeg',
|
|
133
|
+
...(authToken ? { Authorization: `Bearer ${authToken}` } : {}),
|
|
134
|
+
},
|
|
135
|
+
body: JSON.stringify({
|
|
136
|
+
text,
|
|
137
|
+
voice_id: VOICE_ID,
|
|
138
|
+
model_id: MODEL_ID,
|
|
139
|
+
}),
|
|
140
|
+
signal,
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
if (!response.ok) {
|
|
144
|
+
const body = await response.text().catch(() => '<unreadable>')
|
|
145
|
+
logError(new Error(`[elevenlabsTTS] Proxy error ${response.status}: ${body.slice(0, 200)}`))
|
|
146
|
+
return null
|
|
147
|
+
}
|
|
148
|
+
return response.arrayBuffer()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Direct ElevenLabs call (when user has own API key)
|
|
120
152
|
const url = `${API_BASE}/${VOICE_ID}`
|
|
121
153
|
|
|
122
154
|
const response = await fetch(url, {
|
|
@@ -124,7 +156,7 @@ async function fetchTTSAudio(
|
|
|
124
156
|
headers: {
|
|
125
157
|
Accept: 'audio/mpeg',
|
|
126
158
|
'Content-Type': 'application/json',
|
|
127
|
-
'xi-api-key': apiKey
|
|
159
|
+
'xi-api-key': apiKey!,
|
|
128
160
|
},
|
|
129
161
|
body: JSON.stringify({
|
|
130
162
|
text,
|