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