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