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