@burdenoff/fe-libs 2026.924.3 → 2026.925.1
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/i18nManifest.d.ts.map +1 -1
- package/dist/shared/assistant/i18nManifest.js +21 -19
- package/dist/shared/assistant/index.d.ts +2 -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/speech/hostedTtsProtocol.d.ts +7 -0
- package/dist/shared/assistant/speech/hostedTtsProtocol.d.ts.map +1 -1
- package/dist/shared/assistant/speech/hostedTtsProtocol.js +5 -2
- package/dist/shared/assistant/speech/hostedTtsSpeechEngine.d.ts.map +1 -1
- package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +2 -2
- package/dist/shared/assistant/speech/routingSpeechEngine.d.ts.map +1 -1
- package/dist/shared/assistant/speech/routingSpeechEngine.js +49 -31
- 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 +412 -423
- 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 -114
- package/package.json +1 -1
|
@@ -3,448 +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 {
|
|
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";
|
|
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";
|
|
9
8
|
import { getRawMessageCreatedAt as se, sanitize as ce } from "../progress.js";
|
|
10
9
|
import { withIncompleteTurnNotice as le } from "../streamBudget.js";
|
|
11
|
-
import { isVoiceTurn as
|
|
12
|
-
import { buildContinuedFromVoiceNote as ue, buildVoiceTranscriptMarkdown as
|
|
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";
|
|
13
12
|
import { pollDelayMs as fe } from "../voice/assistantPollSchedule.js";
|
|
14
|
-
import { toCaptionText as
|
|
15
|
-
import { resolveAssistantLanguage as
|
|
16
|
-
import { resolveLanguagePair as
|
|
17
|
-
import { countInlineImageCandidates as
|
|
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 { dispatchAssistantQuotaExhausted as
|
|
42
|
-
import { useAssistantAttachments as
|
|
43
|
-
import { AssistantComposer as
|
|
44
|
-
import { isProdRuntime as
|
|
45
|
-
import { AssistantApiCallsConsentDialog as
|
|
46
|
-
import { useCallback as
|
|
47
|
-
import { jsx as
|
|
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";
|
|
48
47
|
//#region src/shared/assistant/ui/AssistantChatArea.tsx
|
|
49
|
-
var
|
|
50
|
-
function
|
|
48
|
+
var pt = 600, mt = 2e4;
|
|
49
|
+
function ht() {
|
|
51
50
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
52
51
|
}
|
|
53
|
-
var
|
|
54
|
-
let
|
|
55
|
-
xt,
|
|
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), [
|
|
56
54
|
St,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
S(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
68
67
|
});
|
|
69
68
|
}, [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
]),
|
|
74
|
-
|
|
75
|
-
}, [
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, [
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
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");
|
|
84
83
|
return;
|
|
85
84
|
}
|
|
86
|
-
|
|
85
|
+
Jt || (!G || G.requiresAdmin && !B) && j !== "assistant" && M("assistant");
|
|
87
86
|
}, [
|
|
87
|
+
j,
|
|
88
|
+
G,
|
|
89
|
+
B,
|
|
90
|
+
Jt,
|
|
88
91
|
M,
|
|
89
|
-
|
|
90
|
-
V,
|
|
91
|
-
qt,
|
|
92
|
-
N,
|
|
93
|
-
Rt
|
|
92
|
+
zt
|
|
94
93
|
]);
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
}, [
|
|
98
|
-
let o =
|
|
99
|
-
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;
|
|
100
99
|
try {
|
|
101
|
-
return await
|
|
100
|
+
return await oe(e, r, a, 3e5), await f(e, r, n, a, 9e4), W.current.markVerified(e), !0;
|
|
102
101
|
} catch {
|
|
103
|
-
return
|
|
102
|
+
return W.current.invalidate(e), on.current.add(e), !1;
|
|
104
103
|
}
|
|
105
104
|
};
|
|
106
|
-
if (o && (
|
|
107
|
-
|
|
108
|
-
let
|
|
109
|
-
|
|
105
|
+
if (o && (I(n, o, "provisioning"), K(e, t, "provisioning", "reusingEnvironment"), await ee(o) || (I(n, null, "provisioning"), o = null)), !o) {
|
|
106
|
+
K(e, t, "provisioning", "lookingForEnvironment");
|
|
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"));
|
|
110
109
|
}
|
|
111
110
|
if (!o) {
|
|
112
|
-
if (n === "api-calls" && !
|
|
113
|
-
|
|
114
|
-
let
|
|
115
|
-
if (
|
|
116
|
-
let e = new Set(
|
|
117
|
-
for (let e of
|
|
118
|
-
let t =
|
|
119
|
-
for (let [n, r] of Object.entries(t))
|
|
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);
|
|
120
119
|
}
|
|
121
|
-
o = await
|
|
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);
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
let
|
|
125
|
-
if (
|
|
126
|
-
let e = await
|
|
122
|
+
I(n, o, "running");
|
|
123
|
+
let l = v.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null, ne = !1;
|
|
124
|
+
if (l) try {
|
|
125
|
+
let e = await u(o, r, l, n, a);
|
|
127
126
|
if (e.mode !== n) throw Error(`Session mode mismatch: expected ${n}, received ${e.mode}`);
|
|
128
127
|
} catch {
|
|
129
|
-
|
|
128
|
+
Lt(e), l = null;
|
|
130
129
|
}
|
|
131
|
-
return
|
|
130
|
+
return l || (K(e, t, "connecting", "preparingSession"), l = (await c(o, r, n, a)).sessionId, It(e, l), ne = !0), {
|
|
132
131
|
sandboxId: o,
|
|
133
|
-
sessionId:
|
|
134
|
-
sessionIsNew:
|
|
132
|
+
sessionId: l,
|
|
133
|
+
sessionIsNew: ne
|
|
135
134
|
};
|
|
136
135
|
}, [
|
|
137
|
-
It,
|
|
138
136
|
Lt,
|
|
139
|
-
|
|
137
|
+
Rt,
|
|
140
138
|
D,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
T,
|
|
140
|
+
It,
|
|
141
|
+
I,
|
|
142
|
+
K
|
|
143
|
+
]), [un, dn] = dt(null), q = S(/* @__PURE__ */ new Set()), fn = S(null), pn = y(() => {
|
|
144
|
+
let e = v.getState(), t = e.activeConversationId;
|
|
146
145
|
if (!t) return;
|
|
147
|
-
let n = e.processingByConversationId[t], r =
|
|
148
|
-
if (!
|
|
146
|
+
let n = e.processingByConversationId[t], r = Le(n?.status) ? n?.messageId ?? null : null;
|
|
147
|
+
if (!ze({
|
|
149
148
|
interruptedTurnId: r,
|
|
150
149
|
activeTurnId: r,
|
|
151
|
-
alreadyRequested: r ?
|
|
150
|
+
alreadyRequested: r ? q.current.has(r) : !1
|
|
152
151
|
}).send || !r) return;
|
|
153
|
-
|
|
154
|
-
let i =
|
|
155
|
-
!i || !
|
|
156
|
-
accessToken:
|
|
157
|
-
workspaceToken:
|
|
158
|
-
userId:
|
|
159
|
-
organizationId:
|
|
152
|
+
q.current.add(r);
|
|
153
|
+
let i = Ie(e), o = qe(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
|
|
154
|
+
!i || !o || !s || a(i.sandboxId, o, s, i.mode, {
|
|
155
|
+
accessToken: D(),
|
|
156
|
+
workspaceToken: O(),
|
|
157
|
+
userId: k,
|
|
158
|
+
organizationId: Ke()
|
|
160
159
|
});
|
|
161
160
|
}, [
|
|
162
|
-
A,
|
|
163
161
|
k,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
D,
|
|
163
|
+
O
|
|
164
|
+
]), mn = y(async (e) => {
|
|
165
|
+
let t = v.getState(), n = Ie(t), r = qe(), i = t.activeConversationId;
|
|
167
166
|
if (!(!n || !r || !i)) {
|
|
168
|
-
|
|
167
|
+
dn(e);
|
|
169
168
|
try {
|
|
170
|
-
await
|
|
171
|
-
accessToken:
|
|
172
|
-
workspaceToken:
|
|
173
|
-
userId:
|
|
174
|
-
organizationId:
|
|
169
|
+
await o(n.sandboxId, r, e, n.mode, {
|
|
170
|
+
accessToken: D(),
|
|
171
|
+
workspaceToken: O(),
|
|
172
|
+
userId: k,
|
|
173
|
+
organizationId: Ke()
|
|
175
174
|
});
|
|
176
175
|
} catch (e) {
|
|
177
|
-
|
|
178
|
-
id:
|
|
176
|
+
dn(null), P(i, {
|
|
177
|
+
id: ht(),
|
|
179
178
|
role: "system",
|
|
180
179
|
content: e instanceof Error ? e.message : "The change could not be approved.",
|
|
181
180
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
182
181
|
});
|
|
183
182
|
return;
|
|
184
183
|
}
|
|
185
|
-
|
|
184
|
+
dn(null), Y.current(w("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
|
|
186
185
|
}
|
|
187
186
|
}, [
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
]), J =
|
|
192
|
-
let r = n.voiceSessionId !== void 0,
|
|
193
|
-
if (
|
|
194
|
-
if (
|
|
195
|
-
let r =
|
|
196
|
-
r &&
|
|
197
|
-
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,
|
|
198
197
|
content: e,
|
|
199
198
|
attachments: t,
|
|
200
199
|
options: n
|
|
201
200
|
});
|
|
202
201
|
return;
|
|
203
202
|
}
|
|
204
|
-
if (
|
|
203
|
+
if (sn.current.has(a)) return;
|
|
205
204
|
}
|
|
206
|
-
if (
|
|
207
|
-
let
|
|
208
|
-
intent: n.autoIntent ??
|
|
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),
|
|
209
208
|
dictated: r,
|
|
210
|
-
conversation:
|
|
211
|
-
mode:
|
|
212
|
-
routedBy:
|
|
213
|
-
hasHistory:
|
|
209
|
+
conversation: o ? {
|
|
210
|
+
mode: o.mode,
|
|
211
|
+
routedBy: o.routedBy,
|
|
212
|
+
hasHistory: o.messages.length > 0 || !!o.backendSessionId
|
|
214
213
|
} : null
|
|
215
214
|
}) : null;
|
|
216
|
-
if (
|
|
217
|
-
|
|
215
|
+
if (s && Yt.current.find((e) => e.id === s.mode)?.writeCapable && !De(i.acknowledgedWriteModes, s.mode)) {
|
|
216
|
+
H.current = {
|
|
218
217
|
content: e,
|
|
219
218
|
attachments: t,
|
|
220
219
|
options: n
|
|
221
|
-
},
|
|
220
|
+
}, tn(s.mode);
|
|
222
221
|
return;
|
|
223
222
|
}
|
|
224
|
-
let
|
|
225
|
-
mode:
|
|
226
|
-
backendSessionId:
|
|
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
|
|
227
226
|
} : null;
|
|
228
|
-
if (
|
|
227
|
+
if (s) s.action === "new" || !o ? d = N(void 0, c, { routedBy: "auto" }) : (d = o.id, L(d, c));
|
|
229
228
|
else {
|
|
230
|
-
let e =
|
|
231
|
-
d ? f && f.mode !==
|
|
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);
|
|
232
231
|
}
|
|
233
232
|
if (!d) return;
|
|
234
|
-
|
|
235
|
-
let
|
|
236
|
-
accessToken:
|
|
237
|
-
workspaceToken:
|
|
238
|
-
userId:
|
|
239
|
-
organizationId:
|
|
233
|
+
an.current[d] = t;
|
|
234
|
+
let p = qe(), h = {
|
|
235
|
+
accessToken: D(),
|
|
236
|
+
workspaceToken: O(),
|
|
237
|
+
userId: k,
|
|
238
|
+
organizationId: Ke()
|
|
240
239
|
}, ue = {
|
|
241
|
-
id:
|
|
240
|
+
id: ht(),
|
|
242
241
|
role: "user",
|
|
243
242
|
content: e,
|
|
244
243
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
245
244
|
metadata: {
|
|
246
|
-
...t.length ? { attachments: t.map(
|
|
247
|
-
...
|
|
245
|
+
...t.length ? { attachments: t.map(be) } : {},
|
|
246
|
+
...m(n.voiceSessionId)
|
|
248
247
|
}
|
|
249
248
|
};
|
|
250
|
-
|
|
251
|
-
let
|
|
252
|
-
|
|
253
|
-
id:
|
|
249
|
+
P(d, ue);
|
|
250
|
+
let g = ht();
|
|
251
|
+
P(d, {
|
|
252
|
+
id: g,
|
|
254
253
|
role: "assistant",
|
|
255
254
|
content: "",
|
|
256
255
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
257
256
|
metadata: {
|
|
258
|
-
lang:
|
|
259
|
-
...
|
|
257
|
+
lang: Dt,
|
|
258
|
+
...m(n.voiceSessionId)
|
|
260
259
|
}
|
|
261
|
-
}),
|
|
262
|
-
let de = (e, t, r, i, a =
|
|
263
|
-
|
|
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, {
|
|
264
263
|
lang: a,
|
|
265
264
|
...t?.length ? { artifacts: t } : {},
|
|
266
|
-
...t?.length || r || i ? { mode:
|
|
265
|
+
...t?.length || r || i ? { mode: c } : {},
|
|
267
266
|
...r ? { sessionId: r } : {},
|
|
268
267
|
...i ? { sandboxId: i } : {},
|
|
269
|
-
...
|
|
268
|
+
...m(n.voiceSessionId)
|
|
270
269
|
});
|
|
271
|
-
},
|
|
270
|
+
}, pe = async (n = 1) => {
|
|
272
271
|
let i = !1;
|
|
273
272
|
try {
|
|
274
|
-
let { sandboxId: n, sessionId: a, sessionIsNew: o } = await
|
|
275
|
-
|
|
276
|
-
let
|
|
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({
|
|
277
276
|
content: s ? `${s}${e}` : e,
|
|
278
277
|
attachments: t,
|
|
279
|
-
limits:
|
|
280
|
-
wrapPrompt: (e) =>
|
|
281
|
-
requestBytes: (e, t) =>
|
|
278
|
+
limits: ye(te),
|
|
279
|
+
wrapPrompt: (e) => yt?.(c, e, Tt, Et, r) ?? e,
|
|
280
|
+
requestBytes: (e, t) => ie({
|
|
282
281
|
sandboxId: n,
|
|
283
|
-
workspaceId:
|
|
282
|
+
workspaceId: p,
|
|
284
283
|
sessionId: a,
|
|
285
|
-
mode:
|
|
284
|
+
mode: c,
|
|
286
285
|
prompt: e,
|
|
287
286
|
parts: t,
|
|
288
|
-
pageContext:
|
|
289
|
-
authContext:
|
|
287
|
+
pageContext: f,
|
|
288
|
+
authContext: h
|
|
290
289
|
})
|
|
291
|
-
}),
|
|
292
|
-
i =
|
|
290
|
+
}), ue = ge(m), pe = ue > 0;
|
|
291
|
+
i = he(t) > ue;
|
|
293
292
|
try {
|
|
294
|
-
await
|
|
293
|
+
await ae(n, p, a, oe, c, f, h, m?.length ? { parts: m } : void 0);
|
|
295
294
|
} catch (e) {
|
|
296
|
-
if (!
|
|
297
|
-
await
|
|
295
|
+
if (!m || !rt(e)) throw e;
|
|
296
|
+
await ae(n, p, a, oe, c, f, h, void 0), i ||= pe;
|
|
298
297
|
}
|
|
299
|
-
let
|
|
300
|
-
turnId:
|
|
301
|
-
abortRequested:
|
|
302
|
-
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
|
|
303
302
|
});
|
|
304
|
-
for (; Date.now() <
|
|
305
|
-
let e =
|
|
303
|
+
for (; Date.now() < me;) {
|
|
304
|
+
let e = be();
|
|
306
305
|
if (e.abandon) {
|
|
307
|
-
e.clearProcessing &&
|
|
306
|
+
e.clearProcessing && Ft(d);
|
|
308
307
|
return;
|
|
309
308
|
}
|
|
310
|
-
if (
|
|
309
|
+
if (_ = Ve(await ne(n, p, a, c, h, {
|
|
311
310
|
limit: 50,
|
|
312
|
-
sinceMs:
|
|
313
|
-
}),
|
|
314
|
-
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)));
|
|
315
314
|
}
|
|
316
|
-
let
|
|
317
|
-
if (
|
|
318
|
-
...
|
|
319
|
-
content: le(
|
|
320
|
-
}), i && (
|
|
321
|
-
...
|
|
322
|
-
content: `${
|
|
323
|
-
}), de(
|
|
324
|
-
|
|
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 });
|
|
325
324
|
try {
|
|
326
|
-
await
|
|
327
|
-
workspaceId:
|
|
325
|
+
await bt?.({
|
|
326
|
+
workspaceId: p,
|
|
328
327
|
sessionId: a,
|
|
329
|
-
messageId:
|
|
330
|
-
model:
|
|
331
|
-
tokens:
|
|
332
|
-
}),
|
|
328
|
+
messageId: _.messageId,
|
|
329
|
+
model: _.model,
|
|
330
|
+
tokens: _.tokens
|
|
331
|
+
}), ot(T);
|
|
333
332
|
} catch {}
|
|
334
333
|
}
|
|
335
|
-
let
|
|
336
|
-
if (
|
|
337
|
-
|
|
334
|
+
let Se = be();
|
|
335
|
+
if (Se.abandon) {
|
|
336
|
+
Se.clearProcessing && Ft(d);
|
|
338
337
|
return;
|
|
339
338
|
}
|
|
340
|
-
|
|
339
|
+
F(d, "complete", g, null);
|
|
341
340
|
} catch (e) {
|
|
342
|
-
let t =
|
|
343
|
-
turnId:
|
|
344
|
-
abortRequested:
|
|
345
|
-
activeTurnId:
|
|
341
|
+
let t = Re({
|
|
342
|
+
turnId: g,
|
|
343
|
+
abortRequested: q.current.has(g),
|
|
344
|
+
activeTurnId: v.getState().processingByConversationId[d]?.messageId ?? null
|
|
346
345
|
});
|
|
347
346
|
if (t.abandon) {
|
|
348
|
-
t.clearProcessing &&
|
|
347
|
+
t.clearProcessing && Ft(d);
|
|
349
348
|
return;
|
|
350
349
|
}
|
|
351
|
-
if (n === 1 &&
|
|
352
|
-
let e =
|
|
353
|
-
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);
|
|
354
353
|
}
|
|
355
354
|
throw e;
|
|
356
355
|
}
|
|
357
|
-
},
|
|
358
|
-
|
|
356
|
+
}, _ = d;
|
|
357
|
+
sn.current.add(_);
|
|
359
358
|
try {
|
|
360
|
-
if (!
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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, {
|
|
364
366
|
dictated: r,
|
|
365
|
-
confirmsWrites:
|
|
367
|
+
confirmsWrites: re(c)
|
|
366
368
|
});
|
|
367
|
-
if (t) throw
|
|
368
|
-
await
|
|
369
|
+
if (t) throw new xe(t, t === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
|
|
370
|
+
await pe();
|
|
369
371
|
} catch (e) {
|
|
370
|
-
|
|
371
|
-
let t =
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
let r = tt(e);
|
|
379
|
-
if (r) {
|
|
380
|
-
let e = nt(r);
|
|
381
|
-
I(d, "error", _, e), Mt(d, _, { content: e }), Nt(d, _, {
|
|
382
|
-
lang: "en",
|
|
383
|
-
...h(n.voiceSessionId)
|
|
384
|
-
});
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
let a = e instanceof Error ? e.message : "Something went wrong";
|
|
388
|
-
I(d, "error", _, a), Mt(d, _, { content: `Sorry, an error occurred: ${a}. Please try again.` }), Nt(d, _, {
|
|
389
|
-
lang: "en",
|
|
390
|
-
...h(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)
|
|
391
379
|
});
|
|
392
380
|
} finally {
|
|
393
|
-
|
|
394
|
-
let e =
|
|
395
|
-
t && (
|
|
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));
|
|
396
384
|
let n = fn.current;
|
|
397
|
-
fn.current = null, n && n.conversationId ===
|
|
385
|
+
fn.current = null, n && n.conversationId === _ && Y.current(n.content, n.attachments, n.options);
|
|
398
386
|
}
|
|
399
387
|
}, [
|
|
400
|
-
|
|
401
|
-
F,
|
|
402
|
-
_t,
|
|
403
|
-
It,
|
|
404
|
-
Lt,
|
|
405
|
-
Dt,
|
|
388
|
+
A,
|
|
406
389
|
P,
|
|
407
|
-
cn,
|
|
408
|
-
gt,
|
|
409
|
-
k,
|
|
410
390
|
yt,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
391
|
+
Lt,
|
|
392
|
+
Rt,
|
|
393
|
+
Ot,
|
|
394
|
+
N,
|
|
395
|
+
ln,
|
|
414
396
|
vt,
|
|
415
|
-
|
|
397
|
+
D,
|
|
398
|
+
O,
|
|
399
|
+
Nt,
|
|
400
|
+
T,
|
|
401
|
+
V,
|
|
402
|
+
bt,
|
|
416
403
|
Et,
|
|
417
|
-
|
|
418
|
-
|
|
404
|
+
xt,
|
|
405
|
+
Dt,
|
|
406
|
+
Tt,
|
|
407
|
+
L,
|
|
408
|
+
It,
|
|
409
|
+
At,
|
|
410
|
+
F,
|
|
419
411
|
Ft,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
jt,
|
|
426
|
-
A
|
|
427
|
-
]), hn = x((e, t) => {
|
|
412
|
+
w,
|
|
413
|
+
K,
|
|
414
|
+
Mt,
|
|
415
|
+
k
|
|
416
|
+
]), hn = y((e, t) => {
|
|
428
417
|
J(e, [], t ? { autoIntent: t } : {});
|
|
429
|
-
}, [J]), gn =
|
|
430
|
-
let e = [...
|
|
418
|
+
}, [J]), gn = y(() => {
|
|
419
|
+
let e = [...R.chat].reverse().find((e) => e.role === "user"), t = A ? an.current[A] ?? [] : [];
|
|
431
420
|
e && J(e.content, t);
|
|
432
421
|
}, [
|
|
433
|
-
|
|
422
|
+
Wt,
|
|
434
423
|
J,
|
|
435
|
-
|
|
436
|
-
]), Y =
|
|
437
|
-
|
|
424
|
+
A
|
|
425
|
+
]), Y = S(J);
|
|
426
|
+
b(() => {
|
|
438
427
|
Y.current = J;
|
|
439
428
|
}, [J]);
|
|
440
|
-
let _n =
|
|
441
|
-
if (
|
|
442
|
-
for (let e =
|
|
443
|
-
let t =
|
|
444
|
-
if (t?.role !== "assistant" || !
|
|
445
|
-
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);
|
|
446
435
|
if (n.kind !== "output") return null;
|
|
447
|
-
let r =
|
|
436
|
+
let r = He(n.text).text.trim();
|
|
448
437
|
return r ? {
|
|
449
438
|
id: t.id,
|
|
450
439
|
text: r
|
|
@@ -452,41 +441,41 @@ var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
|
|
|
452
441
|
}
|
|
453
442
|
return null;
|
|
454
443
|
}, [
|
|
455
|
-
Ut,
|
|
456
444
|
Wt,
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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) => ({
|
|
460
449
|
id: e.id,
|
|
461
450
|
role: e.role,
|
|
462
|
-
text:
|
|
463
|
-
sessionId:
|
|
451
|
+
text: We(e, z, w),
|
|
452
|
+
sessionId: h(e),
|
|
464
453
|
timestamp: e.timestamp
|
|
465
454
|
})).filter((e) => e.text.length > 0), [
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
]), bn =
|
|
455
|
+
R.voice,
|
|
456
|
+
z,
|
|
457
|
+
w
|
|
458
|
+
]), bn = y(() => {
|
|
470
459
|
if (X.length === 0) return;
|
|
471
460
|
let e = /* @__PURE__ */ new Date();
|
|
472
|
-
|
|
473
|
-
title:
|
|
474
|
-
savedAt:
|
|
475
|
-
session:
|
|
476
|
-
earlier:
|
|
477
|
-
you:
|
|
478
|
-
assistant:
|
|
479
|
-
}, e), de(
|
|
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");
|
|
480
469
|
}, [
|
|
481
|
-
|
|
470
|
+
T,
|
|
482
471
|
X,
|
|
483
|
-
|
|
484
|
-
]), Z =
|
|
472
|
+
w
|
|
473
|
+
]), Z = st({ perFileChars: en }), xn = S(Z);
|
|
485
474
|
xn.current = Z;
|
|
486
|
-
let Q =
|
|
487
|
-
onSubmit:
|
|
475
|
+
let Q = Ge({
|
|
476
|
+
onSubmit: y((e, t) => {
|
|
488
477
|
let n = () => {
|
|
489
|
-
let n = xn.current, r =
|
|
478
|
+
let n = xn.current, r = _e(n.attachments);
|
|
490
479
|
Y.current(e, r, { voiceSessionId: t }), n.clear();
|
|
491
480
|
};
|
|
492
481
|
if (!xn.current.isBusy) {
|
|
@@ -494,176 +483,176 @@ var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
|
|
|
494
483
|
return;
|
|
495
484
|
}
|
|
496
485
|
let r = Date.now(), i = window.setInterval(() => {
|
|
497
|
-
xn.current.isBusy && Date.now() - r <
|
|
486
|
+
xn.current.isBusy && Date.now() - r < mt || (window.clearInterval(i), n());
|
|
498
487
|
}, 200);
|
|
499
488
|
}, []),
|
|
500
489
|
latestReply: _n,
|
|
501
|
-
language:
|
|
502
|
-
}), Sn =
|
|
503
|
-
let e =
|
|
504
|
-
!e || X.length === 0 || (
|
|
505
|
-
id:
|
|
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(),
|
|
506
495
|
role: "system",
|
|
507
496
|
content: ue(X.slice(Sn), {
|
|
508
|
-
intro:
|
|
509
|
-
nothing:
|
|
510
|
-
more: (e) =>
|
|
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 })
|
|
511
500
|
}),
|
|
512
501
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
513
502
|
metadata: { continuedVoiceTurns: $ }
|
|
514
|
-
}),
|
|
503
|
+
}), rn(!1), Q.end());
|
|
515
504
|
}, [
|
|
516
505
|
X,
|
|
517
506
|
$,
|
|
518
507
|
Sn,
|
|
519
|
-
|
|
520
|
-
|
|
508
|
+
P,
|
|
509
|
+
w,
|
|
521
510
|
Q
|
|
522
|
-
]), Tn =
|
|
523
|
-
|
|
511
|
+
]), Tn = S(0);
|
|
512
|
+
b(() => {
|
|
524
513
|
Q.active && (Tn.current = $);
|
|
525
514
|
}, [Q.active]);
|
|
526
|
-
let En =
|
|
515
|
+
let En = y(() => {
|
|
527
516
|
let e = $ > Tn.current;
|
|
528
|
-
Q.end(), e &&
|
|
517
|
+
Q.end(), e && rn(!0);
|
|
529
518
|
}, [$, Q]);
|
|
530
|
-
|
|
531
|
-
(!
|
|
519
|
+
b(() => {
|
|
520
|
+
(!gt || !cn) && Q.active && Q.end();
|
|
532
521
|
}, [
|
|
533
|
-
|
|
534
|
-
|
|
522
|
+
gt,
|
|
523
|
+
cn,
|
|
535
524
|
Q
|
|
536
|
-
]),
|
|
525
|
+
]), b(() => {
|
|
537
526
|
Q.active || (xn.current.clear(), fn.current = null);
|
|
538
|
-
}, [Q.active]),
|
|
539
|
-
let e =
|
|
540
|
-
return e && Y.current(e),
|
|
527
|
+
}, [Q.active]), b(() => {
|
|
528
|
+
let e = v.getState().consumePendingPrompt();
|
|
529
|
+
return e && Y.current(e), v.subscribe((e, t) => {
|
|
541
530
|
if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
|
|
542
|
-
let e =
|
|
531
|
+
let e = v.getState().consumePendingPrompt();
|
|
543
532
|
e && Y.current(e);
|
|
544
533
|
}
|
|
545
534
|
});
|
|
546
535
|
}, []);
|
|
547
|
-
let Dn =
|
|
548
|
-
let t =
|
|
536
|
+
let Dn = y((e) => {
|
|
537
|
+
let t = A ? v.getState().conversations.find((e) => e.id === A) : void 0;
|
|
549
538
|
if (t && (t.messages.length > 0 || t.backendSessionId)) {
|
|
550
539
|
if (t.mode !== e) {
|
|
551
|
-
let t =
|
|
552
|
-
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);
|
|
553
542
|
}
|
|
554
|
-
} else
|
|
555
|
-
let n =
|
|
556
|
-
n ?
|
|
543
|
+
} else A && At(A, e);
|
|
544
|
+
let n = v.getState().activeConversationId;
|
|
545
|
+
n ? At(n, e) : Ht(!1), M(e);
|
|
557
546
|
}, [
|
|
558
|
-
|
|
559
|
-
|
|
547
|
+
A,
|
|
548
|
+
N,
|
|
549
|
+
jt,
|
|
550
|
+
Ht,
|
|
560
551
|
At,
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
]), On = x(() => {
|
|
565
|
-
let e = b.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
|
|
552
|
+
M
|
|
553
|
+
]), On = y(() => {
|
|
554
|
+
let e = v.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
|
|
566
555
|
if (!t) {
|
|
567
|
-
|
|
556
|
+
Ht(!0), M(ke);
|
|
568
557
|
return;
|
|
569
558
|
}
|
|
570
559
|
if (t.routedBy === "auto") {
|
|
571
|
-
|
|
560
|
+
Ht(!0);
|
|
572
561
|
return;
|
|
573
562
|
}
|
|
574
563
|
if (t.messages.length === 0 && !t.backendSessionId) {
|
|
575
|
-
|
|
564
|
+
L(t.id, ke);
|
|
576
565
|
return;
|
|
577
566
|
}
|
|
578
567
|
let n = e.conversations.find((t) => t.routedBy === "auto" && t.messages.length === 0 && !t.backendSessionId && !e.processingByConversationId[t.id]);
|
|
579
|
-
n ? (
|
|
568
|
+
n ? (jt(n.id), L(n.id, ke)) : N(void 0, ke, { routedBy: "auto" });
|
|
580
569
|
}, [
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
]), kn =
|
|
587
|
-
if (
|
|
588
|
-
|
|
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);
|
|
589
578
|
return;
|
|
590
579
|
}
|
|
591
580
|
Dn(e);
|
|
592
|
-
}, [Dn,
|
|
593
|
-
let e =
|
|
594
|
-
if (
|
|
595
|
-
let t =
|
|
596
|
-
if (
|
|
597
|
-
|
|
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);
|
|
598
587
|
return;
|
|
599
588
|
}
|
|
600
|
-
|
|
589
|
+
Bt(e), Dn(e);
|
|
601
590
|
}, [
|
|
602
|
-
|
|
603
|
-
|
|
591
|
+
U,
|
|
592
|
+
Bt,
|
|
604
593
|
Dn,
|
|
605
594
|
J
|
|
606
|
-
]), jn =
|
|
607
|
-
|
|
608
|
-
let e =
|
|
609
|
-
|
|
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, {
|
|
610
599
|
...e.options,
|
|
611
600
|
autoIntent: "read"
|
|
612
601
|
});
|
|
613
602
|
}, [J]);
|
|
614
|
-
return /* @__PURE__ */
|
|
603
|
+
return /* @__PURE__ */ ft("div", {
|
|
615
604
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
616
605
|
children: [
|
|
617
|
-
/* @__PURE__ */
|
|
606
|
+
/* @__PURE__ */ ft("div", {
|
|
618
607
|
className: "contents",
|
|
619
608
|
inert: Q.active || void 0,
|
|
620
609
|
children: [
|
|
621
|
-
X.length > 0 && !Q.active ? /* @__PURE__ */
|
|
610
|
+
X.length > 0 && !Q.active ? /* @__PURE__ */ C(Ye, {
|
|
622
611
|
count: X.length,
|
|
623
|
-
onOpenTranscript: () =>
|
|
612
|
+
onOpenTranscript: () => rn(!0)
|
|
624
613
|
}) : null,
|
|
625
|
-
yn.length === 0 ? /* @__PURE__ */
|
|
626
|
-
mode:
|
|
614
|
+
yn.length === 0 ? /* @__PURE__ */ C(Qe, {
|
|
615
|
+
mode: j,
|
|
627
616
|
onSuggestionClick: hn,
|
|
628
|
-
explainsAuto:
|
|
629
|
-
suggestions:
|
|
630
|
-
}) : /* @__PURE__ */
|
|
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", {
|
|
631
620
|
className: "flex min-h-0 flex-1 flex-col",
|
|
632
|
-
children: /* @__PURE__ */
|
|
621
|
+
children: /* @__PURE__ */ C($e, {
|
|
633
622
|
onApprovePendingWrite: mn,
|
|
634
|
-
approvingWriteRef:
|
|
623
|
+
approvingWriteRef: un,
|
|
635
624
|
messages: yn,
|
|
636
|
-
processing:
|
|
637
|
-
streamingMessageId:
|
|
638
|
-
failedMessageId:
|
|
625
|
+
processing: z ?? null,
|
|
626
|
+
streamingMessageId: Kt,
|
|
627
|
+
failedMessageId: qt,
|
|
639
628
|
onRetry: gn
|
|
640
629
|
})
|
|
641
630
|
}),
|
|
642
|
-
/* @__PURE__ */
|
|
643
|
-
onStartVoiceSession: Q.available &&
|
|
631
|
+
/* @__PURE__ */ C(ct, {
|
|
632
|
+
onStartVoiceSession: Q.available && cn ? Q.start : void 0,
|
|
644
633
|
onSend: (e, t) => void J(e, t),
|
|
645
|
-
disabled:
|
|
646
|
-
placeholder:
|
|
647
|
-
mode:
|
|
648
|
-
writeAccessDenied:
|
|
649
|
-
availableModes:
|
|
650
|
-
attachmentCharsPerFile:
|
|
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,
|
|
651
640
|
onModeChange: kn,
|
|
652
|
-
auto:
|
|
653
|
-
active:
|
|
641
|
+
auto: Zt ? {
|
|
642
|
+
active: Qt,
|
|
654
643
|
onSelect: On
|
|
655
644
|
} : void 0
|
|
656
645
|
})
|
|
657
646
|
]
|
|
658
647
|
}),
|
|
659
|
-
|
|
648
|
+
nn && !Q.active ? /* @__PURE__ */ C(Xe, {
|
|
660
649
|
turns: X,
|
|
661
|
-
onClose: () =>
|
|
650
|
+
onClose: () => rn(!1),
|
|
662
651
|
onSave: bn,
|
|
663
652
|
onContinueInChat: Cn ? wn : void 0,
|
|
664
653
|
closeOnEscape: !0
|
|
665
654
|
}) : null,
|
|
666
|
-
Q.active && /* @__PURE__ */
|
|
655
|
+
Q.active && /* @__PURE__ */ C(et, {
|
|
667
656
|
session: Q.session,
|
|
668
657
|
notice: Q.notice,
|
|
669
658
|
capturing: Q.capturing,
|
|
@@ -686,10 +675,10 @@ var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
|
|
|
686
675
|
onToggleMute: Q.toggleMute,
|
|
687
676
|
onEnd: En
|
|
688
677
|
}),
|
|
689
|
-
/* @__PURE__ */
|
|
690
|
-
open:
|
|
678
|
+
/* @__PURE__ */ C(ut, {
|
|
679
|
+
open: U !== null,
|
|
691
680
|
mode: jn,
|
|
692
|
-
currentMode:
|
|
681
|
+
currentMode: G ?? { id: j },
|
|
693
682
|
onConfirm: An,
|
|
694
683
|
onCancel: Mn
|
|
695
684
|
})
|
|
@@ -697,4 +686,4 @@ var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
|
|
|
697
686
|
});
|
|
698
687
|
};
|
|
699
688
|
//#endregion
|
|
700
|
-
export {
|
|
689
|
+
export { gt as AssistantChatArea };
|