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