@burdenoff/microfe-healthybowl 2026.904.24 → 2026.904.26
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 +169 -169
- 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/pages/pest-management/AiPestDetectionPage.js +13 -13
- package/dist/healthybowl/pages/pest-management/AiPestDetectionPage.js.map +1 -1
- package/dist/healthybowl/pages/terrace/JournalEntryModal.js +165 -165
- package/dist/healthybowl/pages/terrace/JournalEntryModal.js.map +1 -1
- 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,7 +66,7 @@ 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);
|
|
70
70
|
return {
|
|
71
71
|
content: [
|
|
72
72
|
i,
|
|
@@ -75,7 +75,7 @@ function We(e, t) {
|
|
|
75
75
|
].filter(Boolean).join("\n\n") || "Thinking...",
|
|
76
76
|
done: !!r.info?.time?.completed && (!!i || a.length > 0 || o.length > 0),
|
|
77
77
|
tokens: r.info?.tokens,
|
|
78
|
-
...
|
|
78
|
+
...s ? { pendingWrite: s } : {}
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
function Ge(e) {
|
|
@@ -87,84 +87,84 @@ function Ge(e) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
var Ke = ({ visible: Ce = !0 }) => {
|
|
90
|
-
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(() =>
|
|
90
|
+
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), [
|
|
91
91
|
Ye,
|
|
92
92
|
Xe,
|
|
93
93
|
Je
|
|
94
|
-
]), Qe = Ze.reply.english, $e = Ze.replyIsExplicit, et = Ze.reply.code, { conversations: tt, activeConversationId: M, mode: N, processingByConversationId: nt, setMode: P, setConversationMode:
|
|
94
|
+
]), 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]);
|
|
95
95
|
w(() => {
|
|
96
|
-
|
|
96
|
+
ht || (!G || G.requiresAdmin && !U) && N !== "assistant" && P("assistant");
|
|
97
97
|
}, [
|
|
98
98
|
N,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
G,
|
|
100
|
+
U,
|
|
101
|
+
ht,
|
|
102
102
|
P
|
|
103
103
|
]);
|
|
104
|
-
let
|
|
105
|
-
|
|
106
|
-
}, [
|
|
107
|
-
let
|
|
108
|
-
if (
|
|
104
|
+
let K = C((e, t, n, r) => {
|
|
105
|
+
R(e, n, t, null), r ? at(e, t, r) : at(e, t, Ge(n));
|
|
106
|
+
}, [R, at]), wt = C(async (r, a, o, c, l) => {
|
|
107
|
+
let f = e.getState().sandboxesByMode[o]?.sandboxId ?? null, p = async (e) => {
|
|
108
|
+
if (W.current.isFresh(e)) return !0;
|
|
109
109
|
try {
|
|
110
|
-
return await
|
|
110
|
+
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;
|
|
111
111
|
} catch {
|
|
112
|
-
return
|
|
112
|
+
return W.current.invalidate(e), !1;
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
let e = await i(A,
|
|
118
|
-
e && (
|
|
115
|
+
if (f && (B(o, f, "provisioning"), K(r, a, "provisioning", "Reusing assistant environment..."), await p(f) || (B(o, null, "provisioning"), f = null)), !f) {
|
|
116
|
+
K(r, a, "provisioning", "Looking for existing environment...");
|
|
117
|
+
let e = await i(A, c, o, l);
|
|
118
|
+
e && (B(o, e, "provisioning"), K(r, a, "provisioning", "Reusing assistant environment..."), await p(e) ? f = e : B(o, null, "provisioning"));
|
|
119
119
|
}
|
|
120
|
-
if (!
|
|
120
|
+
if (!f) {
|
|
121
121
|
if (o === "api-calls" && !j()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
122
|
-
|
|
122
|
+
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));
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
let
|
|
126
|
-
if (
|
|
127
|
-
let e = await
|
|
124
|
+
B(o, f, "running");
|
|
125
|
+
let m = e.getState().conversations.find((e) => e.id === r)?.backendSessionId ?? null;
|
|
126
|
+
if (m) try {
|
|
127
|
+
let e = await s(A, f, c, m, l);
|
|
128
128
|
if (e.mode !== o) throw Error(`Session mode mismatch: expected ${o}, received ${e.mode}`);
|
|
129
129
|
} catch {
|
|
130
|
-
|
|
130
|
+
z(r), m = null;
|
|
131
131
|
}
|
|
132
|
-
return
|
|
133
|
-
sandboxId:
|
|
134
|
-
sessionId:
|
|
132
|
+
return m || (K(r, a, "connecting", "Preparing session..."), m = (await n(A, f, c, o, l)).sessionId, ct(r, m)), {
|
|
133
|
+
sandboxId: f,
|
|
134
|
+
sessionId: m
|
|
135
135
|
};
|
|
136
136
|
}, [
|
|
137
137
|
A,
|
|
138
|
-
|
|
138
|
+
z,
|
|
139
139
|
j,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
]),
|
|
144
|
-
let
|
|
145
|
-
if (
|
|
146
|
-
let
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
let
|
|
140
|
+
ct,
|
|
141
|
+
B,
|
|
142
|
+
K
|
|
143
|
+
]), q = C(async (t, n = [], i = {}) => {
|
|
144
|
+
let s = i.voiceSessionId !== void 0, u = e.getState(), d = u.activeConversationId ?? M;
|
|
145
|
+
if (d && (be(u.processingByConversationId[d]?.status) || Ct.current.has(d))) return;
|
|
146
|
+
let p = u.mode, m = M, h = m ? e.getState().conversations.find((e) => e.id === m) : void 0;
|
|
147
|
+
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;
|
|
148
|
+
St.current[m] = n;
|
|
149
|
+
let g = se(), _ = {
|
|
150
150
|
accessToken: j(),
|
|
151
151
|
workspaceToken: Ke(),
|
|
152
152
|
userId: qe,
|
|
153
|
-
organizationId:
|
|
154
|
-
},
|
|
153
|
+
organizationId: oe()
|
|
154
|
+
}, v = {
|
|
155
155
|
id: Ue(),
|
|
156
156
|
role: "user",
|
|
157
157
|
content: t,
|
|
158
158
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
159
159
|
metadata: {
|
|
160
|
-
...n.length ? { attachments: n.map(
|
|
160
|
+
...n.length ? { attachments: n.map(_e) } : {},
|
|
161
161
|
...Ae(i.voiceSessionId)
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
|
-
|
|
165
|
-
let
|
|
166
|
-
|
|
167
|
-
id:
|
|
164
|
+
I(m, v);
|
|
165
|
+
let y = Ue();
|
|
166
|
+
I(m, {
|
|
167
|
+
id: y,
|
|
168
168
|
role: "assistant",
|
|
169
169
|
content: "",
|
|
170
170
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -172,12 +172,12 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
172
172
|
lang: et,
|
|
173
173
|
...Ae(i.voiceSessionId)
|
|
174
174
|
}
|
|
175
|
-
}),
|
|
176
|
-
let
|
|
177
|
-
|
|
175
|
+
}), R(m, "provisioning", y, null);
|
|
176
|
+
let ee = (e, t, n, r, a = et) => {
|
|
177
|
+
L(m, y, { content: ze(e) }), ot(m, y, {
|
|
178
178
|
lang: a,
|
|
179
179
|
...t?.length ? { artifacts: t } : {},
|
|
180
|
-
...t?.length || n || r ? { mode:
|
|
180
|
+
...t?.length || n || r ? { mode: p } : {},
|
|
181
181
|
...n ? { sessionId: n } : {},
|
|
182
182
|
...r ? { sandboxId: r } : {},
|
|
183
183
|
...Ae(i.voiceSessionId)
|
|
@@ -185,108 +185,108 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
185
185
|
}, b = async (e = 1) => {
|
|
186
186
|
let i = !1;
|
|
187
187
|
try {
|
|
188
|
-
let { sandboxId: e, sessionId:
|
|
189
|
-
|
|
190
|
-
let
|
|
191
|
-
i =
|
|
188
|
+
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);
|
|
189
|
+
K(m, y, "streaming", "Thinking...");
|
|
190
|
+
let h = de(p, pe(t, n), Qe, $e, s), v = fe(h, n), b = he(v), x = b > 0, te = f();
|
|
191
|
+
i = me(n) > b;
|
|
192
192
|
try {
|
|
193
|
-
await
|
|
193
|
+
await l(A, e, g, u, h, p, te, _, v);
|
|
194
194
|
} catch (t) {
|
|
195
|
-
if (!
|
|
196
|
-
await
|
|
195
|
+
if (!v || !ve(t)) throw t;
|
|
196
|
+
await l(A, e, g, u, h, p, te, _, void 0), i ||= x;
|
|
197
197
|
}
|
|
198
|
-
let
|
|
199
|
-
for (; Date.now() <
|
|
200
|
-
if (!
|
|
201
|
-
let
|
|
202
|
-
if (
|
|
203
|
-
...
|
|
204
|
-
content: `${
|
|
205
|
-
}), i && (
|
|
206
|
-
...
|
|
207
|
-
content: `${
|
|
208
|
-
}),
|
|
209
|
-
|
|
198
|
+
let S = We([], d), ne = Date.now() + (Be[p] ?? Ve), re = Date.now(), ie = Date.now();
|
|
199
|
+
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)));
|
|
200
|
+
if (!S.done && p !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
|
|
201
|
+
let ae = p === "vibe-plugins" ? await a(A, e, g, u, _).catch(() => []) : void 0;
|
|
202
|
+
if (S.done || (S = {
|
|
203
|
+
...S,
|
|
204
|
+
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._`
|
|
205
|
+
}), i && (S = {
|
|
206
|
+
...S,
|
|
207
|
+
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._")}`
|
|
208
|
+
}), ee(S.content, ae, u, e), S.tokens) {
|
|
209
|
+
L(m, y, { tokens: S.tokens });
|
|
210
210
|
try {
|
|
211
|
-
await
|
|
211
|
+
await c(A, g, u, S.tokens, _), le();
|
|
212
212
|
} catch {}
|
|
213
213
|
}
|
|
214
|
-
|
|
214
|
+
R(m, "complete", y, null);
|
|
215
215
|
} catch (t) {
|
|
216
|
-
if (e === 1 && ye(t)) return
|
|
216
|
+
if (e === 1 && ye(t)) return z(m), lt(p), b(2);
|
|
217
217
|
throw t;
|
|
218
218
|
}
|
|
219
|
-
},
|
|
220
|
-
|
|
219
|
+
}, x = m;
|
|
220
|
+
Ct.current.add(x);
|
|
221
221
|
try {
|
|
222
|
-
if (!
|
|
222
|
+
if (!g) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
223
223
|
await b();
|
|
224
224
|
} catch (t) {
|
|
225
|
-
if (
|
|
226
|
-
|
|
225
|
+
if (W.current.invalidate(e.getState().sandboxesByMode[p]?.sandboxId ?? null), ue(t)) {
|
|
226
|
+
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);
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
229
|
let n = t instanceof Error ? t.message : "Something went wrong";
|
|
230
|
-
|
|
230
|
+
R(m, "error", y, n), L(m, y, { content: `Sorry, an error occurred: ${n}. Please try again.` }), ot(m, y, {
|
|
231
231
|
lang: "en",
|
|
232
232
|
...Ae(i.voiceSessionId)
|
|
233
233
|
});
|
|
234
234
|
} finally {
|
|
235
|
-
|
|
235
|
+
Ct.current.delete(x);
|
|
236
236
|
}
|
|
237
237
|
}, [
|
|
238
238
|
M,
|
|
239
|
-
|
|
239
|
+
I,
|
|
240
240
|
A,
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
z,
|
|
242
|
+
lt,
|
|
243
243
|
tt,
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
F,
|
|
245
|
+
wt,
|
|
246
246
|
j,
|
|
247
247
|
Ke,
|
|
248
|
-
|
|
248
|
+
L,
|
|
249
249
|
$e,
|
|
250
250
|
et,
|
|
251
251
|
Qe,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
ct,
|
|
253
|
+
rt,
|
|
254
|
+
R,
|
|
255
255
|
O,
|
|
256
|
-
|
|
256
|
+
K,
|
|
257
257
|
qe
|
|
258
|
-
]),
|
|
259
|
-
|
|
260
|
-
}, [
|
|
261
|
-
let e = [...
|
|
262
|
-
e &&
|
|
258
|
+
]), Tt = C((e) => {
|
|
259
|
+
q(e);
|
|
260
|
+
}, [q]), Et = C(() => {
|
|
261
|
+
let e = [...V.chat].reverse().find((e) => e.role === "user"), t = M ? St.current[M] ?? [] : [];
|
|
262
|
+
e && q(e.content, t);
|
|
263
263
|
}, [
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
dt,
|
|
265
|
+
q,
|
|
266
266
|
M
|
|
267
|
-
]),
|
|
267
|
+
]), J = E(q);
|
|
268
268
|
w(() => {
|
|
269
|
-
|
|
270
|
-
}, [
|
|
271
|
-
let
|
|
272
|
-
if (
|
|
273
|
-
for (let e =
|
|
274
|
-
let t =
|
|
269
|
+
J.current = q;
|
|
270
|
+
}, [q]);
|
|
271
|
+
let Y = T(() => {
|
|
272
|
+
if (H) return null;
|
|
273
|
+
for (let e = dt.length - 1; e >= 0; --e) {
|
|
274
|
+
let t = dt[e];
|
|
275
275
|
if (t?.role !== "assistant" || !ke(t)) continue;
|
|
276
|
-
let n =
|
|
276
|
+
let n = x(t.content).text.trim();
|
|
277
277
|
return n ? {
|
|
278
278
|
id: t.id,
|
|
279
279
|
text: n
|
|
280
280
|
} : null;
|
|
281
281
|
}
|
|
282
282
|
return null;
|
|
283
|
-
}, [
|
|
283
|
+
}, [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) => ({
|
|
284
284
|
id: e.id,
|
|
285
285
|
role: e.role,
|
|
286
|
-
text:
|
|
286
|
+
text: x(e.content).text.trim(),
|
|
287
287
|
sessionId: je(e),
|
|
288
288
|
timestamp: e.timestamp
|
|
289
|
-
})).filter((e) => e.text.length > 0), [
|
|
289
|
+
})).filter((e) => e.text.length > 0), [V.voice]), kt = C(() => {
|
|
290
290
|
if (X.length === 0) return;
|
|
291
291
|
let e = /* @__PURE__ */ new Date();
|
|
292
292
|
Oe(Ee(X, {
|
|
@@ -297,13 +297,13 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
297
297
|
you: O("voiceSession.speakerYou", "You"),
|
|
298
298
|
assistant: O("voiceSession.speakerAssistant", "Assistant")
|
|
299
299
|
}, e), De(e), "text/markdown");
|
|
300
|
-
}, [X, O]), Z =
|
|
300
|
+
}, [X, O]), Z = re(), Q = E(Z);
|
|
301
301
|
Q.current = Z;
|
|
302
|
-
let $ =
|
|
302
|
+
let $ = te({
|
|
303
303
|
onSubmit: C((e, t) => {
|
|
304
304
|
let n = () => {
|
|
305
|
-
let n = Q.current, r =
|
|
306
|
-
|
|
305
|
+
let n = Q.current, r = ge(n.attachments);
|
|
306
|
+
J.current(e, r, { voiceSessionId: t }), n.clear();
|
|
307
307
|
};
|
|
308
308
|
if (!Q.current.isBusy) {
|
|
309
309
|
n();
|
|
@@ -313,11 +313,11 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
313
313
|
Q.current.isBusy && Date.now() - r < He || (window.clearInterval(i), n());
|
|
314
314
|
}, 200);
|
|
315
315
|
}, []),
|
|
316
|
-
latestReply:
|
|
317
|
-
language:
|
|
316
|
+
latestReply: Y,
|
|
317
|
+
language: p(Ye, Je).tag
|
|
318
318
|
}), At = C(() => {
|
|
319
319
|
let t = e.getState().activeConversationId;
|
|
320
|
-
!t || X.length === 0 || (
|
|
320
|
+
!t || X.length === 0 || (I(t, {
|
|
321
321
|
id: Ue(),
|
|
322
322
|
role: "system",
|
|
323
323
|
content: Te(X, {
|
|
@@ -326,10 +326,10 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
326
326
|
more: (e) => O("voiceSession.continuedMore", "…and {{count}} more", { count: e })
|
|
327
327
|
}),
|
|
328
328
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
329
|
-
}),
|
|
329
|
+
}), xt(!1), $.end());
|
|
330
330
|
}, [
|
|
331
331
|
X,
|
|
332
|
-
|
|
332
|
+
I,
|
|
333
333
|
O
|
|
334
334
|
]);
|
|
335
335
|
w(() => {
|
|
@@ -338,10 +338,10 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
338
338
|
$.active || Q.current.clear();
|
|
339
339
|
}, [$.active]), w(() => {
|
|
340
340
|
let t = e.getState().consumePendingPrompt();
|
|
341
|
-
return t &&
|
|
341
|
+
return t && J.current(t), e.subscribe((t, n) => {
|
|
342
342
|
if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
|
|
343
343
|
let t = e.getState().consumePendingPrompt();
|
|
344
|
-
t &&
|
|
344
|
+
t && J.current(t);
|
|
345
345
|
}
|
|
346
346
|
});
|
|
347
347
|
}, []);
|
|
@@ -350,31 +350,31 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
350
350
|
if (n && (n.messages.length > 0 || n.backendSessionId)) {
|
|
351
351
|
if (n.mode !== t) {
|
|
352
352
|
let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
|
|
353
|
-
n ?
|
|
353
|
+
n ? it(n.id) : F(void 0, t);
|
|
354
354
|
}
|
|
355
|
-
} else M &&
|
|
355
|
+
} else M && rt(M, t);
|
|
356
356
|
P(t);
|
|
357
357
|
}, [
|
|
358
358
|
M,
|
|
359
|
-
I,
|
|
360
|
-
rt,
|
|
361
359
|
F,
|
|
360
|
+
it,
|
|
361
|
+
rt,
|
|
362
362
|
P
|
|
363
363
|
]), Mt = C((t) => {
|
|
364
364
|
if (xe.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
|
|
365
|
-
|
|
365
|
+
yt(t);
|
|
366
366
|
return;
|
|
367
367
|
}
|
|
368
368
|
jt(t);
|
|
369
369
|
}, [jt]), Nt = C(() => {
|
|
370
|
-
let e =
|
|
371
|
-
|
|
370
|
+
let e = vt;
|
|
371
|
+
yt(null), ut(), e && jt(e);
|
|
372
372
|
}, [
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
vt,
|
|
374
|
+
ut,
|
|
375
375
|
jt
|
|
376
376
|
]), Pt = C(() => {
|
|
377
|
-
|
|
377
|
+
yt(null);
|
|
378
378
|
}, []);
|
|
379
379
|
return /* @__PURE__ */ Fe("div", {
|
|
380
380
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
@@ -383,40 +383,40 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
383
383
|
className: "contents",
|
|
384
384
|
inert: $.active || void 0,
|
|
385
385
|
children: [
|
|
386
|
-
X.length > 0 && !$.active ? /* @__PURE__ */ D(
|
|
386
|
+
X.length > 0 && !$.active ? /* @__PURE__ */ D(v, {
|
|
387
387
|
count: X.length,
|
|
388
|
-
onOpenTranscript: () =>
|
|
388
|
+
onOpenTranscript: () => xt(!0)
|
|
389
389
|
}) : null,
|
|
390
|
-
Ot.length === 0 ? /* @__PURE__ */ D(
|
|
390
|
+
Ot.length === 0 ? /* @__PURE__ */ D(_, {
|
|
391
391
|
mode: N,
|
|
392
|
-
onSuggestionClick:
|
|
392
|
+
onSuggestionClick: Tt
|
|
393
393
|
}) : /* @__PURE__ */ D("div", {
|
|
394
394
|
className: "flex min-h-0 flex-1 flex-col",
|
|
395
|
-
children: /* @__PURE__ */ D(
|
|
395
|
+
children: /* @__PURE__ */ D(h, {
|
|
396
396
|
messages: Ot,
|
|
397
|
-
streamingMessageId:
|
|
398
|
-
failedMessageId:
|
|
399
|
-
onRetry:
|
|
397
|
+
streamingMessageId: pt,
|
|
398
|
+
failedMessageId: mt,
|
|
399
|
+
onRetry: Et
|
|
400
400
|
})
|
|
401
401
|
}),
|
|
402
|
-
/* @__PURE__ */ D(
|
|
402
|
+
/* @__PURE__ */ D(ee, {
|
|
403
403
|
onStartVoiceSession: $.available && N !== "api-calls" ? $.start : void 0,
|
|
404
|
-
onSend: (e, t) => void
|
|
405
|
-
disabled:
|
|
404
|
+
onSend: (e, t) => void q(e, t),
|
|
405
|
+
disabled: H,
|
|
406
406
|
placeholder: N === "api-calls" ? O("chatArea.placeholderActions", "What would you like me to do?") : O("chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
|
|
407
407
|
mode: N,
|
|
408
|
-
writeAccessDenied:
|
|
409
|
-
availableModes:
|
|
408
|
+
writeAccessDenied: gt === "denied" && !!G?.writeCapable,
|
|
409
|
+
availableModes: _t,
|
|
410
410
|
onModeChange: Mt
|
|
411
411
|
})
|
|
412
412
|
]
|
|
413
413
|
}),
|
|
414
|
-
|
|
414
|
+
bt && !$.active ? /* @__PURE__ */ D(y, {
|
|
415
415
|
turns: X,
|
|
416
|
-
onClose: () =>
|
|
416
|
+
onClose: () => xt(!1),
|
|
417
417
|
onSave: kt
|
|
418
418
|
}) : null,
|
|
419
|
-
$.active && /* @__PURE__ */ D(
|
|
419
|
+
$.active && /* @__PURE__ */ D(b, {
|
|
420
420
|
session: $.session,
|
|
421
421
|
notice: $.notice,
|
|
422
422
|
capturing: $.capturing,
|
|
@@ -437,8 +437,8 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
437
437
|
onToggleMute: $.toggleMute,
|
|
438
438
|
onEnd: $.end
|
|
439
439
|
}),
|
|
440
|
-
/* @__PURE__ */ D(
|
|
441
|
-
open:
|
|
440
|
+
/* @__PURE__ */ D(g, {
|
|
441
|
+
open: vt !== null,
|
|
442
442
|
onConfirm: Nt,
|
|
443
443
|
onCancel: Pt
|
|
444
444
|
})
|