@burdenoff/fe-libs 2026.925.5 → 2026.925.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/chrome/MobileTabBar.js +6 -6
- package/dist/chrome/ProductSideNav.js +9 -9
- package/dist/chrome/sideNavigation/useSideNavigationState.js +3 -3
- package/dist/chrome.js +8 -8
- package/dist/shared/assistant/autoRouting.d.ts +3 -0
- package/dist/shared/assistant/autoRouting.d.ts.map +1 -1
- package/dist/shared/assistant/autoRouting.js +1 -1
- package/dist/shared/assistant/conversation.d.ts +20 -0
- package/dist/shared/assistant/conversation.d.ts.map +1 -1
- package/dist/shared/assistant/i18nManifest.d.ts +11 -0
- package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
- package/dist/shared/assistant/i18nManifest.js +11 -0
- package/dist/shared/assistant/index.d.ts +3 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/localUiCommandCopy.d.ts +26 -0
- package/dist/shared/assistant/localUiCommandCopy.d.ts.map +1 -0
- package/dist/shared/assistant/localUiCommandCopy.js +37 -0
- package/dist/shared/assistant/localUiCommands.d.ts +124 -0
- package/dist/shared/assistant/localUiCommands.d.ts.map +1 -0
- package/dist/shared/assistant/localUiCommands.js +173 -0
- package/dist/shared/assistant/prewarm.d.ts +139 -0
- package/dist/shared/assistant/prewarm.d.ts.map +1 -0
- package/dist/shared/assistant/prewarm.js +96 -0
- package/dist/shared/assistant/product.d.ts +13 -1
- package/dist/shared/assistant/product.d.ts.map +1 -1
- package/dist/shared/assistant/product.js +8 -6
- package/dist/shared/assistant/turnTimeline.d.ts +7 -0
- package/dist/shared/assistant/turnTimeline.d.ts.map +1 -1
- package/dist/shared/assistant/turnTimeline.js +2 -2
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +663 -482
- package/dist/shared/assistant/ui/AssistantMessageItem.d.ts +6 -0
- package/dist/shared/assistant/ui/AssistantMessageItem.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantMessageItem.js +3 -3
- package/dist/shared/assistant/ui/AssistantMessageList.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantMessageList.js +14 -7
- package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts +9 -0
- package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +243 -196
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +6 -0
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts.map +1 -1
- package/dist/shared/assistant/ui/composer/AssistantComposer.js +110 -106
- package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
- package/dist/shared/assistant/ui/useVoiceSession.js +44 -43
- package/dist/shared/assistant/voice/captionText.d.ts.map +1 -1
- package/dist/shared/assistant/voice/captionText.js +1 -1
- package/dist/shared/assistant/voice/speakableText.d.ts.map +1 -1
- package/dist/shared/assistant/voice/speakableText.js +63 -62
- package/dist/shared/hooks/shell/index.d.ts +1 -1
- package/dist/shared/hooks/shell/index.d.ts.map +1 -1
- package/dist/shared/providers/shell/ThemeProvider.d.ts +6 -0
- package/dist/shared/providers/shell/ThemeProvider.d.ts.map +1 -1
- package/dist/shared/providers/shell/ThemeProvider.js +28 -25
- package/dist/shared-assistant.js +17 -14
- package/dist/shared-hooks-shell.js +12 -12
- package/package.json +1 -1
|
@@ -1,179 +1,183 @@
|
|
|
1
1
|
import { useI18n as e } from "../../../providers/shell/I18nProvider.js";
|
|
2
2
|
import { useVoiceInput as t } from "../../voice/useVoiceInput.js";
|
|
3
|
-
import { useAssistantTr as
|
|
4
|
-
import { languageDisplayName as
|
|
3
|
+
import { useAssistantTr as ee } from "../../i18n.js";
|
|
4
|
+
import { languageDisplayName as n } from "../../voice/speechVoices.js";
|
|
5
5
|
import { resolveAssistantLanguage as r } from "../../voice/languages.js";
|
|
6
|
-
import { getSendableAttachments as
|
|
7
|
-
import { useAssistantStore as
|
|
8
|
-
import { AssistantAttachmentButton as
|
|
9
|
-
import { AssistantAttachmentChips as
|
|
10
|
-
import { AssistantModeSelector as
|
|
11
|
-
import { AssistantVoiceButton as
|
|
12
|
-
import { AssistantVoiceSessionButton as
|
|
13
|
-
import { useAssistantAttachments as
|
|
14
|
-
import { useCallback as l, useLayoutEffect as u, useMemo as
|
|
15
|
-
import { ArrowUp as
|
|
16
|
-
import { jsx as
|
|
6
|
+
import { getSendableAttachments as i } from "../../attachments.js";
|
|
7
|
+
import { useAssistantStore as a } from "../../store.js";
|
|
8
|
+
import { AssistantAttachmentButton as o } from "./AssistantAttachmentButton.js";
|
|
9
|
+
import { AssistantAttachmentChips as s } from "./AssistantAttachmentChips.js";
|
|
10
|
+
import { AssistantModeSelector as c } from "./AssistantModeSelector.js";
|
|
11
|
+
import { AssistantVoiceButton as te } from "./AssistantVoiceButton.js";
|
|
12
|
+
import { AssistantVoiceSessionButton as ne } from "../voice/AssistantVoiceSessionButton.js";
|
|
13
|
+
import { useAssistantAttachments as re } from "../../useAssistantAttachments.js";
|
|
14
|
+
import { useCallback as l, useEffect as ie, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
15
|
+
import { ArrowUp as m, Loader2 as h } from "lucide-react";
|
|
16
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
17
17
|
//#region src/shared/assistant/ui/composer/AssistantComposer.tsx
|
|
18
|
-
var
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
var v = 200, y = ({ writeAccessDenied: y = !1, onSend: b, disabled: x = !1, placeholder: ae, mode: oe, availableModes: S, attachmentCharsPerFile: se, onModeChange: ce, auto: le, onStartVoiceSession: C, onDraftStart: w }) => {
|
|
19
|
+
let T = ee(), { locale: E } = e(), D = f(null), [O, k] = p(""), [A, j] = p(!1), M = f(0), { attachments: N, isBusy: P, preparingCount: F, sendBlocker: I, rejection: L, addFiles: R, remove: z, retry: B, clear: V, clearRejection: H, canAddMore: ue } = re({ perFileChars: se }), U = O.trim() !== "" || N.length > 0, W = f(!1);
|
|
20
|
+
ie(() => {
|
|
21
|
+
U && !W.current ? (W.current = !0, w?.()) : U || (W.current = !1);
|
|
22
|
+
}, [U, w]);
|
|
23
|
+
let de = l((e) => {
|
|
24
|
+
k((t) => t ? `${t.replace(/\s+$/, "")} ${e}` : e);
|
|
25
|
+
}, []), G = a((e) => e.assistantLanguage), K = t({
|
|
26
|
+
onFinalize: de,
|
|
27
|
+
language: d(() => r(G, E), [G, E]).tag
|
|
28
|
+
}), fe = ae ?? T("composer.placeholder", "Ask me anything…"), q = O.trim(), J = i(N), Y = N.filter((e) => e.status === "error"), X = (q.length > 0 || J.length > 0) && !x && I === null;
|
|
25
29
|
u(() => {
|
|
26
|
-
let e =
|
|
27
|
-
e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight,
|
|
28
|
-
}, [
|
|
30
|
+
let e = D.current;
|
|
31
|
+
e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, v)}px`);
|
|
32
|
+
}, [O]);
|
|
29
33
|
let Z = l(() => {
|
|
30
|
-
X && (K.isActive && K.stop(),
|
|
34
|
+
X && (K.isActive && K.stop(), b(O.trim(), J), k(""), V());
|
|
31
35
|
}, [
|
|
32
36
|
X,
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
b,
|
|
38
|
+
O,
|
|
35
39
|
J,
|
|
36
|
-
|
|
40
|
+
V,
|
|
37
41
|
K
|
|
38
|
-
]),
|
|
42
|
+
]), pe = l((e) => {
|
|
39
43
|
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), Z());
|
|
40
|
-
}, [Z]),
|
|
44
|
+
}, [Z]), me = l((e) => {
|
|
41
45
|
let t = Array.from(e.clipboardData?.files ?? []);
|
|
42
|
-
t.length !== 0 && (e.preventDefault(),
|
|
43
|
-
}, [
|
|
44
|
-
Array.from(e.dataTransfer?.types ?? []).includes("Files") && (
|
|
45
|
-
}, []),
|
|
46
|
-
|
|
47
|
-
}, []),
|
|
46
|
+
t.length !== 0 && (e.preventDefault(), R(t));
|
|
47
|
+
}, [R]), he = l((e) => {
|
|
48
|
+
Array.from(e.dataTransfer?.types ?? []).includes("Files") && (M.current += 1, j(!0));
|
|
49
|
+
}, []), ge = l(() => {
|
|
50
|
+
M.current = Math.max(0, M.current - 1), M.current === 0 && j(!1);
|
|
51
|
+
}, []), _e = l((e) => {
|
|
48
52
|
Array.from(e.dataTransfer?.types ?? []).includes("Files") && e.preventDefault();
|
|
49
|
-
}, []),
|
|
50
|
-
e.preventDefault(),
|
|
51
|
-
}, [
|
|
53
|
+
}, []), Q = l((e) => {
|
|
54
|
+
e.preventDefault(), M.current = 0, j(!1), R(e.dataTransfer?.files ?? null);
|
|
55
|
+
}, [R]), ve = (e) => {
|
|
52
56
|
switch (e) {
|
|
53
|
-
case "too-many": return
|
|
54
|
-
case "too-large": return
|
|
55
|
-
case "empty": return
|
|
56
|
-
case "unreadable": return
|
|
57
|
-
case "unsupported-image": return
|
|
57
|
+
case "too-many": return T("attachments.tooMany", "You can attach up to {{max}} files per message.", { max: 5 });
|
|
58
|
+
case "too-large": return T("attachments.tooLarge", "That file is larger than 10 MB.");
|
|
59
|
+
case "empty": return T("attachments.empty", "That file is empty.");
|
|
60
|
+
case "unreadable": return T("attachments.unreadable", "That file could not be read.");
|
|
61
|
+
case "unsupported-image": return T("attachments.unsupportedImage", "This device can't read that image format, so it can't be resized to send. Save it as JPEG and try again.");
|
|
58
62
|
}
|
|
59
63
|
}, $ = (() => {
|
|
60
64
|
switch (K.error) {
|
|
61
|
-
case "not-allowed": return
|
|
62
|
-
case "audio-capture": return
|
|
63
|
-
case "network": return
|
|
64
|
-
case "language-not-supported": return
|
|
65
|
-
case "unknown": return
|
|
65
|
+
case "not-allowed": return T("voice.denied", "Microphone access is blocked. Allow it in your browser settings to dictate.");
|
|
66
|
+
case "audio-capture": return T("voice.noMic", "No microphone was found.");
|
|
67
|
+
case "network": return T("voice.network", "Speech recognition is offline right now.");
|
|
68
|
+
case "language-not-supported": return T("voice.languageNotSupported", "This browser cannot recognise spoken {{language}}. Try a different browser, or type instead.", { language: n(K.language, E) });
|
|
69
|
+
case "unknown": return T("voice.failed", "Dictation stopped unexpectedly.");
|
|
66
70
|
default: return null;
|
|
67
71
|
}
|
|
68
72
|
})();
|
|
69
|
-
return /* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ _("div", {
|
|
70
74
|
className: "flex-shrink-0 px-3 pb-3 pt-1.5",
|
|
71
75
|
children: [
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
onDragEnter:
|
|
74
|
-
onDragLeave:
|
|
75
|
-
onDragOver:
|
|
76
|
-
onDrop:
|
|
77
|
-
className: `rounded-2xl border p-2 shadow-sm transition-colors focus-within:border-action-primary-bg focus-within:ring-2 focus-within:ring-action-primary-bg/15 ${
|
|
76
|
+
/* @__PURE__ */ _("div", {
|
|
77
|
+
onDragEnter: he,
|
|
78
|
+
onDragLeave: ge,
|
|
79
|
+
onDragOver: _e,
|
|
80
|
+
onDrop: Q,
|
|
81
|
+
className: `rounded-2xl border p-2 shadow-sm transition-colors focus-within:border-action-primary-bg focus-within:ring-2 focus-within:ring-action-primary-bg/15 ${A ? "border-action-primary-bg border-dashed bg-action-primary-bg/5" : "border-border-default bg-bg-sunken"}`,
|
|
78
82
|
"data-testid": "assistant-composer",
|
|
79
83
|
children: [
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
attachments:
|
|
82
|
-
onRemove:
|
|
83
|
-
onRetry:
|
|
84
|
-
disabled:
|
|
85
|
-
preparingCount:
|
|
84
|
+
/* @__PURE__ */ g(s, {
|
|
85
|
+
attachments: N,
|
|
86
|
+
onRemove: z,
|
|
87
|
+
onRetry: B,
|
|
88
|
+
disabled: x,
|
|
89
|
+
preparingCount: F
|
|
86
90
|
}),
|
|
87
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ _("div", {
|
|
88
92
|
className: "flex items-end gap-2",
|
|
89
93
|
children: [
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
onFiles:
|
|
92
|
-
canAddMore:
|
|
93
|
-
disabled:
|
|
94
|
+
/* @__PURE__ */ g(o, {
|
|
95
|
+
onFiles: R,
|
|
96
|
+
canAddMore: ue,
|
|
97
|
+
disabled: x
|
|
94
98
|
}),
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
ref:
|
|
97
|
-
value:
|
|
98
|
-
onChange: (e) =>
|
|
99
|
-
onKeyDown:
|
|
100
|
-
onPaste:
|
|
101
|
-
disabled:
|
|
102
|
-
placeholder:
|
|
99
|
+
/* @__PURE__ */ g("textarea", {
|
|
100
|
+
ref: D,
|
|
101
|
+
value: O,
|
|
102
|
+
onChange: (e) => k(e.target.value),
|
|
103
|
+
onKeyDown: pe,
|
|
104
|
+
onPaste: me,
|
|
105
|
+
disabled: x,
|
|
106
|
+
placeholder: A ? T("composer.dropHere", "Drop files to attach") : fe,
|
|
103
107
|
rows: 1,
|
|
104
108
|
className: "min-h-[36px] flex-1 resize-none self-center bg-transparent px-1 py-2 text-[15px] leading-relaxed text-text-primary placeholder:text-text-muted focus:outline-none disabled:opacity-50",
|
|
105
|
-
"aria-label":
|
|
109
|
+
"aria-label": T("chatInput.ariaLabel", "Message input"),
|
|
106
110
|
"data-testid": "assistant-input"
|
|
107
111
|
}),
|
|
108
|
-
K.isSupported && /* @__PURE__ */
|
|
112
|
+
K.isSupported && /* @__PURE__ */ g(te, {
|
|
109
113
|
isListening: K.isListening,
|
|
110
114
|
isStarting: K.isStarting,
|
|
111
115
|
onToggle: K.toggle,
|
|
112
|
-
disabled:
|
|
116
|
+
disabled: x
|
|
113
117
|
}),
|
|
114
|
-
|
|
115
|
-
onStart:
|
|
116
|
-
disabled:
|
|
117
|
-
}) : /* @__PURE__ */
|
|
118
|
+
C && q.length === 0 && N.length === 0 && !K.isActive ? /* @__PURE__ */ g(ne, {
|
|
119
|
+
onStart: C,
|
|
120
|
+
disabled: x
|
|
121
|
+
}) : /* @__PURE__ */ g("button", {
|
|
118
122
|
type: "button",
|
|
119
123
|
onClick: Z,
|
|
120
124
|
disabled: !X,
|
|
121
125
|
className: `flex size-9 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong ${X ? "bg-action-primary-bg text-action-primary-text hover:scale-105 hover:bg-action-primary-bg-hover" : "bg-bg-elevated text-text-muted"}`,
|
|
122
|
-
"aria-label":
|
|
126
|
+
"aria-label": T("chatInput.send", "Send message"),
|
|
123
127
|
"data-testid": "assistant-send",
|
|
124
|
-
children:
|
|
128
|
+
children: x || P ? /* @__PURE__ */ g(h, { className: "size-4 motion-safe:animate-spin" }) : /* @__PURE__ */ g(m, { className: "size-4" })
|
|
125
129
|
})
|
|
126
130
|
]
|
|
127
131
|
}),
|
|
128
|
-
|
|
132
|
+
S.length > 1 && /* @__PURE__ */ g("div", {
|
|
129
133
|
className: "mt-2 px-0.5",
|
|
130
|
-
children: /* @__PURE__ */
|
|
131
|
-
mode:
|
|
132
|
-
availableModes:
|
|
133
|
-
onModeChange:
|
|
134
|
-
disabled:
|
|
135
|
-
auto:
|
|
134
|
+
children: /* @__PURE__ */ g(c, {
|
|
135
|
+
mode: oe,
|
|
136
|
+
availableModes: S,
|
|
137
|
+
onModeChange: ce,
|
|
138
|
+
disabled: x,
|
|
139
|
+
auto: le
|
|
136
140
|
})
|
|
137
141
|
})
|
|
138
142
|
]
|
|
139
143
|
}),
|
|
140
|
-
|
|
144
|
+
y ? /* @__PURE__ */ g("p", {
|
|
141
145
|
className: "mt-1.5 px-1 text-center text-[11px] text-status-warning",
|
|
142
146
|
"data-testid": "assistant-write-access-warning",
|
|
143
|
-
children:
|
|
147
|
+
children: T("composer.writeAccessDenied", "Changes may not save — your role in this workspace does not currently allow edits. You can still plan and review an action.")
|
|
144
148
|
}) : null,
|
|
145
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ g("div", {
|
|
146
150
|
className: "mt-1.5 px-1 text-center text-[11px]",
|
|
147
151
|
"aria-live": "polite",
|
|
148
|
-
children: K.isStarting && !K.isListening ? /* @__PURE__ */
|
|
152
|
+
children: K.isStarting && !K.isListening ? /* @__PURE__ */ g("p", {
|
|
149
153
|
className: "text-text-muted",
|
|
150
154
|
"data-testid": "assistant-voice-starting",
|
|
151
|
-
children:
|
|
152
|
-
}) : K.isListening ? /* @__PURE__ */
|
|
155
|
+
children: T("voice.starting", "Starting the microphone…")
|
|
156
|
+
}) : K.isListening ? /* @__PURE__ */ _("p", {
|
|
153
157
|
className: "text-status-error-text",
|
|
154
158
|
"data-testid": "assistant-voice-status",
|
|
155
|
-
children: [/* @__PURE__ */
|
|
156
|
-
}) : $ ? /* @__PURE__ */
|
|
159
|
+
children: [/* @__PURE__ */ g("span", { className: "mr-1 inline-block size-1.5 rounded-full bg-status-error-text align-middle motion-safe:animate-pulse" }), K.interim || T("voice.listening", "Listening… speak now, tap the square to stop")]
|
|
160
|
+
}) : $ ? /* @__PURE__ */ g("p", {
|
|
157
161
|
className: "text-status-error-text",
|
|
158
162
|
"data-testid": "assistant-voice-error",
|
|
159
163
|
children: $
|
|
160
|
-
}) :
|
|
164
|
+
}) : L ? /* @__PURE__ */ g("button", {
|
|
161
165
|
type: "button",
|
|
162
|
-
onClick:
|
|
166
|
+
onClick: H,
|
|
163
167
|
className: "text-status-error-text underline-offset-2 hover:underline",
|
|
164
168
|
"data-testid": "assistant-attachment-rejection",
|
|
165
|
-
children:
|
|
166
|
-
}) :
|
|
169
|
+
children: ve(L)
|
|
170
|
+
}) : I === "failed" ? /* @__PURE__ */ g("p", {
|
|
167
171
|
className: "text-status-error-text",
|
|
168
172
|
"data-testid": "assistant-attachment-blocked",
|
|
169
|
-
children: Y.length === 1 ?
|
|
170
|
-
}) : /* @__PURE__ */
|
|
173
|
+
children: Y.length === 1 ? T("attachments.blockedOne", "{{name}} didn't upload. Retry or remove it before sending.", { name: Y[0].filename }) : T("attachments.blockedMany", "{{count}} attachments didn't upload. Retry or remove them before sending.", { count: Y.length })
|
|
174
|
+
}) : /* @__PURE__ */ g("p", {
|
|
171
175
|
className: "text-text-muted",
|
|
172
|
-
children:
|
|
176
|
+
children: T("composer.hint", "Enter to send · Shift+Enter for newline · drag or paste files to attach")
|
|
173
177
|
})
|
|
174
178
|
})
|
|
175
179
|
]
|
|
176
180
|
});
|
|
177
181
|
};
|
|
178
182
|
//#endregion
|
|
179
|
-
export {
|
|
183
|
+
export { y as AssistantComposer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVoiceSession.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/ui/useVoiceSession.ts"],"names":[],"mappings":"AASA,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAcL,KAAK,oBAAoB,EAE1B,MAAM,uBAAuB,CAAC;AAsC/B;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAC5B,SAAS,GAAG,eAAe,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAMvE,UAAU,OAAO;IACf,+EAA+E;IAC/E;;;;;;;OAOG;IACH,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM;IACtB;;;OAGG;IACH,MAAM,EAAE,eAAe,KACpB,IAAI,CAAC;IACV;;;;OAIG;IACH,WAAW,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,OAAO;;
|
|
1
|
+
{"version":3,"file":"useVoiceSession.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/ui/useVoiceSession.ts"],"names":[],"mappings":"AASA,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAcL,KAAK,oBAAoB,EAE1B,MAAM,uBAAuB,CAAC;AAsC/B;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAC5B,SAAS,GAAG,eAAe,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAMvE,UAAU,OAAO;IACf,+EAA+E;IAC/E;;;;;;;OAOG;IACH,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM;IACtB;;;OAGG;IACH,MAAM,EAAE,eAAe,KACpB,IAAI,CAAC;IACV;;;;OAIG;IACH,WAAW,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,OAAO;;IA0kBtE,qEAAqE;;IAErE;;;;;;;OAOG;;;;;IAEH,+DAA+D;;IAE/D;;;;;;;OAOG;;IAIH,0EAA0E;;IAE1E,6DAA6D;;IAE7D,sDAAsD;;;;;;EA4B3D"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { useVoiceInput as e } from "../voice/useVoiceInput.js";
|
|
2
|
-
import { INITIAL_SESSION as t, INTERRUPT_MAX_MS as n, NOTHING_HEARD as r, SILENCE_SUBMIT_MS as
|
|
3
|
-
import { turnClockMs as
|
|
4
|
-
import { useAssistantSpeech as
|
|
5
|
-
import { useCallback as
|
|
2
|
+
import { INITIAL_SESSION as t, INTERRUPT_MAX_MS as n, NOTHING_HEARD as r, SILENCE_SUBMIT_MS as i, advanceHeardClock as a, isCapturing as o, isSubmittable as s, planReplyConsumption as c, spokenSoFar as l, voiceSessionReducer as ee } from "../voice/voiceSession.js";
|
|
3
|
+
import { turnClockMs as u } from "../turnTimeline.js";
|
|
4
|
+
import { useAssistantSpeech as d } from "./AssistantSpeechProvider.js";
|
|
5
|
+
import { useCallback as f, useEffect as p, useMemo as m, useReducer as h, useRef as g, useState as _ } from "react";
|
|
6
6
|
//#region src/shared/assistant/ui/useVoiceSession.ts
|
|
7
|
-
var
|
|
7
|
+
var v = 4e3, te = 2500, ne = 5e3, y = 12e3, b = "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=";
|
|
8
8
|
function x({ onSubmit: x, latestReply: S, language: C }) {
|
|
9
|
-
let w =
|
|
9
|
+
let w = g(null), [T, E] = h(f((e, t) => ee(e, t, w.current), []), t), D = d(), { setSessionSpeaking: O, setSessionMicOpen: k, speakingMessageId: A, stop: j } = D, M = g(null), N = g({}), P = g(r), F = g(null), I = g(!1), [L, R] = _(null), [z, B] = _(!1), [V, H] = _(!1), U = g(T);
|
|
10
10
|
U.current = T;
|
|
11
|
-
let W =
|
|
12
|
-
W.current = S,
|
|
11
|
+
let W = g(S);
|
|
12
|
+
W.current = S, p(() => {
|
|
13
13
|
if (T.phase === "speaking") {
|
|
14
14
|
w.current = S?.text ?? null;
|
|
15
15
|
return;
|
|
@@ -17,70 +17,71 @@ function x({ onSubmit: x, latestReply: S, language: C }) {
|
|
|
17
17
|
if (w.current === null) return;
|
|
18
18
|
let e = setTimeout(() => {
|
|
19
19
|
w.current = null;
|
|
20
|
-
},
|
|
20
|
+
}, te);
|
|
21
21
|
return () => clearTimeout(e);
|
|
22
22
|
}, [T.phase, S]);
|
|
23
|
-
let G =
|
|
23
|
+
let G = f((e, t) => {
|
|
24
24
|
E({
|
|
25
25
|
type: "speech",
|
|
26
26
|
transcript: e,
|
|
27
27
|
final: t
|
|
28
28
|
});
|
|
29
|
-
}, []), K =
|
|
29
|
+
}, []), K = g(0), q = f(() => {
|
|
30
30
|
j(), K.current = Date.now(), B(!0), E({ type: "interrupt" });
|
|
31
31
|
}, [j]), J = e({
|
|
32
|
-
onFinalize:
|
|
32
|
+
onFinalize: f((e) => G(e, !0), [G]),
|
|
33
33
|
language: C
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
p(() => {
|
|
36
36
|
J.interim && G(J.interim, !1);
|
|
37
|
-
}, [J.interim, G]),
|
|
38
|
-
if (M.current && clearTimeout(M.current), H(!1), P.current =
|
|
39
|
-
let e = setTimeout(() => H(!0), 800), t =
|
|
37
|
+
}, [J.interim, G]), p(() => {
|
|
38
|
+
if (M.current && clearTimeout(M.current), H(!1), P.current = a(P.current, T, u()), T.phase !== "listening" || T.muted || !s(l(T))) return;
|
|
39
|
+
let e = setTimeout(() => H(!0), 800), t = u();
|
|
40
40
|
return M.current = setTimeout(() => {
|
|
41
41
|
N.current = {
|
|
42
42
|
speechEnded: P.current.at ?? t,
|
|
43
43
|
graceStarted: t,
|
|
44
|
-
graceEnded:
|
|
44
|
+
graceEnded: u()
|
|
45
45
|
}, E({ type: "silence" });
|
|
46
|
-
},
|
|
46
|
+
}, i), () => {
|
|
47
47
|
clearTimeout(e), M.current && clearTimeout(M.current);
|
|
48
48
|
};
|
|
49
|
-
}, [T]),
|
|
49
|
+
}, [T]), p(() => {
|
|
50
50
|
if (!z) return;
|
|
51
51
|
let e = Date.now() - K.current, t = J.isListening ? Math.max(0, 500 - e) : Math.max(0, n - e), r = setTimeout(() => B(!1), t);
|
|
52
52
|
return () => clearTimeout(r);
|
|
53
53
|
}, [z, J.isListening]);
|
|
54
|
-
let Y =
|
|
55
|
-
T.phase === "listening" && (Y.current =
|
|
54
|
+
let Y = g("");
|
|
55
|
+
T.phase === "listening" && (Y.current = l(T)), p(() => {
|
|
56
56
|
if (T.phase !== "thinking") return;
|
|
57
|
+
k(!1);
|
|
57
58
|
let e = Y.current.trim();
|
|
58
59
|
e && x(e, X.current ?? `vs-orphan-${Date.now().toString(36)}`, N.current), N.current = {}, P.current = r;
|
|
59
|
-
}, [T.phase]),
|
|
60
|
-
let e =
|
|
60
|
+
}, [T.phase]), p(() => {
|
|
61
|
+
let e = c(S?.id, T.phase, F.current);
|
|
61
62
|
e.claim && (F.current = S?.id ?? null, e.advance && S && E({
|
|
62
63
|
type: "reply",
|
|
63
64
|
text: S.text
|
|
64
65
|
}));
|
|
65
|
-
}, [S, T.phase]),
|
|
66
|
+
}, [S, T.phase]), p(() => {
|
|
66
67
|
let e = A !== null;
|
|
67
68
|
I.current && !e && E({ type: "speech-ended" }), I.current = e;
|
|
68
|
-
}, [A]),
|
|
69
|
+
}, [A]), p(() => {
|
|
69
70
|
T.phase !== "listening" && R((e) => e === "nothing-heard" ? null : e);
|
|
70
|
-
}, [T.phase]),
|
|
71
|
+
}, [T.phase]), p(() => {
|
|
71
72
|
if (T.phase !== "speaking" || A !== null) return;
|
|
72
73
|
let e = setTimeout(() => {
|
|
73
74
|
I.current || E({ type: "speech-ended" });
|
|
74
|
-
},
|
|
75
|
+
}, v);
|
|
75
76
|
return () => clearTimeout(e);
|
|
76
|
-
}, [T.phase, A]),
|
|
77
|
-
let e =
|
|
77
|
+
}, [T.phase, A]), p(() => {
|
|
78
|
+
let e = o(T);
|
|
78
79
|
k(e), e ? J.isActive || J.start("auto") : J.isActive && J.stop();
|
|
79
80
|
}, [
|
|
80
81
|
T,
|
|
81
82
|
J,
|
|
82
83
|
k
|
|
83
|
-
]),
|
|
84
|
+
]), p(() => {
|
|
84
85
|
J.error === "not-allowed" || J.error === "audio-capture" ? E({
|
|
85
86
|
type: "fail",
|
|
86
87
|
error: "mic-denied"
|
|
@@ -88,20 +89,20 @@ function x({ onSubmit: x, latestReply: S, language: C }) {
|
|
|
88
89
|
type: "fail",
|
|
89
90
|
error: "no-speech-support"
|
|
90
91
|
}) : J.error === "network" ? R("network") : J.error === "unknown" && R("recognition-failed");
|
|
91
|
-
}, [J.error]),
|
|
92
|
+
}, [J.error]), p(() => {
|
|
92
93
|
J.error !== null || !J.isListening || R((e) => e === "network" || e === "recognition-failed" ? null : e);
|
|
93
|
-
}, [J.error, J.isListening]),
|
|
94
|
-
if (J.isListening && R((e) => e === "not-capturing" ? null : e), !
|
|
95
|
-
let e = setTimeout(() => R("not-capturing"),
|
|
94
|
+
}, [J.error, J.isListening]), p(() => {
|
|
95
|
+
if (J.isListening && R((e) => e === "not-capturing" ? null : e), !o(T) || J.isListening) return;
|
|
96
|
+
let e = setTimeout(() => R("not-capturing"), ne);
|
|
96
97
|
return () => clearTimeout(e);
|
|
97
|
-
}, [T, J.isListening]),
|
|
98
|
-
if (T.phase !== "listening" || T.muted || !J.isListening ||
|
|
98
|
+
}, [T, J.isListening]), p(() => {
|
|
99
|
+
if (T.phase !== "listening" || T.muted || !J.isListening || l(T) !== "") return;
|
|
99
100
|
let e = setTimeout(() => R("nothing-heard"), y);
|
|
100
101
|
return () => clearTimeout(e);
|
|
101
|
-
}, [T, J.isListening]),
|
|
102
|
-
|
|
102
|
+
}, [T, J.isListening]), p(() => {
|
|
103
|
+
l(T) !== "" && R(null);
|
|
103
104
|
}, [T]);
|
|
104
|
-
let X =
|
|
105
|
+
let X = g(null), Z = f(() => {
|
|
105
106
|
if (B(!1), H(!1), !J.isSupported) {
|
|
106
107
|
E({
|
|
107
108
|
type: "fail",
|
|
@@ -134,17 +135,17 @@ function x({ onSubmit: x, latestReply: S, language: C }) {
|
|
|
134
135
|
J.isSupported,
|
|
135
136
|
D.isBlocked,
|
|
136
137
|
O
|
|
137
|
-
]), Q =
|
|
138
|
+
]), Q = f(() => {
|
|
138
139
|
B(!1), H(!1), X.current = null, E({ type: "end" }), j(), O(!1);
|
|
139
|
-
}, [j, O]), $ =
|
|
140
|
+
}, [j, O]), $ = f(() => {
|
|
140
141
|
E({
|
|
141
142
|
type: "mute",
|
|
142
143
|
muted: !U.current.muted
|
|
143
144
|
});
|
|
144
145
|
}, []);
|
|
145
|
-
return
|
|
146
|
+
return p(() => () => {
|
|
146
147
|
O(!1), k(!1);
|
|
147
|
-
}, [O, k]),
|
|
148
|
+
}, [O, k]), m(() => ({
|
|
148
149
|
session: T,
|
|
149
150
|
notice: L,
|
|
150
151
|
spokenChunks: D.spokenChunks,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captionText.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/voice/captionText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;
|
|
1
|
+
{"version":3,"file":"captionText.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/voice/captionText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAuKH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA2CtD"}
|
|
@@ -18,7 +18,7 @@ function o(e) {
|
|
|
18
18
|
}
|
|
19
19
|
function s(n, r) {
|
|
20
20
|
let i = (t) => (r.push(t), `${e}${r.length - 1}${e}`);
|
|
21
|
-
return n.replace(/^ {0,3}```[^\n]*\n([\s\S]*?)^ {0,3}```[^\n]*$/gm, (e, t) => i(t.replace(/\n$/, ""))).replace(/^ {0,3}```[^\n]*\n?([\s\S]*)$/m, (e, t) => i(t)).replace(/`([^`\n]+)`/g, (e, t) => i(t)).replace(RegExp(`<((?:https?://|mailto:)[^>\\s${t}]+)>`, "gi"), (e, t) => i(t)).replace(RegExp(`<([^@<>\\s${t}]+@[^@<>\\s${t}]+\\.[^@<>\\s${t}]+)>`, "g"), (e, t) => i(t)).replace(RegExp(`\\b(?:https?://|www\\.)[^\\s<>()\\[\\]${t}]+`, "gi"), (e) => i(e)).replace(/\b[\w.+-]{1,64}@[\w-]{1,63}\.[\w.-]{1,63}\b/g, (e) => i(e));
|
|
21
|
+
return n.replace(/^ {0,3}```[^\n]*\n([\s\S]*?)^ {0,3}```[^\n]*$/gm, (e, t) => i(t.replace(/\n$/, ""))).replace(/^ {0,3}```[^\n]*\n?([\s\S]*)$/m, (e, t) => i(t)).replace(/`([^`\n]+)`/g, (e, t) => i(t)).replace(/\\([!-/:-@[-`{-~])/g, (e, t) => i(t)).replace(RegExp(`<((?:https?://|mailto:)[^>\\s${t}]+)>`, "gi"), (e, t) => i(t)).replace(RegExp(`<([^@<>\\s${t}]+@[^@<>\\s${t}]+\\.[^@<>\\s${t}]+)>`, "g"), (e, t) => i(t)).replace(RegExp(`\\b(?:https?://|www\\.)[^\\s<>()\\[\\]${t}]+`, "gi"), (e) => i(e)).replace(/\b[\w.+-]{1,64}@[\w-]{1,63}\.[\w.-]{1,63}\b/g, (e) => i(e));
|
|
22
22
|
}
|
|
23
23
|
function c(t, n) {
|
|
24
24
|
let r = RegExp(`${e}(\\d+)${e}`, "g"), i = t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speakableText.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/voice/speakableText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAStC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AAEzC;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AA6CD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAsBpD;AAkBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,SAAO,EAAE,GAAG,SAAQ,GAAG,MAAM,CAE9E;
|
|
1
|
+
{"version":3,"file":"speakableText.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/voice/speakableText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAStC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AAEzC;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AA6CD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAsBpD;AAkBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,SAAO,EAAE,GAAG,SAAQ,GAAG,MAAM,CAE9E;AAkLD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAiJxF;AAiMD,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAkFD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAA2B,EACrC,WAAW,GAAE,MAA+B,GAC3C,MAAM,EAAE,CAoEV"}
|