@burdenoff/fe-libs 2026.1117.4 → 2026.1117.6
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/dist/shared/assistant/liveDeltas.d.ts +6 -0
- package/dist/shared/assistant/liveDeltas.js +4 -3
- package/dist/shared/assistant/ui/AssistantChatArea.js +1159 -1158
- package/dist/shared/assistant/ui/useVoiceSession.js +312 -301
- package/dist/shared/assistant/voice/handsFree.d.ts +16 -0
- package/dist/shared/assistant/voice/handsFree.js +2 -2
- package/dist/shared/assistant/voice/handsfree/audioTrackTransport.js +1 -0
- package/dist/shared/assistant/voice/handsfree/backendStreamTransport.d.ts +11 -0
- package/dist/shared/assistant/voice/handsfree/backendStreamTransport.js +118 -63
- package/dist/shared/assistant/voice/handsfree/bargeIn.d.ts +20 -1
- package/dist/shared/assistant/voice/handsfree/bargeIn.js +3 -3
- package/dist/shared/assistant/voice/handsfree/handsFreeController.d.ts +10 -1
- package/dist/shared/assistant/voice/handsfree/handsFreeController.js +103 -83
- package/dist/shared/assistant/voice/handsfree/sttTransport.d.ts +20 -0
- package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.d.ts +8 -0
- package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.js +31 -26
- package/dist/shared/assistant/voice/handsfree/webSpeechTransport.js +1 -0
- package/dist/shared/assistant/voice/livePhraseSpeech.d.ts +29 -0
- package/dist/shared/assistant/voice/livePhraseSpeech.js +50 -39
- package/dist/shared/assistant/voice/phraseSpeechConfig.d.ts +44 -2
- package/dist/shared/assistant/voice/phraseSpeechConfig.js +9 -6
- package/dist/shared-assistant.js +399 -399
- package/package.json +1 -1
|
@@ -35,6 +35,13 @@ export interface SttTransportError {
|
|
|
35
35
|
export interface SttTransportHandlers {
|
|
36
36
|
onTranscript(transcript: TransportTranscript): void;
|
|
37
37
|
onError(error: SttTransportError): void;
|
|
38
|
+
/**
|
|
39
|
+
* The recogniser is finished with this utterance: the stream said `done`, or
|
|
40
|
+
* dropped it (a retryable error naming it). Transports whose words arrive
|
|
41
|
+
* `after-utterance` call it; for them the controller judges "nothing heard"
|
|
42
|
+
* here (see `SttTransport.wordsArrive`).
|
|
43
|
+
*/
|
|
44
|
+
onUtteranceDone(utteranceId: string): void;
|
|
38
45
|
}
|
|
39
46
|
export interface SttAudioGraph {
|
|
40
47
|
context: AudioContext;
|
|
@@ -58,6 +65,19 @@ export interface SttTransport {
|
|
|
58
65
|
readonly recognitionOwner: 'transport' | 'session-hook';
|
|
59
66
|
/** Whether the words spoken BEFORE the onset was confirmed reach the recogniser. */
|
|
60
67
|
readonly keepsOpeningWords: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* When an utterance's first words can arrive (read only when
|
|
70
|
+
* `recognitionOwner` is `transport`):
|
|
71
|
+
* - `while-speaking`: the recogniser sends partial text as the person talks
|
|
72
|
+
* (Chrome's, with `interimResults`), so no words for `NOTHING_HEARD_MS`
|
|
73
|
+
* after a barge-in means nothing was heard;
|
|
74
|
+
* - `after-utterance`: the first words may come only once the utterance is
|
|
75
|
+
* finalised. Our stream on Google's `chirp_3` sends no partial text (alpha,
|
|
76
|
+
* 17 Nov: one final, 1.0 s after `end`), so a fixed timer would call every
|
|
77
|
+
* real interruption "nothing heard". The controller waits for
|
|
78
|
+
* `onUtteranceDone` instead.
|
|
79
|
+
*/
|
|
80
|
+
readonly wordsArrive: 'while-speaking' | 'after-utterance';
|
|
61
81
|
start(graph: SttAudioGraph | null, language: string, handlers: SttTransportHandlers): Promise<void>;
|
|
62
82
|
openUtterance(utterance: OpenUtterance): void;
|
|
63
83
|
/** A live 16 kHz frame while an utterance is open. */
|
|
@@ -51,5 +51,13 @@ export interface HandsFreeState {
|
|
|
51
51
|
nothingHeard: boolean;
|
|
52
52
|
/** Non-null exactly while `mode` is `notice`: what the notice's buttons do. */
|
|
53
53
|
privacyNotice: HandsFreePrivacyNoticeActions | null;
|
|
54
|
+
/**
|
|
55
|
+
* The running transport sends an utterance's words only once it is finalised
|
|
56
|
+
* (our stream on chirp_3, BOFF-12936): the session times its pause from the
|
|
57
|
+
* last voiced frame instead of from the words.
|
|
58
|
+
*/
|
|
59
|
+
wordsAfterUtterance: boolean;
|
|
60
|
+
/** On such a transport: words of this turn are still to come; nothing may be sent yet. */
|
|
61
|
+
wordsPending: boolean;
|
|
54
62
|
}
|
|
55
63
|
export declare function useHandsFreeInterrupt(options: UseHandsFreeInterruptOptions): HandsFreeState;
|
|
@@ -17,39 +17,41 @@ var y = (e) => e === "listening" || e === "thinking" || e === "speaking";
|
|
|
17
17
|
function b(t) {
|
|
18
18
|
let { enabled: r, phase: i, muted: b, language: x, streamNoticeAccepted: S } = t, C = m(t);
|
|
19
19
|
C.current = t;
|
|
20
|
-
let [w, T] = h(null), [E, D] = h(!1), [O, k] = h(!1), [A, j] = h(!1), M = m(!1), [
|
|
20
|
+
let [w, T] = h(null), [E, D] = h(!1), [O, k] = h(!1), [A, j] = h(!1), [M, N] = h(!1), [P, F] = h(!1), I = m(!1), [L, R] = h(!1), z = g(u, l, l), B = p(() => v(x, z), [x, z]), V = B.kind;
|
|
21
21
|
f(() => {
|
|
22
|
-
S !== "google-stt-eu-1" &&
|
|
22
|
+
S !== "google-stt-eu-1" && R(!1);
|
|
23
23
|
}, [S]), f(() => {
|
|
24
24
|
(i === "idle" || i === "ended") && (T(null), D(!1));
|
|
25
25
|
}, [i]), f(() => {
|
|
26
26
|
if (!r || typeof document > "u") return;
|
|
27
27
|
let e = null, t = () => {
|
|
28
|
-
e !== null && clearTimeout(e), e = null, document.visibilityState === "hidden" ? e = setTimeout(() =>
|
|
28
|
+
e !== null && clearTimeout(e), e = null, document.visibilityState === "hidden" ? e = setTimeout(() => N(!0), _) : N(!1);
|
|
29
29
|
};
|
|
30
30
|
return document.addEventListener("visibilitychange", t), () => {
|
|
31
31
|
document.removeEventListener("visibilitychange", t), e !== null && clearTimeout(e);
|
|
32
32
|
};
|
|
33
33
|
}, [r]);
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
}, []),
|
|
34
|
+
let H = r && B.supported && y(i) && !b && w === null && !M, U = V === "backend-stream" && !L && S !== "google-stt-eu-1", W = H && U, G = H && !U, K = d(() => {
|
|
35
|
+
R(!0), C.current.onAcceptStreamNotice?.(c);
|
|
36
|
+
}, []), q = d(() => {
|
|
37
37
|
T("notice-declined");
|
|
38
|
-
}, []),
|
|
39
|
-
accept:
|
|
40
|
-
decline:
|
|
41
|
-
}), [
|
|
38
|
+
}, []), J = p(() => ({
|
|
39
|
+
accept: K,
|
|
40
|
+
decline: q
|
|
41
|
+
}), [K, q]);
|
|
42
42
|
f(() => {
|
|
43
|
-
if (!
|
|
44
|
-
let t =
|
|
43
|
+
if (!G) return;
|
|
44
|
+
let t = n(V);
|
|
45
|
+
k(t.recognitionOwner === "transport" && t.wordsArrive === "after-utterance");
|
|
46
|
+
let r = e({
|
|
45
47
|
startCapture: o,
|
|
46
|
-
transport:
|
|
48
|
+
transport: t,
|
|
47
49
|
getSession: () => ({
|
|
48
50
|
phase: C.current.phase,
|
|
49
51
|
muted: C.current.muted
|
|
50
52
|
}),
|
|
51
53
|
getPlaybackSource: s,
|
|
52
|
-
getHeadsetHint: () =>
|
|
54
|
+
getHeadsetHint: () => I.current,
|
|
53
55
|
language: () => C.current.language,
|
|
54
56
|
onBargeIn: () => {
|
|
55
57
|
D(!1), C.current.onBargeIn();
|
|
@@ -60,24 +62,27 @@ function b(t) {
|
|
|
60
62
|
onSpeechFrame: (e) => C.current.onSpeechFrame?.(e),
|
|
61
63
|
onFallback: T,
|
|
62
64
|
onNothingHeard: () => D(!0),
|
|
65
|
+
onWordsPending: j,
|
|
63
66
|
isEnabled: () => C.current.enabled
|
|
64
|
-
}),
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
+
}), i = !1;
|
|
68
|
+
return r.start().then(() => {
|
|
69
|
+
i || F(!0);
|
|
67
70
|
}), navigator.mediaDevices?.enumerateDevices().then((e) => {
|
|
68
|
-
|
|
71
|
+
I.current = a(e.filter((e) => e.kind === "audiooutput").map((e) => e.label));
|
|
69
72
|
}).catch(() => void 0), () => {
|
|
70
|
-
|
|
73
|
+
i = !0, r.stop(), F(!1), k(!1), j(!1);
|
|
71
74
|
};
|
|
72
|
-
}, [
|
|
73
|
-
let
|
|
74
|
-
return r && !
|
|
75
|
-
mode:
|
|
76
|
-
transportKind:
|
|
77
|
-
suppressWebSpeech: r &&
|
|
75
|
+
}, [G, V]);
|
|
76
|
+
let Y = "off";
|
|
77
|
+
return r && !B.supported ? Y = "unavailable" : w === null ? W ? Y = "notice" : G && (Y = P ? "active" : "starting") : Y = "fallback", {
|
|
78
|
+
mode: Y,
|
|
79
|
+
transportKind: B.supported ? V : null,
|
|
80
|
+
suppressWebSpeech: r && B.supported && V !== "web-speech" && w === null && y(i),
|
|
78
81
|
fallbackReason: w,
|
|
79
82
|
nothingHeard: E,
|
|
80
|
-
privacyNotice:
|
|
83
|
+
privacyNotice: Y === "notice" ? J : null,
|
|
84
|
+
wordsAfterUtterance: O,
|
|
85
|
+
wordsPending: A
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
88
|
export { _ as HIDDEN_RELEASE_MS, b as useHandsFreeInterrupt };
|
|
@@ -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
|
|
6
|
-
let
|
|
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
|
-
}),
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
if (
|
|
14
|
-
let t =
|
|
15
|
-
|
|
16
|
-
},
|
|
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
|
-
|
|
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 (
|
|
25
|
-
let n =
|
|
26
|
-
|
|
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(
|
|
34
|
-
if (
|
|
35
|
-
let
|
|
36
|
-
if (!
|
|
37
|
-
|
|
38
|
-
|
|
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 (
|
|
43
|
-
let S =
|
|
44
|
-
if (
|
|
45
|
-
|
|
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
|
-
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
66
|
+
p = !0, m();
|
|
56
67
|
}
|
|
57
68
|
};
|
|
58
69
|
}
|
|
59
|
-
export { n as NARRATION_HOLD_MS,
|
|
70
|
+
export { n as NARRATION_HOLD_MS, i as createLivePhraseSpeech };
|
|
@@ -1,5 +1,47 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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 =
|
|
3
|
-
function
|
|
4
|
-
|
|
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
|
|
7
|
-
return
|
|
6
|
+
function r() {
|
|
7
|
+
return t !== null;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
function i() {
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
export { n as configurePhraseSpeech, r as phraseSpeechEnabled, i as phraseSpeechEnvironment };
|