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