feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes

This commit is contained in:
Yun Chan 2026-11-14 11:51:41 +09:00
parent 01ef3293cf
commit 66b6b45ba9
399 changed files with 17828 additions and 11330 deletions

View file

@ -14,7 +14,8 @@
// "no speech" result: it is never retried on the next paid provider and is answered
// with a fixed `stt_no_speech` code (clients reject a 200 with an empty transcript).
import { corsHeaders, handleCorsPreflightRequest } from '../_shared/cors.ts'
import { handleCorsPreflightRequest } from '../_shared/cors.ts'
import { createStatusJsonResponder } from '../_shared/json-response.ts'
import {
type DictionaryHints,
type NormalizedSttResult,
@ -116,12 +117,7 @@ export async function runSttChain(
return { kind: 'failed', billed, unavailable, attempts }
}
function json(status: number, payload: unknown): Response {
return new Response(JSON.stringify(payload), {
status,
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
})
}
const json = createStatusJsonResponder()
export function createSttProxyHandler(deps: SttProxyDeps): (req: Request) => Promise<Response> {
const { quota, logger } = deps
@ -142,7 +138,12 @@ export function createSttProxyHandler(deps: SttProxyDeps): (req: Request) => Pro
const user = auth.user
// 2) input
const formData = await req.formData()
let formData: FormData
try {
formData = await req.formData()
} catch {
return json(400, { error: 'invalid_multipart_body' })
}
const audio = formData.get('audio') ?? formData.get('file')
const languageCode = String(formData.get('language_code') ?? 'ko')
if (!(audio instanceof Blob)) return json(400, { error: 'Missing audio field' })