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