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