@burdenoff/fe-libs 2026.912.4 → 2026.912.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/attachments.d.ts +23 -0
- package/dist/shared/assistant/attachments.d.ts.map +1 -1
- package/dist/shared/assistant/attachments.js +100 -94
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/streamBudget.d.ts +57 -0
- package/dist/shared/assistant/streamBudget.d.ts.map +1 -0
- package/dist/shared/assistant/streamBudget.js +30 -0
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +95 -100
- package/dist/shared-assistant.js +93 -92
- package/package.json +1 -1
|
@@ -6,44 +6,40 @@ import { useAssistantTr as r } from "../i18n.js";
|
|
|
6
6
|
import { describeQuotaError as i } from "../quota.js";
|
|
7
7
|
import { abortAssistantTurn as a, approvePendingWrite as o, createAssistantSandbox as s, createAssistantSession as c, extendAssistantSandboxTTL as l, findExistingSandbox as u, getAssistantArtifacts as ee, getAssistantMessages as te, getAssistantSession as d, releaseSupersededAssistantSandboxes as f, sendAssistantPromptAsync as ne, waitForAssistantServiceReady as p, waitForSandboxRunning as m } from "../api.js";
|
|
8
8
|
import { getAssistantMedia as h, sanitize as re } from "../progress.js";
|
|
9
|
+
import { streamBudgetMs as ie, withIncompleteTurnNotice as ae } from "../streamBudget.js";
|
|
9
10
|
import { isVoiceTurn as g, voiceMarker as _, voiceSessionIdOf as v } from "../voice/turnVisibility.js";
|
|
10
|
-
import { buildContinuedFromVoiceNote as
|
|
11
|
-
import { pollDelayMs as
|
|
12
|
-
import { toCaptionText as
|
|
13
|
-
import { resolveAssistantLanguage as
|
|
14
|
-
import { resolveLanguagePair as
|
|
11
|
+
import { buildContinuedFromVoiceNote as oe, buildVoiceTranscriptMarkdown as y, voiceTranscriptFilename as se } from "../voice/voiceTranscript.js";
|
|
12
|
+
import { pollDelayMs as ce } from "../voice/assistantPollSchedule.js";
|
|
13
|
+
import { toCaptionText as le } from "../voice/captionText.js";
|
|
14
|
+
import { resolveAssistantLanguage as ue } from "../voice/languages.js";
|
|
15
|
+
import { resolveLanguagePair as de } from "../voice/languagePair.js";
|
|
15
16
|
import { findPendingWrite as b } from "../pendingWrite.js";
|
|
16
|
-
import { buildPromptParts as
|
|
17
|
+
import { buildPromptParts as fe, buildPromptWithAttachments as pe, countInlineImageCandidates as me, countInlinedImageParts as he, getSendableAttachments as ge, toMessageAttachment as _e } from "../attachments.js";
|
|
17
18
|
import { useAssistantStore as x } from "../store.js";
|
|
18
|
-
import { isTurnInFlight as
|
|
19
|
-
import { STAGE_COPY as S, isStageCopy as
|
|
20
|
-
import { parseToolActivity as
|
|
21
|
-
import { useVoiceSession as
|
|
22
|
-
import { getOrganizationId as
|
|
23
|
-
import { createReadinessTracker as
|
|
24
|
-
import { AssistantSpokenTurnsNotice as
|
|
25
|
-
import { VoiceTranscriptDrawer as
|
|
26
|
-
import { downloadFile as
|
|
27
|
-
import { AssistantEmptyState as
|
|
28
|
-
import { AssistantMessageList as
|
|
29
|
-
import { AssistantVoiceSession as
|
|
30
|
-
import { useAssistantApiAccess as
|
|
31
|
-
import { useConversationTurns as
|
|
32
|
-
import { isMultimodalBodyRejection as
|
|
33
|
-
import { dispatchAssistantQuotaExhausted as
|
|
34
|
-
import { useAssistantAttachments as
|
|
35
|
-
import { AssistantComposer as
|
|
36
|
-
import { isProdRuntime as
|
|
37
|
-
import { AssistantApiCallsConsentDialog as
|
|
38
|
-
import { useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as
|
|
39
|
-
import { jsx as O, jsxs as
|
|
19
|
+
import { isTurnInFlight as ve, planAbandonedTurn as ye, planTurnAbort as be } from "../turnState.js";
|
|
20
|
+
import { STAGE_COPY as S, isStageCopy as xe, stageText as C, statusStageCopy as Se, thinkingPhrase as Ce } from "../stageCopy.js";
|
|
21
|
+
import { parseToolActivity as we } from "./AssistantToolActivity.js";
|
|
22
|
+
import { useVoiceSession as Te } from "./useVoiceSession.js";
|
|
23
|
+
import { getOrganizationId as Ee, getWorkspaceId as De } from "../context.js";
|
|
24
|
+
import { createReadinessTracker as Oe } from "../sandboxReadiness.js";
|
|
25
|
+
import { AssistantSpokenTurnsNotice as ke } from "./AssistantSpokenTurnsNotice.js";
|
|
26
|
+
import { VoiceTranscriptDrawer as Ae } from "./voice/VoiceTranscriptDrawer.js";
|
|
27
|
+
import { downloadFile as je } from "../exportConversation.js";
|
|
28
|
+
import { AssistantEmptyState as Me } from "./AssistantEmptyState.js";
|
|
29
|
+
import { AssistantMessageList as Ne } from "./AssistantMessageList.js";
|
|
30
|
+
import { AssistantVoiceSession as Pe } from "./voice/AssistantVoiceSession.js";
|
|
31
|
+
import { useAssistantApiAccess as Fe } from "../useAssistantApiAccess.js";
|
|
32
|
+
import { useConversationTurns as Ie } from "../useConversationTurns.js";
|
|
33
|
+
import { isMultimodalBodyRejection as Le, isRecoverableAssistantError as Re } from "../transportErrors.js";
|
|
34
|
+
import { dispatchAssistantQuotaExhausted as ze, notifyAiCreditsUpdated as Be } from "../aiCredits.js";
|
|
35
|
+
import { useAssistantAttachments as Ve } from "../useAssistantAttachments.js";
|
|
36
|
+
import { AssistantComposer as He } from "./composer/AssistantComposer.js";
|
|
37
|
+
import { isProdRuntime as Ue } from "../env.js";
|
|
38
|
+
import { AssistantApiCallsConsentDialog as We } from "./AssistantApiCallsConsentDialog.js";
|
|
39
|
+
import { useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as Ge } from "react";
|
|
40
|
+
import { jsx as O, jsxs as Ke } from "react/jsx-runtime";
|
|
40
41
|
//#region src/shared/assistant/ui/AssistantChatArea.tsx
|
|
41
|
-
var
|
|
42
|
-
general: 18e4,
|
|
43
|
-
assistant: 18e4,
|
|
44
|
-
"api-calls": 18e4,
|
|
45
|
-
"vibe-plugins": 6e5
|
|
46
|
-
}, Ke = 18e4, qe = 600, Je = 2e4;
|
|
42
|
+
var qe = 600, Je = 2e4;
|
|
47
43
|
function Ye() {
|
|
48
44
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
49
45
|
}
|
|
@@ -80,11 +76,11 @@ function Ze(e, t) {
|
|
|
80
76
|
};
|
|
81
77
|
}
|
|
82
78
|
var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
83
|
-
let k = r(), { product: A, modes: j, gatherPageContext: Qe, buildPrompt: $e, reportTokenUsage: et } = n(), { getAccessToken: M, getWorkspaceToken: N, userId: P } = t(), { locale: tt } = e(), nt = x((e) => e.assistantLanguage), rt = x((e) => e.replyLanguage), it = E(() =>
|
|
79
|
+
let k = r(), { product: A, modes: j, gatherPageContext: Qe, buildPrompt: $e, reportTokenUsage: et } = n(), { getAccessToken: M, getWorkspaceToken: N, userId: P } = t(), { locale: tt } = e(), nt = x((e) => e.assistantLanguage), rt = x((e) => e.replyLanguage), it = E(() => de(nt, rt, tt), [
|
|
84
80
|
nt,
|
|
85
81
|
rt,
|
|
86
82
|
tt
|
|
87
|
-
]), at = it.reply.english, ot = it.replyIsExplicit, st = it.reply.code, { conversations: ct, activeConversationId: F, mode: I, processingByConversationId: lt, setMode: ut, setConversationMode: dt, setActiveConversation: ft, createConversation: L, addMessage: R, updateMessage: z, patchMessage: B, mergeMessageMetadata: pt, setConversationProcessing: V, clearConversationProcessing: mt, setBackendSessionId: ht, clearBackendSessionId: gt, setSandbox: H, clearSandbox: _t, acknowledgeApiCalls: vt } = x(), yt = ct.find((e) => e.id === F), U =
|
|
83
|
+
]), at = it.reply.english, ot = it.replyIsExplicit, st = it.reply.code, { conversations: ct, activeConversationId: F, mode: I, processingByConversationId: lt, setMode: ut, setConversationMode: dt, setActiveConversation: ft, createConversation: L, addMessage: R, updateMessage: z, patchMessage: B, mergeMessageMetadata: pt, setConversationProcessing: V, clearConversationProcessing: mt, setBackendSessionId: ht, clearBackendSessionId: gt, setSandbox: H, clearSandbox: _t, acknowledgeApiCalls: vt } = x(), yt = ct.find((e) => e.id === F), U = Ie(yt), bt = U.all, xt = F ? lt[F] : void 0, St = ve(xt?.status), Ct = St ? xt?.messageId ?? null : null, wt = xt?.status === "error" ? xt.messageId : null, { canUseApiCalls: Tt, loading: Et } = Fe(Ee()), Dt = E(() => j.filter((e) => !e.requiresAdmin || Tt), [j, Tt]), [Ot, kt] = Ge(null), [At, jt] = Ge(!1), Mt = D({}), W = D(Oe()), Nt = D(/* @__PURE__ */ new Set()), Pt = E(() => j.find((e) => e.id === I), [j, I]);
|
|
88
84
|
T(() => {
|
|
89
85
|
Et || (!Pt || Pt.requiresAdmin && !Tt) && I !== "assistant" && ut("assistant");
|
|
90
86
|
}, [
|
|
@@ -95,28 +91,28 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
95
91
|
ut
|
|
96
92
|
]);
|
|
97
93
|
let G = w((e, t, n, r) => {
|
|
98
|
-
V(e, n, t, null), r ? z(e, t, r) : z(e, t,
|
|
94
|
+
V(e, n, t, null), r ? z(e, t, r) : z(e, t, Se(k, n));
|
|
99
95
|
}, [
|
|
100
96
|
V,
|
|
101
97
|
z,
|
|
102
98
|
k
|
|
103
99
|
]), Ft = w(async (e, t, n, r, i) => {
|
|
104
100
|
let a = x.getState().sandboxesByMode[n]?.sandboxId ?? null, o = async (e) => {
|
|
105
|
-
if (
|
|
101
|
+
if (W.current.isFresh(e)) return !0;
|
|
106
102
|
try {
|
|
107
|
-
return await m(e, r, i, 3e5), await p(e, r, i, 9e4),
|
|
103
|
+
return await m(e, r, i, 3e5), await p(e, r, i, 9e4), W.current.markVerified(e), !0;
|
|
108
104
|
} catch {
|
|
109
|
-
return
|
|
105
|
+
return W.current.invalidate(e), !1;
|
|
110
106
|
}
|
|
111
107
|
};
|
|
112
108
|
if (a && (H(n, a, "provisioning"), G(e, t, "provisioning", C(k, S.reusingEnvironment)), await o(a) || (H(n, null, "provisioning"), a = null)), !a) {
|
|
113
109
|
G(e, t, "provisioning", C(k, S.lookingForEnvironment));
|
|
114
|
-
let s = await u(r, A, n,
|
|
110
|
+
let s = await u(r, A, n, Ue(), i);
|
|
115
111
|
s && (H(n, s, "provisioning"), G(e, t, "provisioning", C(k, S.reusingEnvironment)), await o(s) ? a = s : H(n, null, "provisioning"));
|
|
116
112
|
}
|
|
117
113
|
if (!a) {
|
|
118
114
|
if (n === "api-calls" && !M()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
119
|
-
G(e, t, "provisioning", C(k, S.startingEnvironment)), H(n, null, "provisioning"), await f(r, A, n,
|
|
115
|
+
G(e, t, "provisioning", C(k, S.startingEnvironment)), H(n, null, "provisioning"), await f(r, A, n, Ue(), i), a = await s(A, n, r, Ue(), qe, i), H(n, a, "provisioning"), await m(a, r, i, 3e5), await p(a, r, i, 9e4);
|
|
120
116
|
}
|
|
121
117
|
H(n, a, "running");
|
|
122
118
|
let l = x.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null;
|
|
@@ -138,29 +134,29 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
138
134
|
H,
|
|
139
135
|
k,
|
|
140
136
|
G
|
|
141
|
-
]), [It, Lt] =
|
|
137
|
+
]), [It, Lt] = Ge(null), K = D(/* @__PURE__ */ new Set()), Rt = D(null), zt = w(() => {
|
|
142
138
|
let e = x.getState(), t = e.activeConversationId;
|
|
143
139
|
if (!t) return;
|
|
144
|
-
let n = e.processingByConversationId[t], r =
|
|
145
|
-
if (!
|
|
140
|
+
let n = e.processingByConversationId[t], r = ve(n?.status) ? n?.messageId ?? null : null;
|
|
141
|
+
if (!be({
|
|
146
142
|
interruptedTurnId: r,
|
|
147
143
|
activeTurnId: r,
|
|
148
144
|
alreadyRequested: r ? K.current.has(r) : !1
|
|
149
145
|
}).send || !r) return;
|
|
150
146
|
K.current.add(r);
|
|
151
|
-
let i = e.sandboxesByMode[e.mode]?.sandboxId, o =
|
|
147
|
+
let i = e.sandboxesByMode[e.mode]?.sandboxId, o = De(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
|
|
152
148
|
!i || !o || !s || a(i, o, s, {
|
|
153
149
|
accessToken: M(),
|
|
154
150
|
workspaceToken: N(),
|
|
155
151
|
userId: P,
|
|
156
|
-
organizationId:
|
|
152
|
+
organizationId: Ee()
|
|
157
153
|
});
|
|
158
154
|
}, [
|
|
159
155
|
P,
|
|
160
156
|
M,
|
|
161
157
|
N
|
|
162
158
|
]), Bt = w(async (e) => {
|
|
163
|
-
let t = x.getState(), n = t.sandboxesByMode[t.mode]?.sandboxId, r =
|
|
159
|
+
let t = x.getState(), n = t.sandboxesByMode[t.mode]?.sandboxId, r = De(), i = t.activeConversationId;
|
|
164
160
|
if (!(!n || !r || !i)) {
|
|
165
161
|
Lt(e);
|
|
166
162
|
try {
|
|
@@ -168,7 +164,7 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
168
164
|
accessToken: M(),
|
|
169
165
|
workspaceToken: N(),
|
|
170
166
|
userId: P,
|
|
171
|
-
organizationId:
|
|
167
|
+
organizationId: Ee()
|
|
172
168
|
});
|
|
173
169
|
} catch (e) {
|
|
174
170
|
Lt(null), R(i, {
|
|
@@ -188,7 +184,7 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
188
184
|
]), q = w(async (e, t = [], n = {}) => {
|
|
189
185
|
let r = n.voiceSessionId !== void 0, a = x.getState(), o = a.activeConversationId ?? F;
|
|
190
186
|
if (o) {
|
|
191
|
-
if (
|
|
187
|
+
if (ve(a.processingByConversationId[o]?.status)) {
|
|
192
188
|
let r = a.processingByConversationId[o]?.messageId ?? null;
|
|
193
189
|
r && K.current.has(r) && (Rt.current = {
|
|
194
190
|
conversationId: o,
|
|
@@ -202,19 +198,19 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
202
198
|
}
|
|
203
199
|
let s = a.mode, c = F, u = c ? x.getState().conversations.find((e) => e.id === c) : void 0;
|
|
204
200
|
if (c ? u && u.mode !== s && (u.messages.length > 0 || u.backendSessionId) ? c = L(void 0, s) : u && u.mode !== s && dt(c, s) : c = L(void 0, s), !c) return;
|
|
205
|
-
|
|
206
|
-
let d =
|
|
201
|
+
Mt.current[c] = t;
|
|
202
|
+
let d = De(), f = {
|
|
207
203
|
accessToken: M(),
|
|
208
204
|
workspaceToken: N(),
|
|
209
205
|
userId: P,
|
|
210
|
-
organizationId:
|
|
206
|
+
organizationId: Ee()
|
|
211
207
|
}, p = {
|
|
212
208
|
id: Ye(),
|
|
213
209
|
role: "user",
|
|
214
210
|
content: e,
|
|
215
211
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
216
212
|
metadata: {
|
|
217
|
-
...t.length ? { attachments: t.map(
|
|
213
|
+
...t.length ? { attachments: t.map(_e) } : {},
|
|
218
214
|
..._(n.voiceSessionId)
|
|
219
215
|
}
|
|
220
216
|
};
|
|
@@ -244,24 +240,24 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
244
240
|
try {
|
|
245
241
|
let { sandboxId: n, sessionId: a } = await Ft(c, m, s, d, f), o = (await te(n, d, a, f, { limit: 50 }).catch(() => [])).reduce((e, t) => Math.max(e, Xe(t)), 0);
|
|
246
242
|
G(c, m, "streaming", C(k, S.thinking));
|
|
247
|
-
let u =
|
|
248
|
-
i =
|
|
243
|
+
let u = pe(e, t), p = $e?.(s, u, at, ot, r) ?? u, g = fe(p, t), _ = he(g), v = _ > 0, oe = Qe?.();
|
|
244
|
+
i = me(t) > _;
|
|
249
245
|
try {
|
|
250
|
-
await ne(n, d, a, p, s,
|
|
246
|
+
await ne(n, d, a, p, s, oe, f, g?.length ? { parts: g } : void 0);
|
|
251
247
|
} catch (e) {
|
|
252
|
-
if (!g || !
|
|
253
|
-
await ne(n, d, a, p, s,
|
|
248
|
+
if (!g || !Le(e)) throw e;
|
|
249
|
+
await ne(n, d, a, p, s, oe, f, void 0), i ||= v;
|
|
254
250
|
}
|
|
255
|
-
let y = Ze([], o),
|
|
251
|
+
let y = Ze([], o), se = Date.now() + ie(s), le = Date.now(), ue = Date.now(), de = () => ye({
|
|
256
252
|
turnId: m,
|
|
257
253
|
abortRequested: K.current.has(m),
|
|
258
254
|
activeTurnId: x.getState().processingByConversationId[c]?.messageId ?? null
|
|
259
255
|
}), b = () => {
|
|
260
256
|
let e = x.getState().conversations.find((e) => e.id === c)?.messages.find((e) => e.id === m)?.content;
|
|
261
|
-
|
|
257
|
+
xe(k, e) && z(c, m, C(k, S.stopped));
|
|
262
258
|
};
|
|
263
|
-
for (; Date.now() <
|
|
264
|
-
let e =
|
|
259
|
+
for (; Date.now() < se;) {
|
|
260
|
+
let e = de();
|
|
265
261
|
if (e.abandon) {
|
|
266
262
|
b(), e.clearProcessing && mt(c);
|
|
267
263
|
return;
|
|
@@ -269,18 +265,17 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
269
265
|
if (y = Ze(await te(n, d, a, f, {
|
|
270
266
|
limit: 50,
|
|
271
267
|
sinceMs: o
|
|
272
|
-
}), o), B(c, m, { content:
|
|
273
|
-
Date.now() -
|
|
268
|
+
}), o), B(c, m, { content: xe(k, y.content) ? Ce(k, Date.now() - ue) : re(y.content) }), y.pendingWrite && pt(c, m, { pendingWrite: y.pendingWrite }), y.done) break;
|
|
269
|
+
Date.now() - le > 3e4 && (await l(n, d, 600, f).catch(() => void 0), le = Date.now()), await new Promise((e) => setTimeout(e, ce(Date.now() - ue)));
|
|
274
270
|
}
|
|
275
|
-
|
|
276
|
-
let me = s === "vibe-plugins" ? await ee(n, d, a, f).then((e) => e).catch(() => []) : void 0;
|
|
271
|
+
let ge = s === "vibe-plugins" ? await ee(n, d, a, f).then((e) => e).catch(() => []) : void 0;
|
|
277
272
|
if (y.done || (y = {
|
|
278
273
|
...y,
|
|
279
|
-
content:
|
|
274
|
+
content: ae(y.content, s, k)
|
|
280
275
|
}), i && (y = {
|
|
281
276
|
...y,
|
|
282
277
|
content: `${y.content}\n\n${k("attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
|
|
283
|
-
}), h(y.content,
|
|
278
|
+
}), h(y.content, ge, a, n), y.tokens) {
|
|
284
279
|
B(c, m, { tokens: y.tokens });
|
|
285
280
|
try {
|
|
286
281
|
await et?.({
|
|
@@ -289,17 +284,17 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
289
284
|
messageId: y.messageId,
|
|
290
285
|
model: y.model,
|
|
291
286
|
tokens: y.tokens
|
|
292
|
-
}),
|
|
287
|
+
}), Be(A);
|
|
293
288
|
} catch {}
|
|
294
289
|
}
|
|
295
|
-
let
|
|
296
|
-
if (
|
|
297
|
-
b(),
|
|
290
|
+
let _e = de();
|
|
291
|
+
if (_e.abandon) {
|
|
292
|
+
b(), _e.clearProcessing && mt(c);
|
|
298
293
|
return;
|
|
299
294
|
}
|
|
300
295
|
V(c, "complete", m, null);
|
|
301
296
|
} catch (e) {
|
|
302
|
-
if (n === 1 &&
|
|
297
|
+
if (n === 1 && Re(e)) return gt(c), _t(s), g(2);
|
|
303
298
|
throw e;
|
|
304
299
|
}
|
|
305
300
|
}, v = c;
|
|
@@ -308,10 +303,10 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
308
303
|
if (!d) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
309
304
|
await g();
|
|
310
305
|
} catch (e) {
|
|
311
|
-
|
|
306
|
+
W.current.invalidate(x.getState().sandboxesByMode[s]?.sandboxId ?? null);
|
|
312
307
|
let t = i(e);
|
|
313
308
|
if (t) {
|
|
314
|
-
t.refusal === "exhausted" &&
|
|
309
|
+
t.refusal === "exhausted" && ze(A, "sandbox");
|
|
315
310
|
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.";
|
|
316
311
|
h(e ? `${n}\n\n${e}` : n, void 0, void 0, void 0, "en"), V(c, "error", m, null);
|
|
317
312
|
return;
|
|
@@ -355,7 +350,7 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
355
350
|
]), Vt = w((e) => {
|
|
356
351
|
q(e);
|
|
357
352
|
}, [q]), Ht = w(() => {
|
|
358
|
-
let e = [...U.chat].reverse().find((e) => e.role === "user"), t = F ?
|
|
353
|
+
let e = [...U.chat].reverse().find((e) => e.role === "user"), t = F ? Mt.current[F] ?? [] : [];
|
|
359
354
|
e && q(e.content, t);
|
|
360
355
|
}, [
|
|
361
356
|
bt,
|
|
@@ -370,40 +365,40 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
370
365
|
for (let e = bt.length - 1; e >= 0; --e) {
|
|
371
366
|
let t = bt[e];
|
|
372
367
|
if (t?.role !== "assistant" || !g(t) || K.current.has(t.id)) continue;
|
|
373
|
-
let n =
|
|
368
|
+
let n = we(t.content).text.trim();
|
|
374
369
|
return n ? {
|
|
375
370
|
id: t.id,
|
|
376
371
|
text: n
|
|
377
372
|
} : null;
|
|
378
373
|
}
|
|
379
374
|
return null;
|
|
380
|
-
}, [bt, St]), Ut = E(() => Y ?
|
|
375
|
+
}, [bt, St]), Ut = E(() => Y ? le(Y.text) : null, [Y]), Wt = U.chat, X = E(() => U.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
381
376
|
id: e.id,
|
|
382
377
|
role: e.role,
|
|
383
|
-
text:
|
|
378
|
+
text: we(e.content).text.trim(),
|
|
384
379
|
sessionId: v(e),
|
|
385
380
|
timestamp: e.timestamp
|
|
386
381
|
})).filter((e) => e.text.length > 0), [U.voice]), Gt = w(() => {
|
|
387
382
|
if (X.length === 0) return;
|
|
388
383
|
let e = /* @__PURE__ */ new Date();
|
|
389
|
-
|
|
384
|
+
je(y(X, {
|
|
390
385
|
title: k("voiceSession.transcript", "Voice conversation"),
|
|
391
386
|
savedAt: k("voiceSession.savedAt", "Saved"),
|
|
392
387
|
session: k("voiceSession.sessionLabel", "Session"),
|
|
393
388
|
earlier: k("voiceSession.earlierLabel", "Earlier"),
|
|
394
389
|
you: k("voiceSession.speakerYou", "You"),
|
|
395
390
|
assistant: k("voiceSession.speakerAssistant", "Assistant")
|
|
396
|
-
}, e),
|
|
391
|
+
}, e), se(A, e), "text/markdown");
|
|
397
392
|
}, [
|
|
398
393
|
A,
|
|
399
394
|
X,
|
|
400
395
|
k
|
|
401
|
-
]), Z =
|
|
396
|
+
]), Z = Ve(), Q = D(Z);
|
|
402
397
|
Q.current = Z;
|
|
403
|
-
let $ =
|
|
398
|
+
let $ = Te({
|
|
404
399
|
onSubmit: w((e, t) => {
|
|
405
400
|
let n = () => {
|
|
406
|
-
let n = Q.current, r =
|
|
401
|
+
let n = Q.current, r = ge(n.attachments);
|
|
407
402
|
J.current(e, r, { voiceSessionId: t }), n.clear();
|
|
408
403
|
};
|
|
409
404
|
if (!Q.current.isBusy) {
|
|
@@ -415,20 +410,20 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
415
410
|
}, 200);
|
|
416
411
|
}, []),
|
|
417
412
|
latestReply: Y,
|
|
418
|
-
language:
|
|
413
|
+
language: ue(nt, tt).tag
|
|
419
414
|
}), Kt = E(() => (yt?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [yt?.messages]), qt = X.length > Kt, Jt = w(() => {
|
|
420
415
|
let e = x.getState().activeConversationId;
|
|
421
416
|
!e || X.length === 0 || (R(e, {
|
|
422
417
|
id: Ye(),
|
|
423
418
|
role: "system",
|
|
424
|
-
content:
|
|
419
|
+
content: oe(X.slice(Kt), {
|
|
425
420
|
intro: k("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
|
|
426
421
|
nothing: k("voiceSession.continuedNothing", "Continued from a voice conversation."),
|
|
427
422
|
more: (e) => k("voiceSession.continuedMore", "…and {{count}} more", { count: e })
|
|
428
423
|
}),
|
|
429
424
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
430
425
|
metadata: { continuedVoiceTurns: X.length }
|
|
431
|
-
}),
|
|
426
|
+
}), jt(!1), $.end());
|
|
432
427
|
}, [
|
|
433
428
|
X,
|
|
434
429
|
Kt,
|
|
@@ -441,7 +436,7 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
441
436
|
}, [$.active]);
|
|
442
437
|
let Xt = w(() => {
|
|
443
438
|
let e = X.length > Yt.current;
|
|
444
|
-
$.end(), e &&
|
|
439
|
+
$.end(), e && jt(!0);
|
|
445
440
|
}, [X, $]);
|
|
446
441
|
T(() => {
|
|
447
442
|
!h && $.active && $.end();
|
|
@@ -487,23 +482,23 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
487
482
|
]), en = w(() => {
|
|
488
483
|
kt(null);
|
|
489
484
|
}, []);
|
|
490
|
-
return /* @__PURE__ */
|
|
485
|
+
return /* @__PURE__ */ Ke("div", {
|
|
491
486
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
492
487
|
children: [
|
|
493
|
-
/* @__PURE__ */
|
|
488
|
+
/* @__PURE__ */ Ke("div", {
|
|
494
489
|
className: "contents",
|
|
495
490
|
inert: $.active || void 0,
|
|
496
491
|
children: [
|
|
497
|
-
X.length > 0 && !$.active ? /* @__PURE__ */ O(
|
|
492
|
+
X.length > 0 && !$.active ? /* @__PURE__ */ O(ke, {
|
|
498
493
|
count: X.length,
|
|
499
|
-
onOpenTranscript: () =>
|
|
494
|
+
onOpenTranscript: () => jt(!0)
|
|
500
495
|
}) : null,
|
|
501
|
-
Wt.length === 0 ? /* @__PURE__ */ O(
|
|
496
|
+
Wt.length === 0 ? /* @__PURE__ */ O(Me, {
|
|
502
497
|
mode: I,
|
|
503
498
|
onSuggestionClick: Vt
|
|
504
499
|
}) : /* @__PURE__ */ O("div", {
|
|
505
500
|
className: "flex min-h-0 flex-1 flex-col",
|
|
506
|
-
children: /* @__PURE__ */ O(
|
|
501
|
+
children: /* @__PURE__ */ O(Ne, {
|
|
507
502
|
onApprovePendingWrite: Bt,
|
|
508
503
|
approvingWriteRef: It,
|
|
509
504
|
messages: Wt,
|
|
@@ -512,7 +507,7 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
512
507
|
onRetry: Ht
|
|
513
508
|
})
|
|
514
509
|
}),
|
|
515
|
-
/* @__PURE__ */ O(
|
|
510
|
+
/* @__PURE__ */ O(He, {
|
|
516
511
|
onStartVoiceSession: $.available && I !== "api-calls" ? $.start : void 0,
|
|
517
512
|
onSend: (e, t) => void q(e, t),
|
|
518
513
|
disabled: St,
|
|
@@ -524,14 +519,14 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
524
519
|
})
|
|
525
520
|
]
|
|
526
521
|
}),
|
|
527
|
-
At && !$.active ? /* @__PURE__ */ O(
|
|
522
|
+
At && !$.active ? /* @__PURE__ */ O(Ae, {
|
|
528
523
|
turns: X,
|
|
529
|
-
onClose: () =>
|
|
524
|
+
onClose: () => jt(!1),
|
|
530
525
|
onSave: Gt,
|
|
531
526
|
onContinueInChat: qt ? Jt : void 0,
|
|
532
527
|
closeOnEscape: !0
|
|
533
528
|
}) : null,
|
|
534
|
-
$.active && /* @__PURE__ */ O(
|
|
529
|
+
$.active && /* @__PURE__ */ O(Pe, {
|
|
535
530
|
session: $.session,
|
|
536
531
|
notice: $.notice,
|
|
537
532
|
capturing: $.capturing,
|
|
@@ -554,7 +549,7 @@ var j = ({ visible: h = !0, writeAccess: b = "unknown" }) => {
|
|
|
554
549
|
onToggleMute: $.toggleMute,
|
|
555
550
|
onEnd: Xt
|
|
556
551
|
}),
|
|
557
|
-
/* @__PURE__ */ O(
|
|
552
|
+
/* @__PURE__ */ O(We, {
|
|
558
553
|
open: Ot !== null,
|
|
559
554
|
onConfirm: $t,
|
|
560
555
|
onCancel: en
|