thaddeus 1.0.16 → 1.0.17

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thaddeus",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Thaddeus — Oracle AI's Permanent Agent Terminal",
5
5
  "author": "Delphi Labs Inc.",
6
6
  "license": "PROPRIETARY",
@@ -9,6 +9,7 @@ import { registerReactorCommand } from './reactorBus.js'
9
9
  import { getTunnelUrl, getMobileUrl } from './tunnel.js'
10
10
  import { toDataURL as qrToDataURL } from 'qrcode'
11
11
  import { handlePhoneCommand, handlePhoneRegister, handlePhonePending, handlePhoneAck, handlePhoneStatus } from './phoneApi.js'
12
+ import { getAuthToken, getBackendUrl } from '../services/thaddeusAuth.js'
12
13
 
13
14
  const STATIC_DIR = join(import.meta.dir, 'static')
14
15
  const CERT_DIR = import.meta.dir
@@ -31,7 +32,8 @@ const MIME: Record<string, string> = {
31
32
  }
32
33
 
33
34
  export function startCommandCenterServer(port = 7888) {
34
- // STT transcription — primary provider preferred, fallback to secondary.
35
+ // STT transcription — proxy mode (no local keys) or direct mode (local keys)
36
+ const useProxy = process.env.THADDEUS_USE_PROXY === 'true' || process.env.THADDEUS_USE_PROXY === '1'
35
37
  const GROQ_API_KEY = process.env.GROQ_API_KEY || ''
36
38
  const OPENAI_API_KEY = process.env.OPENAI_API_KEY || ''
37
39
  const useGroq = !!GROQ_API_KEY
@@ -41,8 +43,10 @@ export function startCommandCenterServer(port = 7888) {
41
43
  : 'https://api.openai.com/v1/audio/transcriptions'
42
44
  const WHISPER_MODEL = useGroq ? 'whisper-large-v3' : 'whisper-1'
43
45
 
44
- if (!WHISPER_KEY) {
45
- console.error('[Command Center] No STT API key set — transcription will fail')
46
+ if (!WHISPER_KEY && !useProxy) {
47
+ console.error('[Command Center] No STT API key set and proxy not enabled — transcription will fail')
48
+ } else if (useProxy && !WHISPER_KEY) {
49
+ console.log('[Command Center] Whisper STT via Render proxy')
46
50
  } else {
47
51
  console.log(`[Command Center] Whisper STT via ${useGroq ? 'primary' : 'secondary'} provider`)
48
52
  }
@@ -126,7 +130,36 @@ export function startCommandCenterServer(port = 7888) {
126
130
  const audioFile = formData.get('audio') as File | null
127
131
  if (!audioFile) return new Response('Missing audio file', { status: 400 })
128
132
 
129
- // Forward to OpenAI Whisper API
133
+ // Route through Render proxy when no local Whisper key
134
+ if (useProxy && !WHISPER_KEY) {
135
+ const authToken = getAuthToken()
136
+ const proxyForm = new FormData()
137
+ proxyForm.append('file', audioFile, 'audio.webm')
138
+ proxyForm.append('model', 'whisper-1')
139
+ proxyForm.append('language', 'en')
140
+
141
+ const resp = await fetch(`${getBackendUrl()}/api/thaddeus/stt`, {
142
+ method: 'POST',
143
+ headers: {
144
+ ...(authToken ? { Authorization: `Bearer ${authToken}` } : {}),
145
+ },
146
+ body: proxyForm,
147
+ })
148
+
149
+ if (!resp.ok) {
150
+ const errText = await resp.text()
151
+ console.error('[Command Center] Proxy STT error:', errText)
152
+ return new Response(errText, { status: resp.status })
153
+ }
154
+
155
+ const result = (await resp.json()) as { text: string }
156
+ return Response.json(
157
+ { text: result.text },
158
+ { headers: { 'Access-Control-Allow-Origin': '*' } },
159
+ )
160
+ }
161
+
162
+ // Direct Whisper call (local API key available)
130
163
  const whisperForm = new FormData()
131
164
  whisperForm.append('file', audioFile, 'audio.webm')
132
165
  whisperForm.append('model', WHISPER_MODEL)