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