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