@burdenoff/fe-libs 2026.1029.5 → 2026.1029.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.
- package/dist/shared/assistant/attachmentAccessCopy.js +1 -1
- package/dist/shared/assistant/index.d.ts +5 -0
- package/dist/shared/assistant/liveDeltas.d.ts +3 -0
- package/dist/shared/assistant/liveDeltas.js +17 -1
- package/dist/shared/assistant/liveOverlay.d.ts +4 -0
- package/dist/shared/assistant/liveOverlay.js +10 -1
- package/dist/shared/assistant/speech/appendSpeechQueue.d.ts +13 -0
- package/dist/shared/assistant/speech/appendSpeechQueue.js +75 -0
- package/dist/shared/assistant/speech/browserSpeechEngine.js +93 -46
- package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +173 -109
- package/dist/shared/assistant/speech/index.d.ts +1 -1
- package/dist/shared/assistant/speech/notifyCancellationSpeechEngine.js +53 -0
- package/dist/shared/assistant/speech/routingSpeechEngine.js +107 -23
- package/dist/shared/assistant/speech/speechFeed.d.ts +17 -2
- package/dist/shared/assistant/speech/speechFeed.js +35 -12
- package/dist/shared/assistant/speech/types.d.ts +20 -1
- package/dist/shared/assistant/turnTimeline.d.ts +3 -0
- package/dist/shared/assistant/turnTimeline.js +4 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +1410 -1393
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +351 -291
- package/dist/shared/assistant/ui/useVoiceSession.js +323 -288
- package/dist/shared/assistant/useAttachmentCommitter.js +46 -45
- package/dist/shared/assistant/voice/livePhraseSpeech.d.ts +14 -0
- package/dist/shared/assistant/voice/livePhraseSpeech.js +72 -0
- package/dist/shared/assistant/voice/phraseGate.d.ts +11 -0
- package/dist/shared/assistant/voice/phraseGate.js +74 -0
- package/dist/shared/assistant/voice/phrasePlayback.d.ts +9 -0
- package/dist/shared/assistant/voice/phrasePlayback.js +78 -0
- package/dist/shared/assistant/voice/phraseSpeechConfig.d.ts +5 -0
- package/dist/shared/assistant/voice/phraseSpeechConfig.js +10 -0
- package/dist/shared/assistant/voice/speakableText.d.ts +1 -0
- package/dist/shared/assistant/voice/speakableText.js +1 -1
- package/dist/shared/assistant/voice/voiceSession.d.ts +5 -0
- package/dist/shared/assistant/voice/voiceSession.js +17 -1
- package/dist/shared/providers/shell/AuthProvider.d.ts +2 -0
- package/dist/shared/providers/shell/AuthProvider.js +34 -31
- package/dist/shared-assistant.js +293 -288
- package/package.json +1 -1
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { useSafeAuth as e } from "../providers/shell/AuthProvider.js";
|
|
2
|
+
import { isSuperAdminBypass as t, useSafePermissions as n } from "../providers/shell/PermissionProvider.js";
|
|
3
|
+
import { useAssistantStorageFolders as r } from "./product.js";
|
|
4
|
+
import { FilesPortError as i, createApolloFilesPort as a } from "../../storage/filesPort.js";
|
|
5
|
+
import { createAttachmentCommitter as o } from "./attachmentCommit.js";
|
|
6
|
+
import { getActorId as s, getWorkspaceId as c } from "./context.js";
|
|
7
|
+
import { probeAttachmentAccess as l } from "./attachmentAccess.js";
|
|
8
|
+
import { createContext as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useRef as h } from "react";
|
|
9
|
+
import { getApolloContext as g } from "@apollo/client/react";
|
|
9
10
|
//#region src/shared/assistant/useAttachmentCommitter.ts
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
let e =
|
|
13
|
-
return
|
|
11
|
+
var _ = u(null);
|
|
12
|
+
function v() {
|
|
13
|
+
let e = f(_), { client: t } = f(g());
|
|
14
|
+
return m(() => e ?? (t ? a(t, { getWorkspaceId: c }) : null), [e, t]);
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
let e =
|
|
17
|
-
return
|
|
16
|
+
function y() {
|
|
17
|
+
let e = v();
|
|
18
|
+
return d(async (t) => e ? e.getDownloadUrl(t) : null, [e]);
|
|
18
19
|
}
|
|
19
|
-
var
|
|
20
|
-
ensureFolder:
|
|
21
|
-
initiate:
|
|
22
|
-
put:
|
|
23
|
-
complete:
|
|
24
|
-
getSession:
|
|
25
|
-
listSessions:
|
|
26
|
-
abort:
|
|
27
|
-
getDownloadUrl:
|
|
28
|
-
deleteFile:
|
|
20
|
+
var b = (e) => () => Promise.reject(new i(e, "File storage is not available here.", void 0)), x = {
|
|
21
|
+
ensureFolder: b("ensureFolder"),
|
|
22
|
+
initiate: b("initiate"),
|
|
23
|
+
put: b("put"),
|
|
24
|
+
complete: b("complete"),
|
|
25
|
+
getSession: b("getSession"),
|
|
26
|
+
listSessions: b("listSessions"),
|
|
27
|
+
abort: b("abort"),
|
|
28
|
+
getDownloadUrl: b("getDownloadUrl"),
|
|
29
|
+
deleteFile: b("deleteFile")
|
|
29
30
|
};
|
|
30
|
-
function
|
|
31
|
+
function S() {
|
|
31
32
|
return {
|
|
32
|
-
workspaceId: typeof window < "u" && window.location ?
|
|
33
|
-
actorId:
|
|
33
|
+
workspaceId: typeof window < "u" && window.location ? c() : "",
|
|
34
|
+
actorId: s()
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, [
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
let
|
|
44
|
-
return
|
|
45
|
-
port:
|
|
37
|
+
function C(i) {
|
|
38
|
+
let a = v(), s = n(), c = e(), u = typeof c?.user?.actorType == "string" ? c.user.actorType : typeof c?.user?.actor_type == "string" ? c.user.actor_type : void 0, d = s?.isSuperAdmin ?? t(c?.isAuthenticated ?? !1, c?.user?.role, u), f = h(d);
|
|
39
|
+
p(() => {
|
|
40
|
+
f.current = d;
|
|
41
|
+
}, [d]);
|
|
42
|
+
let g = r(), _ = h(i);
|
|
43
|
+
_.current = i;
|
|
44
|
+
let y = h(g.attachments);
|
|
45
|
+
return y.current = g.attachments, m(() => o({
|
|
46
|
+
port: a ?? x,
|
|
46
47
|
preflightAccess: () => {
|
|
47
|
-
let { workspaceId: e, actorId: t } =
|
|
48
|
-
return
|
|
48
|
+
let { workspaceId: e, actorId: t } = S();
|
|
49
|
+
return l(e, t, f.current);
|
|
49
50
|
},
|
|
50
|
-
getScopeKey: () => JSON.stringify(
|
|
51
|
+
getScopeKey: () => JSON.stringify(S()),
|
|
51
52
|
get folderPath() {
|
|
52
|
-
return
|
|
53
|
+
return y.current;
|
|
53
54
|
},
|
|
54
|
-
onChange: (e, t) =>
|
|
55
|
-
}), [
|
|
55
|
+
onChange: (e, t) => _.current(e, t)
|
|
56
|
+
}), [a]);
|
|
56
57
|
}
|
|
57
58
|
//#endregion
|
|
58
|
-
export {
|
|
59
|
+
export { _ as AttachmentFilesPortContext, C as useAttachmentCommitter, v as useAttachmentFilesPort, y as useAttachmentUrlResolver };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LiveDeltaState } from '../liveDeltas';
|
|
2
|
+
export declare const NARRATION_HOLD_MS = 700;
|
|
3
|
+
export interface LivePhraseSpeech {
|
|
4
|
+
update(visible: string, live: LiveDeltaState, floor: number): void;
|
|
5
|
+
invalidate(live: LiveDeltaState, floor: number): void;
|
|
6
|
+
close(): void;
|
|
7
|
+
}
|
|
8
|
+
/** One turn's narrator. Its caller runs only on an opted-in voice/SSE overlay. */
|
|
9
|
+
export declare function createLivePhraseSpeech(options: {
|
|
10
|
+
append(phrases: readonly string[], visible: string): void;
|
|
11
|
+
retract(): void;
|
|
12
|
+
setTimer?: (run: () => void, ms: number) => unknown;
|
|
13
|
+
clearTimer?: (timer: unknown) => void;
|
|
14
|
+
}): LivePhraseSpeech;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { toSpeakableText as e } from "./speakableText.js";
|
|
2
|
+
import { phraseCandidates as t } from "./phraseGate.js";
|
|
3
|
+
//#region 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) => {
|
|
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) => {
|
|
17
|
+
let n = [...e.messages].filter(([, e]) => (e.created ?? 0) > t);
|
|
18
|
+
n.sort((e, t) => (e[1].created ?? 0) - (t[1].created ?? 0));
|
|
19
|
+
let r = n.at(-1)?.[0];
|
|
20
|
+
return [...e.parts].filter(([, e]) => e.messageId === r).at(-1);
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
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();
|
|
32
|
+
},
|
|
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();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (u) return;
|
|
43
|
+
let S = b.ended && g.messages.get(b.messageId)?.completed !== void 0;
|
|
44
|
+
if (c = t(b.text, S), s.some((e, t) => c[t] !== e)) {
|
|
45
|
+
p();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
l = i;
|
|
49
|
+
let C = e(i).replace(/\s+/g, " ");
|
|
50
|
+
if (c.some((e) => !C.includes(e.replace(/\s+/g, " ")))) {
|
|
51
|
+
p();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (S) {
|
|
55
|
+
f(), m(c.length);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (m(Math.max(0, c.length - 1)), s.length === c.length) {
|
|
59
|
+
f();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
a === null && (a = r(() => {
|
|
63
|
+
a = null, m(c.length);
|
|
64
|
+
}, 700));
|
|
65
|
+
},
|
|
66
|
+
close() {
|
|
67
|
+
d = !0, f();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { n as NARRATION_HOLD_MS, r as createLivePhraseSpeech };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-scan a bounded, append-only source part. Callers keep their released prefix
|
|
3
|
+
* and freeze if it ever changes; they do not feed arbitrary poll snapshots.
|
|
4
|
+
* Unfinished paragraphs contribute only sentences with a confirmed ending.
|
|
5
|
+
*/
|
|
6
|
+
export declare function phraseCandidates(markdown: string, final?: boolean): string[];
|
|
7
|
+
/** Reconcile F against accepted/unwithdrawn S without reading the final twice. */
|
|
8
|
+
export declare function unspokenFinal(final: string, segments: readonly string[]): {
|
|
9
|
+
text: string;
|
|
10
|
+
diverged: boolean;
|
|
11
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { MAX_SPEAKABLE_CHARS as e, toSpeakableText as t } from "./speakableText.js";
|
|
2
|
+
//#region src/shared/assistant/voice/phraseGate.ts
|
|
3
|
+
var n = /(?:\b(?:mr|mrs|ms|dr|prof|sr|jr|st|vs|etc|e\.g|i\.e)|\b[A-Z])\.$/i, r = /^(?:thinking|working|one moment|just a moment|sure|certainly|let me (?:check|think|look)|सोच रहा हूँ|சிந்திக்கிறேன்|أفكر|思考中)[\s.!…।॥。]*$/iu, i = /^\s*(?:\||[-*+]\s|\d+[.)]\s|[[{])/, a = {
|
|
4
|
+
codeBlock: "",
|
|
5
|
+
image: "",
|
|
6
|
+
link: "",
|
|
7
|
+
largeTable: "",
|
|
8
|
+
truncated: "",
|
|
9
|
+
emailAt: "",
|
|
10
|
+
emailDot: "",
|
|
11
|
+
nestedItem: ""
|
|
12
|
+
};
|
|
13
|
+
function o(e, i) {
|
|
14
|
+
let o = [], s = 0, c = (n) => {
|
|
15
|
+
let i = t(e.slice(s, n), { labels: a }).trim();
|
|
16
|
+
s = n, i && !r.test(i) && o.push(i);
|
|
17
|
+
};
|
|
18
|
+
for (let t = 0; t < e.length; t++) {
|
|
19
|
+
let r = e[t];
|
|
20
|
+
if (!".!?…。!?।॥؟".includes(r)) continue;
|
|
21
|
+
let i = e[t + 1] ?? "";
|
|
22
|
+
r === "." && (/\d/.test(e[t - 1] ?? "") && (i === "" || /\d/.test(i)) || n.test(e.slice(s, t + 1)) || i === ".") || ".!?…".includes(r) && i !== "" && !/\s/.test(i) || i !== r && c(t + 1);
|
|
23
|
+
}
|
|
24
|
+
return i && s < e.length && c(e.length), o;
|
|
25
|
+
}
|
|
26
|
+
function s(t, n = !1) {
|
|
27
|
+
let r = t.slice(0, e).split("\n"), a = [], s = [], c = null, l = !1, u = (e) => {
|
|
28
|
+
l || a.push(...o(s.join("\n"), e)), s = [], l = !1;
|
|
29
|
+
};
|
|
30
|
+
for (let e = 0; e < r.length; e++) {
|
|
31
|
+
let t = r[e], a = /^\s*(`{3,}|~{3,})/.exec(t)?.[1];
|
|
32
|
+
if (c) {
|
|
33
|
+
a && a[0] === c[0] && a.length >= c.length && (c = null);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (a) {
|
|
37
|
+
u(!0), c = a;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (!t.trim()) {
|
|
41
|
+
u(!0);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
(i.test(t) || t.includes("|") || /[[{]\s*"(?:tool|arguments|name)"\s*:/.test(t)) && (l = !0), s.push(t), e === r.length - 1 && u(n);
|
|
45
|
+
}
|
|
46
|
+
return a;
|
|
47
|
+
}
|
|
48
|
+
function c(e, t) {
|
|
49
|
+
let n = (e) => e.replace(/\s+/g, " ").trim(), r = n(e), i = n(t.filter(Boolean).join(" "));
|
|
50
|
+
if (!i) return {
|
|
51
|
+
text: r,
|
|
52
|
+
diverged: !1
|
|
53
|
+
};
|
|
54
|
+
if (r.startsWith(i)) return {
|
|
55
|
+
text: r.slice(i.length).trim(),
|
|
56
|
+
diverged: !1
|
|
57
|
+
};
|
|
58
|
+
for (let e = t.length - 1; e >= 0; e--) {
|
|
59
|
+
let i = n(t[e] ?? "");
|
|
60
|
+
if (!i) continue;
|
|
61
|
+
let a = r.lastIndexOf(i);
|
|
62
|
+
if (a >= 0) return {
|
|
63
|
+
text: r.slice(a + i.length).trim(),
|
|
64
|
+
diverged: !0
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
let a = new Set(t.map(n)), o = s(r, !0);
|
|
68
|
+
return {
|
|
69
|
+
text: o.length ? o.filter((e) => !a.has(n(e))).join(" ") : r,
|
|
70
|
+
diverged: !0
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { s as phraseCandidates, c as unspokenFinal };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SpeechQueue, SpeechSpeakHandlers } from '../speech/types';
|
|
2
|
+
export interface PhrasePlayback {
|
|
3
|
+
append(text: string): void;
|
|
4
|
+
finish(final: string): void;
|
|
5
|
+
retract(): void;
|
|
6
|
+
cancel(): void;
|
|
7
|
+
}
|
|
8
|
+
/** One reply, one engine request. Buffer text only; synthesis stays one ahead. */
|
|
9
|
+
export declare function createPhrasePlayback(open: (handlers: SpeechSpeakHandlers) => SpeechQueue, handlers: SpeechSpeakHandlers, changed: (chunks: readonly string[]) => void, divergence: () => void): PhrasePlayback;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { MAX_SPEAKABLE_CHARS as e, chunkForSpeech as t } from "./speakableText.js";
|
|
2
|
+
import { unspokenFinal as n } from "./phraseGate.js";
|
|
3
|
+
//#region src/shared/assistant/voice/phrasePlayback.ts
|
|
4
|
+
function r(r, i, a, o) {
|
|
5
|
+
let s = [], c = [], l = 0, u = !1, d = !1, f = !1, p = !1, m = !1, h = r({
|
|
6
|
+
onStart: () => {
|
|
7
|
+
p || i.onStart?.();
|
|
8
|
+
},
|
|
9
|
+
onChunkStart: (e) => {
|
|
10
|
+
p || i.onChunkStart?.(e);
|
|
11
|
+
},
|
|
12
|
+
onPause: () => {
|
|
13
|
+
p || i.onPause?.();
|
|
14
|
+
},
|
|
15
|
+
onDeviceFallback: () => {
|
|
16
|
+
p || i.onDeviceFallback?.();
|
|
17
|
+
},
|
|
18
|
+
onChunkEnd(e) {
|
|
19
|
+
p || (g(), i.onChunkEnd?.(e));
|
|
20
|
+
},
|
|
21
|
+
onRetract(e) {
|
|
22
|
+
if (!p) {
|
|
23
|
+
for (let t of e) s[t] = "";
|
|
24
|
+
a([...s]), i.onRetract?.(e);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
onEnd() {
|
|
28
|
+
p || (p = !0, i.onEnd?.());
|
|
29
|
+
},
|
|
30
|
+
onError(e) {
|
|
31
|
+
p || (p = !0, c = [], i.onError?.(e));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
function g() {
|
|
35
|
+
if (!(m || p)) {
|
|
36
|
+
m = !0;
|
|
37
|
+
try {
|
|
38
|
+
for (; c.length && !p && (d || !s.some(Boolean) || c.length > 1);) {
|
|
39
|
+
let e = c[0];
|
|
40
|
+
if (s.push(e), a([...s]), !h.append([e])) {
|
|
41
|
+
s.pop(), a([...s]);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
c.shift();
|
|
45
|
+
}
|
|
46
|
+
d && !c.length && !p && !f && (f = !0, h.end());
|
|
47
|
+
} finally {
|
|
48
|
+
m = !1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let _ = (e) => t(e, void 0, void 0, { ...s.some(Boolean) ? { packFirstChunk: !0 } : { firstChunkMaxChars: 110 } });
|
|
53
|
+
return {
|
|
54
|
+
append(e) {
|
|
55
|
+
if (!(d || p || u)) {
|
|
56
|
+
if (l + e.length > 8e3) {
|
|
57
|
+
u = !0;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
l += e.length, c = _([...c, e].filter(Boolean).join(" ")), g();
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
finish(t) {
|
|
64
|
+
if (d || p) return;
|
|
65
|
+
d = !0;
|
|
66
|
+
let r = n(t.slice(0, e), [...s, ...c]);
|
|
67
|
+
r.diverged && o(), c = _([...c, r.text].filter(Boolean).join(" ")), g();
|
|
68
|
+
},
|
|
69
|
+
retract() {
|
|
70
|
+
d || p || (c = [], h.retract());
|
|
71
|
+
},
|
|
72
|
+
cancel() {
|
|
73
|
+
p = !0, c = [], h.cancel();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { r as createPhrasePlayback };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/shared/assistant/voice/phraseSpeechConfig.ts
|
|
2
|
+
var e = !1;
|
|
3
|
+
function t(t) {
|
|
4
|
+
e = t?.enabled === !0 && t.environment === "alpha";
|
|
5
|
+
}
|
|
6
|
+
function n() {
|
|
7
|
+
return e;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as configurePhraseSpeech, n as phraseSpeechEnabled };
|
|
@@ -302,7 +302,7 @@ function ee(e, t = 180, n = 40, r = {}) {
|
|
|
302
302
|
let n = X(s, t), r = Math.min(c, e);
|
|
303
303
|
n.length <= r ? (s = n, c = r) : (o.push(s), s = t, c = e);
|
|
304
304
|
}
|
|
305
|
-
if (s && o.push(s), o.length > 1) {
|
|
305
|
+
if (s && o.push(s), o.length > 1 && !r.packFirstChunk) {
|
|
306
306
|
let e = W(o[0]);
|
|
307
307
|
if (e.length > 1) {
|
|
308
308
|
let [t, ...n] = e;
|
|
@@ -125,6 +125,11 @@ export type VoiceSessionEvent =
|
|
|
125
125
|
| {
|
|
126
126
|
type: 'reply-audio-started';
|
|
127
127
|
replyId: string;
|
|
128
|
+
partial?: boolean;
|
|
129
|
+
} | {
|
|
130
|
+
type: 'reply-audio-paused';
|
|
131
|
+
} | {
|
|
132
|
+
type: 'reply-audio-ended';
|
|
128
133
|
}
|
|
129
134
|
/**
|
|
130
135
|
* ★ BOFF-9207: the turn ended WITHOUT an answer - the assistant refused it
|
|
@@ -158,13 +158,29 @@ function v(t, r, i = null) {
|
|
|
158
158
|
pending: "",
|
|
159
159
|
interim: ""
|
|
160
160
|
} : t;
|
|
161
|
-
case "reply-audio-started": return t.phase === "thinking" ? {
|
|
161
|
+
case "reply-audio-started": return r.partial && t.phase === "thinking" ? {
|
|
162
|
+
...t,
|
|
163
|
+
phase: "speaking",
|
|
164
|
+
pending: "",
|
|
165
|
+
interim: ""
|
|
166
|
+
} : t.phase === "thinking" ? {
|
|
162
167
|
...t,
|
|
163
168
|
...g,
|
|
164
169
|
phase: "speaking",
|
|
165
170
|
pending: "",
|
|
166
171
|
interim: ""
|
|
167
172
|
} : t;
|
|
173
|
+
case "reply-audio-paused": return t.phase === "speaking" ? {
|
|
174
|
+
...t,
|
|
175
|
+
phase: "thinking"
|
|
176
|
+
} : t;
|
|
177
|
+
case "reply-audio-ended": return t.phase === "thinking" || t.phase === "speaking" ? {
|
|
178
|
+
...t,
|
|
179
|
+
...g,
|
|
180
|
+
phase: "listening",
|
|
181
|
+
pending: "",
|
|
182
|
+
interim: ""
|
|
183
|
+
} : t;
|
|
168
184
|
case "turn-refused": return t.phase === "thinking" ? {
|
|
169
185
|
...t,
|
|
170
186
|
...g,
|
|
@@ -73,3 +73,5 @@ export interface AuthProviderProps {
|
|
|
73
73
|
}
|
|
74
74
|
export declare function AuthProvider({ children, onTokenExpired, onSessionExpiringSoon, onRefreshToken, bridgeUrl, bridgeAllowedOrigins, bridgeDebug, onBridgeReady, onBeforeIdentityChange, }: AuthProviderProps): import('react/jsx-runtime').JSX.Element;
|
|
75
75
|
export declare function useAuth(): AuthContextValue;
|
|
76
|
+
/** Optional shell integration: the same session as useAuth, or no provider. */
|
|
77
|
+
export declare function useSafeAuth(): AuthContextValue | null;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { getActiveProfileId as e, getProfileTokens as t, getProfileUser as n, getProfileWorkspaceToken as ee, getSwitchableProfiles as r, resolveActiveProfileId as te } from "./ProfileStorageManager.js";
|
|
2
|
-
import { readShellSsoCookie as
|
|
3
|
-
import { identityKeyOf as
|
|
4
|
-
import { useBridgeInitialization as
|
|
5
|
-
import { useTokenExpiryTimer as
|
|
6
|
-
import { useStorageSync as
|
|
7
|
-
import { useRemoteSLO as
|
|
2
|
+
import { readShellSsoCookie as ne } from "../../utils/authCookie.js";
|
|
3
|
+
import { identityKeyOf as i } from "./authProvider/identityChange.js";
|
|
4
|
+
import { useBridgeInitialization as a } from "./authProvider/useBridgeInitialization.js";
|
|
5
|
+
import { useTokenExpiryTimer as re } from "./authProvider/useTokenExpiryTimer.js";
|
|
6
|
+
import { useStorageSync as ie } from "./authProvider/useStorageSync.js";
|
|
7
|
+
import { useRemoteSLO as o } from "./authProvider/useRemoteSLO.js";
|
|
8
8
|
import { useAuthActions as ae } from "./authProvider/useAuthActions.js";
|
|
9
9
|
import { useSsoDepositBootGuard as oe } from "./authProvider/useSsoDepositBootGuard.js";
|
|
10
10
|
import { createContext as s, use as c, useCallback as l, useLayoutEffect as se, useMemo as u, useRef as d, useState as f } from "react";
|
|
11
|
-
import { jsx as
|
|
11
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
12
12
|
//#region src/shared/providers/shell/AuthProvider.tsx
|
|
13
|
-
var
|
|
14
|
-
function
|
|
13
|
+
var m = s(null);
|
|
14
|
+
function h(e) {
|
|
15
15
|
return r(e).map((t) => ({
|
|
16
16
|
id: t.id,
|
|
17
17
|
email: t.email,
|
|
@@ -21,29 +21,29 @@ function m(e) {
|
|
|
21
21
|
lastLogin: t.lastLogin
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function g({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefreshToken: g, bridgeUrl: _, bridgeAllowedOrigins: v, bridgeDebug: ce, onBridgeReady: le, onBeforeIdentityChange: y }) {
|
|
25
25
|
let b = d(!1), [x, S] = f(() => te()), [C, w] = f(() => x ? n(x) : null), [T, E] = f(() => x ? t(x) : null), [D, O] = f(() => x ? ee(x) : null), [k, A] = f(() => {
|
|
26
26
|
if (x && n(x)) return !1;
|
|
27
|
-
if (
|
|
28
|
-
let e =
|
|
27
|
+
if (_) try {
|
|
28
|
+
let e = ne()?.id ?? null;
|
|
29
29
|
if (e && localStorage.getItem(`bf-p-${e}-tokens`)) return !1;
|
|
30
30
|
} catch {}
|
|
31
|
-
return !!
|
|
32
|
-
}), [j, ue] = f(!1), [M, de] = f(null), [N, P] = f(() =>
|
|
31
|
+
return !!_;
|
|
32
|
+
}), [j, ue] = f(!1), [M, de] = f(null), [N, P] = f(() => h(x)), F = l(() => {
|
|
33
33
|
P([]);
|
|
34
34
|
}, []), I = l(() => {
|
|
35
|
-
P(
|
|
36
|
-
}, []), L =
|
|
35
|
+
P(h(e()));
|
|
36
|
+
}, []), L = i(x, C?.id), R = d(L), z = d(!1), B = d(y);
|
|
37
37
|
se(() => {
|
|
38
38
|
R.current = L, z.current = !1, B.current = y;
|
|
39
39
|
});
|
|
40
40
|
let V = l((e, t) => {
|
|
41
|
-
z.current ||
|
|
41
|
+
z.current || i(t.profileId, t.userId) !== R.current && (z.current = !0, B.current?.(e));
|
|
42
42
|
}, []);
|
|
43
|
-
|
|
44
|
-
bridgeUrl:
|
|
45
|
-
bridgeAllowedOrigins:
|
|
46
|
-
bridgeDebug:
|
|
43
|
+
a({
|
|
44
|
+
bridgeUrl: _,
|
|
45
|
+
bridgeAllowedOrigins: v,
|
|
46
|
+
bridgeDebug: ce,
|
|
47
47
|
onBridgeReady: le,
|
|
48
48
|
bridgeSyncInProgress: b,
|
|
49
49
|
setIsLoading: A,
|
|
@@ -60,7 +60,7 @@ function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefresh
|
|
|
60
60
|
tokens: T,
|
|
61
61
|
activeId: x,
|
|
62
62
|
bridgeSyncInProgress: b,
|
|
63
|
-
onRefreshToken:
|
|
63
|
+
onRefreshToken: g,
|
|
64
64
|
onTokenExpired: s,
|
|
65
65
|
setActiveId: S,
|
|
66
66
|
setUser: w,
|
|
@@ -73,13 +73,13 @@ function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefresh
|
|
|
73
73
|
refreshAccounts: I,
|
|
74
74
|
announceIdentityChange: V
|
|
75
75
|
});
|
|
76
|
-
|
|
76
|
+
re({
|
|
77
77
|
tokens: T,
|
|
78
|
-
onRefreshToken:
|
|
78
|
+
onRefreshToken: g,
|
|
79
79
|
onTokenExpired: s,
|
|
80
80
|
onSessionExpiringSoon: c,
|
|
81
81
|
refreshAccessToken: K
|
|
82
|
-
}),
|
|
82
|
+
}), ie({
|
|
83
83
|
user: C,
|
|
84
84
|
tokens: T,
|
|
85
85
|
workspaceToken: D,
|
|
@@ -91,9 +91,9 @@ function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefresh
|
|
|
91
91
|
clearAccounts: F,
|
|
92
92
|
refreshAccounts: I,
|
|
93
93
|
announceIdentityChange: V
|
|
94
|
-
}), oe(),
|
|
94
|
+
}), oe(), o({
|
|
95
95
|
tokens: T,
|
|
96
|
-
bridgeUrl:
|
|
96
|
+
bridgeUrl: _,
|
|
97
97
|
logout: U,
|
|
98
98
|
setActiveId: S,
|
|
99
99
|
setUser: w,
|
|
@@ -146,15 +146,18 @@ function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefresh
|
|
|
146
146
|
Q,
|
|
147
147
|
W
|
|
148
148
|
]);
|
|
149
|
-
return /* @__PURE__ */
|
|
149
|
+
return /* @__PURE__ */ p(m.Provider, {
|
|
150
150
|
value: fe,
|
|
151
151
|
children: r
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
let e = c(
|
|
154
|
+
function _() {
|
|
155
|
+
let e = c(m);
|
|
156
156
|
if (!e) throw Error("useAuth must be used within an AuthProvider");
|
|
157
157
|
return e;
|
|
158
158
|
}
|
|
159
|
+
function v() {
|
|
160
|
+
return c(m);
|
|
161
|
+
}
|
|
159
162
|
//#endregion
|
|
160
|
-
export {
|
|
163
|
+
export { g as AuthProvider, _ as useAuth, v as useSafeAuth };
|