@burdenoff/fe-libs 2026.1117.5 → 2026.1117.7

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.
@@ -0,0 +1,4 @@
1
+ export declare function configureFirstClipPrefetch(options: {
2
+ enabled: boolean;
3
+ } | null): void;
4
+ export declare function firstClipPrefetchEnabled(): boolean;
@@ -0,0 +1,9 @@
1
+ // src/shared/assistant/voice/firstClipPrefetchConfig.ts
2
+ var e = !1;
3
+ function t(t) {
4
+ e = t?.enabled === !0;
5
+ }
6
+ function n() {
7
+ return e;
8
+ }
9
+ export { t as configureFirstClipPrefetch, n as firstClipPrefetchEnabled };
@@ -9,6 +9,35 @@ export interface LivePhraseSpeech {
9
9
  export declare function createLivePhraseSpeech(options: {
10
10
  append(phrases: readonly string[], visible: string): void;
11
11
  retract(): void;
12
+ /**
13
+ * ★ BOFF-12936 (production): speak ONLY text known to be part of the final
14
+ * answer, and nothing while a tool step may still follow.
15
+ *
16
+ * Alpha's release rules are a bet that a sentence followed by a tool call is
17
+ * rare: the first of two completed sentences is spoken, and a lone sentence
18
+ * after `NARRATION_HOLD_MS`. Narration of two sentences before a tool, or a
19
+ * tool frame that arrives after the hold, is spoken and then withdrawn (a
20
+ * phrase that has started sounding cannot be taken back), and the recogniser
21
+ * has been stopped for it while the model is still working.
22
+ *
23
+ * With this on there is no bet. The stream cannot say that a step is the last
24
+ * one while its text is being written: a tool call may follow the text, in
25
+ * the same step, and the step's finish reason arrives only with the frame
26
+ * that ends it. So nothing is released until EVERY text part of the step has
27
+ * ended AND the step has completed, with no tool frame after any of the text
28
+ * and a finish reason that is not a tool call (or an error). Then the phrases
29
+ * of all the step's text parts are released at once, in the order the parts
30
+ * were written: a step may write its answer in more than one text part
31
+ * (reasoning between them), and the newest part alone is not the answer. A
32
+ * step that ended in a tool call is never spoken.
33
+ *
34
+ * A part that cannot be vouched for (not live from its start, gapped, frozen,
35
+ * from an older stream, or followed by a tool) withholds the WHOLE step.
36
+ * Speaking only the parts that can be would leave a hole in the middle of the
37
+ * answer that the final reconciliation cannot fill (it resumes after the last
38
+ * sentence spoken); withheld, the answer is read whole when the turn is done.
39
+ */
40
+ holdForFinalAnswer?: boolean;
12
41
  setTimer?: (run: () => void, ms: number) => unknown;
13
42
  clearTimer?: (timer: unknown) => void;
14
43
  }): LivePhraseSpeech;
@@ -1,59 +1,70 @@
1
1
  import { phraseCandidates as e } from "./phraseGate.js";
2
2
  import { toSpeakableText as t } from "./speakableText.js";
3
3
  // src/shared/assistant/voice/livePhraseSpeech.ts
4
- var n = 700;
5
- function r(n) {
6
- let r = n.setTimer ?? ((e, t) => setTimeout(e, t)), i = n.clearTimer ?? ((e) => {
4
+ var n = 700, r = /* @__PURE__ */ new Set(["tool-calls", "error"]);
5
+ function i(n) {
6
+ let i = n.holdForFinalAnswer === !0, a = n.setTimer ?? ((e, t) => setTimeout(e, t)), o = n.clearTimer ?? ((e) => {
7
7
  clearTimeout(e);
8
- }), a = null, o = "", s = [], c = [], l = "", u = !1, d = !1, f = () => {
9
- a !== null && i(a), a = null;
10
- }, p = () => {
11
- f(), n.retract(), u = !0;
12
- }, m = (e) => {
13
- if (d || u || e <= s.length) return;
14
- let t = c.slice(s.length, e);
15
- s = c.slice(0, e), n.append(t, l);
16
- }, h = (e, t) => {
8
+ }), s = null, c = "", l = [], u = [], d = "", f = !1, p = !1, m = () => {
9
+ s !== null && o(s), s = null;
10
+ }, h = () => {
11
+ m(), n.retract(), f = !0;
12
+ }, g = (e) => {
13
+ if (p || f || e <= l.length) return;
14
+ let t = u.slice(l.length, e);
15
+ l = u.slice(0, e), n.append(t, d);
16
+ }, _ = (e, t) => {
17
17
  let n = [...e.messages].filter(([, e]) => (e.created ?? 0) > t);
18
18
  n.sort((e, t) => (e[1].created ?? 0) - (t[1].created ?? 0));
19
19
  let r = n.at(-1)?.[0];
20
- return [...e.parts].filter(([, e]) => e.messageId === r).at(-1);
21
- };
20
+ if (r === void 0) return;
21
+ let a = [...e.parts].filter(([, e]) => e.messageId === r), o = a.at(-1);
22
+ if (o) return i ? {
23
+ key: r,
24
+ messageId: r,
25
+ parts: a
26
+ } : {
27
+ key: `${r}/${o[0]}/${o[1].generation}`,
28
+ messageId: r,
29
+ parts: [o]
30
+ };
31
+ }, v = (e, t) => e.parts.some(([, e]) => !e.live || e.gapped || e.frozen || e.toolAfter || e.generation !== t.generation);
22
32
  return {
23
33
  invalidate(e, t) {
24
- if (d || !o) return;
25
- let n = h(e, t);
26
- if (!n) {
27
- p();
28
- return;
29
- }
30
- let [r, i] = n;
31
- (`${i.messageId}/${r}/${i.generation}` !== o || !i.live || i.gapped || i.frozen || i.toolAfter || i.generation !== e.generation) && p();
34
+ if (p || !c) return;
35
+ let n = _(e, t);
36
+ (!n || n.key !== c || v(n, e)) && h();
32
37
  },
33
- update(i, g, _) {
34
- if (d) return;
35
- let v = h(g, _);
36
- if (!v) return;
37
- let [y, b] = v, x = `${b.messageId}/${y}/${b.generation}`;
38
- if (x !== o && (f(), o && n.retract(), o = x, s = [], u = !1), !b.live || b.gapped || b.frozen || b.toolAfter || b.generation !== g.generation) {
39
- p();
38
+ update(o, y, b) {
39
+ if (p) return;
40
+ let x = _(y, b);
41
+ if (!x) return;
42
+ if (x.key !== c && (m(), c && n.retract(), c = x.key, l = [], f = !1), v(x, y)) {
43
+ h();
40
44
  return;
41
45
  }
42
- if (u) return;
43
- let S = b.ended && g.messages.get(b.messageId)?.completed !== void 0;
44
- if (c = e(b.text, S), s.some((e, t) => c[t] !== e)) {
45
- p();
46
+ if (f) return;
47
+ let S = y.messages.get(x.messageId), C = x.parts.every(([, e]) => e.ended) && S?.completed !== void 0;
48
+ if (i) {
49
+ if (C && S?.finish !== void 0 && r.has(S.finish)) {
50
+ h();
51
+ return;
52
+ }
53
+ if (!C) return;
54
+ }
55
+ if (u = x.parts.flatMap(([, t]) => e(t.text, C)), l.some((e, t) => u[t] !== e)) {
56
+ h();
46
57
  return;
47
58
  }
48
- l = i;
49
- let C = t(i).replace(/\s+/g, " ");
50
- c.some((e) => !C.includes(e.replace(/\s+/g, " "))) ? p() : S ? (f(), m(c.length)) : (m(Math.max(0, c.length - 1)), s.length === c.length ? f() : a === null && (a = r(() => {
51
- a = null, m(c.length);
59
+ d = o;
60
+ let w = t(o).replace(/\s+/g, " ");
61
+ u.some((e) => !w.includes(e.replace(/\s+/g, " "))) ? h() : C ? (m(), g(u.length)) : (g(Math.max(0, u.length - 1)), l.length === u.length ? m() : s === null && (s = a(() => {
62
+ s = null, g(u.length);
52
63
  }, 700)));
53
64
  },
54
65
  close() {
55
- d = !0, f();
66
+ p = !0, m();
56
67
  }
57
68
  };
58
69
  }
59
- export { n as NARRATION_HOLD_MS, r as createLivePhraseSpeech };
70
+ export { n as NARRATION_HOLD_MS, i as createLivePhraseSpeech };
@@ -1,5 +1,47 @@
1
- export declare function configurePhraseSpeech(options: {
1
+ /**
2
+ * Per-app S7 opt-in (BOFF-8062): a voice reply spoken sentence by sentence as
3
+ * it is written, instead of whole once it is done. Runtime configuration only;
4
+ * never persisted or inferred.
5
+ *
6
+ * ★ Alpha takes `enabled: true` with `environment: 'alpha'`, as before.
7
+ * Production takes a second, explicit word from the app as well:
8
+ * `allowProduction: true` (BOFF-12936). Without it a production build keeps
9
+ * whole-answer speech, and every other environment (local, dev, anything
10
+ * unknown) stays off whatever it passes.
11
+ *
12
+ * ★ Production speaks LESS than alpha, on purpose. Alpha releases a sentence as
13
+ * soon as a second one has been written, and a lone sentence after 700 ms,
14
+ * betting that a sentence followed by a tool call is rare. Production does not
15
+ * bet: nothing is spoken while a tool step may still follow. The stream cannot
16
+ * say that a step is the last one while it is being written (a step's finish
17
+ * reason arrives with its end, and a tool call may follow its text), so
18
+ * production holds every phrase until the step that wrote the text has
19
+ * finished, without a tool call (`phraseSpeechEnvironment() === 'production'`,
20
+ * read by the narrator as `holdForFinalAnswer`).
21
+ *
22
+ * ★ On or off, phrases come from the turn's LIVE STREAM only. The narrator
23
+ * (`createLivePhraseSpeech`) reads text parts the SSE stream carried from their
24
+ * start, and nothing else: no poll text, no reasoning part, no tool part. A
25
+ * turn on the poll transport (a relay that refuses the stream, a browser
26
+ * without EventSource, the `transport=poll` override) is read whole once it is
27
+ * done, exactly as it is today.
28
+ */
29
+ export interface PhraseSpeechOptions {
30
+ /** The app's own switch for this build. */
2
31
  enabled: boolean;
32
+ /** The app's deploy environment (`VITE_DEPLOY_ENV`). */
3
33
  environment: string;
4
- } | null): void;
34
+ /** Production as well as alpha. Off unless the app passes `true`. */
35
+ allowProduction?: boolean;
36
+ }
37
+ /** The environment whose opt-in is on. */
38
+ export type PhraseSpeechEnvironment = 'alpha' | 'production';
39
+ export declare function configurePhraseSpeech(options: PhraseSpeechOptions | null): void;
5
40
  export declare function phraseSpeechEnabled(): boolean;
41
+ /**
42
+ * Which opt-in is on, or null when phrase speech is off. It decides how the
43
+ * narrator releases phrases: alpha keeps its lone-sentence hold, production
44
+ * holds every phrase until the step that wrote it has finished without a tool
45
+ * (`createLivePhraseSpeech`'s `holdForFinalAnswer`).
46
+ */
47
+ export declare function phraseSpeechEnvironment(): PhraseSpeechEnvironment | null;
@@ -1,9 +1,12 @@
1
1
  // src/shared/assistant/voice/phraseSpeechConfig.ts
2
- var e = !1;
3
- function t(t) {
4
- e = t?.enabled === !0 && t.environment === "alpha";
2
+ var e = /* @__PURE__ */ new Set(["prod", "production"]), t = null;
3
+ function n(n) {
4
+ t = n?.enabled === !0 ? n.environment === "alpha" ? "alpha" : n.allowProduction === !0 && e.has(n.environment) ? "production" : null : null;
5
5
  }
6
- function n() {
7
- return e;
6
+ function r() {
7
+ return t !== null;
8
8
  }
9
- export { t as configurePhraseSpeech, n as phraseSpeechEnabled };
9
+ function i() {
10
+ return t;
11
+ }
12
+ export { n as configurePhraseSpeech, r as phraseSpeechEnabled, i as phraseSpeechEnvironment };
@@ -157,4 +157,22 @@ export declare function containsCjk(text: string): boolean;
157
157
  export declare function chunkForSpeech(text: string, maxChars?: number, cjkMaxChars?: number, options?: {
158
158
  firstChunkMaxChars?: number;
159
159
  packFirstChunk?: boolean;
160
+ /** P1: lead with a first sentence this long even when the reply fits one chunk. */
161
+ leadSentenceMinChars?: number;
160
162
  }): string[];
163
+ /**
164
+ * ★ P1 (BOFF-12936): the first sentence long enough to lead a reply on its own
165
+ * when its clip is fetched early (see `chunkForSpeech`). About 2.5 s of speech:
166
+ * the clip after it (~1.1 s to synthesise) is ready before it ends.
167
+ */
168
+ export declare const FIRST_CLIP_LEAD_MIN_CHARS = 40;
169
+ /**
170
+ * ★ P1 (BOFF-12936): the first chunk of an answer still being written, once it
171
+ * can no longer change: the answer's first sentence is complete (more text
172
+ * follows it), and the first chunk lies within that sentence. Null until then.
173
+ * `options` must be the ones the finished answer will be chunked with.
174
+ */
175
+ export declare function settledFirstChunk(partial: string, options: {
176
+ firstChunkMaxChars?: number;
177
+ leadSentenceMinChars?: number;
178
+ }): string | null;