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