@burdenoff/microfe-healthybowl 2026.904.23 → 2026.904.25
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 +172 -172
- package/dist/components/assistant/AssistantChatArea.js.map +1 -1
- package/dist/components/assistant/composer/AssistantAttachmentButton.js +1 -2
- package/dist/components/assistant/composer/AssistantAttachmentChips.js +1 -2
- package/dist/components/assistant/composer/AssistantComposer.js +2 -187
- package/dist/components/assistant/composer/AssistantModeSelector.js +1 -2
- package/dist/components/assistant/composer/AssistantVoiceButton.js +1 -2
- package/dist/components/assistant/index.js +4 -4
- package/dist/healthybowl/offline/OfflineSyncProvider.js +79 -79
- package/dist/healthybowl/offline/OfflineSyncProvider.js.map +1 -1
- package/dist/healthybowl/pages/pest-management/AiPestDetectionPage.js +6 -6
- package/dist/healthybowl/pages/terrace/JournalEntryModal.js +1 -1
- package/dist/healthybowl/store/healthybowlStore.js +5 -5
- package/dist/healthybowl/utils/imageDownscale.js +2 -104
- package/dist/hooks/useAssistantAttachments.js +2 -244
- package/dist/utils/assistantAttachments.js +2 -2
- package/package.json +2 -2
- package/dist/components/assistant/composer/AssistantComposer.js.map +0 -1
- package/dist/components/assistant/composer/AssistantLanguageSelector.js +0 -2
- package/dist/components/assistant/voice/AssistantVoiceSessionButton.js +0 -2
- package/dist/healthybowl/utils/imageDownscale.js.map +0 -1
- package/dist/hooks/useAssistantAttachments.js.map +0 -1
- package/dist/hooks/useVoiceInput.js +0 -2
- package/dist/node_modules/fflate/esm/browser.js +0 -326
- package/dist/node_modules/fflate/esm/browser.js.map +0 -1
- package/dist/node_modules/pdfjs-dist/build/pdf.js +0 -16389
- package/dist/node_modules/pdfjs-dist/build/pdf.js.map +0 -1
- package/dist/node_modules/pdfjs-dist/build/pdf.worker.min.js +0 -52138
- package/dist/node_modules/pdfjs-dist/build/pdf.worker.min.js.map +0 -1
- package/dist/utils/documentExtract.js +0 -135
- package/dist/utils/documentExtract.js.map +0 -1
- package/dist/utils/documentText.js +0 -2
- package/dist/utils/speechVoices.js +0 -2
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { useAssistantStore as e } from "../../store/assistantStore.js";
|
|
2
|
-
import { createAssistantSandbox as t, createAssistantSession as n, extendAssistantSandboxTTL as r, findExistingSandbox as i, getAssistantArtifacts as a, getAssistantMessages as o, getAssistantSession as
|
|
3
|
-
import { gatherPageContext as
|
|
4
|
-
import { resolveAssistantLanguage as
|
|
5
|
-
import { resolveLanguagePair as
|
|
6
|
-
import { AssistantMessageList as
|
|
7
|
-
import { AssistantApiCallsConsentDialog as
|
|
8
|
-
import { AssistantEmptyState as
|
|
9
|
-
import { AssistantSpokenTurnsNotice as
|
|
10
|
-
import { VoiceTranscriptDrawer as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
2
|
+
import { createAssistantSandbox as t, createAssistantSession as n, extendAssistantSandboxTTL as r, findExistingSandbox as i, getAssistantArtifacts as a, getAssistantMessages as o, getAssistantSession as s, reportAssistantAiTokenUsage as c, sendAssistantPromptAsync as l, waitForAssistantServiceReady as u, waitForSandboxReady as d } from "../../services/assistantApi.js";
|
|
3
|
+
import { gatherPageContext as f } from "../../utils/pageContext.js";
|
|
4
|
+
import { resolveAssistantLanguage as p } from "../../config/assistantLanguages.js";
|
|
5
|
+
import { resolveLanguagePair as m } from "../../config/assistantLanguagePair.js";
|
|
6
|
+
import { AssistantMessageList as h } from "./AssistantMessageList.js";
|
|
7
|
+
import { AssistantApiCallsConsentDialog as g } from "./AssistantApiCallsConsentDialog.js";
|
|
8
|
+
import { AssistantEmptyState as _ } from "./AssistantEmptyState.js";
|
|
9
|
+
import { AssistantSpokenTurnsNotice as v } from "./AssistantSpokenTurnsNotice.js";
|
|
10
|
+
import { VoiceTranscriptDrawer as y } from "./voice/VoiceTranscriptDrawer.js";
|
|
11
|
+
import { AssistantComposer as ee } from "./composer/AssistantComposer.js";
|
|
12
|
+
import { AssistantVoiceSession as b } from "./voice/AssistantVoiceSession.js";
|
|
13
|
+
import { parseToolActivity as x } from "./AssistantToolActivity.js";
|
|
14
|
+
import { useVoiceSession as te } from "../../hooks/useVoiceSession.js";
|
|
15
|
+
import { useAssistantApiAccess as S } from "../../hooks/useAssistantApiAccess.js";
|
|
16
|
+
import { useWorkspaceWriteAccess as ne } from "../../hooks/useWorkspaceWriteAccess.js";
|
|
17
|
+
import { useAssistantAttachments as re } from "../../hooks/useAssistantAttachments.js";
|
|
18
|
+
import { useConversationTurns as ie } from "../../hooks/useConversationTurns.js";
|
|
19
|
+
import { getActorId as ae, getOrganizationId as oe, getWorkspaceId as se } from "../../utils/assistantContext.js";
|
|
20
|
+
import { dispatchAssistantQuotaExhausted as ce, notifyAiCreditsUpdated as le } from "../../utils/aiCredits.js";
|
|
21
|
+
import { isQuotaExhaustedError as ue } from "../../utils/quotaUtils.js";
|
|
22
|
+
import { buildPromptForMode as de } from "../../utils/assistantPrompt.js";
|
|
23
|
+
import { buildPromptParts as fe, buildPromptWithAttachments as pe, countInlineImageCandidates as me, countInlinedImageParts as he, getSendableAttachments as ge, toMessageAttachment as _e } from "../../utils/assistantAttachments.js";
|
|
24
24
|
import { isMultimodalBodyRejection as ve, isRecoverableAssistantError as ye } from "../../utils/assistantTransportErrors.js";
|
|
25
25
|
import { isTurnInFlight as be } from "../../utils/assistantTurnState.js";
|
|
26
26
|
import { ASSISTANT_MODES as xe } from "../../types/assistant.js";
|
|
@@ -66,18 +66,18 @@ function We(e, t) {
|
|
|
66
66
|
content: "Thinking...",
|
|
67
67
|
done: !1
|
|
68
68
|
};
|
|
69
|
-
let r = n[n.length - 1], i = A(r.parts), a = O(r.parts), o = j(r.parts),
|
|
69
|
+
let r = n[n.length - 1], i = A(r.parts), a = O(r.parts), o = j(r.parts), s = Ce(r.parts), c = [
|
|
70
70
|
i,
|
|
71
71
|
...a,
|
|
72
72
|
...o
|
|
73
|
-
].filter(Boolean).join("\n\n") || "Thinking...",
|
|
73
|
+
].filter(Boolean).join("\n\n") || "Thinking...", l = r.info?.providerID, u = r.info?.modelID;
|
|
74
74
|
return {
|
|
75
|
-
content:
|
|
75
|
+
content: c,
|
|
76
76
|
done: !!r.info?.time?.completed && (!!i || a.length > 0 || o.length > 0),
|
|
77
77
|
tokens: r.info?.tokens,
|
|
78
78
|
messageId: r.info?.id,
|
|
79
|
-
...
|
|
80
|
-
...
|
|
79
|
+
...l && u ? { model: `${l}/${u}` } : {},
|
|
80
|
+
...s ? { pendingWrite: s } : {}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
function Ge(e) {
|
|
@@ -89,84 +89,84 @@ function Ge(e) {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
var Ke = ({ visible: Ce = !0 }) => {
|
|
92
|
-
let O = Re(), A = Ie("workspace"), { getAccessToken: j, getWorkspaceToken: Ke, userId: qe } = Le(), { locale: Je } = Pe(), Ye = e((e) => e.assistantLanguage), Xe = e((e) => e.replyLanguage), Ze = T(() =>
|
|
92
|
+
let O = Re(), A = Ie("workspace"), { getAccessToken: j, getWorkspaceToken: Ke, userId: qe } = Le(), { locale: Je } = Pe(), Ye = e((e) => e.assistantLanguage), Xe = e((e) => e.replyLanguage), Ze = T(() => m(Ye, Xe, Je), [
|
|
93
93
|
Ye,
|
|
94
94
|
Xe,
|
|
95
95
|
Je
|
|
96
|
-
]), Qe = Ze.reply.english, $e = Ze.replyIsExplicit, et = Ze.reply.code, { conversations: tt, activeConversationId: M, mode: N, processingByConversationId: nt, setMode: P, setConversationMode:
|
|
96
|
+
]), Qe = Ze.reply.english, $e = Ze.replyIsExplicit, et = Ze.reply.code, { conversations: tt, activeConversationId: M, mode: N, processingByConversationId: nt, setMode: P, setConversationMode: rt, setActiveConversation: it, createConversation: F, addMessage: I, updateMessage: at, patchMessage: L, mergeMessageMetadata: ot, setConversationProcessing: R, clearConversationProcessing: st, setBackendSessionId: ct, clearBackendSessionId: z, setSandbox: B, clearSandbox: lt, acknowledgeApiCalls: ut } = e(), V = ie(tt.find((e) => e.id === M)), dt = V.all, ft = M ? nt[M] : void 0, H = be(ft?.status), pt = H ? ft?.messageId ?? null : null, mt = ft?.status === "error" ? ft.messageId : null, { canUseApiCalls: U, loading: ht } = S(oe()), gt = ne(ae(), se() || null), _t = T(() => xe.filter((e) => !e.requiresAdmin || U), [U]), [vt, yt] = Ne(null), [bt, xt] = Ne(!1), St = E({}), W = E(Me()), Ct = E(/* @__PURE__ */ new Set()), G = T(() => xe.find((e) => e.id === N), [N]);
|
|
97
97
|
w(() => {
|
|
98
|
-
|
|
98
|
+
ht || (!G || G.requiresAdmin && !U) && N !== "assistant" && P("assistant");
|
|
99
99
|
}, [
|
|
100
100
|
N,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
G,
|
|
102
|
+
U,
|
|
103
|
+
ht,
|
|
104
104
|
P
|
|
105
105
|
]);
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
}, [
|
|
109
|
-
let
|
|
110
|
-
if (
|
|
106
|
+
let K = C((e, t, n, r) => {
|
|
107
|
+
R(e, n, t, null), r ? at(e, t, r) : at(e, t, Ge(n));
|
|
108
|
+
}, [R, at]), wt = C(async (r, a, o, c, l) => {
|
|
109
|
+
let f = e.getState().sandboxesByMode[o]?.sandboxId ?? null, p = async (e) => {
|
|
110
|
+
if (W.current.isFresh(e)) return !0;
|
|
111
111
|
try {
|
|
112
|
-
return await
|
|
112
|
+
return await d(A, e, c, l, 3e5, (e) => K(r, a, "provisioning", e)), await u(A, e, c, l, 9e4, (e) => K(r, a, "connecting", e)), W.current.markVerified(e), !0;
|
|
113
113
|
} catch {
|
|
114
|
-
return
|
|
114
|
+
return W.current.invalidate(e), !1;
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
let e = await i(A,
|
|
120
|
-
e && (
|
|
117
|
+
if (f && (B(o, f, "provisioning"), K(r, a, "provisioning", "Reusing assistant environment..."), await p(f) || (B(o, null, "provisioning"), f = null)), !f) {
|
|
118
|
+
K(r, a, "provisioning", "Looking for existing environment...");
|
|
119
|
+
let e = await i(A, c, o, l);
|
|
120
|
+
e && (B(o, e, "provisioning"), K(r, a, "provisioning", "Reusing assistant environment..."), await p(e) ? f = e : B(o, null, "provisioning"));
|
|
121
121
|
}
|
|
122
|
-
if (!
|
|
122
|
+
if (!f) {
|
|
123
123
|
if (o === "api-calls" && !j()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
124
|
-
|
|
124
|
+
K(r, a, "provisioning", "Starting assistant environment..."), B(o, null, "provisioning"), f = await t(A, o, c, l), B(o, f, "provisioning"), await d(A, f, c, l, 3e5, (e) => K(r, a, "provisioning", e)), await u(A, f, c, l, 9e4, (e) => K(r, a, "connecting", e));
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
let
|
|
128
|
-
if (
|
|
129
|
-
let e = await
|
|
126
|
+
B(o, f, "running");
|
|
127
|
+
let m = e.getState().conversations.find((e) => e.id === r)?.backendSessionId ?? null;
|
|
128
|
+
if (m) try {
|
|
129
|
+
let e = await s(A, f, c, m, l);
|
|
130
130
|
if (e.mode !== o) throw Error(`Session mode mismatch: expected ${o}, received ${e.mode}`);
|
|
131
131
|
} catch {
|
|
132
|
-
|
|
132
|
+
z(r), m = null;
|
|
133
133
|
}
|
|
134
|
-
return
|
|
135
|
-
sandboxId:
|
|
136
|
-
sessionId:
|
|
134
|
+
return m || (K(r, a, "connecting", "Preparing session..."), m = (await n(A, f, c, o, l)).sessionId, ct(r, m)), {
|
|
135
|
+
sandboxId: f,
|
|
136
|
+
sessionId: m
|
|
137
137
|
};
|
|
138
138
|
}, [
|
|
139
139
|
A,
|
|
140
|
-
|
|
140
|
+
z,
|
|
141
141
|
j,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
]),
|
|
146
|
-
let
|
|
147
|
-
if (
|
|
148
|
-
let
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
let
|
|
142
|
+
ct,
|
|
143
|
+
B,
|
|
144
|
+
K
|
|
145
|
+
]), q = C(async (t, n = [], i = {}) => {
|
|
146
|
+
let s = i.voiceSessionId !== void 0, u = e.getState(), d = u.activeConversationId ?? M;
|
|
147
|
+
if (d && (be(u.processingByConversationId[d]?.status) || Ct.current.has(d))) return;
|
|
148
|
+
let p = u.mode, m = M, h = m ? e.getState().conversations.find((e) => e.id === m) : void 0;
|
|
149
|
+
if (m ? h && h.mode !== p && (h.messages.length > 0 || h.backendSessionId) ? m = F(void 0, p) : h && h.mode !== p && rt(m, p) : m = F(void 0, p), !m) return;
|
|
150
|
+
St.current[m] = n;
|
|
151
|
+
let g = se(), _ = {
|
|
152
152
|
accessToken: j(),
|
|
153
153
|
workspaceToken: Ke(),
|
|
154
154
|
userId: qe,
|
|
155
|
-
organizationId:
|
|
156
|
-
},
|
|
155
|
+
organizationId: oe()
|
|
156
|
+
}, v = {
|
|
157
157
|
id: Ue(),
|
|
158
158
|
role: "user",
|
|
159
159
|
content: t,
|
|
160
160
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
161
161
|
metadata: {
|
|
162
|
-
...n.length ? { attachments: n.map(
|
|
162
|
+
...n.length ? { attachments: n.map(_e) } : {},
|
|
163
163
|
...Ae(i.voiceSessionId)
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
|
|
167
|
-
let
|
|
168
|
-
|
|
169
|
-
id:
|
|
166
|
+
I(m, v);
|
|
167
|
+
let y = Ue();
|
|
168
|
+
I(m, {
|
|
169
|
+
id: y,
|
|
170
170
|
role: "assistant",
|
|
171
171
|
content: "",
|
|
172
172
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -174,12 +174,12 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
174
174
|
lang: et,
|
|
175
175
|
...Ae(i.voiceSessionId)
|
|
176
176
|
}
|
|
177
|
-
}),
|
|
178
|
-
let
|
|
179
|
-
|
|
177
|
+
}), R(m, "provisioning", y, null);
|
|
178
|
+
let ee = (e, t, n, r, a = et) => {
|
|
179
|
+
L(m, y, { content: ze(e) }), ot(m, y, {
|
|
180
180
|
lang: a,
|
|
181
181
|
...t?.length ? { artifacts: t } : {},
|
|
182
|
-
...t?.length || n || r ? { mode:
|
|
182
|
+
...t?.length || n || r ? { mode: p } : {},
|
|
183
183
|
...n ? { sessionId: n } : {},
|
|
184
184
|
...r ? { sandboxId: r } : {},
|
|
185
185
|
...Ae(i.voiceSessionId)
|
|
@@ -187,108 +187,108 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
187
187
|
}, b = async (e = 1) => {
|
|
188
188
|
let i = !1;
|
|
189
189
|
try {
|
|
190
|
-
let { sandboxId: e, sessionId:
|
|
191
|
-
|
|
192
|
-
let
|
|
193
|
-
i =
|
|
190
|
+
let { sandboxId: e, sessionId: u } = await wt(m, y, p, g, _), d = (await o(A, e, g, u, _, 50).catch(() => [])).reduce((e, t) => Math.max(e, k(t)), 0);
|
|
191
|
+
K(m, y, "streaming", "Thinking...");
|
|
192
|
+
let h = de(p, pe(t, n), Qe, $e, s), v = fe(h, n), b = he(v), x = b > 0, te = f();
|
|
193
|
+
i = me(n) > b;
|
|
194
194
|
try {
|
|
195
|
-
await
|
|
195
|
+
await l(A, e, g, u, h, p, te, _, v);
|
|
196
196
|
} catch (t) {
|
|
197
|
-
if (!
|
|
198
|
-
await
|
|
197
|
+
if (!v || !ve(t)) throw t;
|
|
198
|
+
await l(A, e, g, u, h, p, te, _, void 0), i ||= x;
|
|
199
199
|
}
|
|
200
|
-
let
|
|
201
|
-
for (; Date.now() <
|
|
202
|
-
if (!
|
|
203
|
-
let
|
|
204
|
-
if (
|
|
205
|
-
...
|
|
206
|
-
content: `${
|
|
207
|
-
}), i && (
|
|
208
|
-
...
|
|
209
|
-
content: `${
|
|
210
|
-
}),
|
|
211
|
-
|
|
200
|
+
let S = We([], d), ne = Date.now() + (Be[p] ?? Ve), re = Date.now(), ie = Date.now();
|
|
201
|
+
for (; Date.now() < ne && (S = We(await o(A, e, g, u, _, 50, d), d), L(m, y, { content: ze(S.content) }), S.pendingWrite && ot(m, y, { pendingWrite: S.pendingWrite }), !S.done);) Date.now() - re > 3e4 && (await r(A, e, g, 600, _).catch(() => void 0), re = Date.now()), await new Promise((e) => setTimeout(e, Se(Date.now() - ie)));
|
|
202
|
+
if (!S.done && p !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
|
|
203
|
+
let ae = p === "vibe-plugins" ? await a(A, e, g, u, _).catch(() => []) : void 0;
|
|
204
|
+
if (S.done || (S = {
|
|
205
|
+
...S,
|
|
206
|
+
content: `${S.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
|
|
207
|
+
}), i && (S = {
|
|
208
|
+
...S,
|
|
209
|
+
content: `${S.content}\n\n${O("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
|
+
}), ee(S.content, ae, u, e), S.tokens) {
|
|
211
|
+
L(m, y, { tokens: S.tokens });
|
|
212
212
|
try {
|
|
213
|
-
await
|
|
213
|
+
await c(A, g, u, S.messageId, S.model, S.tokens, _), le();
|
|
214
214
|
} catch {}
|
|
215
215
|
}
|
|
216
|
-
|
|
216
|
+
R(m, "complete", y, null);
|
|
217
217
|
} catch (t) {
|
|
218
|
-
if (e === 1 && ye(t)) return
|
|
218
|
+
if (e === 1 && ye(t)) return z(m), lt(p), b(2);
|
|
219
219
|
throw t;
|
|
220
220
|
}
|
|
221
|
-
},
|
|
222
|
-
|
|
221
|
+
}, x = m;
|
|
222
|
+
Ct.current.add(x);
|
|
223
223
|
try {
|
|
224
|
-
if (!
|
|
224
|
+
if (!g) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
225
225
|
await b();
|
|
226
226
|
} catch (t) {
|
|
227
|
-
if (
|
|
228
|
-
|
|
227
|
+
if (W.current.invalidate(e.getState().sandboxesByMode[p]?.sandboxId ?? null), ue(t)) {
|
|
228
|
+
ce("sandbox"), ee("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant.", void 0, void 0, void 0, "en"), R(m, "error", y, null);
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
let n = t instanceof Error ? t.message : "Something went wrong";
|
|
232
|
-
|
|
232
|
+
R(m, "error", y, n), L(m, y, { content: `Sorry, an error occurred: ${n}. Please try again.` }), ot(m, y, {
|
|
233
233
|
lang: "en",
|
|
234
234
|
...Ae(i.voiceSessionId)
|
|
235
235
|
});
|
|
236
236
|
} finally {
|
|
237
|
-
|
|
237
|
+
Ct.current.delete(x);
|
|
238
238
|
}
|
|
239
239
|
}, [
|
|
240
240
|
M,
|
|
241
|
-
|
|
241
|
+
I,
|
|
242
242
|
A,
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
z,
|
|
244
|
+
lt,
|
|
245
245
|
tt,
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
F,
|
|
247
|
+
wt,
|
|
248
248
|
j,
|
|
249
249
|
Ke,
|
|
250
|
-
|
|
250
|
+
L,
|
|
251
251
|
$e,
|
|
252
252
|
et,
|
|
253
253
|
Qe,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
ct,
|
|
255
|
+
rt,
|
|
256
|
+
R,
|
|
257
257
|
O,
|
|
258
|
-
|
|
258
|
+
K,
|
|
259
259
|
qe
|
|
260
|
-
]),
|
|
261
|
-
|
|
262
|
-
}, [
|
|
263
|
-
let e = [...
|
|
264
|
-
e &&
|
|
260
|
+
]), Tt = C((e) => {
|
|
261
|
+
q(e);
|
|
262
|
+
}, [q]), Et = C(() => {
|
|
263
|
+
let e = [...V.chat].reverse().find((e) => e.role === "user"), t = M ? St.current[M] ?? [] : [];
|
|
264
|
+
e && q(e.content, t);
|
|
265
265
|
}, [
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
dt,
|
|
267
|
+
q,
|
|
268
268
|
M
|
|
269
|
-
]),
|
|
269
|
+
]), J = E(q);
|
|
270
270
|
w(() => {
|
|
271
|
-
|
|
272
|
-
}, [
|
|
273
|
-
let
|
|
274
|
-
if (
|
|
275
|
-
for (let e =
|
|
276
|
-
let t =
|
|
271
|
+
J.current = q;
|
|
272
|
+
}, [q]);
|
|
273
|
+
let Y = T(() => {
|
|
274
|
+
if (H) return null;
|
|
275
|
+
for (let e = dt.length - 1; e >= 0; --e) {
|
|
276
|
+
let t = dt[e];
|
|
277
277
|
if (t?.role !== "assistant" || !ke(t)) continue;
|
|
278
|
-
let n =
|
|
278
|
+
let n = x(t.content).text.trim();
|
|
279
279
|
return n ? {
|
|
280
280
|
id: t.id,
|
|
281
281
|
text: n
|
|
282
282
|
} : null;
|
|
283
283
|
}
|
|
284
284
|
return null;
|
|
285
|
-
}, [
|
|
285
|
+
}, [dt, H]), Dt = T(() => Y ? we(Y.text) : null, [Y]), Ot = V.chat, X = T(() => V.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
286
286
|
id: e.id,
|
|
287
287
|
role: e.role,
|
|
288
|
-
text:
|
|
288
|
+
text: x(e.content).text.trim(),
|
|
289
289
|
sessionId: je(e),
|
|
290
290
|
timestamp: e.timestamp
|
|
291
|
-
})).filter((e) => e.text.length > 0), [
|
|
291
|
+
})).filter((e) => e.text.length > 0), [V.voice]), kt = C(() => {
|
|
292
292
|
if (X.length === 0) return;
|
|
293
293
|
let e = /* @__PURE__ */ new Date();
|
|
294
294
|
Oe(Ee(X, {
|
|
@@ -299,13 +299,13 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
299
299
|
you: O("voiceSession.speakerYou", "You"),
|
|
300
300
|
assistant: O("voiceSession.speakerAssistant", "Assistant")
|
|
301
301
|
}, e), De(e), "text/markdown");
|
|
302
|
-
}, [X, O]), Z =
|
|
302
|
+
}, [X, O]), Z = re(), Q = E(Z);
|
|
303
303
|
Q.current = Z;
|
|
304
|
-
let $ =
|
|
304
|
+
let $ = te({
|
|
305
305
|
onSubmit: C((e, t) => {
|
|
306
306
|
let n = () => {
|
|
307
|
-
let n = Q.current, r =
|
|
308
|
-
|
|
307
|
+
let n = Q.current, r = ge(n.attachments);
|
|
308
|
+
J.current(e, r, { voiceSessionId: t }), n.clear();
|
|
309
309
|
};
|
|
310
310
|
if (!Q.current.isBusy) {
|
|
311
311
|
n();
|
|
@@ -315,11 +315,11 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
315
315
|
Q.current.isBusy && Date.now() - r < He || (window.clearInterval(i), n());
|
|
316
316
|
}, 200);
|
|
317
317
|
}, []),
|
|
318
|
-
latestReply:
|
|
319
|
-
language:
|
|
318
|
+
latestReply: Y,
|
|
319
|
+
language: p(Ye, Je).tag
|
|
320
320
|
}), At = C(() => {
|
|
321
321
|
let t = e.getState().activeConversationId;
|
|
322
|
-
!t || X.length === 0 || (
|
|
322
|
+
!t || X.length === 0 || (I(t, {
|
|
323
323
|
id: Ue(),
|
|
324
324
|
role: "system",
|
|
325
325
|
content: Te(X, {
|
|
@@ -328,10 +328,10 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
328
328
|
more: (e) => O("voiceSession.continuedMore", "…and {{count}} more", { count: e })
|
|
329
329
|
}),
|
|
330
330
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
331
|
-
}),
|
|
331
|
+
}), xt(!1), $.end());
|
|
332
332
|
}, [
|
|
333
333
|
X,
|
|
334
|
-
|
|
334
|
+
I,
|
|
335
335
|
O
|
|
336
336
|
]);
|
|
337
337
|
w(() => {
|
|
@@ -340,10 +340,10 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
340
340
|
$.active || Q.current.clear();
|
|
341
341
|
}, [$.active]), w(() => {
|
|
342
342
|
let t = e.getState().consumePendingPrompt();
|
|
343
|
-
return t &&
|
|
343
|
+
return t && J.current(t), e.subscribe((t, n) => {
|
|
344
344
|
if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
|
|
345
345
|
let t = e.getState().consumePendingPrompt();
|
|
346
|
-
t &&
|
|
346
|
+
t && J.current(t);
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
349
|
}, []);
|
|
@@ -352,31 +352,31 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
352
352
|
if (n && (n.messages.length > 0 || n.backendSessionId)) {
|
|
353
353
|
if (n.mode !== t) {
|
|
354
354
|
let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
|
|
355
|
-
n ?
|
|
355
|
+
n ? it(n.id) : F(void 0, t);
|
|
356
356
|
}
|
|
357
|
-
} else M &&
|
|
357
|
+
} else M && rt(M, t);
|
|
358
358
|
P(t);
|
|
359
359
|
}, [
|
|
360
360
|
M,
|
|
361
|
-
I,
|
|
362
|
-
rt,
|
|
363
361
|
F,
|
|
362
|
+
it,
|
|
363
|
+
rt,
|
|
364
364
|
P
|
|
365
365
|
]), Mt = C((t) => {
|
|
366
366
|
if (xe.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
|
|
367
|
-
|
|
367
|
+
yt(t);
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
370
370
|
jt(t);
|
|
371
371
|
}, [jt]), Nt = C(() => {
|
|
372
|
-
let e =
|
|
373
|
-
|
|
372
|
+
let e = vt;
|
|
373
|
+
yt(null), ut(), e && jt(e);
|
|
374
374
|
}, [
|
|
375
|
-
|
|
376
|
-
|
|
375
|
+
vt,
|
|
376
|
+
ut,
|
|
377
377
|
jt
|
|
378
378
|
]), Pt = C(() => {
|
|
379
|
-
|
|
379
|
+
yt(null);
|
|
380
380
|
}, []);
|
|
381
381
|
return /* @__PURE__ */ Fe("div", {
|
|
382
382
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
@@ -385,40 +385,40 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
385
385
|
className: "contents",
|
|
386
386
|
inert: $.active || void 0,
|
|
387
387
|
children: [
|
|
388
|
-
X.length > 0 && !$.active ? /* @__PURE__ */ D(
|
|
388
|
+
X.length > 0 && !$.active ? /* @__PURE__ */ D(v, {
|
|
389
389
|
count: X.length,
|
|
390
|
-
onOpenTranscript: () =>
|
|
390
|
+
onOpenTranscript: () => xt(!0)
|
|
391
391
|
}) : null,
|
|
392
|
-
Ot.length === 0 ? /* @__PURE__ */ D(
|
|
392
|
+
Ot.length === 0 ? /* @__PURE__ */ D(_, {
|
|
393
393
|
mode: N,
|
|
394
|
-
onSuggestionClick:
|
|
394
|
+
onSuggestionClick: Tt
|
|
395
395
|
}) : /* @__PURE__ */ D("div", {
|
|
396
396
|
className: "flex min-h-0 flex-1 flex-col",
|
|
397
|
-
children: /* @__PURE__ */ D(
|
|
397
|
+
children: /* @__PURE__ */ D(h, {
|
|
398
398
|
messages: Ot,
|
|
399
|
-
streamingMessageId:
|
|
400
|
-
failedMessageId:
|
|
401
|
-
onRetry:
|
|
399
|
+
streamingMessageId: pt,
|
|
400
|
+
failedMessageId: mt,
|
|
401
|
+
onRetry: Et
|
|
402
402
|
})
|
|
403
403
|
}),
|
|
404
|
-
/* @__PURE__ */ D(
|
|
404
|
+
/* @__PURE__ */ D(ee, {
|
|
405
405
|
onStartVoiceSession: $.available && N !== "api-calls" ? $.start : void 0,
|
|
406
|
-
onSend: (e, t) => void
|
|
407
|
-
disabled:
|
|
406
|
+
onSend: (e, t) => void q(e, t),
|
|
407
|
+
disabled: H,
|
|
408
408
|
placeholder: N === "api-calls" ? O("chatArea.placeholderActions", "What would you like me to do?") : O("chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
|
|
409
409
|
mode: N,
|
|
410
|
-
writeAccessDenied:
|
|
411
|
-
availableModes:
|
|
410
|
+
writeAccessDenied: gt === "denied" && !!G?.writeCapable,
|
|
411
|
+
availableModes: _t,
|
|
412
412
|
onModeChange: Mt
|
|
413
413
|
})
|
|
414
414
|
]
|
|
415
415
|
}),
|
|
416
|
-
|
|
416
|
+
bt && !$.active ? /* @__PURE__ */ D(y, {
|
|
417
417
|
turns: X,
|
|
418
|
-
onClose: () =>
|
|
418
|
+
onClose: () => xt(!1),
|
|
419
419
|
onSave: kt
|
|
420
420
|
}) : null,
|
|
421
|
-
$.active && /* @__PURE__ */ D(
|
|
421
|
+
$.active && /* @__PURE__ */ D(b, {
|
|
422
422
|
session: $.session,
|
|
423
423
|
notice: $.notice,
|
|
424
424
|
capturing: $.capturing,
|
|
@@ -439,8 +439,8 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
439
439
|
onToggleMute: $.toggleMute,
|
|
440
440
|
onEnd: $.end
|
|
441
441
|
}),
|
|
442
|
-
/* @__PURE__ */ D(
|
|
443
|
-
open:
|
|
442
|
+
/* @__PURE__ */ D(g, {
|
|
443
|
+
open: vt !== null,
|
|
444
444
|
onConfirm: Nt,
|
|
445
445
|
onCancel: Pt
|
|
446
446
|
})
|