@burdenoff/microfe-healthybowl 2026.831.7 → 2026.831.9

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.
@@ -35,31 +35,33 @@ function s(s) {
35
35
  }
36
36
  return p;
37
37
  }
38
- function _(e, t) {
39
- return new Promise((n, r) => {
38
+ function _(e, t, n) {
39
+ return new Promise((r, i) => {
40
40
  if (t !== d) {
41
- n();
41
+ r();
42
42
  return;
43
43
  }
44
- let i = new Blob([e.slice().buffer], { type: "audio/mpeg" });
45
- m(), u = URL.createObjectURL(i);
46
- let a = new Audio(u);
47
- l = a, a.onended = () => {
48
- t === d && n();
49
- }, a.onerror = () => {
44
+ let a = new Blob([e.slice().buffer], { type: "audio/mpeg" });
45
+ m(), u = URL.createObjectURL(a);
46
+ let o = new Audio(u);
47
+ l = o, o.onended = () => {
48
+ t === d && r();
49
+ }, o.onerror = () => {
50
50
  if (t !== d) {
51
- n();
51
+ r();
52
52
  return;
53
53
  }
54
54
  let e = /* @__PURE__ */ Error("audio playback failed");
55
- e.reason = "unknown", r(e);
56
- }, a.play().catch((e) => {
55
+ e.reason = "unknown", i(e);
56
+ }, o.play().then(() => {
57
+ t === d && n?.();
58
+ }, (e) => {
57
59
  if (t !== d) {
58
- n();
60
+ r();
59
61
  return;
60
62
  }
61
- let i = /* @__PURE__ */ Error("audio play rejected");
62
- i.reason = e?.name === "NotAllowedError" ? "not-allowed" : "unknown", r(i);
63
+ let n = /* @__PURE__ */ Error("audio play rejected");
64
+ n.reason = e?.name === "NotAllowedError" ? "not-allowed" : "unknown", i(n);
63
65
  });
64
66
  });
65
67
  }
@@ -85,19 +87,21 @@ function s(s) {
85
87
  h();
86
88
  let a = new AbortController();
87
89
  f = a;
88
- let s = (e) => {
90
+ let s = !1, c = () => {
91
+ s || (s = !0, n.onStart?.());
92
+ }, l = (e) => {
89
93
  let n = g(e, t, a.signal);
90
94
  return n.catch(() => {}), n;
91
95
  };
92
96
  (async () => {
93
97
  try {
94
- let e = s(r[0]);
98
+ let e = l(r[0]);
95
99
  for (let t = 0; t < r.length; t += 1) {
96
100
  if (i !== d) return;
97
101
  let n = await e;
98
102
  if (i !== d) return;
99
103
  let a = r[t + 1];
100
- a !== void 0 && (e = s(a)), await _(n, i);
104
+ a !== void 0 && (e = l(a)), await _(n, i, c);
101
105
  }
102
106
  i === d && n.onEnd?.();
103
107
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"hostedTtsSpeechEngine.js","names":[],"sources":["../../../src/services/speech/hostedTtsSpeechEngine.ts"],"sourcesContent":["/**\n * Hosted (server-side) implementation of the `SpeechEngine` seam (BOFF-7111).\n *\n * The device-voice engine is as good as it is ever going to get: the Web Speech\n * API can only play voices the OS has installed, and on the devices that matter\n * here those are compact voices that do not sound human. Every knob was already\n * turned — rate, voice ranking, punctuation — and the result is still not close\n * to Assistant quality. The remaining gap IS the synthesiser, so this engine\n * replaces it.\n *\n * Structure mirrors `browserSpeechEngine` deliberately:\n * - **A generation counter.** `cancel()` bumps it; any fetch or `ended` event\n * from an older batch is dropped rather than clearing the state of a\n * playback that has already started.\n * - **Chunks played in order**, with the NEXT chunk fetched while the current\n * one plays. Without that prefetch every chunk boundary costs a full network\n * round trip and the reply sounds stuttered — worse than the device voice it\n * replaces.\n * - **Everything testable lives elsewhere** (`hostedTtsProtocol.ts`,\n * `hostedVoiceCatalogue.ts`) because this repo's vitest has no DOM and no\n * audio, so this file cannot be unit-tested.\n *\n * Failure is never silent: any error surfaces through `onError`, and the caller\n * (`createSpeechEngine`) is what decides to fall back to the device engine.\n */\n\nimport { HOSTED_TTS_TIER, HOSTED_VOICES, hostedLocaleFor } from './hostedVoiceCatalogue';\nimport { buildRequest, classifyHttpFailure, decodeAudioResponse, splitForVendor } from './hostedTtsProtocol';\nimport type { SpeechEngine, SpeechSpeakHandlers, SpeechSpeakOptions, SpeechVoiceLike } from './types';\n\nexport interface HostedTtsOptions {\n /** Absolute or same-origin path of OUR proxy. Never the vendor directly. */\n endpoint: string;\n /** Extra headers per request (auth). Called fresh each time so a rotated token is picked up. */\n getHeaders?: () => Record<string, string>;\n fetchImpl?: typeof fetch;\n}\n\nexport function createHostedTtsEngine(options: HostedTtsOptions): SpeechEngine {\n const doFetch = options.fetchImpl ?? ((...args: Parameters<typeof fetch>) => fetch(...args));\n let audio: HTMLAudioElement | null = null;\n let objectUrl: string | null = null;\n /**\n * Bumped on every `speak`/`cancel`; anything from an older batch is ignored.\n *\n * Per INSTANCE, not per module. `browserSpeechEngine` can keep this at module\n * scope because it is a singleton object; this is a factory, so a shared\n * counter would let one engine's `cancel()` silently invalidate another\n * engine's in-flight playback.\n */\n let generation = 0;\n /** The in-flight batch's controller, so `cancel()` can actually abort it. */\n let active: AbortController | null = null;\n /**\n * Set after a terminal proxy failure (401/403/404/501). Retrying cannot\n * succeed, and leaving the engine \"supported\" means every later press repeats\n * the same failing request. Reporting unsupported makes the routing engine\n * fall back to device voices, which still work.\n */\n let disabled = false;\n\n const releaseUrl = () => {\n if (objectUrl) {\n URL.revokeObjectURL(objectUrl);\n objectUrl = null;\n }\n };\n\n const stopAudio = () => {\n if (audio) {\n audio.onended = null;\n audio.onerror = null;\n try {\n audio.pause();\n } catch {\n /* pausing an already-dead element is harmless */\n }\n audio = null;\n }\n releaseUrl();\n };\n\n /** One chunk of text -> audio bytes. Throws with a `reason` the engine maps. */\n async function synthesise(text: string, opts: SpeechSpeakOptions, signal: AbortSignal): Promise<Uint8Array> {\n // The vendor's locale, not the app's: the app says `ar-SA`, Google only has\n // `ar-XA`. Sending the app tag would be an unsupported locale AND would\n // make `buildRequest` drop the chosen `ar-XA` voice as a mismatch.\n const languageCode = hostedLocaleFor(opts.lang) ?? opts.lang;\n const body = buildRequest(text, languageCode, HOSTED_TTS_TIER, opts.voice?.name ?? null, opts.rate);\n const response = await doFetch(options.endpoint, {\n method: 'POST',\n signal,\n headers: { 'content-type': 'application/json', ...(options.getHeaders?.() ?? {}) },\n body: JSON.stringify(body),\n });\n if (!response.ok) {\n const err = new Error(`hosted tts ${response.status}`) as Error & { reason?: string };\n err.reason = classifyHttpFailure(response.status);\n throw err;\n }\n const contentType = response.headers.get('content-type');\n const payload = contentType?.includes('json') ? await response.json() : await response.arrayBuffer();\n const bytes = decodeAudioResponse(contentType, payload);\n if (!bytes) {\n // A 200 carrying no audio is a failure, not silence. Treating it as\n // success is exactly the dead-button bug this feature already fixed once.\n const err = new Error('hosted tts returned no audio') as Error & { reason?: string };\n err.reason = 'unknown';\n throw err;\n }\n return bytes;\n }\n\n function play(bytes: Uint8Array, batch: number): Promise<void> {\n return new Promise((resolve, reject) => {\n if (batch !== generation) {\n resolve();\n return;\n }\n // Copy into a fresh ArrayBuffer: the Uint8Array may be a view over a\n // larger buffer, and Blob would then include the neighbouring bytes.\n const blob = new Blob([bytes.slice().buffer as ArrayBuffer], { type: 'audio/mpeg' });\n releaseUrl();\n objectUrl = URL.createObjectURL(blob);\n const element = new Audio(objectUrl);\n audio = element;\n element.onended = () => {\n if (batch !== generation) return;\n resolve();\n };\n element.onerror = () => {\n if (batch !== generation) {\n resolve();\n return;\n }\n const err = new Error('audio playback failed') as Error & { reason?: string };\n err.reason = 'unknown';\n reject(err);\n };\n element.play().catch((cause: unknown) => {\n if (batch !== generation) {\n resolve();\n return;\n }\n // Autoplay policy: playback needs a user gesture. Every path that\n // starts speech here is a button press, but an auto-speak triggered\n // by an arriving reply is not, and that is the case this reports.\n const err = new Error('audio play rejected') as Error & { reason?: string };\n err.reason = (cause as DOMException)?.name === 'NotAllowedError' ? 'not-allowed' : 'unknown';\n reject(err);\n });\n });\n }\n\n return {\n id: 'hosted-tts',\n\n isSupported(): boolean {\n if (disabled) return false;\n return typeof window !== 'undefined' && typeof window.Audio === 'function' && typeof fetch === 'function';\n },\n\n listVoices(): SpeechVoiceLike[] {\n // A hosted catalogue is known up front, so unlike the browser engine\n // there is never an empty-then-populated race: `voiceAvailability` sees a\n // full list on the first read and never reports `pending`.\n return [...HOSTED_VOICES];\n },\n\n subscribeVoices(): () => void {\n // The catalogue is static — nothing to subscribe to. Returning a no-op\n // unsubscribe keeps the caller identical for both engines.\n return () => {};\n },\n\n speak(chunks: readonly string[], opts: SpeechSpeakOptions, handlers: SpeechSpeakHandlers = {}): void {\n const speakable = chunks.filter((chunk) => chunk.trim().length > 0).flatMap((chunk) => splitForVendor(chunk));\n if (speakable.length === 0) {\n handlers.onEnd?.();\n return;\n }\n\n generation += 1;\n const batch = generation;\n stopAudio();\n const controller = new AbortController();\n active = controller;\n\n /**\n * Start a request and neutralise it as an unhandled rejection.\n *\n * A prefetched chunk is abandoned whenever the batch is cancelled\n * mid-loop. Attaching a swallow handler here does NOT consume the\n * rejection for the real `await` — `.catch` returns a NEW promise and the\n * original still rejects — so the error is still reported if we get that\n * far, and is silent if we never do.\n */\n const start = (text: string): Promise<Uint8Array> => {\n const request = synthesise(text, opts, controller.signal);\n request.catch(() => {});\n return request;\n };\n\n void (async () => {\n try {\n // Fetch the first chunk, then keep exactly one chunk in flight ahead\n // of playback so a boundary never costs a whole round trip.\n let pending: Promise<Uint8Array> = start(speakable[0] as string);\n for (let i = 0; i < speakable.length; i += 1) {\n if (batch !== generation) return;\n const current = await pending;\n if (batch !== generation) return;\n const next = speakable[i + 1];\n // On the last chunk nothing new is queued; `pending` keeps its\n // already-settled value and the loop simply ends.\n if (next !== undefined) pending = start(next);\n await play(current, batch);\n }\n if (batch === generation) handlers.onEnd?.();\n } catch (cause) {\n controller.abort();\n if (batch !== generation) return; // cancelled — the caller already knows\n generation += 1; // abandon the rest of this batch\n stopAudio();\n const reason = (cause as { reason?: string })?.reason;\n // Terminal: the proxy is missing or refuses us, and retrying cannot\n // succeed. Stop claiming support so the routing engine falls back to\n // device voices from now on, instead of every later press repeating\n // the same failing request.\n if (reason === 'not-allowed' || reason === 'unsupported') disabled = true;\n handlers.onError?.(\n reason === 'not-allowed' || reason === 'unsupported' || reason === 'cancelled' ? reason : 'unknown'\n );\n }\n })();\n },\n\n cancel(): void {\n generation += 1;\n // Abort the in-flight synthesis too. Without this a cancelled reply keeps\n // downloading — and keeps costing billable vendor characters — until it\n // completes into a batch nobody is listening to.\n active?.abort();\n active = null;\n stopAudio();\n },\n };\n}\n"],"mappings":";;;AAsCA,SAAgB,EAAsB,GAAyC;CAC7E,IAAM,IAAU,EAAQ,eAAe,GAAG,MAAmC,MAAM,GAAG,CAAI,IACtF,IAAiC,MACjC,IAA2B,MAS3B,IAAa,GAEb,IAAiC,MAOjC,IAAW,IAET,UAAmB;EACvB,AAEE,OADA,IAAI,gBAAgB,CAAS,GACjB;CAEhB,GAEM,UAAkB;EACtB,IAAI,GAAO;GAET,AADA,EAAM,UAAU,MAChB,EAAM,UAAU;GAChB,IAAI;IACF,EAAM,MAAM;GACd,QAAQ,CAER;GACA,IAAQ;EACV;EACA,EAAW;CACb;CAGA,eAAe,EAAW,GAAc,GAA0B,GAA0C;EAK1G,IAAM,IAAO,EAAa,GADL,EAAgB,EAAK,IAAI,KAAK,EAAK,MACV,GAAiB,EAAK,OAAO,QAAQ,MAAM,EAAK,IAAI,GAC5F,IAAW,MAAM,EAAQ,EAAQ,UAAU;GAC/C,QAAQ;GACR;GACA,SAAS;IAAE,gBAAgB;IAAoB,GAAI,EAAQ,aAAa,KAAK,CAAC;GAAG;GACjF,MAAM,KAAK,UAAU,CAAI;EAC3B,CAAC;EACD,IAAI,CAAC,EAAS,IAAI;GAChB,IAAM,IAAM,gBAAI,MAAM,cAAc,EAAS,QAAQ;GAErD,MADA,EAAI,SAAS,EAAoB,EAAS,MAAM,GAC1C;EACR;EACA,IAAM,IAAc,EAAS,QAAQ,IAAI,cAAc,GAEjD,IAAQ,EAAoB,GADlB,GAAa,SAAS,MAAM,IAAI,MAAM,EAAS,KAAK,IAAI,MAAM,EAAS,YAAY,CAC7C;EACtD,IAAI,CAAC,GAAO;GAGV,IAAM,IAAM,gBAAI,MAAM,8BAA8B;GAEpD,MADA,EAAI,SAAS,WACP;EACR;EACA,OAAO;CACT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gB;GACvC,IAAS;GAWT,IAAM,KAAS,MAAsC;IACnD,IAAM,IAAU,EAAW,GAAM,GAAM,EAAW,MAAM;IAExD,OADA,EAAQ,YAAY,CAAC,CAAC,GACf;GACT;GAEA,CAAM,YAAY;IAChB,IAAI;KAGF,IAAI,IAA+B,EAAM,EAAU,EAAY;KAC/D,KAAK,IAAI,IAAI,GAAG,IAAI,EAAU,QAAQ,KAAK,GAAG;MAC5C,IAAI,MAAU,GAAY;MAC1B,IAAM,IAAU,MAAM;MACtB,IAAI,MAAU,GAAY;MAC1B,IAAM,IAAO,EAAU,IAAI;MAI3B,AADI,MAAS,KAAA,MAAW,IAAU,EAAM,CAAI,IAC5C,MAAM,EAAK,GAAS,CAAK;KAC3B;KACA,AAAI,MAAU,KAAY,EAAS,QAAQ;IAC7C,SAAS,GAAO;KAEd,IADA,EAAW,MAAM,GACb,MAAU,GAAY;KAE1B,AADA,KAAc,GACd,EAAU;KACV,IAAM,IAAU,GAA+B;KAM/C,CADI,MAAW,iBAAiB,MAAW,mBAAe,IAAW,KACrE,EAAS,UACP,MAAW,iBAAiB,MAAW,iBAAiB,MAAW,cAAc,IAAS,SAC5F;IACF;GACF,GAAG;EACL;EAEA,SAAe;GAOb,AANA,KAAc,GAId,GAAQ,MAAM,GACd,IAAS,MACT,EAAU;EACZ;CACF;AACF"}
1
+ {"version":3,"file":"hostedTtsSpeechEngine.js","names":[],"sources":["../../../src/services/speech/hostedTtsSpeechEngine.ts"],"sourcesContent":["/**\n * Hosted (server-side) implementation of the `SpeechEngine` seam (BOFF-7111).\n *\n * The device-voice engine is as good as it is ever going to get: the Web Speech\n * API can only play voices the OS has installed, and on the devices that matter\n * here those are compact voices that do not sound human. Every knob was already\n * turned — rate, voice ranking, punctuation — and the result is still not close\n * to Assistant quality. The remaining gap IS the synthesiser, so this engine\n * replaces it.\n *\n * Structure mirrors `browserSpeechEngine` deliberately:\n * - **A generation counter.** `cancel()` bumps it; any fetch or `ended` event\n * from an older batch is dropped rather than clearing the state of a\n * playback that has already started.\n * - **Chunks played in order**, with the NEXT chunk fetched while the current\n * one plays. Without that prefetch every chunk boundary costs a full network\n * round trip and the reply sounds stuttered — worse than the device voice it\n * replaces.\n * - **Everything testable lives elsewhere** (`hostedTtsProtocol.ts`,\n * `hostedVoiceCatalogue.ts`) because this repo's vitest has no DOM and no\n * audio, so this file cannot be unit-tested.\n *\n * Failure is never silent: any error surfaces through `onError`, and the caller\n * (`createSpeechEngine`) is what decides to fall back to the device engine.\n */\n\nimport { HOSTED_TTS_TIER, HOSTED_VOICES, hostedLocaleFor } from './hostedVoiceCatalogue';\nimport { buildRequest, classifyHttpFailure, decodeAudioResponse, splitForVendor } from './hostedTtsProtocol';\nimport type { SpeechEngine, SpeechSpeakHandlers, SpeechSpeakOptions, SpeechVoiceLike } from './types';\n\nexport interface HostedTtsOptions {\n /** Absolute or same-origin path of OUR proxy. Never the vendor directly. */\n endpoint: string;\n /** Extra headers per request (auth). Called fresh each time so a rotated token is picked up. */\n getHeaders?: () => Record<string, string>;\n fetchImpl?: typeof fetch;\n}\n\nexport function createHostedTtsEngine(options: HostedTtsOptions): SpeechEngine {\n const doFetch = options.fetchImpl ?? ((...args: Parameters<typeof fetch>) => fetch(...args));\n let audio: HTMLAudioElement | null = null;\n let objectUrl: string | null = null;\n /**\n * Bumped on every `speak`/`cancel`; anything from an older batch is ignored.\n *\n * Per INSTANCE, not per module. `browserSpeechEngine` can keep this at module\n * scope because it is a singleton object; this is a factory, so a shared\n * counter would let one engine's `cancel()` silently invalidate another\n * engine's in-flight playback.\n */\n let generation = 0;\n /** The in-flight batch's controller, so `cancel()` can actually abort it. */\n let active: AbortController | null = null;\n /**\n * Set after a terminal proxy failure (401/403/404/501). Retrying cannot\n * succeed, and leaving the engine \"supported\" means every later press repeats\n * the same failing request. Reporting unsupported makes the routing engine\n * fall back to device voices, which still work.\n */\n let disabled = false;\n\n const releaseUrl = () => {\n if (objectUrl) {\n URL.revokeObjectURL(objectUrl);\n objectUrl = null;\n }\n };\n\n const stopAudio = () => {\n if (audio) {\n audio.onended = null;\n audio.onerror = null;\n try {\n audio.pause();\n } catch {\n /* pausing an already-dead element is harmless */\n }\n audio = null;\n }\n releaseUrl();\n };\n\n /** One chunk of text -> audio bytes. Throws with a `reason` the engine maps. */\n async function synthesise(text: string, opts: SpeechSpeakOptions, signal: AbortSignal): Promise<Uint8Array> {\n // The vendor's locale, not the app's: the app says `ar-SA`, Google only has\n // `ar-XA`. Sending the app tag would be an unsupported locale AND would\n // make `buildRequest` drop the chosen `ar-XA` voice as a mismatch.\n const languageCode = hostedLocaleFor(opts.lang) ?? opts.lang;\n const body = buildRequest(text, languageCode, HOSTED_TTS_TIER, opts.voice?.name ?? null, opts.rate);\n const response = await doFetch(options.endpoint, {\n method: 'POST',\n signal,\n headers: { 'content-type': 'application/json', ...(options.getHeaders?.() ?? {}) },\n body: JSON.stringify(body),\n });\n if (!response.ok) {\n const err = new Error(`hosted tts ${response.status}`) as Error & { reason?: string };\n err.reason = classifyHttpFailure(response.status);\n throw err;\n }\n const contentType = response.headers.get('content-type');\n const payload = contentType?.includes('json') ? await response.json() : await response.arrayBuffer();\n const bytes = decodeAudioResponse(contentType, payload);\n if (!bytes) {\n // A 200 carrying no audio is a failure, not silence. Treating it as\n // success is exactly the dead-button bug this feature already fixed once.\n const err = new Error('hosted tts returned no audio') as Error & { reason?: string };\n err.reason = 'unknown';\n throw err;\n }\n return bytes;\n }\n\n /**\n * `onBegin` fires when audio genuinely starts, not when it is requested, and\n * not when the chunk ends. The distinction matters to the routing engine: a\n * failure before any sound reached the user can be retried on the device\n * engine, and a failure after it cannot without repeating words.\n */\n function play(bytes: Uint8Array, batch: number, onBegin?: () => void): Promise<void> {\n return new Promise((resolve, reject) => {\n if (batch !== generation) {\n resolve();\n return;\n }\n // Copy into a fresh ArrayBuffer: the Uint8Array may be a view over a\n // larger buffer, and Blob would then include the neighbouring bytes.\n const blob = new Blob([bytes.slice().buffer as ArrayBuffer], { type: 'audio/mpeg' });\n releaseUrl();\n objectUrl = URL.createObjectURL(blob);\n const element = new Audio(objectUrl);\n audio = element;\n element.onended = () => {\n if (batch !== generation) return;\n resolve();\n };\n element.onerror = () => {\n if (batch !== generation) {\n resolve();\n return;\n }\n const err = new Error('audio playback failed') as Error & { reason?: string };\n err.reason = 'unknown';\n reject(err);\n };\n element.play().then(\n () => {\n if (batch === generation) onBegin?.();\n },\n (cause: unknown) => {\n if (batch !== generation) {\n resolve();\n return;\n }\n // Autoplay policy: playback needs a user gesture. Every path that\n // starts speech here is a button press, but an auto-speak triggered\n // by an arriving reply is not, and that is the case this reports.\n const err = new Error('audio play rejected') as Error & { reason?: string };\n err.reason = (cause as DOMException)?.name === 'NotAllowedError' ? 'not-allowed' : 'unknown';\n reject(err);\n }\n );\n });\n }\n\n return {\n id: 'hosted-tts',\n\n isSupported(): boolean {\n if (disabled) return false;\n return typeof window !== 'undefined' && typeof window.Audio === 'function' && typeof fetch === 'function';\n },\n\n listVoices(): SpeechVoiceLike[] {\n // A hosted catalogue is known up front, so unlike the browser engine\n // there is never an empty-then-populated race: `voiceAvailability` sees a\n // full list on the first read and never reports `pending`.\n return [...HOSTED_VOICES];\n },\n\n subscribeVoices(): () => void {\n // The catalogue is static — nothing to subscribe to. Returning a no-op\n // unsubscribe keeps the caller identical for both engines.\n return () => {};\n },\n\n speak(chunks: readonly string[], opts: SpeechSpeakOptions, handlers: SpeechSpeakHandlers = {}): void {\n const speakable = chunks.filter((chunk) => chunk.trim().length > 0).flatMap((chunk) => splitForVendor(chunk));\n if (speakable.length === 0) {\n handlers.onEnd?.();\n return;\n }\n\n generation += 1;\n const batch = generation;\n stopAudio();\n const controller = new AbortController();\n active = controller;\n\n // Announced at most once per batch: the caller only needs to know that\n // sound reached the user, not how many chunks did.\n let announcedStart = false;\n const notifyStarted = (): void => {\n if (announcedStart) return;\n announcedStart = true;\n handlers.onStart?.();\n };\n\n /**\n * Start a request and neutralise it as an unhandled rejection.\n *\n * A prefetched chunk is abandoned whenever the batch is cancelled\n * mid-loop. Attaching a swallow handler here does NOT consume the\n * rejection for the real `await` — `.catch` returns a NEW promise and the\n * original still rejects — so the error is still reported if we get that\n * far, and is silent if we never do.\n */\n const start = (text: string): Promise<Uint8Array> => {\n const request = synthesise(text, opts, controller.signal);\n request.catch(() => {});\n return request;\n };\n\n void (async () => {\n try {\n // Fetch the first chunk, then keep exactly one chunk in flight ahead\n // of playback so a boundary never costs a whole round trip.\n let pending: Promise<Uint8Array> = start(speakable[0] as string);\n for (let i = 0; i < speakable.length; i += 1) {\n if (batch !== generation) return;\n const current = await pending;\n if (batch !== generation) return;\n const next = speakable[i + 1];\n // On the last chunk nothing new is queued; `pending` keeps its\n // already-settled value and the loop simply ends.\n if (next !== undefined) pending = start(next);\n await play(current, batch, notifyStarted);\n }\n if (batch === generation) handlers.onEnd?.();\n } catch (cause) {\n controller.abort();\n if (batch !== generation) return; // cancelled — the caller already knows\n generation += 1; // abandon the rest of this batch\n stopAudio();\n const reason = (cause as { reason?: string })?.reason;\n // Terminal: the proxy is missing or refuses us, and retrying cannot\n // succeed. Stop claiming support so the routing engine falls back to\n // device voices from now on, instead of every later press repeating\n // the same failing request.\n if (reason === 'not-allowed' || reason === 'unsupported') disabled = true;\n handlers.onError?.(\n reason === 'not-allowed' || reason === 'unsupported' || reason === 'cancelled' ? reason : 'unknown'\n );\n }\n })();\n },\n\n cancel(): void {\n generation += 1;\n // Abort the in-flight synthesis too. Without this a cancelled reply keeps\n // downloading — and keeps costing billable vendor characters — until it\n // completes into a batch nobody is listening to.\n active?.abort();\n active = null;\n stopAudio();\n },\n };\n}\n"],"mappings":";;;AAsCA,SAAgB,EAAsB,GAAyC;CAC7E,IAAM,IAAU,EAAQ,eAAe,GAAG,MAAmC,MAAM,GAAG,CAAI,IACtF,IAAiC,MACjC,IAA2B,MAS3B,IAAa,GAEb,IAAiC,MAOjC,IAAW,IAET,UAAmB;EACvB,AAEE,OADA,IAAI,gBAAgB,CAAS,GACjB;CAEh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,GAAG;MAC5C,IAAI,MAAU,GAAY;MAC1B,IAAM,IAAU,MAAM;MACtB,IAAI,MAAU,GAAY;MAC1B,IAAM,IAAO,EAAU,IAAI;MAI3B,AADI,MAAS,KAAA,MAAW,IAAU,EAAM,CAAI,IAC5C,MAAM,EAAK,GAAS,GAAO,CAAa;KAC1C;KACA,AAAI,MAAU,KAAY,EAAS,QAAQ;IAC7C,SAAS,GAAO;KAEd,IADA,EAAW,MAAM,GACb,MAAU,GAAY;KAE1B,AADA,KAAc,GACd,EAAU;KACV,IAAM,IAAU,GAA+B;KAM/C,CADI,MAAW,iBAAiB,MAAW,mBAAe,IAAW,KACrE,EAAS,UACP,MAAW,iBAAiB,MAAW,iBAAiB,MAAW,cAAc,IAAS,SAC5F;IACF;GACF,GAAG;EACL;EAEA,SAAe;GAOb,AANA,KAAc,GAId,GAAQ,MAAM,GACd,IAAS,MACT,EAAU;EACZ;CACF;AACF"}
@@ -15,7 +15,24 @@ function t({ device: t, hosted: n }) {
15
15
  return t.subscribeVoices(e);
16
16
  },
17
17
  speak(e, r, a) {
18
- t.cancel(), n.cancel(), i(r).speak(e, r, a);
18
+ if (t.cancel(), n.cancel(), i(r) !== n) {
19
+ t.speak(e, r, a);
20
+ return;
21
+ }
22
+ let o = !1;
23
+ n.speak(e, r, {
24
+ onStart: () => {
25
+ o = !0, a?.onStart?.();
26
+ },
27
+ onEnd: () => a?.onEnd?.(),
28
+ onError: (n) => {
29
+ if (n === "cancelled" || o) {
30
+ a?.onError?.(n);
31
+ return;
32
+ }
33
+ t.speak(e, r, a);
34
+ }
35
+ });
19
36
  },
20
37
  cancel() {
21
38
  t.cancel(), n.cancel();
@@ -1 +1 @@
1
- {"version":3,"file":"routingSpeechEngine.js","names":[],"sources":["../../../src/services/speech/routingSpeechEngine.ts"],"sourcesContent":["/**\n * One `SpeechEngine` that routes each playback to the device or the hosted\n * engine (BOFF-7111).\n *\n * Why a routing engine rather than teaching `AssistantSpeechProvider` about two\n * engines: the provider, the availability logic, the gate and the voice picker\n * are all written against a SINGLE `SpeechEngine`, and they work. Splitting that\n * assumption would touch every one of them. Composing instead means the\n * hosted-TTS rollout changes **no component and no existing test** — which is\n * also what the seam's original author promised in `types.ts`.\n *\n * Routing is decided by the VOICE, not the language, because the voice is what\n * the user actually chose. `listVoices()` returns the hosted catalogue and the\n * device list together, `voiceQualityRank` already scores hosted voices above\n * compact local ones (they are `localService: false`), and the existing picker\n * therefore offers both with the hosted one selected by default. Picking a\n * device voice deliberately still works and routes to the device engine.\n */\n\nimport { hostedSupportsLanguage } from './hostedVoiceCatalogue';\nimport type { SpeechEngine, SpeechSpeakHandlers, SpeechSpeakOptions, SpeechVoiceLike } from './types';\n\nexport interface RoutingEngines {\n device: SpeechEngine;\n /** Null when hosted TTS is not configured — then this is a pass-through. */\n hosted: SpeechEngine | null;\n}\n\nexport function createRoutingSpeechEngine({ device, hosted }: RoutingEngines): SpeechEngine {\n if (!hosted) return device;\n\n /** Hosted voice names are the vendor ids the hosted catalogue declares. */\n const hostedNames = new Set(hosted.listVoices().map((voice) => voice.name));\n\n const pick = (options: SpeechSpeakOptions): SpeechEngine => {\n if (!hosted.isSupported()) return device;\n // An explicit pick wins: it is the user's own decision.\n if (options.voice) return hostedNames.has(options.voice.name) ? hosted : device;\n // No voice resolved (the caller found none for this language). Hosted can\n // still speak it if the vendor covers the language; otherwise the device\n // engine's own \"no voice\" handling explains the problem, as it does today.\n return hostedSupportsLanguage(options.lang) ? hosted : device;\n };\n\n return {\n id: `routing(${hosted.id}+${device.id})`,\n\n isSupported(): boolean {\n return hosted.isSupported() || device.isSupported();\n },\n\n listVoices(): SpeechVoiceLike[] {\n // Hosted first so that where ranks tie, list order favours the hosted\n // voice. Device voices are still offered: they work offline and some\n // users will prefer a familiar system voice.\n return [...hosted.listVoices(), ...device.listVoices()];\n },\n\n subscribeVoices(listener: () => void): () => void {\n // Only the device list changes over time; the hosted catalogue is static.\n return device.subscribeVoices(listener);\n },\n\n speak(chunks: readonly string[], options: SpeechSpeakOptions, handlers?: SpeechSpeakHandlers): void {\n // Stop BOTH before starting: the previous playback may have been on the\n // other engine, and leaving it running would produce two overlapping\n // voices — the one failure mode a routing layer can uniquely cause.\n device.cancel();\n hosted.cancel();\n pick(options).speak(chunks, options, handlers);\n },\n\n cancel(): void {\n device.cancel();\n hosted.cancel();\n },\n };\n}\n"],"mappings":";;AA4BA,SAAgB,EAA0B,EAAE,WAAQ,aAAwC;CAC1F,IAAI,CAAC,GAAQ,OAAO;CAGpB,IAAM,IAAc,IAAI,IAAI,EAAO,WAAW,EAAE,KAAK,MAAU,EAAM,IAAI,CAAC,GAEpE,KAAQ,MACP,EAAO,YAAY,IAEpB,EAAQ,QAAc,EAAY,IAAI,EAAQ,MAAM,IAAI,IAAI,IAAS,IAIlE,EAAuB,EAAQ,IAAI,IAAI,IAAS,IANrB;CASpC,OAAO;EACL,IAAI,WAAW,EAAO,GAAG,GAAG,EAAO,GAAG;EAEtC,cAAuB;GACrB,OAAO,EAAO,YAAY,KAAK,EAAO,YAAY;EACpD;EAEA,aAAgC;GAI9B,OAAO,CAAC,GAAG,EAAO,WAAW,GAAG,GAAG,EAAO,WAAW,CAAC;EACxD;EAEA,gBAAgB,GAAkC;GAEhD,OAAO,EAAO,gBAAgB,CAAQ;EACxC;EAEA,MAAM,GAA2B,GAA6B,GAAsC;GAMlG,AAFA,EAAO,OAAO,GACd,EAAO,OAAO,GACd,EAAK,CAAO,EAAE,MAAM,GAAQ,GAAS,CAAQ;EAC/C;EAEA,SAAe;GAEb,AADA,EAAO,OAAO,GACd,EAAO,OAAO;EAChB;CACF;AACF"}
1
+ {"version":3,"file":"routingSpeechEngine.js","names":[],"sources":["../../../src/services/speech/routingSpeechEngine.ts"],"sourcesContent":["/**\n * One `SpeechEngine` that routes each playback to the device or the hosted\n * engine (BOFF-7111).\n *\n * Why a routing engine rather than teaching `AssistantSpeechProvider` about two\n * engines: the provider, the availability logic, the gate and the voice picker\n * are all written against a SINGLE `SpeechEngine`, and they work. Splitting that\n * assumption would touch every one of them. Composing instead means the\n * hosted-TTS rollout changes **no component and no existing test** — which is\n * also what the seam's original author promised in `types.ts`.\n *\n * Routing is decided by the VOICE, not the language, because the voice is what\n * the user actually chose. `listVoices()` returns the hosted catalogue and the\n * device list together, `voiceQualityRank` already scores hosted voices above\n * compact local ones (they are `localService: false`), and the existing picker\n * therefore offers both with the hosted one selected by default. Picking a\n * device voice deliberately still works and routes to the device engine.\n */\n\nimport { hostedSupportsLanguage } from './hostedVoiceCatalogue';\nimport type { SpeechEngine, SpeechSpeakHandlers, SpeechSpeakOptions, SpeechVoiceLike } from './types';\n\nexport interface RoutingEngines {\n device: SpeechEngine;\n /** Null when hosted TTS is not configured — then this is a pass-through. */\n hosted: SpeechEngine | null;\n}\n\nexport function createRoutingSpeechEngine({ device, hosted }: RoutingEngines): SpeechEngine {\n if (!hosted) return device;\n\n /** Hosted voice names are the vendor ids the hosted catalogue declares. */\n const hostedNames = new Set(hosted.listVoices().map((voice) => voice.name));\n\n const pick = (options: SpeechSpeakOptions): SpeechEngine => {\n if (!hosted.isSupported()) return device;\n // An explicit pick wins: it is the user's own decision.\n if (options.voice) return hostedNames.has(options.voice.name) ? hosted : device;\n // No voice resolved (the caller found none for this language). Hosted can\n // still speak it if the vendor covers the language; otherwise the device\n // engine's own \"no voice\" handling explains the problem, as it does today.\n return hostedSupportsLanguage(options.lang) ? hosted : device;\n };\n\n return {\n id: `routing(${hosted.id}+${device.id})`,\n\n isSupported(): boolean {\n return hosted.isSupported() || device.isSupported();\n },\n\n listVoices(): SpeechVoiceLike[] {\n // Hosted first so that where ranks tie, list order favours the hosted\n // voice. Device voices are still offered: they work offline and some\n // users will prefer a familiar system voice.\n return [...hosted.listVoices(), ...device.listVoices()];\n },\n\n subscribeVoices(listener: () => void): () => void {\n // Only the device list changes over time; the hosted catalogue is static.\n return device.subscribeVoices(listener);\n },\n\n speak(chunks: readonly string[], options: SpeechSpeakOptions, handlers?: SpeechSpeakHandlers): void {\n // Stop BOTH before starting: the previous playback may have been on the\n // other engine, and leaving it running would produce two overlapping\n // voices — the one failure mode a routing layer can uniquely cause.\n device.cancel();\n hosted.cancel();\n\n const chosen = pick(options);\n if (chosen !== hosted) {\n device.speak(chunks, options, handlers);\n return;\n }\n\n /**\n * ★ Fall back to the device voice when the hosted engine fails before the\n * user has heard anything.\n *\n * Without this, turning hosted TTS on makes the product WORSE in exactly\n * the case it is meant to survive. The hosted engine already latches\n * itself off for `not-allowed` and `unsupported`, but everything else —\n * a proxy 500, a vendor outage, a timeout, a dropped connection — maps to\n * `unknown`, which latches nothing. So an outage produced silence on\n * every reply, indefinitely, where the device voice would have spoken.\n *\n * Two conditions, both necessary:\n *\n * - `cancelled` never retries. It is not a failure; it is the user (or a\n * new reply, or a closing panel) deliberately stopping playback, and\n * speaking again would be the worst possible response.\n * - Nothing may have been heard yet. If audio already started, the\n * remaining chunks are not worth repeating the earlier ones for, so the\n * error is reported as-is.\n *\n * Deliberately NOT a latch: it is decided per utterance, so a transient\n * outage costs one failed request per reply and recovers by itself the\n * moment the proxy is healthy again. A latch would strand every user on\n * the device voice until the page was reloaded.\n */\n let heardSomething = false;\n hosted.speak(chunks, options, {\n onStart: () => {\n heardSomething = true;\n handlers?.onStart?.();\n },\n onEnd: () => handlers?.onEnd?.(),\n onError: (reason) => {\n if (reason === 'cancelled' || heardSomething) {\n handlers?.onError?.(reason);\n return;\n }\n device.speak(chunks, options, handlers);\n },\n });\n },\n\n cancel(): void {\n device.cancel();\n hosted.cancel();\n },\n };\n}\n"],"mappings":";;AA4BA,SAAgB,EAA0B,EAAE,WAAQ,aAAwC;CAC1F,IAAI,CAAC,GAAQ,OAAO;CAGpB,IAAM,IAAc,IAAI,IAAI,EAAO,WAAW,EAAE,KAAK,MAAU,EAAM,IAAI,CAAC,GAEpE,KAAQ,MACP,EAAO,YAAY,IAEpB,EAAQ,QAAc,EAAY,IAAI,EAAQ,MAAM,IAAI,IAAI,IAAS,IAIlE,EAAuB,EAAQ,IAAI,IAAI,IAAS,IANrB;CASpC,OAAO;EACL,IAAI,WAAW,EAAO,GAAG,GAAG,EAAO,GAAG;EAEtC,cAAuB;GACrB,OAAO,EAAO,YAAY,KAAK,EAAO,YAAY;EACpD;EAEA,aAAgC;GAI9B,OAAO,CAAC,GAAG,EAAO,WAAW,GAAG,GAAG,EAAO,WAAW,CAAC;EACxD;EAEA,gBAAgB,GAAkC;GAEhD,OAAO,EAAO,gBAAgB,CAAQ;EACxC;EAEA,MAAM,GAA2B,GAA6B,GAAsC;GAQlG,IAJA,EAAO,OAAO,GACd,EAAO,OAAO,GAEC,EAAK,CAChB,MAAW,GAAQ;IACrB,EAAO,MAAM,GAAQ,GAAS,CAAQ;IACtC;GACF;GA2BA,IAAI,IAAiB;GACrB,EAAO,MAAM,GAAQ,GAAS;IAC5B,eAAe;KAEb,AADA,IAAiB,IACjB,GAAU,UAAU;IACtB;IACA,aAAa,GAAU,QAAQ;IAC/B,UAAU,MAAW;KACnB,IAAI,MAAW,eAAe,GAAgB;MAC5C,GAAU,UAAU,CAAM;MAC1B;KACF;KACA,EAAO,MAAM,GAAQ,GAAS,CAAQ;IACxC;GACF,CAAC;EACH;EAEA,SAAe;GAEb,AADA,EAAO,OAAO,GACd,EAAO,OAAO;EAChB;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.831.7",
3
+ "version": "2026.831.9",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [
@@ -49,7 +49,7 @@
49
49
  "dependencies": {
50
50
  "@apollo/client": "^4.0.11",
51
51
  "@burdenoff/fe-libs": "2026.813.3",
52
- "@burdenoff/planmagnet-fe-sdk": "2026.813.1",
52
+ "@burdenoff/planmagnet-fe-sdk": "2026.831.1",
53
53
  "@tanstack/react-query": "^5.90.16",
54
54
  "clsx": "^2.1.1",
55
55
  "date-fns": "^4.1.0",