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