@burdenoff/microfe-healthybowl 2026.903.5 → 2026.903.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/components/assistant/AssistantChatArea.js +202 -182
- package/dist/components/assistant/AssistantChatArea.js.map +1 -1
- package/dist/components/assistant/composer/AssistantAttachmentButton.js +27 -25
- package/dist/components/assistant/composer/AssistantAttachmentButton.js.map +1 -1
- package/dist/components/assistant/voice/AssistantVoiceSession.js +119 -88
- package/dist/components/assistant/voice/AssistantVoiceSession.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,45 +9,46 @@ import { resolveLanguagePair as ee } from "../../config/assistantLanguagePair.js
|
|
|
9
9
|
import { isTurnInFlight as b } from "../../utils/assistantTurnState.js";
|
|
10
10
|
import { parseToolActivity as x } from "./AssistantToolActivity.js";
|
|
11
11
|
import { getActorId as S, getOrganizationId as C, getWorkspaceId as te } from "../../utils/assistantContext.js";
|
|
12
|
-
import { buildPromptParts as ne, buildPromptWithAttachments as re, countInlineImageCandidates as ie, countInlinedImageParts as ae, toMessageAttachment as oe } from "../../utils/assistantAttachments.js";
|
|
13
|
-
import { AssistantMessageList as
|
|
14
|
-
import { AssistantApiCallsConsentDialog as
|
|
15
|
-
import { ASSISTANT_MODES as
|
|
16
|
-
import { AssistantEmptyState as
|
|
17
|
-
import { AssistantSpokenTurnsNotice as
|
|
18
|
-
import { VoiceTranscriptDrawer as
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
12
|
+
import { buildPromptParts as ne, buildPromptWithAttachments as re, countInlineImageCandidates as ie, countInlinedImageParts as ae, getSendableAttachments as w, toMessageAttachment as oe } from "../../utils/assistantAttachments.js";
|
|
13
|
+
import { AssistantMessageList as T } from "./AssistantMessageList.js";
|
|
14
|
+
import { AssistantApiCallsConsentDialog as se } from "./AssistantApiCallsConsentDialog.js";
|
|
15
|
+
import { ASSISTANT_MODES as ce } from "../../types/assistant.js";
|
|
16
|
+
import { AssistantEmptyState as le } from "./AssistantEmptyState.js";
|
|
17
|
+
import { AssistantSpokenTurnsNotice as ue } from "./AssistantSpokenTurnsNotice.js";
|
|
18
|
+
import { VoiceTranscriptDrawer as de } from "./voice/VoiceTranscriptDrawer.js";
|
|
19
|
+
import { useAssistantAttachments as fe } from "../../hooks/useAssistantAttachments.js";
|
|
20
|
+
import { AssistantComposer as pe } from "./composer/AssistantComposer.js";
|
|
21
|
+
import { AssistantVoiceSession as me } from "./voice/AssistantVoiceSession.js";
|
|
22
|
+
import { useVoiceSession as he } from "../../hooks/useVoiceSession.js";
|
|
23
|
+
import { useAssistantApiAccess as ge } from "../../hooks/useAssistantApiAccess.js";
|
|
24
|
+
import { useWorkspaceWriteAccess as _e } from "../../hooks/useWorkspaceWriteAccess.js";
|
|
25
|
+
import { useConversationTurns as ve } from "../../hooks/useConversationTurns.js";
|
|
26
|
+
import { isQuotaExhaustedError as ye } from "../../utils/quotaUtils.js";
|
|
27
|
+
import { dispatchAssistantQuotaExhausted as be, notifyAiCreditsUpdated as xe } from "../../utils/aiCredits.js";
|
|
28
|
+
import { buildPromptForMode as Se } from "../../utils/assistantPrompt.js";
|
|
29
|
+
import { isMultimodalBodyRejection as Ce, isRecoverableAssistantError as we } from "../../utils/assistantTransportErrors.js";
|
|
30
|
+
import { pollDelayMs as Te } from "../../utils/assistantPollSchedule.js";
|
|
31
|
+
import { findPendingWrite as Ee } from "../../utils/pendingWrite.js";
|
|
32
|
+
import { toCaptionText as De } from "../../utils/captionText.js";
|
|
33
|
+
import { buildContinuedFromVoiceNote as Oe, buildVoiceTranscriptMarkdown as ke, voiceTranscriptFilename as Ae } from "../../utils/voiceTranscript.js";
|
|
34
|
+
import { createReadinessTracker as je } from "../../utils/sandboxReadiness.js";
|
|
35
|
+
import { useCallback as E, useEffect as D, useMemo as O, useRef as k, useState as Me } from "react";
|
|
36
|
+
import { useI18n as Ne } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
37
|
+
import { jsx as A, jsxs as Pe } from "react/jsx-runtime";
|
|
38
|
+
import { useGatewayClient as Fe } from "@burdenoff/fe-libs/shared/graphql";
|
|
39
|
+
import { useAuthToken as Ie } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
39
40
|
import { getAssistantMedia as j } from "@burdenoff/fe-libs/shared/assistant";
|
|
40
41
|
//#region src/components/assistant/AssistantChatArea.tsx
|
|
41
|
-
var
|
|
42
|
+
var Le = {
|
|
42
43
|
general: 18e4,
|
|
43
44
|
assistant: 18e4,
|
|
44
45
|
"api-calls": 18e4,
|
|
45
46
|
"vibe-plugins": 6e5
|
|
46
|
-
},
|
|
47
|
-
function
|
|
47
|
+
}, Re = 18e4, ze = 2e4;
|
|
48
|
+
function Be() {
|
|
48
49
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function Ve(e) {
|
|
51
52
|
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]");
|
|
52
53
|
}
|
|
53
54
|
function M(e) {
|
|
@@ -62,13 +63,13 @@ function P(e) {
|
|
|
62
63
|
return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
+
function He(e, t) {
|
|
66
67
|
let n = e.filter((e) => e.info?.role === "assistant" && M(e) > t).sort((e, t) => M(e) - M(t));
|
|
67
68
|
if (n.length === 0) return {
|
|
68
69
|
content: "Thinking...",
|
|
69
70
|
done: !1
|
|
70
71
|
};
|
|
71
|
-
let r = n[n.length - 1], i = N(r.parts), a = j(r.parts), o = P(r.parts), s =
|
|
72
|
+
let r = n[n.length - 1], i = N(r.parts), a = j(r.parts), o = P(r.parts), s = Ee(r.parts);
|
|
72
73
|
return {
|
|
73
74
|
content: [
|
|
74
75
|
i,
|
|
@@ -80,7 +81,7 @@ function ze(e, t) {
|
|
|
80
81
|
...s ? { pendingWrite: s } : {}
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function Ue(e) {
|
|
84
85
|
switch (e) {
|
|
85
86
|
case "provisioning": return "Starting assistant environment...";
|
|
86
87
|
case "connecting": return "Connecting to assistant...";
|
|
@@ -88,40 +89,40 @@ function Be(e) {
|
|
|
88
89
|
default: return "";
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
var
|
|
92
|
-
let j = t(), N =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
]),
|
|
92
|
+
var We = ({ visible: Ee = !0 }) => {
|
|
93
|
+
let j = t(), N = Fe("workspace"), { getAccessToken: P, getWorkspaceToken: We, userId: Ge } = Ie(), { locale: Ke } = Ne(), qe = e((e) => e.assistantLanguage), Je = e((e) => e.replyLanguage), Ye = O(() => ee(qe, Je, Ke), [
|
|
94
|
+
qe,
|
|
95
|
+
Je,
|
|
96
|
+
Ke
|
|
97
|
+
]), Xe = Ye.reply.english, Ze = Ye.replyIsExplicit, Qe = Ye.reply.code, { conversations: $e, activeConversationId: F, mode: I, processingByConversationId: et, setMode: L, setConversationMode: R, setActiveConversation: tt, createConversation: z, addMessage: B, updateMessage: nt, patchMessage: V, mergeMessageMetadata: rt, setConversationProcessing: H, clearConversationProcessing: it, setBackendSessionId: at, clearBackendSessionId: U, setSandbox: W, clearSandbox: ot, acknowledgeApiCalls: st } = e(), G = ve($e.find((e) => e.id === F)), ct = G.all, lt = F ? et[F] : void 0, ut = b(lt?.status), dt = ut ? lt?.messageId ?? null : null, ft = lt?.status === "error" ? lt.messageId : null, { canUseApiCalls: pt, loading: mt } = ge(C()), ht = _e(S(), te() || null), gt = O(() => ce.filter((e) => !e.requiresAdmin || pt), [pt]), [_t, vt] = Me(null), [yt, bt] = Me(!1), xt = k({}), St = k(je()), Ct = k(/* @__PURE__ */ new Set()), wt = O(() => ce.find((e) => e.id === I), [I]);
|
|
97
98
|
D(() => {
|
|
98
|
-
|
|
99
|
+
mt || (!wt || wt.requiresAdmin && !pt) && I !== "assistant" && L("assistant");
|
|
99
100
|
}, [
|
|
100
101
|
I,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
wt,
|
|
103
|
+
pt,
|
|
104
|
+
mt,
|
|
104
105
|
L
|
|
105
106
|
]);
|
|
106
|
-
let
|
|
107
|
-
H(e, n, t, null), r ?
|
|
108
|
-
}, [H,
|
|
107
|
+
let K = E((e, t, n, r) => {
|
|
108
|
+
H(e, n, t, null), r ? nt(e, t, r) : nt(e, t, Ue(n));
|
|
109
|
+
}, [H, nt]), Tt = E(async (t, n, a, s, c) => {
|
|
109
110
|
let u = e.getState().sandboxesByMode[a]?.sandboxId ?? null, d = async (e) => {
|
|
110
|
-
if (
|
|
111
|
+
if (St.current.isFresh(e)) return !0;
|
|
111
112
|
try {
|
|
112
|
-
return await p(N, e, s, c, 3e5, (e) =>
|
|
113
|
+
return await p(N, e, s, c, 3e5, (e) => K(t, n, "provisioning", e)), await f(N, e, s, c, 9e4, (e) => K(t, n, "connecting", e)), St.current.markVerified(e), !0;
|
|
113
114
|
} catch {
|
|
114
|
-
return
|
|
115
|
+
return St.current.invalidate(e), !1;
|
|
115
116
|
}
|
|
116
117
|
};
|
|
117
|
-
if (u && (W(a, u, "provisioning"),
|
|
118
|
-
|
|
118
|
+
if (u && (W(a, u, "provisioning"), K(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (W(a, null, "provisioning"), u = null)), !u) {
|
|
119
|
+
K(t, n, "provisioning", "Looking for existing environment...");
|
|
119
120
|
let e = await o(N, s, a, c);
|
|
120
|
-
e && (W(a, e, "provisioning"),
|
|
121
|
+
e && (W(a, e, "provisioning"), K(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : W(a, null, "provisioning"));
|
|
121
122
|
}
|
|
122
123
|
if (!u) {
|
|
123
124
|
if (a === "api-calls" && !P()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
124
|
-
|
|
125
|
+
K(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(N, a, s, c), W(a, u, "provisioning"), await p(N, u, s, c, 3e5, (e) => K(t, n, "provisioning", e)), await f(N, u, s, c, 9e4, (e) => K(t, n, "connecting", e));
|
|
125
126
|
}
|
|
126
127
|
W(a, u, "running");
|
|
127
128
|
let m = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
|
|
@@ -131,7 +132,7 @@ var Ve = ({ visible: we = !0 }) => {
|
|
|
131
132
|
} catch {
|
|
132
133
|
U(t), m = null;
|
|
133
134
|
}
|
|
134
|
-
return m || (
|
|
135
|
+
return m || (K(t, n, "connecting", "Preparing session..."), m = (await i(N, u, s, a, c)).sessionId, at(t, m)), {
|
|
135
136
|
sandboxId: u,
|
|
136
137
|
sessionId: m
|
|
137
138
|
};
|
|
@@ -139,22 +140,22 @@ var Ve = ({ visible: we = !0 }) => {
|
|
|
139
140
|
N,
|
|
140
141
|
U,
|
|
141
142
|
P,
|
|
142
|
-
|
|
143
|
+
at,
|
|
143
144
|
W,
|
|
144
|
-
|
|
145
|
-
]),
|
|
145
|
+
K
|
|
146
|
+
]), q = E(async (t, r = [], i = {}) => {
|
|
146
147
|
let o = i.voiceSessionId !== void 0, l = e.getState(), f = l.activeConversationId ?? F;
|
|
147
|
-
if (f && (b(l.processingByConversationId[f]?.status) ||
|
|
148
|
+
if (f && (b(l.processingByConversationId[f]?.status) || Ct.current.has(f))) return;
|
|
148
149
|
let p = l.mode, h = F, _ = h ? e.getState().conversations.find((e) => e.id === h) : void 0;
|
|
149
150
|
if (h ? _ && _.mode !== p && (_.messages.length > 0 || _.backendSessionId) ? h = z(void 0, p) : _ && _.mode !== p && R(h, p) : h = z(void 0, p), !h) return;
|
|
150
|
-
|
|
151
|
+
xt.current[h] = r;
|
|
151
152
|
let v = te(), y = {
|
|
152
153
|
accessToken: P(),
|
|
153
|
-
workspaceToken:
|
|
154
|
-
userId:
|
|
154
|
+
workspaceToken: We(),
|
|
155
|
+
userId: Ge,
|
|
155
156
|
organizationId: C()
|
|
156
157
|
}, ee = {
|
|
157
|
-
id:
|
|
158
|
+
id: Be(),
|
|
158
159
|
role: "user",
|
|
159
160
|
content: t,
|
|
160
161
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -164,19 +165,19 @@ var Ve = ({ visible: we = !0 }) => {
|
|
|
164
165
|
}
|
|
165
166
|
};
|
|
166
167
|
B(h, ee);
|
|
167
|
-
let x =
|
|
168
|
+
let x = Be();
|
|
168
169
|
B(h, {
|
|
169
170
|
id: x,
|
|
170
171
|
role: "assistant",
|
|
171
172
|
content: "",
|
|
172
173
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
173
174
|
metadata: {
|
|
174
|
-
lang:
|
|
175
|
+
lang: Qe,
|
|
175
176
|
...g(i.voiceSessionId)
|
|
176
177
|
}
|
|
177
178
|
}), H(h, "provisioning", x, null);
|
|
178
|
-
let S = (e, t, n, r, a =
|
|
179
|
-
V(h, x, { content:
|
|
179
|
+
let S = (e, t, n, r, a = Qe) => {
|
|
180
|
+
V(h, x, { content: Ve(e) }), rt(h, x, {
|
|
180
181
|
lang: a,
|
|
181
182
|
...t?.length ? { artifacts: t } : {},
|
|
182
183
|
...t?.length || n || r ? { mode: p } : {},
|
|
@@ -189,25 +190,25 @@ var Ve = ({ visible: we = !0 }) => {
|
|
|
189
190
|
try {
|
|
190
191
|
await n(N, v, y);
|
|
191
192
|
} catch (e) {
|
|
192
|
-
if (
|
|
193
|
-
|
|
193
|
+
if (ye(e)) {
|
|
194
|
+
be("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(h, "error", x, null);
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
196
197
|
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);
|
|
197
198
|
}
|
|
198
199
|
try {
|
|
199
|
-
let { sandboxId: e, sessionId: n } = await
|
|
200
|
-
|
|
201
|
-
let f =
|
|
200
|
+
let { sandboxId: e, sessionId: n } = await Tt(h, x, p, v, y), l = (await c(N, e, v, n, y, 50).catch(() => [])).reduce((e, t) => Math.max(e, M(t)), 0);
|
|
201
|
+
K(h, x, "streaming", "Thinking...");
|
|
202
|
+
let f = Se(p, re(t, r), Xe, Ze, o), g = ne(f, r), _ = ae(g), ee = _ > 0, b = m();
|
|
202
203
|
i = ie(r) > _;
|
|
203
204
|
try {
|
|
204
205
|
await d(N, e, v, n, f, p, b, y, g);
|
|
205
206
|
} catch (t) {
|
|
206
|
-
if (!g || !
|
|
207
|
+
if (!g || !Ce(t)) throw t;
|
|
207
208
|
await d(N, e, v, n, f, p, b, y, void 0), i ||= ee;
|
|
208
209
|
}
|
|
209
|
-
let C =
|
|
210
|
-
for (; Date.now() < te && (C =
|
|
210
|
+
let C = He([], l), te = Date.now() + (Le[p] ?? Re), w = Date.now(), oe = Date.now();
|
|
211
|
+
for (; Date.now() < te && (C = He(await c(N, e, v, n, y, 50, l), l), V(h, x, { content: Ve(C.content) }), C.pendingWrite && rt(h, x, { pendingWrite: C.pendingWrite }), !C.done);) Date.now() - w > 3e4 && (await a(N, e, v, 600, y).catch(() => void 0), w = Date.now()), await new Promise((e) => setTimeout(e, Te(Date.now() - oe)));
|
|
211
212
|
if (!C.done && p !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
|
|
212
213
|
let T = p === "vibe-plugins" ? await s(N, e, v, n, y).catch(() => []) : void 0;
|
|
213
214
|
if (C.done || (C = {
|
|
@@ -219,70 +220,70 @@ var Ve = ({ visible: we = !0 }) => {
|
|
|
219
220
|
}), S(C.content, T, n, e), C.tokens) {
|
|
220
221
|
V(h, x, { tokens: C.tokens });
|
|
221
222
|
try {
|
|
222
|
-
await u(N, v, n, C.tokens, y),
|
|
223
|
+
await u(N, v, n, C.tokens, y), xe();
|
|
223
224
|
} catch {}
|
|
224
225
|
}
|
|
225
226
|
H(h, "complete", x, null);
|
|
226
227
|
} catch (t) {
|
|
227
|
-
if (e === 1 &&
|
|
228
|
+
if (e === 1 && we(t)) return U(h), ot(p), w(2);
|
|
228
229
|
throw t;
|
|
229
230
|
}
|
|
230
231
|
}, T = h;
|
|
231
|
-
|
|
232
|
+
Ct.current.add(T);
|
|
232
233
|
try {
|
|
233
234
|
if (!v) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
234
235
|
await w();
|
|
235
236
|
} catch (t) {
|
|
236
|
-
if (
|
|
237
|
-
|
|
237
|
+
if (St.current.invalidate(e.getState().sandboxesByMode[p]?.sandboxId ?? null), ye(t)) {
|
|
238
|
+
be("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(h, "error", x, null);
|
|
238
239
|
return;
|
|
239
240
|
}
|
|
240
241
|
let n = t instanceof Error ? t.message : "Something went wrong";
|
|
241
|
-
H(h, "error", x, n), V(h, x, { content: `Sorry, an error occurred: ${n}. Please try again.` }),
|
|
242
|
+
H(h, "error", x, n), V(h, x, { content: `Sorry, an error occurred: ${n}. Please try again.` }), rt(h, x, {
|
|
242
243
|
lang: "en",
|
|
243
244
|
...g(i.voiceSessionId)
|
|
244
245
|
});
|
|
245
246
|
} finally {
|
|
246
|
-
|
|
247
|
+
Ct.current.delete(T);
|
|
247
248
|
}
|
|
248
249
|
}, [
|
|
249
250
|
F,
|
|
250
251
|
B,
|
|
251
252
|
N,
|
|
252
253
|
U,
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
ot,
|
|
255
|
+
$e,
|
|
255
256
|
z,
|
|
256
|
-
|
|
257
|
+
Tt,
|
|
257
258
|
P,
|
|
258
|
-
|
|
259
|
+
We,
|
|
259
260
|
V,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
Ze,
|
|
262
|
+
Qe,
|
|
263
|
+
Xe,
|
|
264
|
+
at,
|
|
264
265
|
R,
|
|
265
266
|
H,
|
|
266
267
|
j,
|
|
267
|
-
J,
|
|
268
|
-
He
|
|
269
|
-
]), xt = E((e) => {
|
|
270
|
-
Y(e);
|
|
271
|
-
}, [Y]), St = E(() => {
|
|
272
|
-
let e = [...G.chat].reverse().find((e) => e.role === "user"), t = F ? gt.current[F] ?? [] : [];
|
|
273
|
-
e && Y(e.content, t);
|
|
274
|
-
}, [
|
|
275
268
|
K,
|
|
276
|
-
|
|
269
|
+
Ge
|
|
270
|
+
]), Et = E((e) => {
|
|
271
|
+
q(e);
|
|
272
|
+
}, [q]), Dt = E(() => {
|
|
273
|
+
let e = [...G.chat].reverse().find((e) => e.role === "user"), t = F ? xt.current[F] ?? [] : [];
|
|
274
|
+
e && q(e.content, t);
|
|
275
|
+
}, [
|
|
276
|
+
ct,
|
|
277
|
+
q,
|
|
277
278
|
F
|
|
278
|
-
]),
|
|
279
|
+
]), Ot = k(q);
|
|
279
280
|
D(() => {
|
|
280
|
-
|
|
281
|
-
}, [
|
|
282
|
-
let
|
|
283
|
-
if (
|
|
284
|
-
for (let e =
|
|
285
|
-
let t =
|
|
281
|
+
Ot.current = q;
|
|
282
|
+
}, [q]);
|
|
283
|
+
let J = O(() => {
|
|
284
|
+
if (ut) return null;
|
|
285
|
+
for (let e = ct.length - 1; e >= 0; --e) {
|
|
286
|
+
let t = ct[e];
|
|
286
287
|
if (t?.role !== "assistant" || !h(t)) continue;
|
|
287
288
|
let n = x(t.content).text.trim();
|
|
288
289
|
return n ? {
|
|
@@ -291,151 +292,170 @@ var Ve = ({ visible: we = !0 }) => {
|
|
|
291
292
|
} : null;
|
|
292
293
|
}
|
|
293
294
|
return null;
|
|
294
|
-
}, [
|
|
295
|
+
}, [ct, ut]), kt = O(() => J ? De(J.text) : null, [J]), At = G.chat, Y = O(() => G.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
295
296
|
id: e.id,
|
|
296
297
|
role: e.role,
|
|
297
298
|
text: x(e.content).text.trim(),
|
|
298
299
|
sessionId: _(e),
|
|
299
300
|
timestamp: e.timestamp
|
|
300
|
-
})).filter((e) => e.text.length > 0), [G.voice]),
|
|
301
|
-
if (
|
|
301
|
+
})).filter((e) => e.text.length > 0), [G.voice]), jt = E(() => {
|
|
302
|
+
if (Y.length === 0) return;
|
|
302
303
|
let e = /* @__PURE__ */ new Date();
|
|
303
|
-
v(
|
|
304
|
+
v(ke(Y, {
|
|
304
305
|
title: j("healthybowl.assistant.voiceSession.transcript", "Voice conversation"),
|
|
305
306
|
savedAt: j("healthybowl.assistant.voiceSession.savedAt", "Saved"),
|
|
306
307
|
session: j("healthybowl.assistant.voiceSession.sessionLabel", "Session"),
|
|
307
308
|
earlier: j("healthybowl.assistant.voiceSession.earlierLabel", "Earlier"),
|
|
308
309
|
you: j("healthybowl.assistant.voiceSession.speakerYou", "You"),
|
|
309
310
|
assistant: j("healthybowl.assistant.voiceSession.speakerAssistant", "Assistant")
|
|
310
|
-
}, e),
|
|
311
|
-
}, [
|
|
311
|
+
}, e), Ae(e), "text/markdown");
|
|
312
|
+
}, [Y, j]), X = fe(), Z = k(X);
|
|
313
|
+
Z.current = X;
|
|
314
|
+
let Q = he({
|
|
312
315
|
onSubmit: E((e, t) => {
|
|
313
|
-
|
|
316
|
+
let n = () => {
|
|
317
|
+
let n = Z.current, r = w(n.attachments);
|
|
318
|
+
Ot.current(e, r, { voiceSessionId: t }), n.clear();
|
|
319
|
+
};
|
|
320
|
+
if (!Z.current.isBusy) {
|
|
321
|
+
n();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
let r = Date.now(), i = window.setInterval(() => {
|
|
325
|
+
Z.current.isBusy && Date.now() - r < ze || (window.clearInterval(i), n());
|
|
326
|
+
}, 200);
|
|
314
327
|
}, []),
|
|
315
|
-
latestReply:
|
|
316
|
-
language: y(
|
|
317
|
-
}),
|
|
328
|
+
latestReply: J,
|
|
329
|
+
language: y(qe, Ke).tag
|
|
330
|
+
}), Mt = E(() => {
|
|
318
331
|
let t = e.getState().activeConversationId;
|
|
319
|
-
!t ||
|
|
320
|
-
id:
|
|
332
|
+
!t || Y.length === 0 || (B(t, {
|
|
333
|
+
id: Be(),
|
|
321
334
|
role: "system",
|
|
322
|
-
content:
|
|
335
|
+
content: Oe(Y, {
|
|
323
336
|
intro: j("healthybowl.assistant.voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
|
|
324
337
|
nothing: j("healthybowl.assistant.voiceSession.continuedNothing", "Continued from a voice conversation."),
|
|
325
338
|
more: (e) => j("healthybowl.assistant.voiceSession.continuedMore", "…and {{count}} more", { count: e })
|
|
326
339
|
}),
|
|
327
340
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
328
|
-
}),
|
|
341
|
+
}), bt(!1), Q.end());
|
|
329
342
|
}, [
|
|
330
|
-
|
|
343
|
+
Y,
|
|
331
344
|
B,
|
|
332
345
|
j
|
|
333
346
|
]);
|
|
334
347
|
D(() => {
|
|
335
|
-
!
|
|
336
|
-
}, [
|
|
348
|
+
!Ee && Q.active && Q.end();
|
|
349
|
+
}, [Ee, Q]), D(() => {
|
|
350
|
+
Q.active || Z.current.clear();
|
|
351
|
+
}, [Q.active]), D(() => {
|
|
337
352
|
let t = e.getState().consumePendingPrompt();
|
|
338
|
-
return t &&
|
|
353
|
+
return t && Ot.current(t), e.subscribe((t, n) => {
|
|
339
354
|
if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
|
|
340
355
|
let t = e.getState().consumePendingPrompt();
|
|
341
|
-
t &&
|
|
356
|
+
t && Ot.current(t);
|
|
342
357
|
}
|
|
343
358
|
});
|
|
344
359
|
}, []);
|
|
345
|
-
let
|
|
360
|
+
let $ = E((t) => {
|
|
346
361
|
let n = F ? e.getState().conversations.find((e) => e.id === F) : void 0;
|
|
347
362
|
if (n && (n.messages.length > 0 || n.backendSessionId)) {
|
|
348
363
|
if (n.mode !== t) {
|
|
349
364
|
let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
|
|
350
|
-
n ?
|
|
365
|
+
n ? tt(n.id) : z(void 0, t);
|
|
351
366
|
}
|
|
352
367
|
} else F && R(F, t);
|
|
353
368
|
L(t);
|
|
354
369
|
}, [
|
|
355
370
|
F,
|
|
356
371
|
z,
|
|
357
|
-
|
|
372
|
+
tt,
|
|
358
373
|
R,
|
|
359
374
|
L
|
|
360
|
-
]),
|
|
361
|
-
if (
|
|
362
|
-
|
|
375
|
+
]), Nt = E((t) => {
|
|
376
|
+
if (ce.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
|
|
377
|
+
vt(t);
|
|
363
378
|
return;
|
|
364
379
|
}
|
|
365
|
-
|
|
366
|
-
}, [
|
|
367
|
-
let e =
|
|
368
|
-
|
|
380
|
+
$(t);
|
|
381
|
+
}, [$]), Pt = E(() => {
|
|
382
|
+
let e = _t;
|
|
383
|
+
vt(null), st(), e && $(e);
|
|
369
384
|
}, [
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
]),
|
|
374
|
-
|
|
385
|
+
_t,
|
|
386
|
+
st,
|
|
387
|
+
$
|
|
388
|
+
]), Ft = E(() => {
|
|
389
|
+
vt(null);
|
|
375
390
|
}, []);
|
|
376
|
-
return /* @__PURE__ */
|
|
391
|
+
return /* @__PURE__ */ Pe("div", {
|
|
377
392
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
378
393
|
children: [
|
|
379
|
-
/* @__PURE__ */
|
|
394
|
+
/* @__PURE__ */ Pe("div", {
|
|
380
395
|
className: "contents",
|
|
381
|
-
inert:
|
|
396
|
+
inert: Q.active || void 0,
|
|
382
397
|
children: [
|
|
383
|
-
|
|
384
|
-
count:
|
|
385
|
-
onOpenTranscript: () =>
|
|
398
|
+
Y.length > 0 && !Q.active ? /* @__PURE__ */ A(ue, {
|
|
399
|
+
count: Y.length,
|
|
400
|
+
onOpenTranscript: () => bt(!0)
|
|
386
401
|
}) : null,
|
|
387
|
-
|
|
402
|
+
At.length === 0 ? /* @__PURE__ */ A(le, {
|
|
388
403
|
mode: I,
|
|
389
|
-
onSuggestionClick:
|
|
404
|
+
onSuggestionClick: Et
|
|
390
405
|
}) : /* @__PURE__ */ A("div", {
|
|
391
406
|
className: "flex min-h-0 flex-1 flex-col",
|
|
392
|
-
children: /* @__PURE__ */ A(
|
|
393
|
-
messages:
|
|
394
|
-
streamingMessageId:
|
|
395
|
-
failedMessageId:
|
|
396
|
-
onRetry:
|
|
407
|
+
children: /* @__PURE__ */ A(T, {
|
|
408
|
+
messages: At,
|
|
409
|
+
streamingMessageId: dt,
|
|
410
|
+
failedMessageId: ft,
|
|
411
|
+
onRetry: Dt
|
|
397
412
|
})
|
|
398
413
|
}),
|
|
399
|
-
/* @__PURE__ */ A(
|
|
400
|
-
onStartVoiceSession:
|
|
401
|
-
onSend: (e, t) => void
|
|
402
|
-
disabled:
|
|
414
|
+
/* @__PURE__ */ A(pe, {
|
|
415
|
+
onStartVoiceSession: Q.available && I !== "api-calls" ? Q.start : void 0,
|
|
416
|
+
onSend: (e, t) => void q(e, t),
|
|
417
|
+
disabled: ut,
|
|
403
418
|
placeholder: I === "api-calls" ? j("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : j("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
|
|
404
419
|
mode: I,
|
|
405
|
-
writeAccessDenied:
|
|
406
|
-
availableModes:
|
|
407
|
-
onModeChange:
|
|
420
|
+
writeAccessDenied: ht === "denied" && !!wt?.writeCapable,
|
|
421
|
+
availableModes: gt,
|
|
422
|
+
onModeChange: Nt
|
|
408
423
|
})
|
|
409
424
|
]
|
|
410
425
|
}),
|
|
411
|
-
|
|
412
|
-
turns:
|
|
413
|
-
onClose: () =>
|
|
414
|
-
onSave:
|
|
426
|
+
yt && !Q.active ? /* @__PURE__ */ A(de, {
|
|
427
|
+
turns: Y,
|
|
428
|
+
onClose: () => bt(!1),
|
|
429
|
+
onSave: jt
|
|
415
430
|
}) : null,
|
|
416
|
-
|
|
417
|
-
session:
|
|
418
|
-
notice:
|
|
419
|
-
capturing:
|
|
420
|
-
interrupting:
|
|
421
|
-
awaitingEndpoint:
|
|
422
|
-
turns:
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
431
|
+
Q.active && /* @__PURE__ */ A(me, {
|
|
432
|
+
session: Q.session,
|
|
433
|
+
notice: Q.notice,
|
|
434
|
+
capturing: Q.capturing,
|
|
435
|
+
interrupting: Q.interrupting,
|
|
436
|
+
awaitingEndpoint: Q.awaitingEndpoint,
|
|
437
|
+
turns: Y,
|
|
438
|
+
attachments: X.attachments,
|
|
439
|
+
onAttachFiles: X.addFiles,
|
|
440
|
+
onRemoveAttachment: X.remove,
|
|
441
|
+
onRetryAttachment: X.retry,
|
|
442
|
+
canAttachMore: X.canAddMore,
|
|
443
|
+
onSaveTranscript: jt,
|
|
444
|
+
onContinueInChat: Mt,
|
|
445
|
+
onInterrupt: Q.interrupt,
|
|
446
|
+
spoken: kt,
|
|
447
|
+
onToggleMute: Q.toggleMute,
|
|
448
|
+
onEnd: Q.end
|
|
429
449
|
}),
|
|
430
|
-
/* @__PURE__ */ A(
|
|
431
|
-
open:
|
|
432
|
-
onConfirm:
|
|
433
|
-
onCancel:
|
|
450
|
+
/* @__PURE__ */ A(se, {
|
|
451
|
+
open: _t !== null,
|
|
452
|
+
onConfirm: Pt,
|
|
453
|
+
onCancel: Ft
|
|
434
454
|
})
|
|
435
455
|
]
|
|
436
456
|
});
|
|
437
457
|
};
|
|
438
458
|
//#endregion
|
|
439
|
-
export {
|
|
459
|
+
export { We as AssistantChatArea };
|
|
440
460
|
|
|
441
461
|
//# sourceMappingURL=AssistantChatArea.js.map
|