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