@burdenoff/fe-libs 2026.926.3 → 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/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 +3 -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/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/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +704 -568
- 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-assistant.js +101 -98
- package/package.json +1 -1
|
@@ -6,282 +6,290 @@ 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 ee, findExistingSandboxWithStatus as
|
|
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
10
|
import { sanitize as ie } from "../progress.js";
|
|
11
11
|
import { withIncompleteTurnNotice as ae } from "../streamBudget.js";
|
|
12
|
-
import { isVoiceTurn as
|
|
13
|
-
import { buildContinuedFromVoiceNote as se, buildVoiceTranscriptMarkdown as ce, voiceTranscriptFilename as
|
|
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
14
|
import { pollDelayMs as le } from "../voice/assistantPollSchedule.js";
|
|
15
15
|
import { toCaptionText as ue } from "../voice/captionText.js";
|
|
16
16
|
import { resolveAssistantLanguage as de } from "../voice/languages.js";
|
|
17
17
|
import { resolveLanguagePair as fe } from "../voice/languagePair.js";
|
|
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 {
|
|
55
|
-
import {
|
|
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";
|
|
56
58
|
//#region src/shared/assistant/ui/AssistantChatArea.tsx
|
|
57
|
-
var
|
|
58
|
-
function
|
|
59
|
+
var Zt = 600, Qt = 2e4;
|
|
60
|
+
function $t() {
|
|
59
61
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
60
62
|
}
|
|
61
|
-
var
|
|
62
|
-
let j = i(), { product: M, modes: N, gatherPageContext:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
]),
|
|
67
|
-
loading:
|
|
68
|
-
canUseAdminModes:
|
|
69
|
-
})).current,
|
|
70
|
-
|
|
71
|
-
|
|
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,
|
|
67
|
+
L
|
|
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;
|
|
72
74
|
}, [N]);
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
let Bn = k(P);
|
|
76
|
+
O(() => {
|
|
77
|
+
Bn.current = P;
|
|
76
78
|
}, [P]);
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
workspaceId:
|
|
79
|
+
let Vn = !!M && an !== !1;
|
|
80
|
+
O(() => {
|
|
81
|
+
if (Vn) return Et({ send: (e) => Tt(e, {
|
|
82
|
+
workspaceId: dt(),
|
|
81
83
|
authContext: {
|
|
82
|
-
accessToken:
|
|
83
|
-
organizationId:
|
|
84
|
+
accessToken: Bn.current(),
|
|
85
|
+
organizationId: ut()
|
|
84
86
|
}
|
|
85
87
|
}) });
|
|
86
|
-
}, [
|
|
87
|
-
|
|
88
|
-
loading:
|
|
89
|
-
canUseAdminModes:
|
|
88
|
+
}, [Vn]), O(() => {
|
|
89
|
+
G.update({
|
|
90
|
+
loading: Rn,
|
|
91
|
+
canUseAdminModes: Ln
|
|
90
92
|
});
|
|
91
93
|
}, [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
]),
|
|
96
|
-
|
|
97
|
-
}, [
|
|
98
|
-
let
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}, [
|
|
102
|
-
let
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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");
|
|
106
114
|
return;
|
|
107
115
|
}
|
|
108
|
-
|
|
116
|
+
Rn || (!Y || Y.requiresAdmin && !Ln) && z !== "assistant" && gn("assistant");
|
|
109
117
|
}, [
|
|
110
|
-
|
|
118
|
+
z,
|
|
111
119
|
Y,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
Ln,
|
|
121
|
+
Rn,
|
|
122
|
+
gn,
|
|
123
|
+
En
|
|
116
124
|
]);
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
}, [
|
|
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) => {
|
|
120
128
|
let s = (e, t) => {
|
|
121
|
-
r &&
|
|
129
|
+
r && rr(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
|
|
122
130
|
}, c = (e) => {
|
|
123
|
-
r &&
|
|
131
|
+
r && E(r.assistantMessageId, e);
|
|
124
132
|
}, u = () => {
|
|
125
133
|
c("bootAdopted"), a?.beginBoot();
|
|
126
|
-
}, ee = () => a !== null && (a.signal.aborted ||
|
|
127
|
-
if (ee()) throw new
|
|
128
|
-
},
|
|
129
|
-
if (i && !J.current.has(r) && q.current.isFresh(r)) return
|
|
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;
|
|
130
138
|
ne = !0;
|
|
131
139
|
let o = !1;
|
|
132
140
|
try {
|
|
133
|
-
await
|
|
141
|
+
await re(r, t, n, 3e5), await _(r, t, e, n, 9e4, () => {
|
|
134
142
|
o = !0, u();
|
|
135
143
|
});
|
|
136
144
|
} catch {
|
|
137
|
-
if (ee()) throw new
|
|
145
|
+
if (ee()) throw new Dt("cancelled");
|
|
138
146
|
return q.current.invalidate(r), J.current.add(r), a?.dead.push(r), ie = !0, !1;
|
|
139
147
|
}
|
|
140
|
-
return
|
|
148
|
+
return d(), q.current.markVerified(r), o && (g = !0), !0;
|
|
141
149
|
};
|
|
142
|
-
if (
|
|
150
|
+
if (f && (H(e, f, "provisioning"), s("provisioning", "reusingEnvironment"), await ae(f) || (H(e, null, "provisioning"), f = null)), !f) {
|
|
143
151
|
s("provisioning", "lookingForEnvironment");
|
|
144
|
-
let r = await
|
|
145
|
-
|
|
152
|
+
let r = await te(t, M, e, Wt(), n, J.current);
|
|
153
|
+
d();
|
|
146
154
|
let i = r?.id ?? null;
|
|
147
155
|
if (i) {
|
|
148
|
-
|
|
156
|
+
H(e, i, "provisioning"), s("provisioning", "reusingEnvironment");
|
|
149
157
|
let t = r?.status === "PROVISIONING" || r?.status === "PENDING";
|
|
150
|
-
t && u(), await ae(i) ? (
|
|
158
|
+
t && u(), await ae(i) ? (f = i, t && (g = !0)) : H(e, null, "provisioning");
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
|
-
if (!
|
|
154
|
-
if (a && !a.mayCreate) throw new
|
|
161
|
+
if (!f) {
|
|
162
|
+
if (a && !a.mayCreate) throw new Dt("no-create");
|
|
155
163
|
if (c("provisionStarted"), e === "api-calls" && !P()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
156
|
-
s("provisioning", "startingEnvironment"),
|
|
157
|
-
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);
|
|
158
166
|
if (r.length > 0) {
|
|
159
167
|
let e = new Set(r);
|
|
160
168
|
for (let e of r) q.current.invalidate(e), J.current.add(e);
|
|
161
|
-
let t =
|
|
162
|
-
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);
|
|
163
171
|
}
|
|
164
172
|
c("createRequested");
|
|
165
173
|
let i = a?.beginCreate();
|
|
166
174
|
try {
|
|
167
|
-
|
|
175
|
+
f = await l(M, e, t, Wt(), Zt, n);
|
|
168
176
|
} finally {
|
|
169
177
|
i?.();
|
|
170
178
|
}
|
|
171
|
-
|
|
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);
|
|
172
180
|
}
|
|
173
|
-
return
|
|
174
|
-
sandboxId:
|
|
175
|
-
sandboxIsNew:
|
|
181
|
+
return H(e, f, "running"), {
|
|
182
|
+
sandboxId: f,
|
|
183
|
+
sandboxIsNew: m,
|
|
176
184
|
sandboxProbed: ne,
|
|
177
|
-
sandboxAdopted:
|
|
185
|
+
sandboxAdopted: g,
|
|
178
186
|
deadSandboxProbe: ie,
|
|
179
|
-
trustedFromCache:
|
|
187
|
+
trustedFromCache: p
|
|
180
188
|
};
|
|
181
189
|
}, [
|
|
182
|
-
|
|
190
|
+
U,
|
|
183
191
|
P,
|
|
184
192
|
M,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
]),
|
|
188
|
-
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"));
|
|
189
197
|
for (let e of s.dead) q.current.invalidate(e), J.current.add(e);
|
|
190
|
-
s.verified && !J.current.has(s.verified) && q.current.markVerified(s.verified), s.joined &&
|
|
191
|
-
let { sandboxId: c, sandboxIsNew: l, sandboxProbed: ee, sandboxAdopted:
|
|
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, {
|
|
192
200
|
conversationId: t,
|
|
193
201
|
assistantMessageId: n
|
|
194
|
-
}, o.trustCache !== !1),
|
|
195
|
-
!s.waited &&
|
|
196
|
-
let
|
|
197
|
-
if (
|
|
198
|
-
let e =
|
|
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;
|
|
205
|
+
if (g) {
|
|
206
|
+
let e = $e(c, g, (e, t) => f(e, i, t, r, a, { limit: 50 }));
|
|
199
207
|
try {
|
|
200
|
-
let t = await
|
|
208
|
+
let t = await p(c, i, g, r, a);
|
|
201
209
|
if (t.mode !== r) throw Error(`Session mode mismatch: expected ${r}, received ${t.mode}`);
|
|
202
|
-
|
|
210
|
+
re = e;
|
|
203
211
|
} catch {
|
|
204
|
-
|
|
212
|
+
Tn(t), g = null;
|
|
205
213
|
}
|
|
206
214
|
}
|
|
207
|
-
if (!
|
|
208
|
-
|
|
215
|
+
if (!g) {
|
|
216
|
+
rr(t, n, "connecting", "preparingSession");
|
|
209
217
|
let s;
|
|
210
218
|
try {
|
|
211
219
|
s = await u(c, i, r, a);
|
|
212
220
|
} catch (s) {
|
|
213
221
|
if (ne) {
|
|
214
222
|
q.current.invalidate(c);
|
|
215
|
-
let l =
|
|
216
|
-
if (l === "check-network" && (l = await
|
|
217
|
-
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));
|
|
218
226
|
let s = await e(t, n, r, i, a, {
|
|
219
227
|
...o,
|
|
220
228
|
trustCache: !1
|
|
221
229
|
});
|
|
222
|
-
return u && (s.deadSandboxProbe || s.sandboxId !== c) &&
|
|
230
|
+
return u && (s.deadSandboxProbe || s.sandboxId !== c) && T(n, { cacheProofFailed: !0 }), {
|
|
223
231
|
...s,
|
|
224
232
|
sandboxProbed: s.sandboxProbed || ee,
|
|
225
|
-
sandboxAdopted: s.sandboxAdopted ||
|
|
226
|
-
deadSandboxProbe: s.deadSandboxProbe ||
|
|
233
|
+
sandboxAdopted: s.sandboxAdopted || d,
|
|
234
|
+
deadSandboxProbe: s.deadSandboxProbe || m
|
|
227
235
|
};
|
|
228
236
|
}
|
|
229
237
|
}
|
|
230
238
|
throw s;
|
|
231
239
|
}
|
|
232
|
-
|
|
240
|
+
g = s.sessionId, wn(t, g), _ = !0;
|
|
233
241
|
}
|
|
234
242
|
return {
|
|
235
243
|
sandboxId: c,
|
|
236
|
-
sessionId:
|
|
237
|
-
sessionIsNew:
|
|
238
|
-
readAhead:
|
|
244
|
+
sessionId: g,
|
|
245
|
+
sessionIsNew: _,
|
|
246
|
+
readAhead: re,
|
|
239
247
|
sandboxIsNew: l,
|
|
240
248
|
sandboxProbed: ee,
|
|
241
|
-
sandboxAdopted:
|
|
242
|
-
deadSandboxProbe:
|
|
249
|
+
sandboxAdopted: d,
|
|
250
|
+
deadSandboxProbe: m
|
|
243
251
|
};
|
|
244
252
|
}, [
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
253
|
+
ir,
|
|
254
|
+
Tn,
|
|
255
|
+
U,
|
|
248
256
|
M,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
]),
|
|
252
|
-
let t =
|
|
257
|
+
wn,
|
|
258
|
+
rr
|
|
259
|
+
]), or = D((e) => {
|
|
260
|
+
let t = dt();
|
|
253
261
|
if (!t) return;
|
|
254
|
-
let n =
|
|
262
|
+
let n = w.getState(), r = Date.now(), i = kt({
|
|
255
263
|
autoRouting: n.autoRouting,
|
|
256
|
-
autoOffered:
|
|
264
|
+
autoOffered: Gn.current,
|
|
257
265
|
active: n.activeConversationId ? n.conversations.find((e) => e.id === n.activeConversationId) : void 0,
|
|
258
266
|
selectedMode: n.mode,
|
|
259
|
-
autoReadMode:
|
|
260
|
-
modes:
|
|
267
|
+
autoReadMode: Le,
|
|
268
|
+
modes: zn.current,
|
|
261
269
|
acknowledgedWriteModes: n.acknowledgedWriteModes,
|
|
262
|
-
adminAccess:
|
|
270
|
+
adminAccess: G.read(),
|
|
263
271
|
dictated: e,
|
|
264
|
-
turnInFlight: Object.values(n.processingByConversationId).some((e) =>
|
|
265
|
-
...
|
|
272
|
+
turnInFlight: Object.values(n.processingByConversationId).some((e) => Ge(e?.status)),
|
|
273
|
+
...Mt(t),
|
|
266
274
|
now: r
|
|
267
275
|
});
|
|
268
276
|
if (!i) return;
|
|
269
|
-
let a =
|
|
277
|
+
let a = jt(t, i, r), o = {
|
|
270
278
|
accessToken: P(),
|
|
271
|
-
workspaceToken:
|
|
272
|
-
userId:
|
|
273
|
-
organizationId:
|
|
279
|
+
workspaceToken: F(),
|
|
280
|
+
userId: I,
|
|
281
|
+
organizationId: ut()
|
|
274
282
|
};
|
|
275
|
-
|
|
283
|
+
ir(i.mode, t, o, null, !0, a).then((e) => a.finish({
|
|
276
284
|
ok: !0,
|
|
277
285
|
sandboxId: e.sandboxId,
|
|
278
286
|
didWork: !e.trustedFromCache && (e.sandboxIsNew || e.sandboxProbed || e.sandboxAdopted),
|
|
279
287
|
booted: e.sandboxIsNew || e.sandboxAdopted,
|
|
280
288
|
dead: a.dead
|
|
281
289
|
}), (e) => {
|
|
282
|
-
if (!(e instanceof
|
|
283
|
-
let e =
|
|
284
|
-
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));
|
|
285
293
|
}
|
|
286
294
|
a.finish({
|
|
287
295
|
ok: !1,
|
|
@@ -291,90 +299,108 @@ var Bt = ({ visible: Bt = !0, writeAccess: Vt = "unknown" }) => {
|
|
|
291
299
|
});
|
|
292
300
|
});
|
|
293
301
|
}, [
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
302
|
+
ir,
|
|
303
|
+
G,
|
|
304
|
+
U,
|
|
297
305
|
P,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
]),
|
|
301
|
-
let e =
|
|
306
|
+
F,
|
|
307
|
+
I
|
|
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;
|
|
302
310
|
if (!t) return;
|
|
303
|
-
let n = e.processingByConversationId[t], r =
|
|
304
|
-
if (!
|
|
311
|
+
let n = e.processingByConversationId[t], r = Ge(n?.status) ? n?.messageId ?? null : null;
|
|
312
|
+
if (!qe({
|
|
305
313
|
interruptedTurnId: r,
|
|
306
314
|
activeTurnId: r,
|
|
307
|
-
alreadyRequested: r ?
|
|
315
|
+
alreadyRequested: r ? dr.current.has(r) : !1
|
|
308
316
|
}).send || !r) return;
|
|
309
|
-
|
|
310
|
-
let i =
|
|
317
|
+
dr.current.add(r);
|
|
318
|
+
let i = We(e), a = dt(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
|
|
311
319
|
!i || !a || !o || s(i.sandboxId, a, o, i.mode, {
|
|
312
320
|
accessToken: P(),
|
|
313
|
-
workspaceToken:
|
|
314
|
-
userId:
|
|
315
|
-
organizationId:
|
|
321
|
+
workspaceToken: F(),
|
|
322
|
+
userId: I,
|
|
323
|
+
organizationId: ut()
|
|
316
324
|
});
|
|
317
325
|
}, [
|
|
318
|
-
|
|
326
|
+
I,
|
|
319
327
|
P,
|
|
320
|
-
|
|
321
|
-
]),
|
|
322
|
-
let t =
|
|
323
|
-
if (!
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
328
|
+
F
|
|
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;
|
|
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;
|
|
342
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
|
+
});
|
|
343
368
|
}, [
|
|
344
|
-
|
|
345
|
-
|
|
369
|
+
I,
|
|
370
|
+
V,
|
|
371
|
+
xn,
|
|
346
372
|
j
|
|
347
|
-
]),
|
|
348
|
-
theme:
|
|
349
|
-
navigate:
|
|
350
|
-
navItems:
|
|
351
|
-
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 ?? {}
|
|
352
378
|
});
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
theme:
|
|
356
|
-
navigate:
|
|
357
|
-
navItems:
|
|
358
|
-
options:
|
|
379
|
+
O(() => {
|
|
380
|
+
yr.current = {
|
|
381
|
+
theme: hr,
|
|
382
|
+
navigate: _r,
|
|
383
|
+
navItems: vr,
|
|
384
|
+
options: sn ?? {}
|
|
359
385
|
};
|
|
360
386
|
}, [
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
387
|
+
hr,
|
|
388
|
+
_r,
|
|
389
|
+
vr,
|
|
390
|
+
sn
|
|
365
391
|
]);
|
|
366
|
-
let
|
|
367
|
-
let { theme: r, navigate: i } =
|
|
392
|
+
let br = D((e, t, n) => {
|
|
393
|
+
let { theme: r, navigate: i } = yr.current, a, o;
|
|
368
394
|
if (e.kind === "theme") {
|
|
369
395
|
if (!r) return !1;
|
|
370
|
-
let t =
|
|
396
|
+
let t = It(e.request, {
|
|
371
397
|
mode: r.mode,
|
|
372
398
|
resolvedTheme: r.resolvedTheme
|
|
373
399
|
});
|
|
374
400
|
if (!t.alreadyApplied) try {
|
|
375
401
|
r.setMode(t.mode);
|
|
376
402
|
} catch {}
|
|
377
|
-
a =
|
|
403
|
+
a = zt(j, t, e.request.kind === "family"), o = {
|
|
378
404
|
kind: "theme",
|
|
379
405
|
mode: t.mode,
|
|
380
406
|
alreadyApplied: t.alreadyApplied
|
|
@@ -382,53 +408,53 @@ var Bt = ({ visible: Bt = !0, writeAccess: Vt = "unknown" }) => {
|
|
|
382
408
|
} else {
|
|
383
409
|
if (!i) return !1;
|
|
384
410
|
if (e.kind === "navigate") {
|
|
385
|
-
let { destination: t } = e, n =
|
|
386
|
-
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 = {
|
|
387
413
|
kind: "navigate",
|
|
388
414
|
destinationId: t.id,
|
|
389
415
|
path: t.path,
|
|
390
416
|
alreadyHere: n
|
|
391
417
|
};
|
|
392
|
-
} else a =
|
|
418
|
+
} else a = Lt(j, e.candidates[0]?.label ?? e.query, e.candidates), o = {
|
|
393
419
|
kind: "choose-destination",
|
|
394
420
|
candidateIds: e.candidates.map((e) => e.id)
|
|
395
421
|
};
|
|
396
422
|
}
|
|
397
|
-
let s =
|
|
398
|
-
|
|
399
|
-
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(),
|
|
400
426
|
role: "user",
|
|
401
427
|
content: t,
|
|
402
428
|
timestamp: l,
|
|
403
429
|
metadata: {
|
|
404
430
|
localAction: o,
|
|
405
|
-
...
|
|
431
|
+
...oe(n)
|
|
406
432
|
}
|
|
407
433
|
});
|
|
408
|
-
let u =
|
|
409
|
-
return
|
|
434
|
+
let u = $t();
|
|
435
|
+
return V(c, {
|
|
410
436
|
id: u,
|
|
411
437
|
role: "assistant",
|
|
412
438
|
content: a.text,
|
|
413
439
|
timestamp: l,
|
|
414
440
|
metadata: {
|
|
415
|
-
lang: a.translated ?
|
|
441
|
+
lang: a.translated ? L : "en",
|
|
416
442
|
localAction: o,
|
|
417
|
-
...
|
|
443
|
+
...oe(n)
|
|
418
444
|
}
|
|
419
|
-
}),
|
|
445
|
+
}), gr(c, u), !0;
|
|
420
446
|
}, [
|
|
447
|
+
V,
|
|
421
448
|
B,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
Qn,
|
|
449
|
+
L,
|
|
450
|
+
gr,
|
|
425
451
|
j
|
|
426
|
-
]), X =
|
|
427
|
-
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;
|
|
428
454
|
if (a) {
|
|
429
|
-
if (
|
|
455
|
+
if (Ge(i.processingByConversationId[a]?.status)) {
|
|
430
456
|
let r = i.processingByConversationId[a]?.messageId ?? null;
|
|
431
|
-
r &&
|
|
457
|
+
r && dr.current.has(r) && (fr.current = {
|
|
432
458
|
conversationId: a,
|
|
433
459
|
content: e,
|
|
434
460
|
attachments: t,
|
|
@@ -436,272 +462,311 @@ var Bt = ({ visible: Bt = !0, writeAccess: Vt = "unknown" }) => {
|
|
|
436
462
|
});
|
|
437
463
|
return;
|
|
438
464
|
}
|
|
439
|
-
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;
|
|
440
472
|
}
|
|
441
|
-
if (jn.current) return;
|
|
442
473
|
if (n.fromPerson && t.length === 0) {
|
|
443
|
-
let t =
|
|
444
|
-
if (t &&
|
|
474
|
+
let t = Pt(e, Ft(yr.current.navItems), yr.current.options);
|
|
475
|
+
if (t && br(t, e, n.voiceSessionId)) return;
|
|
445
476
|
}
|
|
446
|
-
let
|
|
447
|
-
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),
|
|
448
479
|
dictated: r,
|
|
449
|
-
conversation:
|
|
450
|
-
mode:
|
|
451
|
-
routedBy:
|
|
452
|
-
hasHistory:
|
|
480
|
+
conversation: c ? {
|
|
481
|
+
mode: c.mode,
|
|
482
|
+
routedBy: c.routedBy,
|
|
483
|
+
hasHistory: c.messages.length > 0 || !!c.backendSessionId
|
|
453
484
|
} : null
|
|
454
485
|
}) : null;
|
|
455
|
-
if (
|
|
456
|
-
|
|
486
|
+
if (l && zn.current.find((e) => e.id === l.mode)?.writeCapable && !Fe(i.acknowledgedWriteModes, l.mode)) {
|
|
487
|
+
Kn.current = {
|
|
457
488
|
content: e,
|
|
458
489
|
attachments: t,
|
|
459
490
|
options: n
|
|
460
|
-
},
|
|
491
|
+
}, Yn(l.mode);
|
|
461
492
|
return;
|
|
462
493
|
}
|
|
463
|
-
let
|
|
464
|
-
mode:
|
|
465
|
-
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
|
|
466
497
|
} : null;
|
|
467
|
-
if (
|
|
498
|
+
if (l) l.action === "new" || !c ? h = B(void 0, u, { routedBy: "auto" }) : (h = c.id, An(h, u));
|
|
468
499
|
else {
|
|
469
500
|
let e = i.autoRouting ? { routedBy: "auto" } : void 0;
|
|
470
|
-
|
|
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);
|
|
471
502
|
}
|
|
472
|
-
if (!
|
|
473
|
-
|
|
474
|
-
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 = {
|
|
475
506
|
accessToken: P(),
|
|
476
|
-
workspaceToken:
|
|
477
|
-
userId:
|
|
478
|
-
organizationId:
|
|
479
|
-
},
|
|
480
|
-
|
|
507
|
+
workspaceToken: F(),
|
|
508
|
+
userId: I,
|
|
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(),
|
|
481
519
|
role: "user",
|
|
482
520
|
content: e,
|
|
483
521
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
484
522
|
metadata: {
|
|
485
|
-
...t.length ? { attachments: t.map(
|
|
486
|
-
...
|
|
523
|
+
...t.length ? { attachments: t.map(Oe) } : {},
|
|
524
|
+
...n.approvalFollowUp ? {
|
|
525
|
+
approvalFollowUp: !0,
|
|
526
|
+
approvedReplyId: n.approvalFollowUp.approvedReplyId
|
|
527
|
+
} : {},
|
|
528
|
+
...oe(n.voiceSessionId)
|
|
487
529
|
}
|
|
488
530
|
};
|
|
489
|
-
|
|
490
|
-
let
|
|
491
|
-
|
|
492
|
-
id:
|
|
531
|
+
V(h, ce);
|
|
532
|
+
let x = $t();
|
|
533
|
+
V(h, {
|
|
534
|
+
id: x,
|
|
493
535
|
role: "assistant",
|
|
494
536
|
content: "",
|
|
495
537
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
496
538
|
metadata: {
|
|
497
|
-
lang:
|
|
498
|
-
...
|
|
539
|
+
lang: pn,
|
|
540
|
+
...oe(n.voiceSessionId)
|
|
499
541
|
}
|
|
500
|
-
}),
|
|
542
|
+
}), it(x, {
|
|
501
543
|
channel: r ? "voice" : "chat",
|
|
502
|
-
mode:
|
|
544
|
+
mode: u,
|
|
503
545
|
product: M,
|
|
504
|
-
language:
|
|
505
|
-
device:
|
|
506
|
-
routedByAuto: !!
|
|
507
|
-
}, n.voiceTiming),
|
|
508
|
-
let
|
|
509
|
-
|
|
510
|
-
|
|
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,
|
|
511
558
|
...t?.length ? { artifacts: t } : {},
|
|
512
|
-
...t?.length || r || i ? { mode:
|
|
559
|
+
...t?.length || r || i ? { mode: u } : {},
|
|
513
560
|
...r ? { sessionId: r } : {},
|
|
514
561
|
...i ? { sandboxId: i } : {},
|
|
515
|
-
...
|
|
562
|
+
...a ? { incomplete: !0 } : {},
|
|
563
|
+
...oe(n.voiceSessionId)
|
|
516
564
|
});
|
|
517
|
-
},
|
|
518
|
-
|
|
519
|
-
let i = null, a = !1;
|
|
565
|
+
}, fe = async (n = 1) => {
|
|
566
|
+
E(x, "attemptStarted");
|
|
567
|
+
let i = null, a = null, o = !1;
|
|
520
568
|
try {
|
|
521
|
-
let { sandboxId: n, sessionId:
|
|
522
|
-
turnId:
|
|
523
|
-
abortRequested:
|
|
524
|
-
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()
|
|
525
574
|
}).abandon });
|
|
526
|
-
i = n,
|
|
527
|
-
runtime:
|
|
528
|
-
deadSandboxProbe:
|
|
529
|
-
});
|
|
530
|
-
let ce =
|
|
531
|
-
|
|
532
|
-
let
|
|
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({
|
|
533
582
|
content: ce ? `${ce}${e}` : e,
|
|
534
583
|
attachments: t,
|
|
535
|
-
limits:
|
|
536
|
-
wrapPrompt: (e) =>
|
|
584
|
+
limits: De(te),
|
|
585
|
+
wrapPrompt: (e) => rn?.(u, e, dn, fn, r) ?? e,
|
|
537
586
|
requestBytes: (e, t) => ne({
|
|
538
587
|
sandboxId: n,
|
|
539
|
-
workspaceId:
|
|
540
|
-
sessionId:
|
|
541
|
-
mode:
|
|
588
|
+
workspaceId: y,
|
|
589
|
+
sessionId: s,
|
|
590
|
+
mode: u,
|
|
542
591
|
prompt: e,
|
|
543
592
|
parts: t,
|
|
544
|
-
pageContext:
|
|
545
|
-
authContext:
|
|
593
|
+
pageContext: S,
|
|
594
|
+
authContext: b
|
|
546
595
|
})
|
|
547
|
-
}), he = me
|
|
548
|
-
|
|
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
|
+
}
|
|
549
603
|
try {
|
|
550
|
-
await
|
|
604
|
+
await g(n, y, s, pe, u, S, b, me?.length ? { parts: me } : void 0);
|
|
551
605
|
} catch (e) {
|
|
552
|
-
if (!
|
|
553
|
-
await
|
|
606
|
+
if (!me || !ft(e)) throw e;
|
|
607
|
+
await g(n, y, s, pe, u, S, b, void 0), o ||= ge;
|
|
554
608
|
}
|
|
555
|
-
|
|
556
|
-
let ve = null, ye = !1, be =
|
|
557
|
-
turnId: y,
|
|
558
|
-
abortRequested: qn.current.has(y),
|
|
559
|
-
activeTurnId: S.getState().processingByConversationId[d]?.messageId ?? null
|
|
560
|
-
});
|
|
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();
|
|
561
611
|
for (; Date.now() < xe;) {
|
|
562
|
-
|
|
612
|
+
se(n, s);
|
|
613
|
+
let e = ue();
|
|
563
614
|
if (e.abandon) {
|
|
564
|
-
e.clearProcessing &&
|
|
615
|
+
e.clearProcessing && Cn(h);
|
|
565
616
|
return;
|
|
566
617
|
}
|
|
567
|
-
if (
|
|
618
|
+
if (C = Xe(await f(n, y, s, u, b, {
|
|
568
619
|
limit: 50,
|
|
569
|
-
sinceMs:
|
|
570
|
-
}),
|
|
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");
|
|
571
622
|
else {
|
|
572
|
-
let e =
|
|
573
|
-
be = e.tracker, e.confirmedAt !== null &&
|
|
623
|
+
let e = et(be, C, st());
|
|
624
|
+
be = e.tracker, e.confirmedAt !== null && E(x, "firstText", e.confirmedAt);
|
|
574
625
|
}
|
|
575
|
-
if (
|
|
576
|
-
|
|
626
|
+
if (C.pendingWrite && xn(h, x, { pendingWrite: C.pendingWrite }), C.done) {
|
|
627
|
+
E(x, "answerDone"), q.current.markVerified(n);
|
|
577
628
|
break;
|
|
578
629
|
}
|
|
579
|
-
Date.now() - Se > 3e4 && (await ee(n,
|
|
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)));
|
|
580
631
|
}
|
|
581
|
-
let Ee =
|
|
582
|
-
|
|
583
|
-
...
|
|
584
|
-
content: ae(
|
|
585
|
-
}),
|
|
586
|
-
...
|
|
587
|
-
content: `${
|
|
588
|
-
})
|
|
589
|
-
|
|
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 });
|
|
590
643
|
try {
|
|
591
|
-
await
|
|
592
|
-
workspaceId:
|
|
593
|
-
sessionId:
|
|
594
|
-
messageId:
|
|
595
|
-
model:
|
|
596
|
-
tokens:
|
|
597
|
-
}),
|
|
644
|
+
await on?.({
|
|
645
|
+
workspaceId: y,
|
|
646
|
+
sessionId: s,
|
|
647
|
+
messageId: C.messageId,
|
|
648
|
+
model: C.model,
|
|
649
|
+
tokens: C.tokens
|
|
650
|
+
}), Vt(M);
|
|
598
651
|
} catch {}
|
|
599
652
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
653
|
+
C.done || se(n, s);
|
|
654
|
+
let ke = ue();
|
|
655
|
+
if (ke.abandon) {
|
|
656
|
+
ke.clearProcessing && Cn(h);
|
|
603
657
|
return;
|
|
604
658
|
}
|
|
605
|
-
|
|
659
|
+
E(x, "complete"), T(x, { outcome: "answered" }), Sn(h, "complete", x, null);
|
|
606
660
|
} catch (e) {
|
|
607
|
-
q.current.invalidate(i ??
|
|
608
|
-
let t =
|
|
609
|
-
turnId:
|
|
610
|
-
abortRequested:
|
|
611
|
-
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()
|
|
612
667
|
});
|
|
613
|
-
if (t.abandon) {
|
|
614
|
-
t.clearProcessing &&
|
|
668
|
+
if (i && a && se(i, a), t.abandon) {
|
|
669
|
+
t.clearProcessing && Cn(h);
|
|
615
670
|
return;
|
|
616
671
|
}
|
|
617
|
-
if (n === 1 &&
|
|
618
|
-
let e = i ??
|
|
619
|
-
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);
|
|
620
675
|
}
|
|
621
676
|
throw e;
|
|
622
677
|
}
|
|
623
|
-
},
|
|
624
|
-
|
|
678
|
+
}, S = h;
|
|
679
|
+
tr.current.add(S);
|
|
625
680
|
try {
|
|
626
|
-
if (!
|
|
681
|
+
if (!y) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
|
|
627
682
|
code: "UNAUTHENTICATED",
|
|
628
683
|
authFailure: "WORKSPACE_CONTEXT_MISSING"
|
|
629
684
|
} });
|
|
630
|
-
let e = await
|
|
631
|
-
|
|
632
|
-
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, {
|
|
633
693
|
dictated: r,
|
|
634
|
-
confirmsWrites:
|
|
694
|
+
confirmsWrites: m(u)
|
|
635
695
|
});
|
|
636
|
-
if (
|
|
637
|
-
|
|
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();
|
|
638
698
|
} catch (e) {
|
|
639
|
-
q.current.invalidate(
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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, {
|
|
707
|
+
lang: r.translated ? L : "en",
|
|
708
|
+
...oe(n.voiceSessionId)
|
|
646
709
|
});
|
|
647
710
|
} finally {
|
|
648
|
-
|
|
649
|
-
let e =
|
|
650
|
-
t && (
|
|
651
|
-
let n =
|
|
652
|
-
|
|
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);
|
|
653
716
|
}
|
|
654
717
|
}, [
|
|
655
|
-
|
|
718
|
+
R,
|
|
719
|
+
V,
|
|
720
|
+
rn,
|
|
721
|
+
Tn,
|
|
722
|
+
U,
|
|
723
|
+
mn,
|
|
656
724
|
B,
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
H,
|
|
660
|
-
tn,
|
|
661
|
-
z,
|
|
662
|
-
Hn,
|
|
663
|
-
Ht,
|
|
725
|
+
ar,
|
|
726
|
+
nn,
|
|
664
727
|
P,
|
|
665
|
-
|
|
666
|
-
|
|
728
|
+
F,
|
|
729
|
+
bn,
|
|
667
730
|
M,
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
Qt,
|
|
674
|
-
U,
|
|
675
|
-
nr,
|
|
731
|
+
G,
|
|
732
|
+
on,
|
|
733
|
+
fn,
|
|
734
|
+
L,
|
|
735
|
+
pn,
|
|
676
736
|
dn,
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
737
|
+
An,
|
|
738
|
+
br,
|
|
739
|
+
wn,
|
|
740
|
+
_n,
|
|
741
|
+
Sn,
|
|
742
|
+
Cn,
|
|
680
743
|
j,
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
]),
|
|
744
|
+
rr,
|
|
745
|
+
yn,
|
|
746
|
+
I
|
|
747
|
+
]), xr = D((e, t) => {
|
|
685
748
|
X(e, [], t ? { autoIntent: t } : {});
|
|
686
|
-
}, [X]),
|
|
687
|
-
let e = [...
|
|
688
|
-
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);
|
|
689
754
|
}, [
|
|
690
|
-
|
|
755
|
+
Nn,
|
|
691
756
|
X,
|
|
692
|
-
|
|
693
|
-
]),
|
|
694
|
-
|
|
695
|
-
|
|
757
|
+
R
|
|
758
|
+
]), Cr = k(X);
|
|
759
|
+
O(() => {
|
|
760
|
+
Cr.current = X;
|
|
696
761
|
}, [X]);
|
|
697
|
-
let
|
|
698
|
-
if (
|
|
699
|
-
for (let e =
|
|
700
|
-
let t =
|
|
701
|
-
if (t?.role !== "assistant" || !
|
|
702
|
-
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);
|
|
703
768
|
if (n.kind !== "output") return null;
|
|
704
|
-
let r =
|
|
769
|
+
let r = tt(n.text).text.trim();
|
|
705
770
|
return r ? {
|
|
706
771
|
id: t.id,
|
|
707
772
|
text: r
|
|
@@ -709,228 +774,299 @@ var Bt = ({ visible: Bt = !0, writeAccess: Vt = "unknown" }) => {
|
|
|
709
774
|
}
|
|
710
775
|
return null;
|
|
711
776
|
}, [
|
|
712
|
-
|
|
713
|
-
|
|
777
|
+
Nn,
|
|
778
|
+
Pn,
|
|
714
779
|
W,
|
|
715
780
|
j
|
|
716
|
-
]),
|
|
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) => ({
|
|
717
792
|
id: e.id,
|
|
718
793
|
role: e.role,
|
|
719
|
-
text:
|
|
720
|
-
sessionId:
|
|
794
|
+
text: rt(e, W, j),
|
|
795
|
+
sessionId: b(e),
|
|
721
796
|
timestamp: e.timestamp
|
|
722
797
|
})).filter((e) => e.text.length > 0), [
|
|
723
|
-
|
|
798
|
+
Mn.voice,
|
|
724
799
|
W,
|
|
725
800
|
j
|
|
726
|
-
]),
|
|
801
|
+
]), jr = D(() => {
|
|
727
802
|
if (Z.length === 0) return;
|
|
728
803
|
let e = /* @__PURE__ */ new Date();
|
|
729
|
-
|
|
804
|
+
yt(ce(Z, {
|
|
730
805
|
title: j("voiceSession.transcript", "Voice conversation"),
|
|
731
806
|
savedAt: j("voiceSession.savedAt", "Saved"),
|
|
732
807
|
session: j("voiceSession.sessionLabel", "Session"),
|
|
733
808
|
earlier: j("voiceSession.earlierLabel", "Earlier"),
|
|
734
809
|
you: j("voiceSession.speakerYou", "You"),
|
|
735
810
|
assistant: j("voiceSession.speakerAssistant", "Assistant")
|
|
736
|
-
}, e),
|
|
811
|
+
}, e), x(M, e), "text/markdown");
|
|
737
812
|
}, [
|
|
738
813
|
M,
|
|
739
814
|
Z,
|
|
740
815
|
j
|
|
741
|
-
]), Q =
|
|
742
|
-
|
|
743
|
-
let $ =
|
|
744
|
-
onSubmit:
|
|
745
|
-
let r = () => {
|
|
746
|
-
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 = {
|
|
747
832
|
...n,
|
|
748
|
-
handedOver:
|
|
833
|
+
handedOver: st()
|
|
749
834
|
};
|
|
750
|
-
|
|
835
|
+
Cr.current(e, o, {
|
|
751
836
|
fromPerson: !0,
|
|
752
837
|
voiceSessionId: t,
|
|
753
|
-
voiceTiming:
|
|
754
|
-
}),
|
|
838
|
+
voiceTiming: s
|
|
839
|
+
}), i.clear();
|
|
755
840
|
};
|
|
756
|
-
if (!
|
|
757
|
-
|
|
841
|
+
if (!Mr.current.isBusy) {
|
|
842
|
+
i();
|
|
758
843
|
return;
|
|
759
844
|
}
|
|
760
|
-
let
|
|
761
|
-
|
|
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());
|
|
762
847
|
}, 200);
|
|
848
|
+
o.add(s);
|
|
763
849
|
}, []),
|
|
764
|
-
latestReply:
|
|
765
|
-
language: de(
|
|
766
|
-
})
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
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(),
|
|
772
860
|
role: "system",
|
|
773
|
-
content: se(Z.slice(
|
|
861
|
+
content: se(Z.slice(Lr), {
|
|
774
862
|
intro: j("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
|
|
775
863
|
nothing: j("voiceSession.continuedNothing", "Continued from a voice conversation."),
|
|
776
864
|
more: (e) => j("voiceSession.continuedMore", "…and {{count}} more", { count: e })
|
|
777
865
|
}),
|
|
778
866
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
779
|
-
metadata: { continuedVoiceTurns:
|
|
780
|
-
}),
|
|
867
|
+
metadata: { continuedVoiceTurns: Rr }
|
|
868
|
+
}), K(!1), $.end());
|
|
781
869
|
}, [
|
|
782
870
|
Z,
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
871
|
+
Rr,
|
|
872
|
+
Lr,
|
|
873
|
+
V,
|
|
786
874
|
j,
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
875
|
+
$,
|
|
876
|
+
K
|
|
877
|
+
]), Vr = k(0);
|
|
878
|
+
O(() => {
|
|
879
|
+
$.active && (Vr.current = Rr);
|
|
791
880
|
}, [$.active]);
|
|
792
|
-
let
|
|
793
|
-
let e =
|
|
794
|
-
$.end(), e &&
|
|
795
|
-
}, [mr, $]);
|
|
796
|
-
D(() => {
|
|
797
|
-
(!Bt || !zn) && $.active && $.end();
|
|
881
|
+
let Hr = D(() => {
|
|
882
|
+
let e = Rr > Vr.current;
|
|
883
|
+
$.end(), e && K(!0);
|
|
798
884
|
}, [
|
|
799
|
-
|
|
800
|
-
|
|
885
|
+
Rr,
|
|
886
|
+
$,
|
|
887
|
+
K
|
|
888
|
+
]);
|
|
889
|
+
O(() => {
|
|
890
|
+
(!en || !nr) && $.active && $.end();
|
|
891
|
+
}, [
|
|
892
|
+
en,
|
|
893
|
+
nr,
|
|
801
894
|
$
|
|
802
|
-
]),
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
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) => {
|
|
807
941
|
if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
|
|
808
|
-
let e =
|
|
809
|
-
e &&
|
|
942
|
+
let e = w.getState().consumePendingPrompt();
|
|
943
|
+
e && Cr.current(e);
|
|
810
944
|
}
|
|
811
945
|
});
|
|
812
946
|
}, []);
|
|
813
|
-
let
|
|
814
|
-
let t =
|
|
947
|
+
let Wr = D((e) => {
|
|
948
|
+
let t = R ? w.getState().conversations.find((e) => e.id === R) : void 0;
|
|
815
949
|
if (t && (t.messages.length > 0 || t.backendSessionId)) {
|
|
816
950
|
if (t.mode !== e) {
|
|
817
|
-
let t =
|
|
818
|
-
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);
|
|
819
953
|
}
|
|
820
|
-
} else
|
|
821
|
-
let n =
|
|
822
|
-
n ?
|
|
954
|
+
} else R && _n(R, e);
|
|
955
|
+
let n = w.getState().activeConversationId;
|
|
956
|
+
n ? _n(n, e) : kn(!1), gn(e);
|
|
823
957
|
}, [
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
]),
|
|
831
|
-
let e =
|
|
958
|
+
R,
|
|
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;
|
|
832
966
|
if (!t) {
|
|
833
|
-
|
|
967
|
+
kn(!0), gn(Le);
|
|
834
968
|
return;
|
|
835
969
|
}
|
|
836
970
|
if (t.routedBy === "auto") {
|
|
837
|
-
|
|
971
|
+
kn(!0);
|
|
838
972
|
return;
|
|
839
973
|
}
|
|
840
974
|
if (t.messages.length === 0 && !t.backendSessionId) {
|
|
841
|
-
|
|
975
|
+
An(t.id, Le);
|
|
842
976
|
return;
|
|
843
977
|
}
|
|
844
978
|
let n = e.conversations.find((t) => t.routedBy === "auto" && t.messages.length === 0 && !t.backendSessionId && !e.processingByConversationId[t.id]);
|
|
845
|
-
n ? (
|
|
979
|
+
n ? (vn(n.id), An(n.id, Le)) : B(void 0, Le, { routedBy: "auto" });
|
|
846
980
|
}, [
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
]),
|
|
853
|
-
if (N.find((t) => t.id === e)?.writeCapable && !
|
|
854
|
-
|
|
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);
|
|
855
989
|
return;
|
|
856
990
|
}
|
|
857
|
-
|
|
858
|
-
}, [
|
|
859
|
-
let e =
|
|
860
|
-
if (
|
|
861
|
-
let t =
|
|
862
|
-
if (
|
|
863
|
-
|
|
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);
|
|
864
998
|
return;
|
|
865
999
|
}
|
|
866
|
-
|
|
1000
|
+
Dn(e), Wr(e);
|
|
867
1001
|
}, [
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1002
|
+
Jn,
|
|
1003
|
+
Dn,
|
|
1004
|
+
Wr,
|
|
871
1005
|
X
|
|
872
|
-
]),
|
|
873
|
-
|
|
874
|
-
let e =
|
|
875
|
-
|
|
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, {
|
|
876
1010
|
...e.options,
|
|
877
1011
|
autoIntent: "read"
|
|
878
1012
|
});
|
|
879
1013
|
}, [X]);
|
|
880
|
-
return /* @__PURE__ */
|
|
1014
|
+
return /* @__PURE__ */ Xt("div", {
|
|
881
1015
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
882
1016
|
children: [
|
|
883
|
-
/* @__PURE__ */
|
|
1017
|
+
/* @__PURE__ */ Xt("div", {
|
|
884
1018
|
className: "contents",
|
|
885
1019
|
inert: $.active || void 0,
|
|
886
1020
|
children: [
|
|
887
|
-
Z.length > 0 && !$.active ? /* @__PURE__ */ A(
|
|
1021
|
+
Z.length > 0 && !$.active ? /* @__PURE__ */ A(_t, {
|
|
888
1022
|
count: Z.length,
|
|
889
|
-
onOpenTranscript: () =>
|
|
1023
|
+
onOpenTranscript: () => K(!0)
|
|
890
1024
|
}) : null,
|
|
891
|
-
|
|
892
|
-
mode:
|
|
893
|
-
onSuggestionClick:
|
|
894
|
-
explainsAuto:
|
|
895
|
-
suggestions:
|
|
1025
|
+
Er.length === 0 ? /* @__PURE__ */ A(bt, {
|
|
1026
|
+
mode: z,
|
|
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
|
|
896
1030
|
}) : /* @__PURE__ */ A("div", {
|
|
897
1031
|
className: "flex min-h-0 flex-1 flex-col",
|
|
898
|
-
children: /* @__PURE__ */ A(
|
|
899
|
-
onApprovePendingWrite:
|
|
900
|
-
approvingWriteRef:
|
|
901
|
-
|
|
1032
|
+
children: /* @__PURE__ */ A(xt, {
|
|
1033
|
+
onApprovePendingWrite: mr,
|
|
1034
|
+
approvingWriteRef: cr,
|
|
1035
|
+
approvableMessageId: Or?.messageId ?? null,
|
|
1036
|
+
retryableMessageId: kr,
|
|
1037
|
+
messages: Er,
|
|
902
1038
|
processing: W ?? null,
|
|
903
|
-
streamingMessageId:
|
|
904
|
-
failedMessageId:
|
|
905
|
-
onRetry:
|
|
1039
|
+
streamingMessageId: Fn,
|
|
1040
|
+
failedMessageId: In,
|
|
1041
|
+
onRetry: cr === null ? Sr : void 0
|
|
906
1042
|
})
|
|
907
1043
|
}),
|
|
908
|
-
/* @__PURE__ */ A(
|
|
909
|
-
onStartVoiceSession: $.available &&
|
|
1044
|
+
/* @__PURE__ */ A(Ut, {
|
|
1045
|
+
onStartVoiceSession: $.available && nr ? Ir : void 0,
|
|
910
1046
|
onSend: (e, t) => void X(e, t, { fromPerson: !0 }),
|
|
911
|
-
onDraftStart:
|
|
912
|
-
disabled:
|
|
913
|
-
placeholder:
|
|
914
|
-
mode:
|
|
915
|
-
writeAccessDenied:
|
|
916
|
-
availableModes:
|
|
917
|
-
attachmentCharsPerFile:
|
|
918
|
-
onModeChange:
|
|
919
|
-
auto:
|
|
920
|
-
active:
|
|
921
|
-
onSelect:
|
|
1047
|
+
onDraftStart: sr,
|
|
1048
|
+
disabled: Pn || cr !== null,
|
|
1049
|
+
placeholder: z === "api-calls" ? j("chatArea.placeholderActions", "What would you like me to do?") : j("chatArea.placeholderGeneral", "Ask me anything…"),
|
|
1050
|
+
mode: z,
|
|
1051
|
+
writeAccessDenied: tn === "denied" && !!Y?.writeCapable,
|
|
1052
|
+
availableModes: Hn,
|
|
1053
|
+
attachmentCharsPerFile: qn,
|
|
1054
|
+
onModeChange: Kr,
|
|
1055
|
+
auto: Un ? {
|
|
1056
|
+
active: Wn,
|
|
1057
|
+
onSelect: Gr
|
|
922
1058
|
} : void 0
|
|
923
1059
|
})
|
|
924
1060
|
]
|
|
925
1061
|
}),
|
|
926
|
-
|
|
1062
|
+
Qn && !$.active ? /* @__PURE__ */ A(vt, {
|
|
927
1063
|
turns: Z,
|
|
928
|
-
onClose: () =>
|
|
929
|
-
onSave:
|
|
930
|
-
onContinueInChat:
|
|
1064
|
+
onClose: () => K(!1),
|
|
1065
|
+
onSave: jr,
|
|
1066
|
+
onContinueInChat: zr ? Br : void 0,
|
|
931
1067
|
closeOnEscape: !0
|
|
932
1068
|
}) : null,
|
|
933
|
-
$.active && /* @__PURE__ */ A(
|
|
1069
|
+
$.active && /* @__PURE__ */ A(St, {
|
|
934
1070
|
session: $.session,
|
|
935
1071
|
notice: $.notice,
|
|
936
1072
|
capturing: $.capturing,
|
|
@@ -944,24 +1080,24 @@ var Bt = ({ visible: Bt = !0, writeAccess: Vt = "unknown" }) => {
|
|
|
944
1080
|
onRetryAttachment: Q.retry,
|
|
945
1081
|
canAttachMore: Q.canAddMore,
|
|
946
1082
|
preparingAttachments: Q.preparingCount,
|
|
947
|
-
onSaveTranscript:
|
|
948
|
-
onContinueInChat:
|
|
1083
|
+
onSaveTranscript: jr,
|
|
1084
|
+
onContinueInChat: Br,
|
|
949
1085
|
onInterrupt: () => {
|
|
950
|
-
$.interrupt(),
|
|
1086
|
+
$.interrupt(), pr();
|
|
951
1087
|
},
|
|
952
|
-
spoken:
|
|
1088
|
+
spoken: Tr,
|
|
953
1089
|
onToggleMute: $.toggleMute,
|
|
954
|
-
onEnd:
|
|
1090
|
+
onEnd: Hr
|
|
955
1091
|
}),
|
|
956
|
-
/* @__PURE__ */ A(
|
|
957
|
-
open:
|
|
958
|
-
mode:
|
|
959
|
-
currentMode: Y ?? { id:
|
|
960
|
-
onConfirm:
|
|
961
|
-
onCancel:
|
|
1092
|
+
/* @__PURE__ */ A(Gt, {
|
|
1093
|
+
open: Jn !== null,
|
|
1094
|
+
mode: Jr,
|
|
1095
|
+
currentMode: Y ?? { id: z },
|
|
1096
|
+
onConfirm: qr,
|
|
1097
|
+
onCancel: Yr
|
|
962
1098
|
})
|
|
963
1099
|
]
|
|
964
1100
|
});
|
|
965
1101
|
};
|
|
966
1102
|
//#endregion
|
|
967
|
-
export {
|
|
1103
|
+
export { en as AssistantChatArea };
|