@burdenoff/microfe-healthybowl 2026.901.14 → 2026.901.16
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/components/assistant/AssistantChatArea.js +201 -198
- package/dist/components/assistant/AssistantChatArea.js.map +1 -1
- package/dist/components/assistant/voice/AssistantVoiceOrb.js +5 -5
- package/dist/components/assistant/voice/AssistantVoiceOrb.js.map +1 -1
- package/dist/components/assistant/voice/AssistantVoiceSession.js +55 -41
- package/dist/components/assistant/voice/AssistantVoiceSession.js.map +1 -1
- package/dist/components/assistant/voice/VoiceCaption.js +1 -1
- package/dist/components/assistant/voice/VoiceCaption.js.map +1 -1
- package/dist/components/assistant/voice/VoiceMiniController.js +24 -22
- package/dist/components/assistant/voice/VoiceMiniController.js.map +1 -1
- package/dist/components/assistant/voice/VoiceStage.js +33 -31
- package/dist/components/assistant/voice/VoiceStage.js.map +1 -1
- package/dist/components/assistant/voice/VoiceWaveform.js +14 -6
- package/dist/components/assistant/voice/VoiceWaveform.js.map +1 -1
- package/dist/hooks/useVoiceSession.js +108 -98
- package/dist/hooks/useVoiceSession.js.map +1 -1
- package/dist/utils/captionText.js +51 -0
- package/dist/utils/captionText.js.map +1 -0
- package/dist/utils/voiceSession.js +29 -28
- package/dist/utils/voiceSession.js.map +1 -1
- package/dist/utils/voiceStageState.js +8 -2
- package/dist/utils/voiceStageState.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,56 +10,57 @@ import { buildPromptParts as te, buildPromptWithAttachments as ne, countInlineIm
|
|
|
10
10
|
import { AssistantMessageList as b } from "./AssistantMessageList.js";
|
|
11
11
|
import { AssistantApiCallsConsentDialog as x } from "./AssistantApiCallsConsentDialog.js";
|
|
12
12
|
import { ASSISTANT_MODES as S } from "../../types/assistant.js";
|
|
13
|
-
import { AssistantEmptyState as
|
|
14
|
-
import { AssistantComposer as
|
|
15
|
-
import { AssistantVoiceSession as
|
|
16
|
-
import { useVoiceSession as
|
|
17
|
-
import { useAssistantApiAccess as
|
|
18
|
-
import { isQuotaExhaustedError as
|
|
19
|
-
import { dispatchAssistantQuotaExhausted as
|
|
20
|
-
import { buildPromptForMode as
|
|
21
|
-
import { isMultimodalBodyRejection as
|
|
22
|
-
import { pollDelayMs as
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
13
|
+
import { AssistantEmptyState as oe } from "./AssistantEmptyState.js";
|
|
14
|
+
import { AssistantComposer as C } from "./composer/AssistantComposer.js";
|
|
15
|
+
import { AssistantVoiceSession as se } from "./voice/AssistantVoiceSession.js";
|
|
16
|
+
import { useVoiceSession as ce } from "../../hooks/useVoiceSession.js";
|
|
17
|
+
import { useAssistantApiAccess as le } from "../../hooks/useAssistantApiAccess.js";
|
|
18
|
+
import { isQuotaExhaustedError as ue } from "../../utils/quotaUtils.js";
|
|
19
|
+
import { dispatchAssistantQuotaExhausted as de, notifyAiCreditsUpdated as fe } from "../../utils/aiCredits.js";
|
|
20
|
+
import { buildPromptForMode as pe } from "../../utils/assistantPrompt.js";
|
|
21
|
+
import { isMultimodalBodyRejection as me, isRecoverableAssistantError as he } from "../../utils/assistantTransportErrors.js";
|
|
22
|
+
import { pollDelayMs as ge } from "../../utils/assistantPollSchedule.js";
|
|
23
|
+
import { toCaptionText as _e } from "../../utils/captionText.js";
|
|
24
|
+
import { chatTurns as ve, voiceMarker as w, voiceTurnsOnly as ye } from "../../utils/voiceTurnVisibility.js";
|
|
25
|
+
import { createReadinessTracker as be } from "../../utils/sandboxReadiness.js";
|
|
26
|
+
import { useCallback as T, useEffect as E, useMemo as D, useRef as O, useState as xe } from "react";
|
|
27
|
+
import { useI18n as Se } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
28
|
+
import { jsx as k, jsxs as Ce } from "react/jsx-runtime";
|
|
29
|
+
import { useGatewayClient as we } from "@burdenoff/fe-libs/shared/graphql";
|
|
30
|
+
import { useAuthToken as Te } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
31
|
+
import { getAssistantMedia as Ee } from "@burdenoff/fe-libs/shared/assistant";
|
|
31
32
|
//#region src/components/assistant/AssistantChatArea.tsx
|
|
32
|
-
var
|
|
33
|
+
var De = {
|
|
33
34
|
general: 18e4,
|
|
34
35
|
assistant: 18e4,
|
|
35
36
|
"api-calls": 18e4,
|
|
36
37
|
"vibe-plugins": 6e5
|
|
37
|
-
},
|
|
38
|
-
function
|
|
38
|
+
}, Oe = 18e4;
|
|
39
|
+
function ke() {
|
|
39
40
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
+
function Ae(e) {
|
|
42
43
|
return e.replace(/(Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/(X-Workspace-Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+\b/g, "[REDACTED_JWT]").replace(/\bsk-ant-[A-Za-z0-9-]+\b/g, "[REDACTED_API_KEY]");
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
+
function A(e) {
|
|
45
46
|
return e.info?.time?.created ?? 0;
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function j(e) {
|
|
48
49
|
return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function M(e) {
|
|
51
52
|
return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
|
|
52
53
|
let t = e.state?.status ?? "running", n = e.tool ?? "tool";
|
|
53
54
|
return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
-
let n = e.filter((e) => e.info?.role === "assistant" &&
|
|
57
|
+
function je(e, t) {
|
|
58
|
+
let n = e.filter((e) => e.info?.role === "assistant" && A(e) > t).sort((e, t) => A(e) - A(t));
|
|
58
59
|
if (n.length === 0) return {
|
|
59
60
|
content: "Thinking...",
|
|
60
61
|
done: !1
|
|
61
62
|
};
|
|
62
|
-
let r = n[n.length - 1], i =
|
|
63
|
+
let r = n[n.length - 1], i = j(r.parts), a = Ee(r.parts), o = M(r.parts);
|
|
63
64
|
return {
|
|
64
65
|
content: [
|
|
65
66
|
i,
|
|
@@ -70,7 +71,7 @@ function ke(e, t) {
|
|
|
70
71
|
tokens: r.info?.tokens
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
+
function Me(e) {
|
|
74
75
|
switch (e) {
|
|
75
76
|
case "provisioning": return "Starting assistant environment...";
|
|
76
77
|
case "connecting": return "Connecting to assistant...";
|
|
@@ -78,204 +79,204 @@ function Ae(e) {
|
|
|
78
79
|
default: return "";
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
|
-
var
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
let e = S.find((e) => e.id ===
|
|
86
|
-
(!e || e.requiresAdmin && !
|
|
82
|
+
var N = ({ visible: Ee = !0 }) => {
|
|
83
|
+
let j = t(), M = we("workspace"), { getAccessToken: N, getWorkspaceToken: Ne, userId: Pe } = Te(), { locale: P } = Se(), F = e((e) => e.assistantLanguage), Fe = D(() => g(F, P).english, [F, P]), Ie = h(F) !== null, Le = D(() => g(F, P).code, [F, P]), { conversations: Re, activeConversationId: I, mode: L, processingByConversationId: ze, setMode: R, setConversationMode: z, setActiveConversation: Be, createConversation: B, addMessage: Ve, updateMessage: He, patchMessage: V, setConversationProcessing: H, clearConversationProcessing: Ue, setBackendSessionId: We, clearBackendSessionId: U, setSandbox: W, clearSandbox: Ge, acknowledgeApiCalls: Ke } = e(), G = Re.find((e) => e.id === I)?.messages ?? [], K = I ? ze[I] : void 0, q = _(K?.status), qe = q ? K?.messageId ?? null : null, Je = K?.status === "error" ? K.messageId : null, { canUseApiCalls: J, loading: Ye } = le(y()), Xe = D(() => S.filter((e) => !e.requiresAdmin || J), [J]), [Ze, Qe] = xe(null), $e = O({}), Y = O(be()), et = O(/* @__PURE__ */ new Set());
|
|
84
|
+
E(() => {
|
|
85
|
+
if (Ye) return;
|
|
86
|
+
let e = S.find((e) => e.id === L);
|
|
87
|
+
(!e || e.requiresAdmin && !J) && L !== "assistant" && R("assistant");
|
|
87
88
|
}, [
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
L,
|
|
90
|
+
J,
|
|
91
|
+
Ye,
|
|
92
|
+
R
|
|
92
93
|
]);
|
|
93
|
-
let
|
|
94
|
-
|
|
95
|
-
}, [
|
|
94
|
+
let X = T((e, t, n, r) => {
|
|
95
|
+
H(e, n, t, null), r ? He(e, t, r) : He(e, t, Me(n));
|
|
96
|
+
}, [H, He]), tt = T(async (t, n, a, s, c) => {
|
|
96
97
|
let u = e.getState().sandboxesByMode[a]?.sandboxId ?? null, d = async (e) => {
|
|
97
|
-
if (
|
|
98
|
+
if (Y.current.isFresh(e)) return !0;
|
|
98
99
|
try {
|
|
99
|
-
return await p(
|
|
100
|
+
return await p(M, e, s, c, 3e5, (e) => X(t, n, "provisioning", e)), await f(M, e, s, c, 9e4, (e) => X(t, n, "connecting", e)), Y.current.markVerified(e), !0;
|
|
100
101
|
} catch {
|
|
101
|
-
return
|
|
102
|
+
return Y.current.invalidate(e), !1;
|
|
102
103
|
}
|
|
103
104
|
};
|
|
104
|
-
if (u && (
|
|
105
|
-
|
|
106
|
-
let e = await o(
|
|
107
|
-
e && (
|
|
105
|
+
if (u && (W(a, u, "provisioning"), X(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (W(a, null, "provisioning"), u = null)), !u) {
|
|
106
|
+
X(t, n, "provisioning", "Looking for existing environment...");
|
|
107
|
+
let e = await o(M, s, a, c);
|
|
108
|
+
e && (W(a, e, "provisioning"), X(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : W(a, null, "provisioning"));
|
|
108
109
|
}
|
|
109
110
|
if (!u) {
|
|
110
|
-
if (a === "api-calls" && !
|
|
111
|
-
|
|
111
|
+
if (a === "api-calls" && !N()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
112
|
+
X(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(M, a, s, c), W(a, u, "provisioning"), await p(M, u, s, c, 3e5, (e) => X(t, n, "provisioning", e)), await f(M, u, s, c, 9e4, (e) => X(t, n, "connecting", e));
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
+
W(a, u, "running");
|
|
114
115
|
let m = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
|
|
115
116
|
if (m) try {
|
|
116
|
-
let e = await l(
|
|
117
|
+
let e = await l(M, u, s, m, c);
|
|
117
118
|
if (e.mode !== a) throw Error(`Session mode mismatch: expected ${a}, received ${e.mode}`);
|
|
118
119
|
} catch {
|
|
119
|
-
|
|
120
|
+
U(t), m = null;
|
|
120
121
|
}
|
|
121
|
-
return m || (
|
|
122
|
+
return m || (X(t, n, "connecting", "Preparing session..."), m = (await i(M, u, s, a, c)).sessionId, We(t, m)), {
|
|
122
123
|
sandboxId: u,
|
|
123
124
|
sessionId: m
|
|
124
125
|
};
|
|
125
126
|
}, [
|
|
127
|
+
M,
|
|
128
|
+
U,
|
|
126
129
|
N,
|
|
130
|
+
We,
|
|
127
131
|
W,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
let f = o.mode, p = L, h = p ? e.getState().conversations.find((e) => e.id === p) : void 0;
|
|
136
|
-
if (p ? h && h.mode !== f && (h.messages.length > 0 || h.backendSessionId) ? p = V(void 0, f) : h && h.mode !== f && B(p, f) : p = V(void 0, f), !p) return;
|
|
137
|
-
Ze.current[p] = r;
|
|
132
|
+
X
|
|
133
|
+
]), Z = T(async (t, r = [], i = {}) => {
|
|
134
|
+
let o = e.getState(), l = o.activeConversationId ?? I;
|
|
135
|
+
if (l && (_(o.processingByConversationId[l]?.status) || et.current.has(l))) return;
|
|
136
|
+
let f = o.mode, p = I, h = p ? e.getState().conversations.find((e) => e.id === p) : void 0;
|
|
137
|
+
if (p ? h && h.mode !== f && (h.messages.length > 0 || h.backendSessionId) ? p = B(void 0, f) : h && h.mode !== f && z(p, f) : p = B(void 0, f), !p) return;
|
|
138
|
+
$e.current[p] = r;
|
|
138
139
|
let g = ee(), v = {
|
|
139
|
-
accessToken:
|
|
140
|
-
workspaceToken:
|
|
141
|
-
userId:
|
|
140
|
+
accessToken: N(),
|
|
141
|
+
workspaceToken: Ne(),
|
|
142
|
+
userId: Pe,
|
|
142
143
|
organizationId: y()
|
|
143
144
|
}, b = {
|
|
144
|
-
id:
|
|
145
|
+
id: ke(),
|
|
145
146
|
role: "user",
|
|
146
147
|
content: t,
|
|
147
148
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
148
149
|
metadata: {
|
|
149
150
|
...r.length ? { attachments: r.map(ae) } : {},
|
|
150
|
-
...
|
|
151
|
+
...w(i.dictated)
|
|
151
152
|
}
|
|
152
153
|
};
|
|
153
|
-
|
|
154
|
-
let x =
|
|
155
|
-
|
|
154
|
+
Ve(p, b);
|
|
155
|
+
let x = ke();
|
|
156
|
+
Ve(p, {
|
|
156
157
|
id: x,
|
|
157
158
|
role: "assistant",
|
|
158
159
|
content: "",
|
|
159
160
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
160
161
|
metadata: {
|
|
161
|
-
lang:
|
|
162
|
-
...
|
|
162
|
+
lang: Le,
|
|
163
|
+
...w(i.dictated)
|
|
163
164
|
}
|
|
164
|
-
}),
|
|
165
|
-
let S = (e, t, n, r, a =
|
|
166
|
-
|
|
167
|
-
content:
|
|
165
|
+
}), H(p, "provisioning", x, null);
|
|
166
|
+
let S = (e, t, n, r, a = Le) => {
|
|
167
|
+
V(p, x, {
|
|
168
|
+
content: Ae(e),
|
|
168
169
|
metadata: {
|
|
169
170
|
lang: a,
|
|
170
171
|
...t?.length ? { artifacts: t } : {},
|
|
171
172
|
...t?.length || n || r ? { mode: f } : {},
|
|
172
173
|
...n ? { sessionId: n } : {},
|
|
173
174
|
...r ? { sandboxId: r } : {},
|
|
174
|
-
...
|
|
175
|
+
...w(i.dictated)
|
|
175
176
|
}
|
|
176
177
|
});
|
|
177
|
-
},
|
|
178
|
+
}, oe = async (e = 1) => {
|
|
178
179
|
let o = !1;
|
|
179
180
|
try {
|
|
180
|
-
await n(
|
|
181
|
+
await n(M, g, v);
|
|
181
182
|
} catch (e) {
|
|
182
|
-
if (
|
|
183
|
-
|
|
183
|
+
if (ue(e)) {
|
|
184
|
+
de("ai-credits"), S("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting.", void 0, void 0, void 0, "en"), H(p, "error", x, null);
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
186
187
|
console.warn("[assistant] AI-credit pre-flight check failed with a non-quota error; proceeding — gateway @usage(checkQuota) still enforces the real budget downstream", e);
|
|
187
188
|
}
|
|
188
189
|
try {
|
|
189
|
-
let { sandboxId: e, sessionId: n } = await
|
|
190
|
-
|
|
191
|
-
let h =
|
|
190
|
+
let { sandboxId: e, sessionId: n } = await tt(p, x, f, g, v), l = (await c(M, e, g, n, v, 50).catch(() => [])).reduce((e, t) => Math.max(e, A(t)), 0);
|
|
191
|
+
X(p, x, "streaming", "Thinking...");
|
|
192
|
+
let h = pe(f, ne(t, r), Fe, Ie, i.dictated === !0), _ = te(h, r), y = ie(_), ee = y > 0, ae = m();
|
|
192
193
|
o = re(r) > y;
|
|
193
194
|
try {
|
|
194
|
-
await d(
|
|
195
|
+
await d(M, e, g, n, h, f, ae, v, _);
|
|
195
196
|
} catch (t) {
|
|
196
|
-
if (!_ || !
|
|
197
|
-
await d(
|
|
197
|
+
if (!_ || !me(t)) throw t;
|
|
198
|
+
await d(M, e, g, n, h, f, ae, v, void 0), o ||= ee;
|
|
198
199
|
}
|
|
199
|
-
let b =
|
|
200
|
-
for (; Date.now() <
|
|
200
|
+
let b = je([], l), oe = Date.now() + (De[f] ?? Oe), C = Date.now(), se = Date.now();
|
|
201
|
+
for (; Date.now() < oe && (b = je(await c(M, e, g, n, v, 50), l), V(p, x, { content: Ae(b.content) }), !b.done);) Date.now() - C > 3e4 && (await a(M, e, g, 600, v).catch(() => void 0), C = Date.now()), await new Promise((e) => setTimeout(e, ge(Date.now() - se)));
|
|
201
202
|
if (!b.done && f !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
|
|
202
|
-
let
|
|
203
|
+
let ce = f === "vibe-plugins" ? await s(M, e, g, n, v).catch(() => []) : void 0;
|
|
203
204
|
if (b.done || (b = {
|
|
204
205
|
...b,
|
|
205
206
|
content: `${b.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
|
|
206
207
|
}), o && (b = {
|
|
207
208
|
...b,
|
|
208
|
-
content: `${b.content}\n\n${
|
|
209
|
-
}), S(b.content,
|
|
210
|
-
|
|
209
|
+
content: `${b.content}\n\n${j("healthybowl.assistant.attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
|
|
210
|
+
}), S(b.content, ce, n, e), b.tokens) {
|
|
211
|
+
V(p, x, { tokens: b.tokens });
|
|
211
212
|
try {
|
|
212
|
-
await u(
|
|
213
|
+
await u(M, g, n, b.tokens, v), fe();
|
|
213
214
|
} catch {}
|
|
214
215
|
}
|
|
215
|
-
|
|
216
|
+
H(p, "complete", x, null);
|
|
216
217
|
} catch (t) {
|
|
217
|
-
if (e === 1 &&
|
|
218
|
+
if (e === 1 && he(t)) return U(p), Ge(f), oe(2);
|
|
218
219
|
throw t;
|
|
219
220
|
}
|
|
220
|
-
},
|
|
221
|
-
|
|
221
|
+
}, C = p;
|
|
222
|
+
et.current.add(C);
|
|
222
223
|
try {
|
|
223
224
|
if (!g) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
224
|
-
await
|
|
225
|
+
await oe();
|
|
225
226
|
} catch (t) {
|
|
226
|
-
if (
|
|
227
|
-
|
|
227
|
+
if (Y.current.invalidate(e.getState().sandboxesByMode[f]?.sandboxId ?? null), ue(t)) {
|
|
228
|
+
de("sandbox"), S("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant.", void 0, void 0, void 0, "en"), H(p, "error", x, null);
|
|
228
229
|
return;
|
|
229
230
|
}
|
|
230
231
|
let n = t instanceof Error ? t.message : "Something went wrong";
|
|
231
|
-
|
|
232
|
+
H(p, "error", x, n), V(p, x, {
|
|
232
233
|
content: `Sorry, an error occurred: ${n}. Please try again.`,
|
|
233
234
|
metadata: {
|
|
234
235
|
lang: "en",
|
|
235
|
-
...
|
|
236
|
+
...w(i.dictated)
|
|
236
237
|
}
|
|
237
238
|
});
|
|
238
239
|
} finally {
|
|
239
|
-
|
|
240
|
+
et.current.delete(C);
|
|
240
241
|
}
|
|
241
242
|
}, [
|
|
242
|
-
|
|
243
|
-
|
|
243
|
+
I,
|
|
244
|
+
Ve,
|
|
245
|
+
M,
|
|
246
|
+
U,
|
|
247
|
+
Ge,
|
|
248
|
+
Re,
|
|
249
|
+
B,
|
|
250
|
+
tt,
|
|
244
251
|
N,
|
|
245
|
-
|
|
246
|
-
Ue,
|
|
247
|
-
Ie,
|
|
252
|
+
Ne,
|
|
248
253
|
V,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
je,
|
|
252
|
-
H,
|
|
253
|
-
Pe,
|
|
254
|
+
Ie,
|
|
255
|
+
Le,
|
|
254
256
|
Fe,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
e && Q(e.content, t);
|
|
257
|
+
We,
|
|
258
|
+
z,
|
|
259
|
+
H,
|
|
260
|
+
j,
|
|
261
|
+
X,
|
|
262
|
+
Pe
|
|
263
|
+
]), nt = T((e) => {
|
|
264
|
+
Z(e);
|
|
265
|
+
}, [Z]), rt = T(() => {
|
|
266
|
+
let e = [...G].reverse().find((e) => e.role === "user"), t = I ? $e.current[I] ?? [] : [];
|
|
267
|
+
e && Z(e.content, t);
|
|
267
268
|
}, [
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
]),
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}, [
|
|
275
|
-
let
|
|
276
|
-
if (
|
|
277
|
-
for (let e =
|
|
278
|
-
let t =
|
|
269
|
+
G,
|
|
270
|
+
Z,
|
|
271
|
+
I
|
|
272
|
+
]), it = O(Z);
|
|
273
|
+
E(() => {
|
|
274
|
+
it.current = Z;
|
|
275
|
+
}, [Z]);
|
|
276
|
+
let Q = D(() => {
|
|
277
|
+
if (q) return null;
|
|
278
|
+
for (let e = G.length - 1; e >= 0; --e) {
|
|
279
|
+
let t = G[e];
|
|
279
280
|
if (t?.role !== "assistant") continue;
|
|
280
281
|
let n = v(t.content).text.trim();
|
|
281
282
|
return n ? {
|
|
@@ -284,105 +285,107 @@ var P = ({ visible: we = !0 }) => {
|
|
|
284
285
|
} : null;
|
|
285
286
|
}
|
|
286
287
|
return null;
|
|
287
|
-
}, [
|
|
288
|
+
}, [G, q]), at = D(() => Q ? _e(Q.text) : null, [Q]), ot = D(() => ve(G), [G]), st = D(() => ye(G).filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
288
289
|
id: e.id,
|
|
289
290
|
role: e.role,
|
|
290
291
|
text: v(e.content).text.trim()
|
|
291
|
-
})).filter((e) => e.text.length > 0), [
|
|
292
|
-
onSubmit:
|
|
293
|
-
|
|
292
|
+
})).filter((e) => e.text.length > 0), [G]), $ = ce({
|
|
293
|
+
onSubmit: T((e) => {
|
|
294
|
+
it.current(e, [], { dictated: !0 });
|
|
294
295
|
}, []),
|
|
295
|
-
latestReply:
|
|
296
|
-
language: g(
|
|
296
|
+
latestReply: Q,
|
|
297
|
+
language: g(F, P).tag
|
|
297
298
|
});
|
|
298
|
-
|
|
299
|
-
!
|
|
300
|
-
}, [
|
|
299
|
+
E(() => {
|
|
300
|
+
!Ee && $.active && $.end();
|
|
301
|
+
}, [Ee, $]), E(() => {
|
|
301
302
|
let t = e.getState().consumePendingPrompt();
|
|
302
|
-
return t &&
|
|
303
|
+
return t && it.current(t), e.subscribe((t, n) => {
|
|
303
304
|
if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
|
|
304
305
|
let t = e.getState().consumePendingPrompt();
|
|
305
|
-
t &&
|
|
306
|
+
t && it.current(t);
|
|
306
307
|
}
|
|
307
308
|
});
|
|
308
309
|
}, []);
|
|
309
|
-
let
|
|
310
|
-
let n =
|
|
310
|
+
let ct = T((t) => {
|
|
311
|
+
let n = I ? e.getState().conversations.find((e) => e.id === I) : void 0;
|
|
311
312
|
if (n && (n.messages.length > 0 || n.backendSessionId)) {
|
|
312
313
|
if (n.mode !== t) {
|
|
313
314
|
let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
|
|
314
|
-
n ?
|
|
315
|
+
n ? Be(n.id) : B(void 0, t);
|
|
315
316
|
}
|
|
316
|
-
} else
|
|
317
|
-
|
|
317
|
+
} else I && z(I, t);
|
|
318
|
+
R(t);
|
|
318
319
|
}, [
|
|
319
|
-
|
|
320
|
-
V,
|
|
321
|
-
Re,
|
|
320
|
+
I,
|
|
322
321
|
B,
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
Be,
|
|
323
|
+
z,
|
|
324
|
+
R
|
|
325
|
+
]), lt = T((t) => {
|
|
325
326
|
if (S.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
|
|
326
|
-
|
|
327
|
+
Qe(t);
|
|
327
328
|
return;
|
|
328
329
|
}
|
|
329
|
-
|
|
330
|
-
}, [
|
|
331
|
-
let e =
|
|
332
|
-
|
|
330
|
+
ct(t);
|
|
331
|
+
}, [ct]), ut = T(() => {
|
|
332
|
+
let e = Ze;
|
|
333
|
+
Qe(null), Ke(), e && ct(e);
|
|
333
334
|
}, [
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
]),
|
|
338
|
-
|
|
335
|
+
Ze,
|
|
336
|
+
Ke,
|
|
337
|
+
ct
|
|
338
|
+
]), dt = T(() => {
|
|
339
|
+
Qe(null);
|
|
339
340
|
}, []);
|
|
340
|
-
return /* @__PURE__ */
|
|
341
|
+
return /* @__PURE__ */ Ce("div", {
|
|
341
342
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
342
343
|
children: [
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
+
/* @__PURE__ */ Ce("div", {
|
|
344
345
|
className: "contents",
|
|
345
346
|
inert: $.active || void 0,
|
|
346
|
-
children: [
|
|
347
|
-
mode:
|
|
348
|
-
onSuggestionClick:
|
|
349
|
-
}) : /* @__PURE__ */
|
|
347
|
+
children: [ot.length === 0 ? /* @__PURE__ */ k(oe, {
|
|
348
|
+
mode: L,
|
|
349
|
+
onSuggestionClick: nt
|
|
350
|
+
}) : /* @__PURE__ */ k("div", {
|
|
350
351
|
className: "flex min-h-0 flex-1 flex-col",
|
|
351
|
-
children: /* @__PURE__ */
|
|
352
|
-
messages:
|
|
353
|
-
streamingMessageId:
|
|
354
|
-
failedMessageId:
|
|
355
|
-
onRetry:
|
|
352
|
+
children: /* @__PURE__ */ k(b, {
|
|
353
|
+
messages: ot,
|
|
354
|
+
streamingMessageId: qe,
|
|
355
|
+
failedMessageId: Je,
|
|
356
|
+
onRetry: rt
|
|
356
357
|
})
|
|
357
|
-
}), /* @__PURE__ */
|
|
358
|
-
onStartVoiceSession: $.available &&
|
|
359
|
-
onSend: (e, t) => void
|
|
360
|
-
disabled:
|
|
361
|
-
placeholder:
|
|
362
|
-
mode:
|
|
363
|
-
availableModes:
|
|
364
|
-
onModeChange:
|
|
358
|
+
}), /* @__PURE__ */ k(C, {
|
|
359
|
+
onStartVoiceSession: $.available && L !== "api-calls" ? $.start : void 0,
|
|
360
|
+
onSend: (e, t) => void Z(e, t),
|
|
361
|
+
disabled: q,
|
|
362
|
+
placeholder: L === "api-calls" ? j("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : j("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
|
|
363
|
+
mode: L,
|
|
364
|
+
availableModes: Xe,
|
|
365
|
+
onModeChange: lt
|
|
365
366
|
})]
|
|
366
367
|
}),
|
|
367
|
-
$.active && /* @__PURE__ */
|
|
368
|
+
$.active && /* @__PURE__ */ k(se, {
|
|
368
369
|
session: $.session,
|
|
369
370
|
notice: $.notice,
|
|
370
371
|
capturing: $.capturing,
|
|
371
|
-
|
|
372
|
+
interrupting: $.interrupting,
|
|
373
|
+
awaitingEndpoint: $.awaitingEndpoint,
|
|
374
|
+
turns: st,
|
|
372
375
|
onInterrupt: $.interrupt,
|
|
373
|
-
spoken:
|
|
376
|
+
spoken: at,
|
|
374
377
|
onToggleMute: $.toggleMute,
|
|
375
378
|
onEnd: $.end
|
|
376
379
|
}),
|
|
377
|
-
/* @__PURE__ */
|
|
378
|
-
open:
|
|
379
|
-
onConfirm:
|
|
380
|
-
onCancel:
|
|
380
|
+
/* @__PURE__ */ k(x, {
|
|
381
|
+
open: Ze !== null,
|
|
382
|
+
onConfirm: ut,
|
|
383
|
+
onCancel: dt
|
|
381
384
|
})
|
|
382
385
|
]
|
|
383
386
|
});
|
|
384
387
|
};
|
|
385
388
|
//#endregion
|
|
386
|
-
export {
|
|
389
|
+
export { N as AssistantChatArea };
|
|
387
390
|
|
|
388
391
|
//# sourceMappingURL=AssistantChatArea.js.map
|