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