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