@burdenoff/fe-libs 2026.924.1 → 2026.924.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/assistant/autoRouting.d.ts +197 -0
- package/dist/shared/assistant/autoRouting.d.ts.map +1 -0
- package/dist/shared/assistant/autoRouting.js +854 -0
- package/dist/shared/assistant/conversation.d.ts +13 -0
- package/dist/shared/assistant/conversation.d.ts.map +1 -1
- package/dist/shared/assistant/i18nManifest.d.ts +2 -0
- package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
- package/dist/shared/assistant/i18nManifest.js +2 -0
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/store.d.ts +32 -2
- package/dist/shared/assistant/store.d.ts.map +1 -1
- package/dist/shared/assistant/store.js +69 -29
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +428 -341
- package/dist/shared/assistant/ui/AssistantEmptyState.d.ts +17 -1
- package/dist/shared/assistant/ui/AssistantEmptyState.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantEmptyState.js +14 -9
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +3 -0
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts.map +1 -1
- package/dist/shared/assistant/ui/composer/AssistantComposer.js +110 -109
- package/dist/shared/assistant/ui/composer/AssistantModeSelector.d.ts +20 -0
- package/dist/shared/assistant/ui/composer/AssistantModeSelector.d.ts.map +1 -1
- package/dist/shared/assistant/ui/composer/AssistantModeSelector.js +89 -45
- package/dist/shared/config/products.d.ts.map +1 -1
- package/dist/shared/config/products.js +1 -2
- package/dist/shared-assistant.js +80 -79
- package/package.json +1 -1
|
@@ -4,180 +4,196 @@ import "../../../shared-providers-shell.js";
|
|
|
4
4
|
import { useAssistantProduct as n } from "../product.js";
|
|
5
5
|
import { useAssistantTr as r } from "../i18n.js";
|
|
6
6
|
import { describeQuotaError as i } from "../quota.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
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 {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
7
|
+
import { isAssistantModeId as a } from "../modeIds.js";
|
|
8
|
+
import { abortAssistantTurn as o, approvePendingWrite as s, createAssistantSandbox as c, createAssistantSession as l, extendAssistantSandboxTTL as u, findExistingSandbox as ee, getAssistantArtifacts as te, getAssistantMessages as ne, getAssistantSession as re, modeRequiresConfirmWrites as ie, promptGatewayRequestBytes as ae, releaseSupersededAssistantSandboxes as d, sendAssistantPromptAsync as oe, waitForAssistantServiceReady as f, waitForSandboxRunning as p } from "../api.js";
|
|
9
|
+
import { getRawMessageCreatedAt as se, sanitize as ce } from "../progress.js";
|
|
10
|
+
import { withIncompleteTurnNotice as le } from "../streamBudget.js";
|
|
11
|
+
import { isVoiceTurn as m, voiceMarker as h, voiceSessionIdOf as g } from "../voice/turnVisibility.js";
|
|
12
|
+
import { buildContinuedFromVoiceNote as ue, buildVoiceTranscriptMarkdown as _, voiceTranscriptFilename as de } from "../voice/voiceTranscript.js";
|
|
13
|
+
import { pollDelayMs as fe } from "../voice/assistantPollSchedule.js";
|
|
14
|
+
import { toCaptionText as v } from "../voice/captionText.js";
|
|
15
|
+
import { resolveAssistantLanguage as y } from "../voice/languages.js";
|
|
16
|
+
import { resolveLanguagePair as pe } from "../voice/languagePair.js";
|
|
17
|
+
import { countInlineImageCandidates as me, countInlinedImageParts as he, getSendableAttachments as ge, largestInlineCharsPerFile as _e, resolveAssistantInlineLimits as ve, toMessageAttachment as ye } from "../attachments.js";
|
|
18
|
+
import { createAdminModeAccessGate as be, resolveAssistantSendModeAfterAccess as xe } from "../adminModeSendGate.js";
|
|
19
|
+
import { buildBoundedAttachmentTurn as Se } from "../attachmentTurn.js";
|
|
20
|
+
import { isWriteModeAcknowledged as Ce, writeModeSendRefusal as we } from "../writeModeConsent.js";
|
|
21
|
+
import { AUTO_READ_MODE as Te, autoCarryOverFor as Ee, autoSuggestions as De, classifyAssistantIntent as Oe, escalationToUndo as ke, isAutoRoutingOffered as Ae, resolveAutoRoute as je } from "../autoRouting.js";
|
|
22
|
+
import { resolveActiveModeSandbox as Me, useAssistantStore as b } from "../store.js";
|
|
23
|
+
import { isTurnInFlight as Ne, planAbandonedTurn as Pe, planTurnAbort as Fe } from "../turnState.js";
|
|
24
|
+
import { getAssistantDisplayContent as Ie } from "../displayContent.js";
|
|
25
|
+
import { buildAssistantProgress as Le } from "../turnProgress.js";
|
|
26
|
+
import { parseToolActivity as Re } from "./AssistantToolActivity.js";
|
|
27
|
+
import { countSpokenTurns as ze, spokenTurnText as Be } from "../spokenTurns.js";
|
|
28
|
+
import { useVoiceSession as Ve } from "./useVoiceSession.js";
|
|
29
|
+
import { getOrganizationId as He, getWorkspaceId as Ue } from "../context.js";
|
|
30
|
+
import { createReadinessTracker as We } from "../sandboxReadiness.js";
|
|
31
|
+
import { AssistantSpokenTurnsNotice as Ge } from "./AssistantSpokenTurnsNotice.js";
|
|
32
|
+
import { VoiceTranscriptDrawer as Ke } from "./voice/VoiceTranscriptDrawer.js";
|
|
33
|
+
import { downloadFile as qe } from "../exportConversation.js";
|
|
34
|
+
import { AssistantEmptyState as Je } from "./AssistantEmptyState.js";
|
|
35
|
+
import { AssistantMessageList as Ye } from "./AssistantMessageList.js";
|
|
36
|
+
import { AssistantVoiceSession as Xe } from "./voice/AssistantVoiceSession.js";
|
|
37
|
+
import { useAssistantApiAccess as Ze } from "../useAssistantApiAccess.js";
|
|
38
|
+
import { useConversationTurns as Qe } from "../useConversationTurns.js";
|
|
39
|
+
import { isMultimodalBodyRejection as $e, isRecoverableAssistantError as et } from "../transportErrors.js";
|
|
40
|
+
import { describePermissionError as tt, permissionRefusalMessage as nt } from "../permissionError.js";
|
|
41
|
+
import { dispatchAssistantQuotaExhausted as rt, notifyAiCreditsUpdated as it } from "../aiCredits.js";
|
|
42
|
+
import { useAssistantAttachments as at } from "../useAssistantAttachments.js";
|
|
43
|
+
import { AssistantComposer as ot } from "./composer/AssistantComposer.js";
|
|
44
|
+
import { isProdRuntime as st } from "../env.js";
|
|
45
|
+
import { AssistantApiCallsConsentDialog as ct } from "./AssistantApiCallsConsentDialog.js";
|
|
46
|
+
import { useCallback as x, useEffect as S, useMemo as C, useRef as w, useState as lt } from "react";
|
|
47
|
+
import { jsx as T, jsxs as ut } from "react/jsx-runtime";
|
|
46
48
|
//#region src/shared/assistant/ui/AssistantChatArea.tsx
|
|
47
|
-
var
|
|
48
|
-
function
|
|
49
|
+
var dt = 600, ft = 2e4;
|
|
50
|
+
function pt() {
|
|
49
51
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
50
52
|
}
|
|
51
|
-
var
|
|
52
|
-
let E = r(), { product: D, modes: O, gatherPageContext:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
]),
|
|
57
|
-
loading:
|
|
58
|
-
canUseAdminModes:
|
|
59
|
-
})).current,
|
|
53
|
+
var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
|
|
54
|
+
let E = r(), { product: D, modes: O, gatherPageContext: gt, buildPrompt: _t, reportTokenUsage: vt } = n(), { getAccessToken: k, getWorkspaceToken: yt, userId: A } = t(), { locale: bt } = e(), xt = b((e) => e.assistantLanguage), St = b((e) => e.replyLanguage), Ct = C(() => pe(xt, St, bt), [
|
|
55
|
+
xt,
|
|
56
|
+
St,
|
|
57
|
+
bt
|
|
58
|
+
]), wt = Ct.reply.english, Tt = Ct.replyIsExplicit, Et = Ct.reply.code, { conversations: Dt, activeConversationId: j, mode: M, processingByConversationId: Ot, setMode: N, setConversationMode: kt, setActiveConversation: At, createConversation: P, addMessage: F, updateMessage: jt, patchMessage: Mt, mergeMessageMetadata: Nt, setConversationProcessing: I, clearConversationProcessing: Pt, setBackendSessionId: Ft, clearBackendSessionId: It, setSandbox: L, clearSandbox: Lt, acknowledgedWriteModes: Rt, acknowledgeWriteMode: zt, autoRouting: Bt, setAutoRouting: Vt, routeConversation: R } = b(), Ht = Dt.find((e) => e.id === j), z = Qe(Ht), Ut = z.all, B = j ? Ot[j] : void 0, Wt = Ne(B?.status), Gt = Wt ? B?.messageId ?? null : null, Kt = B?.status === "error" ? B.messageId : null, { canUseApiCalls: V, loading: qt } = Ze(He()), H = w(be({
|
|
59
|
+
loading: qt,
|
|
60
|
+
canUseAdminModes: V
|
|
61
|
+
})).current, Jt = w(O);
|
|
60
62
|
S(() => {
|
|
61
|
-
|
|
63
|
+
Jt.current = O;
|
|
62
64
|
}, [O]), S(() => {
|
|
63
|
-
|
|
64
|
-
loading:
|
|
65
|
-
canUseAdminModes:
|
|
65
|
+
H.update({
|
|
66
|
+
loading: qt,
|
|
67
|
+
canUseAdminModes: V
|
|
66
68
|
});
|
|
67
69
|
}, [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
H,
|
|
71
|
+
qt,
|
|
72
|
+
V
|
|
71
73
|
]), S(() => () => {
|
|
72
|
-
|
|
73
|
-
}, [
|
|
74
|
-
let
|
|
74
|
+
H.abandon();
|
|
75
|
+
}, [H]);
|
|
76
|
+
let Yt = C(() => O.filter((e) => !e.requiresAdmin || V), [O, V]), Xt = Ae(Yt), Zt = Bt && Xt, Qt = w(Xt);
|
|
77
|
+
S(() => {
|
|
78
|
+
Qt.current = Xt;
|
|
79
|
+
}, [Xt]);
|
|
80
|
+
let U = w(null), $t = _e(O), [W, en] = lt(null), [tn, nn] = lt(!1), rn = w({}), G = w(We()), an = w(/* @__PURE__ */ new Set()), on = w(/* @__PURE__ */ new Set()), K = C(() => O.find((e) => e.id === M), [O, M]), sn = M === "assistant" || K !== void 0 && !K.writeCapable && !ie(M);
|
|
75
81
|
S(() => {
|
|
76
|
-
if (
|
|
77
|
-
|
|
82
|
+
if (M !== "assistant" && K?.writeCapable && !Ce(Rt, M)) {
|
|
83
|
+
N("assistant");
|
|
78
84
|
return;
|
|
79
85
|
}
|
|
80
|
-
|
|
86
|
+
qt || (!K || K.requiresAdmin && !V) && M !== "assistant" && N("assistant");
|
|
81
87
|
}, [
|
|
88
|
+
M,
|
|
89
|
+
K,
|
|
90
|
+
V,
|
|
91
|
+
qt,
|
|
82
92
|
N,
|
|
83
|
-
|
|
84
|
-
H,
|
|
85
|
-
Ft,
|
|
86
|
-
P,
|
|
87
|
-
Ot
|
|
93
|
+
Rt
|
|
88
94
|
]);
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
}, [
|
|
92
|
-
let
|
|
93
|
-
if (
|
|
95
|
+
let q = x((e, t, n, r) => {
|
|
96
|
+
I(e, n, t, null, r);
|
|
97
|
+
}, [I]), cn = x(async (e, t, n, r, i) => {
|
|
98
|
+
let o = b.getState().sandboxesByMode[n]?.sandboxId ?? null, s = async (e) => {
|
|
99
|
+
if (G.current.isFresh(e)) return !0;
|
|
94
100
|
try {
|
|
95
|
-
return await
|
|
101
|
+
return await p(e, r, i, 3e5), await f(e, r, n, i, 9e4), G.current.markVerified(e), !0;
|
|
96
102
|
} catch {
|
|
97
|
-
return
|
|
103
|
+
return G.current.invalidate(e), an.current.add(e), !1;
|
|
98
104
|
}
|
|
99
105
|
};
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
let
|
|
103
|
-
|
|
106
|
+
if (o && (L(n, o, "provisioning"), q(e, t, "provisioning", "reusingEnvironment"), await s(o) || (L(n, null, "provisioning"), o = null)), !o) {
|
|
107
|
+
q(e, t, "provisioning", "lookingForEnvironment");
|
|
108
|
+
let a = await ee(r, D, n, st(), i, an.current);
|
|
109
|
+
a && (L(n, a, "provisioning"), q(e, t, "provisioning", "reusingEnvironment"), await s(a) ? o = a : L(n, null, "provisioning"));
|
|
104
110
|
}
|
|
105
|
-
if (!
|
|
111
|
+
if (!o) {
|
|
106
112
|
if (n === "api-calls" && !k()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
107
|
-
|
|
113
|
+
q(e, t, "provisioning", "startingEnvironment"), L(n, null, "provisioning");
|
|
114
|
+
let s = await d(r, D, n, st(), i, an.current);
|
|
115
|
+
if (s.length > 0) {
|
|
116
|
+
let e = new Set(s);
|
|
117
|
+
for (let e of s) G.current.invalidate(e), an.current.add(e);
|
|
118
|
+
let t = b.getState().sandboxesByMode;
|
|
119
|
+
for (let [n, r] of Object.entries(t)) a(n) && r?.sandboxId && e.has(r.sandboxId) && Lt(n);
|
|
120
|
+
}
|
|
121
|
+
o = await c(D, n, r, st(), dt, i), L(n, o, "provisioning"), await p(o, r, i, 3e5), await f(o, r, n, i, 9e4);
|
|
108
122
|
}
|
|
109
|
-
|
|
110
|
-
let
|
|
111
|
-
if (
|
|
112
|
-
let e = await
|
|
123
|
+
L(n, o, "running");
|
|
124
|
+
let u = b.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null, te = !1;
|
|
125
|
+
if (u) try {
|
|
126
|
+
let e = await re(o, r, u, n, i);
|
|
113
127
|
if (e.mode !== n) throw Error(`Session mode mismatch: expected ${n}, received ${e.mode}`);
|
|
114
128
|
} catch {
|
|
115
|
-
|
|
129
|
+
It(e), u = null;
|
|
116
130
|
}
|
|
117
|
-
return
|
|
118
|
-
sandboxId:
|
|
119
|
-
sessionId:
|
|
131
|
+
return u || (q(e, t, "connecting", "preparingSession"), u = (await l(o, r, n, i)).sessionId, Ft(e, u), te = !0), {
|
|
132
|
+
sandboxId: o,
|
|
133
|
+
sessionId: u,
|
|
134
|
+
sessionIsNew: te
|
|
120
135
|
};
|
|
121
136
|
}, [
|
|
122
|
-
|
|
137
|
+
It,
|
|
138
|
+
Lt,
|
|
123
139
|
k,
|
|
124
140
|
D,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
]), [
|
|
141
|
+
Ft,
|
|
142
|
+
L,
|
|
143
|
+
q
|
|
144
|
+
]), [ln, un] = lt(null), dn = w(/* @__PURE__ */ new Set()), fn = w(null), pn = x(() => {
|
|
129
145
|
let e = b.getState(), t = e.activeConversationId;
|
|
130
146
|
if (!t) return;
|
|
131
|
-
let n = e.processingByConversationId[t], r =
|
|
132
|
-
if (!
|
|
147
|
+
let n = e.processingByConversationId[t], r = Ne(n?.status) ? n?.messageId ?? null : null;
|
|
148
|
+
if (!Fe({
|
|
133
149
|
interruptedTurnId: r,
|
|
134
150
|
activeTurnId: r,
|
|
135
|
-
alreadyRequested: r ?
|
|
151
|
+
alreadyRequested: r ? dn.current.has(r) : !1
|
|
136
152
|
}).send || !r) return;
|
|
137
|
-
|
|
138
|
-
let i =
|
|
139
|
-
!i || !
|
|
153
|
+
dn.current.add(r);
|
|
154
|
+
let i = Me(e), a = Ue(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
|
|
155
|
+
!i || !a || !s || o(i.sandboxId, a, s, i.mode, {
|
|
140
156
|
accessToken: k(),
|
|
141
|
-
workspaceToken:
|
|
142
|
-
userId:
|
|
143
|
-
organizationId:
|
|
157
|
+
workspaceToken: yt(),
|
|
158
|
+
userId: A,
|
|
159
|
+
organizationId: He()
|
|
144
160
|
});
|
|
145
161
|
}, [
|
|
146
|
-
|
|
162
|
+
A,
|
|
147
163
|
k,
|
|
148
|
-
|
|
149
|
-
]),
|
|
150
|
-
let t = b.getState(), n =
|
|
164
|
+
yt
|
|
165
|
+
]), mn = x(async (e) => {
|
|
166
|
+
let t = b.getState(), n = Me(t), r = Ue(), i = t.activeConversationId;
|
|
151
167
|
if (!(!n || !r || !i)) {
|
|
152
|
-
|
|
168
|
+
un(e);
|
|
153
169
|
try {
|
|
154
|
-
await
|
|
170
|
+
await s(n.sandboxId, r, e, n.mode, {
|
|
155
171
|
accessToken: k(),
|
|
156
|
-
workspaceToken:
|
|
157
|
-
userId:
|
|
158
|
-
organizationId:
|
|
172
|
+
workspaceToken: yt(),
|
|
173
|
+
userId: A,
|
|
174
|
+
organizationId: He()
|
|
159
175
|
});
|
|
160
176
|
} catch (e) {
|
|
161
|
-
|
|
162
|
-
id:
|
|
177
|
+
un(null), F(i, {
|
|
178
|
+
id: pt(),
|
|
163
179
|
role: "system",
|
|
164
180
|
content: e instanceof Error ? e.message : "The change could not be approved.",
|
|
165
181
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
166
182
|
});
|
|
167
183
|
return;
|
|
168
184
|
}
|
|
169
|
-
|
|
185
|
+
un(null), Y.current(E("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
|
|
170
186
|
}
|
|
171
187
|
}, [
|
|
172
|
-
|
|
173
|
-
|
|
188
|
+
A,
|
|
189
|
+
F,
|
|
174
190
|
E
|
|
175
191
|
]), J = x(async (e, t = [], n = {}) => {
|
|
176
|
-
let r = n.voiceSessionId !== void 0, a = b.getState(), o = a.activeConversationId ??
|
|
192
|
+
let r = n.voiceSessionId !== void 0, a = b.getState(), o = a.activeConversationId ?? j;
|
|
177
193
|
if (o) {
|
|
178
|
-
if (
|
|
194
|
+
if (Ne(a.processingByConversationId[o]?.status)) {
|
|
179
195
|
let r = a.processingByConversationId[o]?.messageId ?? null;
|
|
180
|
-
r &&
|
|
196
|
+
r && dn.current.has(r) && (fn.current = {
|
|
181
197
|
conversationId: o,
|
|
182
198
|
content: e,
|
|
183
199
|
attachments: t,
|
|
@@ -185,221 +201,250 @@ var ot = ({ visible: ot = !0, writeAccess: st = "unknown" }) => {
|
|
|
185
201
|
});
|
|
186
202
|
return;
|
|
187
203
|
}
|
|
188
|
-
if (
|
|
204
|
+
if (on.current.has(o)) return;
|
|
205
|
+
}
|
|
206
|
+
if (U.current) return;
|
|
207
|
+
let s = a.activeConversationId ? a.conversations.find((e) => e.id === a.activeConversationId) : void 0, c = a.autoRouting && Qt.current ? je({
|
|
208
|
+
intent: n.autoIntent ?? Oe(e),
|
|
209
|
+
dictated: r,
|
|
210
|
+
conversation: s ? {
|
|
211
|
+
mode: s.mode,
|
|
212
|
+
routedBy: s.routedBy,
|
|
213
|
+
hasHistory: s.messages.length > 0 || !!s.backendSessionId
|
|
214
|
+
} : null
|
|
215
|
+
}) : null;
|
|
216
|
+
if (c && Jt.current.find((e) => e.id === c.mode)?.writeCapable && !Ce(a.acknowledgedWriteModes, c.mode)) {
|
|
217
|
+
U.current = {
|
|
218
|
+
content: e,
|
|
219
|
+
attachments: t,
|
|
220
|
+
options: n
|
|
221
|
+
}, en(c.mode);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
let l = c ? c.mode : a.mode, ee, re, d = j, f = d ? b.getState().conversations.find((e) => e.id === d) : void 0, p = c?.action === "escalate" && s ? {
|
|
225
|
+
mode: s.mode,
|
|
226
|
+
backendSessionId: s.backendSessionId ?? null
|
|
227
|
+
} : null;
|
|
228
|
+
if (c) c.action === "new" || !s ? d = P(void 0, l, { routedBy: "auto" }) : (d = s.id, R(d, l));
|
|
229
|
+
else {
|
|
230
|
+
let e = a.autoRouting ? { routedBy: "auto" } : void 0;
|
|
231
|
+
d ? f && f.mode !== l && (f.messages.length > 0 || f.backendSessionId) ? d = P(void 0, l, e) : f && f.mode !== l && (e ? R(d, l) : kt(d, l)) : d = P(void 0, l, e);
|
|
189
232
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
let m = Fe(), h = {
|
|
233
|
+
if (!d) return;
|
|
234
|
+
rn.current[d] = t;
|
|
235
|
+
let m = Ue(), g = {
|
|
194
236
|
accessToken: k(),
|
|
195
|
-
workspaceToken:
|
|
196
|
-
userId:
|
|
197
|
-
organizationId:
|
|
198
|
-
},
|
|
199
|
-
id:
|
|
237
|
+
workspaceToken: yt(),
|
|
238
|
+
userId: A,
|
|
239
|
+
organizationId: He()
|
|
240
|
+
}, ue = {
|
|
241
|
+
id: pt(),
|
|
200
242
|
role: "user",
|
|
201
243
|
content: e,
|
|
202
244
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
203
245
|
metadata: {
|
|
204
|
-
...t.length ? { attachments: t.map(
|
|
205
|
-
...
|
|
246
|
+
...t.length ? { attachments: t.map(ye) } : {},
|
|
247
|
+
...h(n.voiceSessionId)
|
|
206
248
|
}
|
|
207
249
|
};
|
|
208
|
-
|
|
209
|
-
let
|
|
210
|
-
|
|
211
|
-
id:
|
|
250
|
+
F(d, ue);
|
|
251
|
+
let _ = pt();
|
|
252
|
+
F(d, {
|
|
253
|
+
id: _,
|
|
212
254
|
role: "assistant",
|
|
213
255
|
content: "",
|
|
214
256
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
215
257
|
metadata: {
|
|
216
|
-
lang:
|
|
217
|
-
...
|
|
258
|
+
lang: Et,
|
|
259
|
+
...h(n.voiceSessionId)
|
|
218
260
|
}
|
|
219
|
-
}),
|
|
220
|
-
let
|
|
221
|
-
|
|
261
|
+
}), I(d, "provisioning", _, null);
|
|
262
|
+
let de = (e, t, r, i, a = Et) => {
|
|
263
|
+
Mt(d, _, { content: ce(e) }), Nt(d, _, {
|
|
222
264
|
lang: a,
|
|
223
265
|
...t?.length ? { artifacts: t } : {},
|
|
224
|
-
...t?.length || r || i ? { mode:
|
|
266
|
+
...t?.length || r || i ? { mode: l } : {},
|
|
225
267
|
...r ? { sessionId: r } : {},
|
|
226
268
|
...i ? { sandboxId: i } : {},
|
|
227
|
-
...
|
|
269
|
+
...h(n.voiceSessionId)
|
|
228
270
|
});
|
|
229
|
-
},
|
|
271
|
+
}, v = async (n = 1) => {
|
|
230
272
|
let i = !1;
|
|
231
273
|
try {
|
|
232
|
-
let { sandboxId: n, sessionId: a } = await
|
|
233
|
-
|
|
234
|
-
let
|
|
235
|
-
content: e,
|
|
274
|
+
let { sandboxId: n, sessionId: a, sessionIsNew: o } = await cn(d, _, l, m, g), s = Ee(b.getState().conversations.find((e) => e.id === d), e, o), c = (await ne(n, m, a, l, g, { limit: 50 }).catch(() => [])).reduce((e, t) => Math.max(e, se(t)), 0);
|
|
275
|
+
q(d, _, "streaming", "thinking");
|
|
276
|
+
let ie = gt?.(), { prompt: f, parts: p } = Se({
|
|
277
|
+
content: s ? `${s}${e}` : e,
|
|
236
278
|
attachments: t,
|
|
237
|
-
limits:
|
|
238
|
-
wrapPrompt: (e) =>
|
|
239
|
-
requestBytes: (e, t) =>
|
|
279
|
+
limits: ve(ee),
|
|
280
|
+
wrapPrompt: (e) => _t?.(l, e, wt, Tt, r) ?? e,
|
|
281
|
+
requestBytes: (e, t) => ae({
|
|
240
282
|
sandboxId: n,
|
|
241
283
|
workspaceId: m,
|
|
242
284
|
sessionId: a,
|
|
243
|
-
mode:
|
|
285
|
+
mode: l,
|
|
244
286
|
prompt: e,
|
|
245
287
|
parts: t,
|
|
246
|
-
pageContext:
|
|
247
|
-
authContext:
|
|
288
|
+
pageContext: ie,
|
|
289
|
+
authContext: g
|
|
248
290
|
})
|
|
249
|
-
}),
|
|
250
|
-
i =
|
|
291
|
+
}), h = he(p), ue = h > 0;
|
|
292
|
+
i = me(t) > h;
|
|
251
293
|
try {
|
|
252
|
-
await
|
|
294
|
+
await oe(n, m, a, f, l, ie, g, p?.length ? { parts: p } : void 0);
|
|
253
295
|
} catch (e) {
|
|
254
|
-
if (!
|
|
255
|
-
await
|
|
296
|
+
if (!p || !$e(e)) throw e;
|
|
297
|
+
await oe(n, m, a, f, l, ie, g, void 0), i ||= ue;
|
|
256
298
|
}
|
|
257
|
-
let
|
|
258
|
-
turnId:
|
|
259
|
-
abortRequested:
|
|
299
|
+
let v = Le([], c), y = Date.now() + re.streamBudgetMs, pe = Date.now(), ge = Date.now(), _e = () => Pe({
|
|
300
|
+
turnId: _,
|
|
301
|
+
abortRequested: dn.current.has(_),
|
|
260
302
|
activeTurnId: b.getState().processingByConversationId[d]?.messageId ?? null
|
|
261
303
|
});
|
|
262
|
-
for (; Date.now() <
|
|
263
|
-
let e =
|
|
304
|
+
for (; Date.now() < y;) {
|
|
305
|
+
let e = _e();
|
|
264
306
|
if (e.abandon) {
|
|
265
|
-
e.clearProcessing &&
|
|
307
|
+
e.clearProcessing && Pt(d);
|
|
266
308
|
return;
|
|
267
309
|
}
|
|
268
|
-
if (
|
|
310
|
+
if (v = Le(await ne(n, m, a, l, g, {
|
|
269
311
|
limit: 50,
|
|
270
|
-
sinceMs:
|
|
271
|
-
}),
|
|
272
|
-
Date.now() -
|
|
312
|
+
sinceMs: c
|
|
313
|
+
}), c, { accumulateNarration: re.accumulatesNarration }), Mt(d, _, { content: ce(v.content) }), v.pendingWrite && Nt(d, _, { pendingWrite: v.pendingWrite }), v.done) break;
|
|
314
|
+
Date.now() - pe > 3e4 && (await u(n, m, 600, g).catch(() => void 0), pe = Date.now()), await new Promise((e) => setTimeout(e, fe(Date.now() - ge)));
|
|
273
315
|
}
|
|
274
|
-
let
|
|
275
|
-
if (
|
|
276
|
-
...
|
|
277
|
-
content:
|
|
278
|
-
}), i && (
|
|
279
|
-
...
|
|
280
|
-
content: `${
|
|
281
|
-
}),
|
|
282
|
-
|
|
316
|
+
let ye = re.producesArtifacts ? await te(n, m, a, l, g).then((e) => e).catch(() => []) : void 0;
|
|
317
|
+
if (v.done || (v = {
|
|
318
|
+
...v,
|
|
319
|
+
content: le(v.content, l, E, ee)
|
|
320
|
+
}), i && (v = {
|
|
321
|
+
...v,
|
|
322
|
+
content: `${v.content}\n\n${E("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._")}`
|
|
323
|
+
}), de(v.content, ye, a, n), v.tokens) {
|
|
324
|
+
Mt(d, _, { tokens: v.tokens });
|
|
283
325
|
try {
|
|
284
|
-
await
|
|
326
|
+
await vt?.({
|
|
285
327
|
workspaceId: m,
|
|
286
328
|
sessionId: a,
|
|
287
|
-
messageId:
|
|
288
|
-
model:
|
|
289
|
-
tokens:
|
|
290
|
-
}),
|
|
329
|
+
messageId: v.messageId,
|
|
330
|
+
model: v.model,
|
|
331
|
+
tokens: v.tokens
|
|
332
|
+
}), it(D);
|
|
291
333
|
} catch {}
|
|
292
334
|
}
|
|
293
|
-
let
|
|
294
|
-
if (
|
|
295
|
-
|
|
335
|
+
let be = _e();
|
|
336
|
+
if (be.abandon) {
|
|
337
|
+
be.clearProcessing && Pt(d);
|
|
296
338
|
return;
|
|
297
339
|
}
|
|
298
|
-
|
|
340
|
+
I(d, "complete", _, null);
|
|
299
341
|
} catch (e) {
|
|
300
|
-
let t =
|
|
301
|
-
turnId:
|
|
302
|
-
abortRequested:
|
|
342
|
+
let t = Pe({
|
|
343
|
+
turnId: _,
|
|
344
|
+
abortRequested: dn.current.has(_),
|
|
303
345
|
activeTurnId: b.getState().processingByConversationId[d]?.messageId ?? null
|
|
304
346
|
});
|
|
305
347
|
if (t.abandon) {
|
|
306
|
-
t.clearProcessing &&
|
|
348
|
+
t.clearProcessing && Pt(d);
|
|
307
349
|
return;
|
|
308
350
|
}
|
|
309
|
-
if (n === 1 &&
|
|
310
|
-
let e = b.getState().sandboxesByMode[
|
|
311
|
-
return e && (
|
|
351
|
+
if (n === 1 && et(e)) {
|
|
352
|
+
let e = b.getState().sandboxesByMode[l]?.sandboxId ?? null;
|
|
353
|
+
return e && (an.current.add(e), G.current.invalidate(e)), It(d), Lt(l), jt(d, _, ""), Nt(d, _, { pendingWrite: void 0 }), v(2);
|
|
312
354
|
}
|
|
313
355
|
throw e;
|
|
314
356
|
}
|
|
315
357
|
}, y = d;
|
|
316
|
-
|
|
358
|
+
on.current.add(y);
|
|
317
359
|
try {
|
|
318
360
|
if (!m) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
319
|
-
let e = await
|
|
320
|
-
|
|
321
|
-
let t =
|
|
361
|
+
let e = await xe(l, () => Jt.current.find((e) => e.id === l), H);
|
|
362
|
+
ee = e.config, re = e.capabilities;
|
|
363
|
+
let t = we(l, ee, b.getState().acknowledgedWriteModes, {
|
|
322
364
|
dictated: r,
|
|
323
|
-
confirmsWrites:
|
|
365
|
+
confirmsWrites: ie(l)
|
|
324
366
|
});
|
|
325
367
|
if (t) throw Error(t);
|
|
326
|
-
await
|
|
368
|
+
await v();
|
|
327
369
|
} catch (e) {
|
|
328
|
-
|
|
370
|
+
G.current.invalidate(b.getState().sandboxesByMode[l]?.sandboxId ?? null);
|
|
329
371
|
let t = i(e);
|
|
330
372
|
if (t) {
|
|
331
|
-
t.refusal === "exhausted" &&
|
|
373
|
+
t.refusal === "exhausted" && rt(D, "sandbox");
|
|
332
374
|
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.";
|
|
333
|
-
|
|
375
|
+
de(e ? `${n}\n\n${e}` : n, void 0, void 0, void 0, "en"), I(d, "error", _, null);
|
|
334
376
|
return;
|
|
335
377
|
}
|
|
336
|
-
let r =
|
|
378
|
+
let r = tt(e);
|
|
337
379
|
if (r) {
|
|
338
|
-
let e =
|
|
339
|
-
|
|
380
|
+
let e = nt(r);
|
|
381
|
+
I(d, "error", _, e), Mt(d, _, { content: e }), Nt(d, _, {
|
|
340
382
|
lang: "en",
|
|
341
|
-
...
|
|
383
|
+
...h(n.voiceSessionId)
|
|
342
384
|
});
|
|
343
385
|
return;
|
|
344
386
|
}
|
|
345
387
|
let a = e instanceof Error ? e.message : "Something went wrong";
|
|
346
|
-
|
|
388
|
+
I(d, "error", _, a), Mt(d, _, { content: `Sorry, an error occurred: ${a}. Please try again.` }), Nt(d, _, {
|
|
347
389
|
lang: "en",
|
|
348
|
-
...
|
|
390
|
+
...h(n.voiceSessionId)
|
|
349
391
|
});
|
|
350
392
|
} finally {
|
|
351
|
-
|
|
352
|
-
let e =
|
|
353
|
-
|
|
393
|
+
on.current.delete(y);
|
|
394
|
+
let e = b.getState(), t = ke(p, l, e.conversations.find((e) => e.id === y), (t) => !!e.sandboxesByMode[t]?.sandboxId);
|
|
395
|
+
t && (R(y, t.mode), t.backendSessionId && Ft(y, t.backendSessionId));
|
|
396
|
+
let n = fn.current;
|
|
397
|
+
fn.current = null, n && n.conversationId === y && Y.current(n.content, n.attachments, n.options);
|
|
354
398
|
}
|
|
355
399
|
}, [
|
|
356
|
-
|
|
357
|
-
I,
|
|
358
|
-
lt,
|
|
359
|
-
Et,
|
|
360
|
-
Dt,
|
|
361
|
-
vt,
|
|
400
|
+
j,
|
|
362
401
|
F,
|
|
363
|
-
|
|
364
|
-
|
|
402
|
+
_t,
|
|
403
|
+
It,
|
|
404
|
+
Lt,
|
|
405
|
+
Dt,
|
|
406
|
+
P,
|
|
407
|
+
cn,
|
|
408
|
+
gt,
|
|
365
409
|
k,
|
|
366
|
-
|
|
367
|
-
|
|
410
|
+
yt,
|
|
411
|
+
Mt,
|
|
368
412
|
D,
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
gt,
|
|
372
|
-
_t,
|
|
373
|
-
ht,
|
|
413
|
+
H,
|
|
414
|
+
vt,
|
|
374
415
|
Tt,
|
|
375
|
-
|
|
376
|
-
R,
|
|
416
|
+
Et,
|
|
377
417
|
wt,
|
|
418
|
+
R,
|
|
419
|
+
Ft,
|
|
420
|
+
kt,
|
|
421
|
+
I,
|
|
422
|
+
Pt,
|
|
378
423
|
E,
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
]),
|
|
383
|
-
J(e);
|
|
384
|
-
}, [J]),
|
|
385
|
-
let e = [...
|
|
424
|
+
q,
|
|
425
|
+
jt,
|
|
426
|
+
A
|
|
427
|
+
]), hn = x((e, t) => {
|
|
428
|
+
J(e, [], t ? { autoIntent: t } : {});
|
|
429
|
+
}, [J]), gn = x(() => {
|
|
430
|
+
let e = [...z.chat].reverse().find((e) => e.role === "user"), t = j ? rn.current[j] ?? [] : [];
|
|
386
431
|
e && J(e.content, t);
|
|
387
432
|
}, [
|
|
388
|
-
|
|
433
|
+
Ut,
|
|
389
434
|
J,
|
|
390
|
-
|
|
435
|
+
j
|
|
391
436
|
]), Y = w(J);
|
|
392
437
|
S(() => {
|
|
393
438
|
Y.current = J;
|
|
394
439
|
}, [J]);
|
|
395
|
-
let
|
|
396
|
-
if (
|
|
397
|
-
for (let e =
|
|
398
|
-
let t =
|
|
399
|
-
if (t?.role !== "assistant" || !
|
|
400
|
-
let n =
|
|
440
|
+
let _n = C(() => {
|
|
441
|
+
if (Wt) return null;
|
|
442
|
+
for (let e = Ut.length - 1; e >= 0; --e) {
|
|
443
|
+
let t = Ut[e];
|
|
444
|
+
if (t?.role !== "assistant" || !m(t) || dn.current.has(t.id)) continue;
|
|
445
|
+
let n = Ie(t, B, E);
|
|
401
446
|
if (n.kind !== "output") return null;
|
|
402
|
-
let r =
|
|
447
|
+
let r = Re(n.text).text.trim();
|
|
403
448
|
return r ? {
|
|
404
449
|
id: t.id,
|
|
405
450
|
text: r
|
|
@@ -407,89 +452,89 @@ var ot = ({ visible: ot = !0, writeAccess: st = "unknown" }) => {
|
|
|
407
452
|
}
|
|
408
453
|
return null;
|
|
409
454
|
}, [
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
455
|
+
Ut,
|
|
456
|
+
Wt,
|
|
457
|
+
B,
|
|
413
458
|
E
|
|
414
|
-
]),
|
|
459
|
+
]), vn = C(() => _n ? v(_n.text) : null, [_n]), yn = z.chat, X = C(() => z.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
415
460
|
id: e.id,
|
|
416
461
|
role: e.role,
|
|
417
|
-
text:
|
|
418
|
-
sessionId:
|
|
462
|
+
text: Be(e, B, E),
|
|
463
|
+
sessionId: g(e),
|
|
419
464
|
timestamp: e.timestamp
|
|
420
465
|
})).filter((e) => e.text.length > 0), [
|
|
421
|
-
|
|
422
|
-
|
|
466
|
+
z.voice,
|
|
467
|
+
B,
|
|
423
468
|
E
|
|
424
|
-
]),
|
|
469
|
+
]), bn = x(() => {
|
|
425
470
|
if (X.length === 0) return;
|
|
426
471
|
let e = /* @__PURE__ */ new Date();
|
|
427
|
-
|
|
472
|
+
qe(_(X, {
|
|
428
473
|
title: E("voiceSession.transcript", "Voice conversation"),
|
|
429
474
|
savedAt: E("voiceSession.savedAt", "Saved"),
|
|
430
475
|
session: E("voiceSession.sessionLabel", "Session"),
|
|
431
476
|
earlier: E("voiceSession.earlierLabel", "Earlier"),
|
|
432
477
|
you: E("voiceSession.speakerYou", "You"),
|
|
433
478
|
assistant: E("voiceSession.speakerAssistant", "Assistant")
|
|
434
|
-
}, e),
|
|
479
|
+
}, e), de(D, e), "text/markdown");
|
|
435
480
|
}, [
|
|
436
481
|
D,
|
|
437
482
|
X,
|
|
438
483
|
E
|
|
439
|
-
]), Z =
|
|
440
|
-
|
|
441
|
-
let Q =
|
|
484
|
+
]), Z = at({ perFileChars: $t }), xn = w(Z);
|
|
485
|
+
xn.current = Z;
|
|
486
|
+
let Q = Ve({
|
|
442
487
|
onSubmit: x((e, t) => {
|
|
443
488
|
let n = () => {
|
|
444
|
-
let n =
|
|
489
|
+
let n = xn.current, r = ge(n.attachments);
|
|
445
490
|
Y.current(e, r, { voiceSessionId: t }), n.clear();
|
|
446
491
|
};
|
|
447
|
-
if (!
|
|
492
|
+
if (!xn.current.isBusy) {
|
|
448
493
|
n();
|
|
449
494
|
return;
|
|
450
495
|
}
|
|
451
496
|
let r = Date.now(), i = window.setInterval(() => {
|
|
452
|
-
|
|
497
|
+
xn.current.isBusy && Date.now() - r < ft || (window.clearInterval(i), n());
|
|
453
498
|
}, 200);
|
|
454
499
|
}, []),
|
|
455
|
-
latestReply:
|
|
456
|
-
language:
|
|
457
|
-
}),
|
|
500
|
+
latestReply: _n,
|
|
501
|
+
language: y(xt, bt).tag
|
|
502
|
+
}), Sn = C(() => (Ht?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [Ht?.messages]), $ = ze(z.voice, B, E), Cn = $ > Sn, wn = x(() => {
|
|
458
503
|
let e = b.getState().activeConversationId;
|
|
459
|
-
!e || X.length === 0 || (
|
|
460
|
-
id:
|
|
504
|
+
!e || X.length === 0 || (F(e, {
|
|
505
|
+
id: pt(),
|
|
461
506
|
role: "system",
|
|
462
|
-
content:
|
|
507
|
+
content: ue(X.slice(Sn), {
|
|
463
508
|
intro: E("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
|
|
464
509
|
nothing: E("voiceSession.continuedNothing", "Continued from a voice conversation."),
|
|
465
510
|
more: (e) => E("voiceSession.continuedMore", "…and {{count}} more", { count: e })
|
|
466
511
|
}),
|
|
467
512
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
468
513
|
metadata: { continuedVoiceTurns: $ }
|
|
469
|
-
}),
|
|
514
|
+
}), nn(!1), Q.end());
|
|
470
515
|
}, [
|
|
471
516
|
X,
|
|
472
517
|
$,
|
|
473
|
-
|
|
474
|
-
|
|
518
|
+
Sn,
|
|
519
|
+
F,
|
|
475
520
|
E,
|
|
476
521
|
Q
|
|
477
|
-
]),
|
|
522
|
+
]), Tn = w(0);
|
|
478
523
|
S(() => {
|
|
479
|
-
Q.active && (
|
|
524
|
+
Q.active && (Tn.current = $);
|
|
480
525
|
}, [Q.active]);
|
|
481
|
-
let
|
|
482
|
-
let e = $ >
|
|
483
|
-
Q.end(), e &&
|
|
526
|
+
let En = x(() => {
|
|
527
|
+
let e = $ > Tn.current;
|
|
528
|
+
Q.end(), e && nn(!0);
|
|
484
529
|
}, [$, Q]);
|
|
485
530
|
S(() => {
|
|
486
|
-
(!
|
|
531
|
+
(!mt || !sn) && Q.active && Q.end();
|
|
487
532
|
}, [
|
|
488
|
-
|
|
489
|
-
|
|
533
|
+
mt,
|
|
534
|
+
sn,
|
|
490
535
|
Q
|
|
491
536
|
]), S(() => {
|
|
492
|
-
Q.active || (
|
|
537
|
+
Q.active || (xn.current.clear(), fn.current = null);
|
|
493
538
|
}, [Q.active]), S(() => {
|
|
494
539
|
let e = b.getState().consumePendingPrompt();
|
|
495
540
|
return e && Y.current(e), b.subscribe((e, t) => {
|
|
@@ -499,84 +544,126 @@ var ot = ({ visible: ot = !0, writeAccess: st = "unknown" }) => {
|
|
|
499
544
|
}
|
|
500
545
|
});
|
|
501
546
|
}, []);
|
|
502
|
-
let
|
|
503
|
-
let t =
|
|
547
|
+
let Dn = x((e) => {
|
|
548
|
+
let t = j ? b.getState().conversations.find((e) => e.id === j) : void 0;
|
|
504
549
|
if (t && (t.messages.length > 0 || t.backendSessionId)) {
|
|
505
550
|
if (t.mode !== e) {
|
|
506
551
|
let t = b.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !b.getState().processingByConversationId[t.id]);
|
|
507
|
-
t ?
|
|
552
|
+
t ? At(t.id) : P(void 0, e);
|
|
508
553
|
}
|
|
509
|
-
} else
|
|
510
|
-
|
|
554
|
+
} else j && kt(j, e);
|
|
555
|
+
let n = b.getState().activeConversationId;
|
|
556
|
+
n ? kt(n, e) : Vt(!1), N(e);
|
|
511
557
|
}, [
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
558
|
+
j,
|
|
559
|
+
P,
|
|
560
|
+
At,
|
|
561
|
+
Vt,
|
|
562
|
+
kt,
|
|
563
|
+
N
|
|
564
|
+
]), On = x(() => {
|
|
565
|
+
let e = b.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
|
|
566
|
+
if (!t) {
|
|
567
|
+
Vt(!0), N(Te);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if (t.routedBy === "auto") {
|
|
571
|
+
Vt(!0);
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (t.messages.length === 0 && !t.backendSessionId) {
|
|
575
|
+
R(t.id, Te);
|
|
520
576
|
return;
|
|
521
577
|
}
|
|
522
|
-
|
|
523
|
-
|
|
578
|
+
let n = e.conversations.find((t) => t.routedBy === "auto" && t.messages.length === 0 && !t.backendSessionId && !e.processingByConversationId[t.id]);
|
|
579
|
+
n ? (At(n.id), R(n.id, Te)) : P(void 0, Te, { routedBy: "auto" });
|
|
580
|
+
}, [
|
|
581
|
+
P,
|
|
582
|
+
R,
|
|
583
|
+
At,
|
|
584
|
+
Vt,
|
|
585
|
+
N
|
|
586
|
+
]), kn = x((e) => {
|
|
587
|
+
if (O.find((t) => t.id === e)?.writeCapable && !Ce(b.getState().acknowledgedWriteModes, e)) {
|
|
588
|
+
en(e);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
Dn(e);
|
|
592
|
+
}, [Dn, O]), An = x(() => {
|
|
524
593
|
let e = W;
|
|
525
|
-
|
|
594
|
+
if (en(null), !e) return;
|
|
595
|
+
let t = U.current;
|
|
596
|
+
if (U.current = null, t) {
|
|
597
|
+
zt(e), J(t.content, t.attachments, t.options);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
zt(e), Dn(e);
|
|
526
601
|
}, [
|
|
527
602
|
W,
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
603
|
+
zt,
|
|
604
|
+
Dn,
|
|
605
|
+
J
|
|
606
|
+
]), jn = W === null ? void 0 : O.find((e) => e.id === W) ?? { id: W }, Mn = x(() => {
|
|
607
|
+
en(null);
|
|
608
|
+
let e = U.current;
|
|
609
|
+
U.current = null, e && J(e.content, e.attachments, {
|
|
610
|
+
...e.options,
|
|
611
|
+
autoIntent: "read"
|
|
612
|
+
});
|
|
613
|
+
}, [J]);
|
|
614
|
+
return /* @__PURE__ */ ut("div", {
|
|
534
615
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
535
616
|
children: [
|
|
536
|
-
/* @__PURE__ */
|
|
617
|
+
/* @__PURE__ */ ut("div", {
|
|
537
618
|
className: "contents",
|
|
538
619
|
inert: Q.active || void 0,
|
|
539
620
|
children: [
|
|
540
|
-
X.length > 0 && !Q.active ? /* @__PURE__ */ T(
|
|
621
|
+
X.length > 0 && !Q.active ? /* @__PURE__ */ T(Ge, {
|
|
541
622
|
count: X.length,
|
|
542
|
-
onOpenTranscript: () =>
|
|
623
|
+
onOpenTranscript: () => nn(!0)
|
|
543
624
|
}) : null,
|
|
544
|
-
|
|
545
|
-
mode:
|
|
546
|
-
onSuggestionClick:
|
|
625
|
+
yn.length === 0 ? /* @__PURE__ */ T(Je, {
|
|
626
|
+
mode: M,
|
|
627
|
+
onSuggestionClick: hn,
|
|
628
|
+
explainsAuto: Zt,
|
|
629
|
+
suggestions: Zt && M === "assistant" ? De(O.find((e) => e.id === "assistant")?.suggestions ?? [], O.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
|
|
547
630
|
}) : /* @__PURE__ */ T("div", {
|
|
548
631
|
className: "flex min-h-0 flex-1 flex-col",
|
|
549
|
-
children: /* @__PURE__ */ T(
|
|
550
|
-
onApprovePendingWrite:
|
|
551
|
-
approvingWriteRef:
|
|
552
|
-
messages:
|
|
553
|
-
processing:
|
|
554
|
-
streamingMessageId:
|
|
555
|
-
failedMessageId:
|
|
556
|
-
onRetry:
|
|
632
|
+
children: /* @__PURE__ */ T(Ye, {
|
|
633
|
+
onApprovePendingWrite: mn,
|
|
634
|
+
approvingWriteRef: ln,
|
|
635
|
+
messages: yn,
|
|
636
|
+
processing: B ?? null,
|
|
637
|
+
streamingMessageId: Gt,
|
|
638
|
+
failedMessageId: Kt,
|
|
639
|
+
onRetry: gn
|
|
557
640
|
})
|
|
558
641
|
}),
|
|
559
|
-
/* @__PURE__ */ T(
|
|
560
|
-
onStartVoiceSession: Q.available &&
|
|
642
|
+
/* @__PURE__ */ T(ot, {
|
|
643
|
+
onStartVoiceSession: Q.available && sn ? Q.start : void 0,
|
|
561
644
|
onSend: (e, t) => void J(e, t),
|
|
562
|
-
disabled:
|
|
563
|
-
placeholder:
|
|
564
|
-
mode:
|
|
565
|
-
writeAccessDenied:
|
|
566
|
-
availableModes:
|
|
567
|
-
attachmentCharsPerFile:
|
|
568
|
-
onModeChange:
|
|
645
|
+
disabled: Wt,
|
|
646
|
+
placeholder: M === "api-calls" ? E("chatArea.placeholderActions", "What would you like me to do?") : E("chatArea.placeholderGeneral", "Ask me anything…"),
|
|
647
|
+
mode: M,
|
|
648
|
+
writeAccessDenied: ht === "denied" && !!K?.writeCapable,
|
|
649
|
+
availableModes: Yt,
|
|
650
|
+
attachmentCharsPerFile: $t,
|
|
651
|
+
onModeChange: kn,
|
|
652
|
+
auto: Xt ? {
|
|
653
|
+
active: Zt,
|
|
654
|
+
onSelect: On
|
|
655
|
+
} : void 0
|
|
569
656
|
})
|
|
570
657
|
]
|
|
571
658
|
}),
|
|
572
|
-
|
|
659
|
+
tn && !Q.active ? /* @__PURE__ */ T(Ke, {
|
|
573
660
|
turns: X,
|
|
574
|
-
onClose: () =>
|
|
575
|
-
onSave:
|
|
576
|
-
onContinueInChat:
|
|
661
|
+
onClose: () => nn(!1),
|
|
662
|
+
onSave: bn,
|
|
663
|
+
onContinueInChat: Cn ? wn : void 0,
|
|
577
664
|
closeOnEscape: !0
|
|
578
665
|
}) : null,
|
|
579
|
-
Q.active && /* @__PURE__ */ T(
|
|
666
|
+
Q.active && /* @__PURE__ */ T(Xe, {
|
|
580
667
|
session: Q.session,
|
|
581
668
|
notice: Q.notice,
|
|
582
669
|
capturing: Q.capturing,
|
|
@@ -590,24 +677,24 @@ var ot = ({ visible: ot = !0, writeAccess: st = "unknown" }) => {
|
|
|
590
677
|
onRetryAttachment: Z.retry,
|
|
591
678
|
canAttachMore: Z.canAddMore,
|
|
592
679
|
preparingAttachments: Z.preparingCount,
|
|
593
|
-
onSaveTranscript:
|
|
594
|
-
onContinueInChat:
|
|
680
|
+
onSaveTranscript: bn,
|
|
681
|
+
onContinueInChat: wn,
|
|
595
682
|
onInterrupt: () => {
|
|
596
|
-
Q.interrupt(),
|
|
683
|
+
Q.interrupt(), pn();
|
|
597
684
|
},
|
|
598
|
-
spoken:
|
|
685
|
+
spoken: vn,
|
|
599
686
|
onToggleMute: Q.toggleMute,
|
|
600
|
-
onEnd:
|
|
687
|
+
onEnd: En
|
|
601
688
|
}),
|
|
602
|
-
/* @__PURE__ */ T(
|
|
689
|
+
/* @__PURE__ */ T(ct, {
|
|
603
690
|
open: W !== null,
|
|
604
|
-
mode:
|
|
605
|
-
currentMode:
|
|
606
|
-
onConfirm:
|
|
607
|
-
onCancel:
|
|
691
|
+
mode: jn,
|
|
692
|
+
currentMode: K ?? { id: M },
|
|
693
|
+
onConfirm: An,
|
|
694
|
+
onCancel: Mn
|
|
608
695
|
})
|
|
609
696
|
]
|
|
610
697
|
});
|
|
611
698
|
};
|
|
612
699
|
//#endregion
|
|
613
|
-
export {
|
|
700
|
+
export { mt as AssistantChatArea };
|