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