@burdenoff/fe-libs 2026.1003.1 → 2026.1003.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/prewarm.d.ts +71 -0
- package/dist/shared/assistant/prewarm.d.ts.map +1 -1
- package/dist/shared/assistant/prewarm.js +49 -2
- package/dist/shared/assistant/speech/speechFeed.d.ts +63 -0
- package/dist/shared/assistant/speech/speechFeed.d.ts.map +1 -0
- package/dist/shared/assistant/speech/speechFeed.js +40 -0
- package/dist/shared/assistant/turnTimeline.d.ts +22 -2
- package/dist/shared/assistant/turnTimeline.d.ts.map +1 -1
- package/dist/shared/assistant/turnTimeline.js +18 -1
- package/dist/shared/assistant/turnTimingReport.d.ts.map +1 -1
- package/dist/shared/assistant/turnTimingReport.js +5 -4
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +981 -931
- package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +198 -169
- package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
- package/dist/shared/assistant/ui/useVoiceSession.js +165 -153
- package/dist/shared/assistant/voice/speakableText.d.ts +16 -1
- package/dist/shared/assistant/voice/speakableText.d.ts.map +1 -1
- package/dist/shared/assistant/voice/speakableText.js +116 -102
- package/dist/shared/assistant/voice/voiceSession.d.ts +12 -0
- package/dist/shared/assistant/voice/voiceSession.d.ts.map +1 -1
- package/dist/shared/assistant/voice/voiceSession.js +6 -0
- package/dist/shared-assistant.js +151 -150
- package/package.json +1 -1
|
@@ -8,296 +8,313 @@ import { useAssistantNavigate as a } from "./AssistantMarkdownRenderer.js";
|
|
|
8
8
|
import { isAssistantModeId as o } from "../modeIds.js";
|
|
9
9
|
import { AUTO_READ_MODE as s, autoSuggestions as c, classifyAssistantIntent as l, escalationToUndo as u, isAutoRoutingOffered as d, resolveAutoRoute as f } from "../autoRouting.js";
|
|
10
10
|
import { getHistoryStamp as p, setHistoryBusyProbe as ee } from "../history/stampRegistry.js";
|
|
11
|
-
import { beginApprovalInFlight as m, endApprovalInFlight as
|
|
12
|
-
import { isWriteModeAcknowledged as
|
|
13
|
-
import { resolveActiveModeSandbox as
|
|
14
|
-
import { abortAssistantTurn as
|
|
15
|
-
import { sanitize as
|
|
16
|
-
import { AssistantSendRefusal as
|
|
17
|
-
import { assistantUsageLedger as
|
|
18
|
-
import { withIncompleteTurnNotice as
|
|
19
|
-
import { chatTurns as
|
|
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 {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
11
|
+
import { beginApprovalInFlight as m, endApprovalInFlight as h, getApprovalInFlight as g, markLiveTurn as te, newestModelReplyId as ne, resolveApprovablePendingWrite as _, resolveRetryableMessageId as v, subscribeApprovalInFlight as y } from "../liveTurns.js";
|
|
12
|
+
import { isWriteModeAcknowledged as re, writeModeSendRefusalReason as ie } from "../writeModeConsent.js";
|
|
13
|
+
import { resolveActiveModeSandbox as b, useAssistantStore as x } from "../store.js";
|
|
14
|
+
import { abortAssistantTurn as ae, approvePendingWrite as oe, createAssistantSandbox as S, createAssistantSession as C, extendAssistantSandboxTTL as se, findExistingSandboxWithStatus as ce, getAssistantArtifacts as le, getAssistantMessages as ue, getAssistantSession as de, modeRequiresConfirmWrites as fe, promptGatewayRequestBytes as pe, releaseSupersededAssistantSandboxes as w, sendAssistantPromptAsync as me, waitForAssistantServiceReady as T, waitForSandboxRunning as he, writeApprovalModeOf as ge } from "../api.js";
|
|
15
|
+
import { sanitize as _e } from "../progress.js";
|
|
16
|
+
import { AssistantSendRefusal as ve, classifyTurnFailure as ye, turnConfirmsNoAction as be, turnOutcomeCopy as xe } from "../turnOutcome.js";
|
|
17
|
+
import { assistantUsageLedger as Se, hasPendingUsageReports as Ce, reportUsageWithRetry as we, retryPendingUsageReports as Te, usageSendRefusal as Ee } from "../usageReporting.js";
|
|
18
|
+
import { withIncompleteTurnNotice as De } from "../streamBudget.js";
|
|
19
|
+
import { chatTurns as E, isVoiceTurn as Oe, voiceMarker as D, voiceSessionIdOf as ke } from "../voice/turnVisibility.js";
|
|
20
|
+
import { speechFeed as Ae } from "../speech/speechFeed.js";
|
|
21
|
+
import { buildContinuedFromVoiceNote as je, buildVoiceTranscriptMarkdown as Me, voiceTranscriptFilename as Ne } from "../voice/voiceTranscript.js";
|
|
22
|
+
import { pollDelayMs as Pe } from "../voice/assistantPollSchedule.js";
|
|
23
|
+
import { toCaptionText as Fe } from "../voice/captionText.js";
|
|
24
|
+
import { resolveAssistantLanguage as Ie } from "../voice/languages.js";
|
|
25
|
+
import { resolveLanguagePair as Le } from "../voice/languagePair.js";
|
|
26
|
+
import { INITIAL_TRANSCRIPT_AUTO_OPEN as Re, isAwaitingOwnConversation as ze, maySendSpokenTurn as Be, planTranscriptAutoOpen as Ve, planVoiceSessionBinding as He, planVoiceSessionStart as Ue, planVoiceSpokenEntry as We, voiceBindingAtStart as Ge, voiceBindingConversationId as Ke } from "../voice/voiceReopen.js";
|
|
27
|
+
import { countInlineImageCandidates as qe, countInlinedImageParts as Je, getSendableAttachments as Ye, largestInlineCharsPerFile as Xe, resolveAssistantInlineLimits as Ze, toMessageAttachment as Qe } from "../attachments.js";
|
|
28
|
+
import { WRITE_PROPOSAL_VOICE_COPY as $e, isVoiceProposalBound as et, voiceProposalChip as tt, voiceProposalChipText as nt, voiceReadbacksDue as rt, voiceWaitingProposals as it, writeProposalVoiceLine as at, writeProposalVoiceReadback as ot } from "../writeProposalVoice.js";
|
|
29
|
+
import { createAdminModeAccessGate as st, resolveAssistantSendModeAfterAccess as ct } from "../adminModeSendGate.js";
|
|
30
|
+
import { buildBoundedAttachmentTurn as lt } from "../attachmentTurn.js";
|
|
31
|
+
import { isTurnInFlight as ut, planAbandonedTurn as dt, planTurnAbort as ft } from "../turnState.js";
|
|
32
|
+
import { getAssistantDisplayContent as pt } from "../displayContent.js";
|
|
33
|
+
import { NO_FIRST_TEXT as mt, buildAssistantProgress as ht, readAheadFor as gt, snapshotReplyFloor as _t, startSessionReadAhead as vt, trackFirstText as yt } from "../turnProgress.js";
|
|
34
|
+
import { parseToolActivity as bt } from "./AssistantToolActivity.js";
|
|
35
|
+
import { countSpokenTurns as xt, spokenMessagesSinceContinueNote as St, spokenTurnText as Ct } from "../spokenTurns.js";
|
|
36
|
+
import { beginTurn as wt, describeTurn as O, detectTurnDevice as Tt, markTurn as k, restartAttempt as Et, turnClockMs as Dt } from "../turnTimeline.js";
|
|
37
|
+
import { useAssistantSpeech as Ot } from "./AssistantSpeechProvider.js";
|
|
38
|
+
import { useVoiceSession as kt } from "./useVoiceSession.js";
|
|
39
|
+
import { getOrganizationId as At, getWorkspaceId as A } from "../context.js";
|
|
40
|
+
import { isMultimodalBodyRejection as jt, isRecoverableAssistantError as Mt } from "../transportErrors.js";
|
|
41
|
+
import { createReadinessTracker as Nt, planAfterTransportFailure as Pt, planTrustedSandboxFailure as Ft } from "../sandboxReadiness.js";
|
|
42
|
+
import { writeProposalConfirmState as It } from "./writeProposalPresentation.js";
|
|
43
|
+
import { writeProposalUsesDialog as Lt } from "./AssistantWriteProposalCard.js";
|
|
44
|
+
import { AssistantWriteConfirmDialog as Rt } from "./AssistantWriteConfirmDialog.js";
|
|
45
|
+
import { useWriteProposalConfirm as zt } from "./useWriteProposalConfirm.js";
|
|
46
|
+
import { AssistantWriteProposalSlot as Bt } from "./AssistantWriteProposalSlot.js";
|
|
47
|
+
import { readWriteProposalRefs as Vt, writeProposalsEnabledFor as Ht } from "../writeProposalDiscovery.js";
|
|
48
|
+
import { planWriteReply as Ut, promptWriteApproval as Wt } from "../writeReplySend.js";
|
|
49
|
+
import { useWriteProposals as Gt } from "./useWriteProposals.js";
|
|
50
|
+
import { AssistantSpokenTurnsNotice as Kt } from "./AssistantSpokenTurnsNotice.js";
|
|
51
|
+
import { AssistantHistoryArchivedNotice as qt, AssistantHistoryDeletedNotice as Jt, AssistantHistoryLoadState as Yt, AssistantHistoryReadOnlyBanner as Xt, AssistantHistoryShowEarlier as Zt } from "./AssistantHistoryNotices.js";
|
|
52
|
+
import { VoiceTranscriptDrawer as Qt } from "./voice/VoiceTranscriptDrawer.js";
|
|
53
|
+
import { downloadFile as $t } from "../exportConversation.js";
|
|
54
|
+
import { conversationHasHistory as en, isOtherScopeHistoryConversation as tn, isReadOnlyHistoryConversation as nn, isReusableHistoryDraft as rn } from "../history/historyList.js";
|
|
55
|
+
import { useAssistantHistoryStatus as an } from "../history/historyStatus.js";
|
|
56
|
+
import { assistantHistory as on } from "../history/historyEngine.js";
|
|
57
|
+
import { AssistantEmptyState as sn } from "./AssistantEmptyState.js";
|
|
58
|
+
import { AssistantNothingToDeleteNotice as cn } from "./AssistantDeleteConversationDialog.js";
|
|
59
|
+
import { assistantHistoryIsOn as ln } from "./conversationDelete.js";
|
|
60
|
+
import { useConversationDeleteDialog as un } from "./conversationDeleteDialog.js";
|
|
61
|
+
import { resolveConversationDeleteTarget as dn } from "../conversationDeleteCommand.js";
|
|
62
|
+
import { resumeContextFor as fn } from "../history/historyResume.js";
|
|
63
|
+
import { useHistoryRowControlsFor as pn } from "../history/useHistoryRowControls.js";
|
|
64
|
+
import { AssistantMessageList as mn } from "./AssistantMessageList.js";
|
|
65
|
+
import { AssistantVoiceSession as hn } from "./voice/AssistantVoiceSession.js";
|
|
66
|
+
import { useAssistantApiAccess as gn } from "../useAssistantApiAccess.js";
|
|
67
|
+
import { useConversationTurns as _n } from "../useConversationTurns.js";
|
|
68
|
+
import { sendAssistantTurnTimings as vn, startTurnTimingReporting as yn } from "../turnTimingReporter.js";
|
|
69
|
+
import { QuarantineSet as bn, WarmCancelled as xn, claimPreopenedSession as Sn, consumeWarm as Cn, preopenKey as wn, preopenWanted as Tn, prewarmTarget as En, settleWarmBeforeSend as Dn, startPreopen as On, startWarm as kn, warmState as An } from "../prewarm.js";
|
|
70
|
+
import { isAlreadyThere as jn, matchLocalUiCommand as Mn, navDestinations as Nn, planThemeChange as Pn } from "../localUiCommands.js";
|
|
71
|
+
import { chooseDestinationCopy as Fn, navigationCommandCopy as In, themeCommandCopy as Ln } from "../localUiCommandCopy.js";
|
|
72
|
+
import { dispatchAssistantQuotaExhausted as Rn, notifyAiCreditsUpdated as zn } from "../aiCredits.js";
|
|
73
|
+
import { useAssistantAttachments as Bn } from "../useAssistantAttachments.js";
|
|
74
|
+
import { AssistantComposer as Vn } from "./composer/AssistantComposer.js";
|
|
75
|
+
import { isProdRuntime as Hn } from "../env.js";
|
|
76
|
+
import { AssistantApiCallsConsentDialog as Un } from "./AssistantApiCallsConsentDialog.js";
|
|
77
|
+
import { useVisibleNavItems as Wn } from "../../../chrome/mobileTabBar/useVisibleNavItems.js";
|
|
78
|
+
import { useCallback as j, useEffect as M, useMemo as Gn, useRef as N, useState as Kn, useSyncExternalStore as qn } from "react";
|
|
79
|
+
import { jsx as P, jsxs as Jn } from "react/jsx-runtime";
|
|
79
80
|
//#region src/shared/assistant/ui/AssistantChatArea.tsx
|
|
80
|
-
var
|
|
81
|
-
function
|
|
81
|
+
var Yn = 600, Xn = 2e4, Zn = 1e4, Qn = 6e3;
|
|
82
|
+
function F() {
|
|
82
83
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
83
84
|
}
|
|
84
|
-
var
|
|
85
|
-
let
|
|
86
|
-
let n =
|
|
87
|
-
return
|
|
85
|
+
var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
|
|
86
|
+
let I = i(), { product: L, modes: R, gatherPageContext: tr, buildPrompt: nr, reportTurnTimings: rr, reportTokenUsage: ir, localUiCommands: ar } = r(), z = ge(r().writeApproval), or = j((e, t) => {
|
|
87
|
+
let n = x.getState(), r = t ?? n.sandboxesByMode[e]?.sandboxId ?? null;
|
|
88
|
+
return et({
|
|
88
89
|
mode: e,
|
|
89
|
-
productWriteApproval:
|
|
90
|
+
productWriteApproval: z,
|
|
90
91
|
capabilities: r ? n.sandboxWriteCapabilities[r] : null
|
|
91
92
|
});
|
|
92
|
-
}, [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
]),
|
|
97
|
-
tr:
|
|
98
|
-
productWriteApproval:
|
|
99
|
-
}),
|
|
100
|
-
approve: (e, t) =>
|
|
101
|
-
decline: (e, t, n) =>
|
|
102
|
-
presented: (e, t) =>
|
|
103
|
-
}),
|
|
93
|
+
}, [z]), { getAccessToken: B, getWorkspaceToken: sr, userId: V } = n(), { locale: H } = t(), cr = x((e) => e.assistantLanguage), lr = x((e) => e.replyLanguage), ur = Gn(() => Le(cr, lr, H), [
|
|
94
|
+
cr,
|
|
95
|
+
lr,
|
|
96
|
+
H
|
|
97
|
+
]), dr = ur.reply.english, fr = ur.replyIsExplicit, pr = ur.reply.code, { conversations: mr, activeConversationId: U, mode: W, processingByConversationId: hr, setMode: gr, setConversationMode: _r, setActiveConversation: vr, createConversation: G, addMessage: K, updateMessage: yr, patchMessage: br, mergeMessageMetadata: xr, setConversationProcessing: Sr, clearConversationProcessing: Cr, setBackendSessionId: wr, clearBackendSessionId: Tr, setSandbox: Er, clearSandbox: Dr, acknowledgedWriteModes: Or, acknowledgeWriteMode: kr, autoRouting: Ar, setAutoRouting: jr, routeConversation: Mr } = x(), Nr = mr.find((e) => e.id === U), Pr = _n(Nr), Fr = Pr.all, q = U ? hr[U] : void 0, Ir = ut(q?.status), Lr = Ir ? q?.messageId ?? null : null, Rr = q?.status === "error" ? q.messageId : null, zr = x((e) => e.sandboxWriteCapabilities), { panel: J, entries: Br, retiredSandboxes: Vr } = Gt({
|
|
98
|
+
tr: I,
|
|
99
|
+
productWriteApproval: z
|
|
100
|
+
}), Hr = zt({
|
|
101
|
+
approve: (e, t) => J.approve(e, t),
|
|
102
|
+
decline: (e, t, n) => J.decline(e, t, n),
|
|
103
|
+
presented: (e, t) => J.presented(e, t)
|
|
104
|
+
}), Ur = Hr.dismiss, Wr = N(null);
|
|
104
105
|
M(() => {
|
|
105
|
-
|
|
106
|
-
let e =
|
|
107
|
-
|
|
106
|
+
Ur();
|
|
107
|
+
let e = Wr.current;
|
|
108
|
+
Wr.current = U, e && e !== U && J.withdraw(e, "conversation_closed"), U && J.openConversation(U);
|
|
108
109
|
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
U,
|
|
111
|
+
J,
|
|
112
|
+
Ur
|
|
112
113
|
]);
|
|
113
|
-
let
|
|
114
|
+
let Gr = nn(Nr), Kr = pn(Nr)?.archivedAt != null, qr = an((e) => U !== null && U in e.loadingIds), Jr = an((e) => U !== null && U in e.loadErrorIds), Yr = an((e) => e.remoteDelete), [Xr, Zr] = Kn(() => an.getState().remoteDelete?.at ?? null), Qr = Yr?.wasActive === !0 && Yr.at !== Xr ? Yr.at : null;
|
|
114
115
|
M(() => {
|
|
115
|
-
if (
|
|
116
|
-
let e = window.setTimeout(() =>
|
|
116
|
+
if (Qr === null) return;
|
|
117
|
+
let e = window.setTimeout(() => Zr(Qr), Zn);
|
|
117
118
|
return () => window.clearTimeout(e);
|
|
118
|
-
}, [
|
|
119
|
-
let { canUseApiCalls:
|
|
120
|
-
loading:
|
|
121
|
-
canUseAdminModes:
|
|
122
|
-
})).current,
|
|
119
|
+
}, [Qr]);
|
|
120
|
+
let { canUseApiCalls: $r, loading: ei } = gn(A(), V), ti = N(st({
|
|
121
|
+
loading: ei,
|
|
122
|
+
canUseAdminModes: $r
|
|
123
|
+
})).current, ni = N(R);
|
|
123
124
|
M(() => {
|
|
124
|
-
|
|
125
|
-
}, [
|
|
126
|
-
let
|
|
127
|
-
let e =
|
|
128
|
-
e &&
|
|
129
|
-
},
|
|
130
|
-
let e =
|
|
131
|
-
e &&
|
|
132
|
-
},
|
|
125
|
+
ni.current = R;
|
|
126
|
+
}, [R]);
|
|
127
|
+
let ri = () => {
|
|
128
|
+
let e = x.getState().activeConversationId;
|
|
129
|
+
e && on.openConversation(e, { modes: ni.current });
|
|
130
|
+
}, ii = () => {
|
|
131
|
+
let e = x.getState().activeConversationId;
|
|
132
|
+
e && on.loadEarlier(e);
|
|
133
|
+
}, ai = N(B);
|
|
133
134
|
M(() => {
|
|
134
|
-
|
|
135
|
-
}, [
|
|
136
|
-
let
|
|
135
|
+
ai.current = B;
|
|
136
|
+
}, [B]);
|
|
137
|
+
let oi = !!L && rr !== !1;
|
|
137
138
|
M(() => {
|
|
138
|
-
if (
|
|
139
|
+
if (oi) return yn({ send: (e) => vn(e, {
|
|
139
140
|
workspaceId: A(),
|
|
140
141
|
authContext: {
|
|
141
|
-
accessToken:
|
|
142
|
-
organizationId:
|
|
142
|
+
accessToken: ai.current(),
|
|
143
|
+
organizationId: At()
|
|
143
144
|
}
|
|
144
145
|
}) });
|
|
145
|
-
}, [
|
|
146
|
-
|
|
147
|
-
loading:
|
|
148
|
-
canUseAdminModes:
|
|
146
|
+
}, [oi]), M(() => {
|
|
147
|
+
ti.update({
|
|
148
|
+
loading: ei,
|
|
149
|
+
canUseAdminModes: $r
|
|
149
150
|
});
|
|
150
151
|
}, [
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
ti,
|
|
153
|
+
ei,
|
|
154
|
+
$r
|
|
154
155
|
]), M(() => () => {
|
|
155
|
-
|
|
156
|
-
}, [
|
|
157
|
-
let
|
|
156
|
+
ti.abandon();
|
|
157
|
+
}, [ti]);
|
|
158
|
+
let si = Gn(() => R.filter((e) => !e.requiresAdmin || $r), [R, $r]), ci = d(si), li = Ar && ci, ui = N(ci);
|
|
158
159
|
M(() => {
|
|
159
|
-
|
|
160
|
-
}, [
|
|
161
|
-
let
|
|
162
|
-
|
|
160
|
+
ui.current = ci;
|
|
161
|
+
}, [ci]);
|
|
162
|
+
let di = N(null), fi = N(!1), pi = Xe(R), [mi, hi] = Kn(null), [gi, _i] = Kn(null), vi = gi !== null && gi === U, yi = j((e) => {
|
|
163
|
+
_i(e ? x.getState().activeConversationId : null);
|
|
163
164
|
}, []);
|
|
164
165
|
M(() => {
|
|
165
|
-
|
|
166
|
-
}, [
|
|
167
|
-
let
|
|
168
|
-
|
|
169
|
-
}, []),
|
|
170
|
-
let e =
|
|
166
|
+
_i((e) => e !== null && e !== U ? null : e);
|
|
167
|
+
}, [U]);
|
|
168
|
+
let bi = N(void 0), [xi, Si] = Kn(!1), Ci = j((e) => {
|
|
169
|
+
bi.current = e, Si(ze(e));
|
|
170
|
+
}, []), wi = j(() => {
|
|
171
|
+
let e = x.getState(), t = e.activeConversationId, n = t ? e.conversations.find((e) => e.id === t) : void 0;
|
|
171
172
|
return !t || !n ? null : {
|
|
172
173
|
id: t,
|
|
173
|
-
reusableDraft:
|
|
174
|
-
liveProposals:
|
|
175
|
-
turnInFlight:
|
|
174
|
+
reusableDraft: rn(n, p()),
|
|
175
|
+
liveProposals: J.liveFor(t).count,
|
|
176
|
+
turnInFlight: ut(e.processingByConversationId[t]?.status)
|
|
176
177
|
};
|
|
177
|
-
}, [
|
|
178
|
-
let t = e.sandboxesByMode[
|
|
178
|
+
}, [J]), Ti = N({}), Y = N(Nt()), X = N(new bn()), Ei = N(/* @__PURE__ */ new Set()), Di = Gn(() => R.find((e) => e.id === W), [R, W]), Oi = x((e) => {
|
|
179
|
+
let t = e.sandboxesByMode[W]?.sandboxId;
|
|
179
180
|
return t ? e.sandboxWriteCapabilities[t] : void 0;
|
|
180
|
-
}),
|
|
181
|
-
mode:
|
|
182
|
-
productWriteApproval:
|
|
183
|
-
capabilities:
|
|
184
|
-
}),
|
|
181
|
+
}), ki = Di !== void 0 && et({
|
|
182
|
+
mode: W,
|
|
183
|
+
productWriteApproval: z,
|
|
184
|
+
capabilities: Oi
|
|
185
|
+
}), Ai = W === "assistant" || Di !== void 0 && !Di.writeCapable && !fe(W) || ki;
|
|
185
186
|
M(() => {
|
|
186
|
-
if (
|
|
187
|
-
|
|
187
|
+
if (W !== "assistant" && Di?.writeCapable && !re(Or, W)) {
|
|
188
|
+
gr("assistant");
|
|
188
189
|
return;
|
|
189
190
|
}
|
|
190
|
-
|
|
191
|
+
ei || (!Di || Di.requiresAdmin && !$r) && W !== "assistant" && gr("assistant");
|
|
191
192
|
}, [
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
W,
|
|
194
|
+
Di,
|
|
195
|
+
$r,
|
|
196
|
+
ei,
|
|
197
|
+
gr,
|
|
198
|
+
Or
|
|
198
199
|
]);
|
|
199
|
-
let
|
|
200
|
-
|
|
201
|
-
}, [
|
|
200
|
+
let ji = j((e, t, n, r) => {
|
|
201
|
+
Sr(e, n, t, null, r);
|
|
202
|
+
}, [Sr]), Mi = j(async (e, t, n, r, i, a = null) => {
|
|
202
203
|
let s = (e, t) => {
|
|
203
|
-
r &&
|
|
204
|
+
r && ji(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
|
|
204
205
|
}, c = (e) => {
|
|
205
206
|
r && k(r.assistantMessageId, e);
|
|
206
207
|
}, l = () => {
|
|
207
208
|
c("bootAdopted"), a?.beginBoot();
|
|
208
209
|
}, u = () => a !== null && (a.signal.aborted || A() !== t), d = () => {
|
|
209
|
-
if (u()) throw new
|
|
210
|
-
}, f =
|
|
211
|
-
if (i && !
|
|
210
|
+
if (u()) throw new xn("cancelled");
|
|
211
|
+
}, f = x.getState().sandboxesByMode[e]?.sandboxId ?? null, p = !1, ee = !1, m = !1, h = !1, g = !1, te = async (r) => {
|
|
212
|
+
if (i && !X.current.has(r) && Y.current.isFresh(r)) return p = !0, !0;
|
|
212
213
|
m = !0;
|
|
213
214
|
let o = !1;
|
|
214
215
|
try {
|
|
215
|
-
await
|
|
216
|
+
await he(r, t, n, 3e5), await T(r, t, e, n, 9e4, () => {
|
|
216
217
|
o = !0, l();
|
|
217
218
|
});
|
|
218
219
|
} catch {
|
|
219
|
-
if (u()) throw new
|
|
220
|
-
return
|
|
220
|
+
if (u()) throw new xn("cancelled");
|
|
221
|
+
return Y.current.invalidate(r), X.current.add(r), a?.dead.push(r), g = !0, !1;
|
|
221
222
|
}
|
|
222
|
-
return d(),
|
|
223
|
+
return d(), Y.current.markVerified(r), o && (h = !0), !0;
|
|
223
224
|
};
|
|
224
|
-
if (f && (
|
|
225
|
+
if (f && (Er(e, f, "provisioning"), s("provisioning", "reusingEnvironment"), await te(f) || (Er(e, null, "provisioning"), f = null)), !f) {
|
|
225
226
|
s("provisioning", "lookingForEnvironment");
|
|
226
|
-
let r = await
|
|
227
|
+
let r = await ce(t, L, e, Hn(), n, X.current, z);
|
|
227
228
|
d();
|
|
228
229
|
let i = r?.id ?? null;
|
|
229
230
|
if (i) {
|
|
230
|
-
|
|
231
|
+
Er(e, i, "provisioning"), s("provisioning", "reusingEnvironment");
|
|
231
232
|
let t = r?.status === "PROVISIONING" || r?.status === "PENDING";
|
|
232
|
-
t && l(), await
|
|
233
|
+
t && l(), await te(i) ? (f = i, t && (h = !0)) : Er(e, null, "provisioning");
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
if (!f) {
|
|
236
|
-
if (a && !a.mayCreate) throw new
|
|
237
|
-
if (c("provisionStarted"), e === "api-calls" && !
|
|
238
|
-
s("provisioning", "startingEnvironment"),
|
|
239
|
-
let r = a ? [] : await
|
|
237
|
+
if (a && !a.mayCreate) throw new xn("no-create");
|
|
238
|
+
if (c("provisionStarted"), e === "api-calls" && !B()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
239
|
+
s("provisioning", "startingEnvironment"), Er(e, null, "provisioning");
|
|
240
|
+
let r = a ? [] : await w(t, L, e, Hn(), n, X.current, z);
|
|
240
241
|
if (r.length > 0) {
|
|
241
242
|
let e = new Set(r);
|
|
242
|
-
for (let e of r)
|
|
243
|
-
let t =
|
|
244
|
-
for (let [n, r] of Object.entries(t)) o(n) && r?.sandboxId && e.has(r.sandboxId) &&
|
|
243
|
+
for (let e of r) Y.current.invalidate(e), X.current.add(e);
|
|
244
|
+
let t = x.getState().sandboxesByMode;
|
|
245
|
+
for (let [n, r] of Object.entries(t)) o(n) && r?.sandboxId && e.has(r.sandboxId) && Dr(n);
|
|
245
246
|
}
|
|
246
247
|
c("createRequested");
|
|
247
248
|
let i = a?.beginCreate();
|
|
248
249
|
try {
|
|
249
|
-
f = await
|
|
250
|
+
f = await S(L, e, t, Hn(), Yn, n, { writeApproval: z });
|
|
250
251
|
} finally {
|
|
251
252
|
i?.();
|
|
252
253
|
}
|
|
253
|
-
ee = !0, d(),
|
|
254
|
+
ee = !0, d(), Er(e, f, "provisioning"), await he(f, t, n, 3e5), d(), c("sandboxRunning"), await T(f, t, e, n, 9e4), d(), c("serviceReady"), Y.current.markVerified(f);
|
|
254
255
|
}
|
|
255
|
-
return
|
|
256
|
+
return Er(e, f, "running"), {
|
|
256
257
|
sandboxId: f,
|
|
257
258
|
sandboxIsNew: ee,
|
|
258
259
|
sandboxProbed: m,
|
|
259
|
-
sandboxAdopted:
|
|
260
|
-
deadSandboxProbe:
|
|
260
|
+
sandboxAdopted: h,
|
|
261
|
+
deadSandboxProbe: g,
|
|
261
262
|
trustedFromCache: p
|
|
262
263
|
};
|
|
263
264
|
}, [
|
|
264
|
-
|
|
265
|
+
Dr,
|
|
266
|
+
B,
|
|
267
|
+
L,
|
|
265
268
|
z,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
s.verified && !Y.current.has(s.verified) && J.current.markVerified(s.verified), s.joined && O(n, { prewarm: s.joined });
|
|
274
|
-
let { sandboxId: c, sandboxIsNew: l, sandboxProbed: u, sandboxAdopted: d, deadSandboxProbe: f, trustedFromCache: p } = await Di(r, i, a, {
|
|
269
|
+
Er,
|
|
270
|
+
ji
|
|
271
|
+
]), Ni = j(async function e(t, n, r, i, a, o = {}) {
|
|
272
|
+
let s = await Dn(i, r, (e) => ji(t, n, "provisioning", e), () => k(n, "prewarmJoined"));
|
|
273
|
+
for (let e of s.dead) Y.current.invalidate(e), X.current.add(e);
|
|
274
|
+
s.verified && !X.current.has(s.verified) && Y.current.markVerified(s.verified), s.joined && O(n, { prewarm: s.joined });
|
|
275
|
+
let { sandboxId: c, sandboxIsNew: l, sandboxProbed: u, sandboxAdopted: d, deadSandboxProbe: f, trustedFromCache: p } = await Mi(r, i, a, {
|
|
275
276
|
conversationId: t,
|
|
276
277
|
assistantMessageId: n
|
|
277
|
-
}, o.trustCache !== !1), ee =
|
|
278
|
+
}, o.trustCache !== !1), ee = Cn(i, r, c);
|
|
278
279
|
!s.waited && ee && O(n, { prewarm: "hit" });
|
|
279
|
-
let m =
|
|
280
|
+
let m = x.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, h = !1, g = null;
|
|
280
281
|
if (m) {
|
|
281
|
-
let e =
|
|
282
|
+
let e = vt(c, m, (e, t) => ue(e, i, t, r, a, { limit: 50 }));
|
|
282
283
|
try {
|
|
283
|
-
let t = await
|
|
284
|
+
let t = await de(c, i, m, r, a);
|
|
284
285
|
if (t.mode !== r) throw Error(`Session mode mismatch: expected ${r}, received ${t.mode}`);
|
|
285
|
-
|
|
286
|
+
g = e;
|
|
286
287
|
} catch {
|
|
287
|
-
|
|
288
|
+
Tr(t), m = null;
|
|
288
289
|
}
|
|
289
290
|
}
|
|
291
|
+
let te = !1;
|
|
290
292
|
if (!m) {
|
|
291
|
-
|
|
293
|
+
let e = Sn(wn({
|
|
294
|
+
workspaceId: i,
|
|
295
|
+
mode: r,
|
|
296
|
+
sandboxId: c,
|
|
297
|
+
userId: V
|
|
298
|
+
}), Date.now());
|
|
299
|
+
if (e) {
|
|
300
|
+
"pending" in e && ji(t, n, "connecting", "preparingSession");
|
|
301
|
+
let o = "sessionId" in e ? e.sessionId : await e.pending;
|
|
302
|
+
if (o && !X.current.has(c)) try {
|
|
303
|
+
(await de(c, i, o, r, a)).mode === r && (m = o, te = !0, wr(t, m), h = !0);
|
|
304
|
+
} catch {}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (!m) {
|
|
308
|
+
ji(t, n, "connecting", "preparingSession");
|
|
292
309
|
let s;
|
|
293
310
|
try {
|
|
294
|
-
s = await
|
|
311
|
+
s = await C(c, i, r, a);
|
|
295
312
|
} catch (s) {
|
|
296
313
|
if (p) {
|
|
297
|
-
|
|
298
|
-
let l =
|
|
299
|
-
if (l === "check-network" && (l = await
|
|
300
|
-
p || O(n, { cacheProofFailed: !0 }), l === "replace" && (
|
|
314
|
+
Y.current.invalidate(c);
|
|
315
|
+
let l = Ft(s, o.isAbandoned?.() ?? !1), p = l === "check-network";
|
|
316
|
+
if (l === "check-network" && (l = await Pt(() => ce(i, L, r, Hn(), a, X.current, z))), l !== "rethrow" && o.isAbandoned?.() && (l = "rethrow"), l !== "rethrow") {
|
|
317
|
+
p || O(n, { cacheProofFailed: !0 }), l === "replace" && (X.current.add(c), Tr(t), Dr(r), J.retireSandbox(c));
|
|
301
318
|
let s = await e(t, n, r, i, a, {
|
|
302
319
|
...o,
|
|
303
320
|
trustCache: !1
|
|
@@ -312,62 +329,81 @@ var Jn = ({ visible: Jn = !0, writeAccess: Yn = "unknown" }) => {
|
|
|
312
329
|
}
|
|
313
330
|
throw s;
|
|
314
331
|
}
|
|
315
|
-
m = s.sessionId,
|
|
332
|
+
m = s.sessionId, wr(t, m), h = !0;
|
|
316
333
|
}
|
|
317
334
|
return {
|
|
318
335
|
sandboxId: c,
|
|
319
336
|
sessionId: m,
|
|
320
|
-
sessionIsNew:
|
|
321
|
-
readAhead:
|
|
337
|
+
sessionIsNew: h,
|
|
338
|
+
readAhead: g,
|
|
322
339
|
sandboxIsNew: l,
|
|
323
340
|
sandboxProbed: u,
|
|
324
341
|
sandboxAdopted: d,
|
|
325
|
-
deadSandboxProbe: f
|
|
342
|
+
deadSandboxProbe: f,
|
|
343
|
+
sessionPreopened: te
|
|
326
344
|
};
|
|
327
345
|
}, [
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
346
|
+
Mi,
|
|
347
|
+
Tr,
|
|
348
|
+
Dr,
|
|
349
|
+
L,
|
|
350
|
+
z,
|
|
351
|
+
wr,
|
|
352
|
+
ji,
|
|
353
|
+
V,
|
|
354
|
+
J
|
|
355
|
+
]), Pi = j((e, t = !1) => {
|
|
337
356
|
let n = A();
|
|
338
357
|
if (!n) return;
|
|
339
|
-
let r =
|
|
358
|
+
let r = x.getState(), i = Date.now(), a = En({
|
|
340
359
|
autoRouting: r.autoRouting,
|
|
341
|
-
autoOffered:
|
|
360
|
+
autoOffered: ui.current,
|
|
342
361
|
active: !t && r.activeConversationId ? r.conversations.find((e) => e.id === r.activeConversationId) : void 0,
|
|
343
362
|
selectedMode: r.mode,
|
|
344
363
|
autoReadMode: s,
|
|
345
|
-
modes:
|
|
364
|
+
modes: ni.current,
|
|
346
365
|
acknowledgedWriteModes: r.acknowledgedWriteModes,
|
|
347
|
-
adminAccess:
|
|
366
|
+
adminAccess: ti.read(),
|
|
348
367
|
dictated: e,
|
|
349
|
-
voiceProposalBound: (e) =>
|
|
350
|
-
turnInFlight: Object.values(r.processingByConversationId).some((e) =>
|
|
351
|
-
...
|
|
368
|
+
voiceProposalBound: (e) => or(e),
|
|
369
|
+
turnInFlight: Object.values(r.processingByConversationId).some((e) => ut(e?.status)),
|
|
370
|
+
...An(n),
|
|
352
371
|
now: i
|
|
353
372
|
});
|
|
354
373
|
if (!a) return;
|
|
355
|
-
let o =
|
|
356
|
-
accessToken:
|
|
357
|
-
workspaceToken:
|
|
358
|
-
userId:
|
|
359
|
-
organizationId:
|
|
374
|
+
let o = kn(n, a, i), c = {
|
|
375
|
+
accessToken: B(),
|
|
376
|
+
workspaceToken: sr(),
|
|
377
|
+
userId: V,
|
|
378
|
+
organizationId: At()
|
|
360
379
|
};
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
380
|
+
Mi(a.mode, n, c, null, !0, o).then((e) => {
|
|
381
|
+
if (o.finish({
|
|
382
|
+
ok: !0,
|
|
383
|
+
sandboxId: e.sandboxId,
|
|
384
|
+
didWork: !e.trustedFromCache && (e.sandboxIsNew || e.sandboxProbed || e.sandboxAdopted),
|
|
385
|
+
booted: e.sandboxIsNew || e.sandboxAdopted,
|
|
386
|
+
dead: o.dead
|
|
387
|
+
}), o.signal.aborted || A() !== n || X.current.has(e.sandboxId)) return;
|
|
388
|
+
let r = x.getState(), i = !t && r.activeConversationId ? r.conversations.find((e) => e.id === r.activeConversationId) : void 0, s = p();
|
|
389
|
+
Tn({
|
|
390
|
+
active: i ? {
|
|
391
|
+
mode: i.mode,
|
|
392
|
+
backendSessionId: i.backendSessionId,
|
|
393
|
+
continuable: !nn(i) && !tn(i, s),
|
|
394
|
+
hasHistory: en(i)
|
|
395
|
+
} : void 0,
|
|
396
|
+
mode: a.mode
|
|
397
|
+
}) && On(wn({
|
|
398
|
+
workspaceId: n,
|
|
399
|
+
mode: a.mode,
|
|
400
|
+
sandboxId: e.sandboxId,
|
|
401
|
+
userId: V
|
|
402
|
+
}), () => C(e.sandboxId, n, a.mode, c).then((e) => e.sessionId), Date.now());
|
|
403
|
+
}, (e) => {
|
|
404
|
+
if (!(e instanceof xn) && !o.signal.aborted && A() === n) {
|
|
405
|
+
let e = x.getState().sandboxesByMode[a.mode]?.sandboxId ?? null;
|
|
406
|
+
e && (Y.current.invalidate(e), X.current.add(e), o.dead.push(e), Dr(a.mode));
|
|
371
407
|
}
|
|
372
408
|
o.finish({
|
|
373
409
|
ok: !1,
|
|
@@ -377,44 +413,44 @@ var Jn = ({ visible: Jn = !0, writeAccess: Yn = "unknown" }) => {
|
|
|
377
413
|
});
|
|
378
414
|
});
|
|
379
415
|
}, [
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
z,
|
|
384
|
-
nr,
|
|
416
|
+
Mi,
|
|
417
|
+
ti,
|
|
418
|
+
Dr,
|
|
385
419
|
B,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
420
|
+
sr,
|
|
421
|
+
V,
|
|
422
|
+
or
|
|
423
|
+
]), Fi = j(() => Pi(!1), [Pi]), Ii = qn(y, g, g)?.reference ?? null, [Li, Ri] = Kn(0), zi = N(/* @__PURE__ */ new Set()), Bi = N(null), Vi = j(() => {
|
|
424
|
+
let e = x.getState(), t = e.activeConversationId;
|
|
389
425
|
if (!t) return;
|
|
390
|
-
let n = e.processingByConversationId[t], r =
|
|
391
|
-
if (!
|
|
426
|
+
let n = e.processingByConversationId[t], r = ut(n?.status) ? n?.messageId ?? null : null;
|
|
427
|
+
if (!ft({
|
|
392
428
|
interruptedTurnId: r,
|
|
393
429
|
activeTurnId: r,
|
|
394
|
-
alreadyRequested: r ?
|
|
430
|
+
alreadyRequested: r ? zi.current.has(r) : !1
|
|
395
431
|
}).send || !r) return;
|
|
396
|
-
|
|
397
|
-
let i =
|
|
398
|
-
!i || !a || !o ||
|
|
399
|
-
accessToken:
|
|
400
|
-
workspaceToken:
|
|
401
|
-
userId:
|
|
402
|
-
organizationId:
|
|
432
|
+
zi.current.add(r);
|
|
433
|
+
let i = b(e), a = A(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
|
|
434
|
+
!i || !a || !o || ae(i.sandboxId, a, o, i.mode, {
|
|
435
|
+
accessToken: B(),
|
|
436
|
+
workspaceToken: sr(),
|
|
437
|
+
userId: V,
|
|
438
|
+
organizationId: At()
|
|
403
439
|
});
|
|
404
440
|
}, [
|
|
441
|
+
V,
|
|
405
442
|
B,
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
let a = t.conversations.find((e) => e.id === i), o = a ? g(T(a.messages), {
|
|
443
|
+
sr
|
|
444
|
+
]), Hi = j(async (e) => {
|
|
445
|
+
let t = x.getState(), n = b(t), r = A(), i = t.activeConversationId;
|
|
446
|
+
if (!n || !r || !i || Ht(t.sandboxWriteCapabilities[n.sandboxId])) return;
|
|
447
|
+
let a = t.conversations.find((e) => e.id === i), o = a ? _(E(a.messages), {
|
|
412
448
|
sessionId: a.backendSessionId,
|
|
413
449
|
sandboxId: n.sandboxId,
|
|
414
450
|
nowMs: Date.now()
|
|
415
451
|
}) : null;
|
|
416
452
|
if (o?.reference !== e) {
|
|
417
|
-
|
|
453
|
+
Ri((e) => e + 1);
|
|
418
454
|
return;
|
|
419
455
|
}
|
|
420
456
|
let s = {
|
|
@@ -423,127 +459,127 @@ var Jn = ({ visible: Jn = !0, writeAccess: Yn = "unknown" }) => {
|
|
|
423
459
|
};
|
|
424
460
|
if (!m(s)) return;
|
|
425
461
|
try {
|
|
426
|
-
await
|
|
427
|
-
accessToken:
|
|
428
|
-
workspaceToken:
|
|
429
|
-
userId:
|
|
430
|
-
organizationId:
|
|
462
|
+
await oe(n.sandboxId, r, e, n.mode, {
|
|
463
|
+
accessToken: B(),
|
|
464
|
+
workspaceToken: sr(),
|
|
465
|
+
userId: V,
|
|
466
|
+
organizationId: At()
|
|
431
467
|
});
|
|
432
468
|
} catch (e) {
|
|
433
|
-
|
|
434
|
-
id:
|
|
469
|
+
h(s), K(i, {
|
|
470
|
+
id: F(),
|
|
435
471
|
role: "system",
|
|
436
472
|
content: e instanceof Error ? e.message : "The change could not be approved.",
|
|
437
473
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
438
474
|
});
|
|
439
475
|
return;
|
|
440
476
|
}
|
|
441
|
-
|
|
442
|
-
let c =
|
|
443
|
-
c.activeConversationId !== i || !l || c.mode !== n.mode || l.backendSessionId !== a?.backendSessionId ||
|
|
477
|
+
h(s), xr(i, o.messageId, { pendingWriteApprovedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
478
|
+
let c = x.getState(), l = c.conversations.find((e) => e.id === i);
|
|
479
|
+
c.activeConversationId !== i || !l || c.mode !== n.mode || l.backendSessionId !== a?.backendSessionId || b(c)?.sandboxId !== n.sandboxId || ut(c.processingByConversationId[i]?.status) || ne(E(l.messages)) !== o.messageId || oa.current(I("pendingWrite.approvedPrompt", "I approved that change — go ahead."), [], {
|
|
444
480
|
approvalFollowUp: { approvedReplyId: o.messageId },
|
|
445
481
|
targetConversationId: i
|
|
446
482
|
});
|
|
447
483
|
}, [
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
]),
|
|
453
|
-
theme:
|
|
454
|
-
navigate:
|
|
455
|
-
navItems:
|
|
456
|
-
options:
|
|
484
|
+
V,
|
|
485
|
+
K,
|
|
486
|
+
xr,
|
|
487
|
+
I
|
|
488
|
+
]), Ui = e(), { speakFinishedReply: Wi } = Ot(), Gi = a(), { items: Ki } = Wn(), qi = N({
|
|
489
|
+
theme: Ui,
|
|
490
|
+
navigate: Gi,
|
|
491
|
+
navItems: Ki,
|
|
492
|
+
options: ar ?? {}
|
|
457
493
|
});
|
|
458
494
|
M(() => {
|
|
459
|
-
|
|
460
|
-
theme:
|
|
461
|
-
navigate:
|
|
462
|
-
navItems:
|
|
463
|
-
options:
|
|
495
|
+
qi.current = {
|
|
496
|
+
theme: Ui,
|
|
497
|
+
navigate: Gi,
|
|
498
|
+
navItems: Ki,
|
|
499
|
+
options: ar ?? {}
|
|
464
500
|
};
|
|
465
501
|
}, [
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
502
|
+
Ui,
|
|
503
|
+
Gi,
|
|
504
|
+
Ki,
|
|
505
|
+
ar
|
|
470
506
|
]);
|
|
471
|
-
let
|
|
472
|
-
let a =
|
|
507
|
+
let Ji = j((e, t, n, r, i) => {
|
|
508
|
+
let a = I(n.key, n.fallback, r), o = n.fallback.replace(/\{\{\s*count\s*\}\}/g, String(r.count)), s = {
|
|
473
509
|
kind: "write-reply",
|
|
474
510
|
line: n.key
|
|
475
|
-
}, c = (/* @__PURE__ */ new Date()).toISOString(), l =
|
|
476
|
-
|
|
511
|
+
}, c = (/* @__PURE__ */ new Date()).toISOString(), l = F();
|
|
512
|
+
K(e, {
|
|
477
513
|
id: l,
|
|
478
514
|
role: "user",
|
|
479
515
|
content: t,
|
|
480
516
|
timestamp: c,
|
|
481
517
|
metadata: {
|
|
482
518
|
localAction: s,
|
|
483
|
-
...
|
|
519
|
+
...D(i)
|
|
484
520
|
}
|
|
485
521
|
});
|
|
486
|
-
let u =
|
|
487
|
-
|
|
522
|
+
let u = F();
|
|
523
|
+
K(e, {
|
|
488
524
|
id: u,
|
|
489
525
|
role: "assistant",
|
|
490
526
|
content: a,
|
|
491
527
|
timestamp: c,
|
|
492
528
|
metadata: {
|
|
493
|
-
lang: a === o ? "en" :
|
|
529
|
+
lang: a === o ? "en" : H,
|
|
494
530
|
localAction: s,
|
|
495
|
-
...
|
|
531
|
+
...D(i)
|
|
496
532
|
}
|
|
497
|
-
}),
|
|
533
|
+
}), on.recordCommittedEntries(e, [l, u], "LOCAL_COMMAND", A()), Wi(e, u);
|
|
498
534
|
}, [
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
]),
|
|
535
|
+
K,
|
|
536
|
+
H,
|
|
537
|
+
Wi,
|
|
538
|
+
I
|
|
539
|
+
]), Yi = un(), Xi = Yi?.request ?? null, Zi = N(() => void 0), [Qi, $i] = Kn(null);
|
|
504
540
|
M(() => {
|
|
505
|
-
if (
|
|
506
|
-
let e = window.setTimeout(() =>
|
|
541
|
+
if (Qi === null) return;
|
|
542
|
+
let e = window.setTimeout(() => $i(null), Qn);
|
|
507
543
|
return () => window.clearTimeout(e);
|
|
508
|
-
}, [
|
|
509
|
-
let
|
|
510
|
-
let e =
|
|
511
|
-
return
|
|
512
|
-
}, [
|
|
513
|
-
if (!
|
|
514
|
-
let t = e !== void 0, n =
|
|
544
|
+
}, [Qi]);
|
|
545
|
+
let ea = j(() => {
|
|
546
|
+
let e = x.getState();
|
|
547
|
+
return G(void 0, e.autoRouting && ui.current ? s : e.mode, e.autoRouting ? { routedBy: "auto" } : void 0);
|
|
548
|
+
}, [G]), ta = j((e) => {
|
|
549
|
+
if (!Xi) return !1;
|
|
550
|
+
let t = e !== void 0, n = x.getState(), r = dn({
|
|
515
551
|
spoken: t,
|
|
516
|
-
bound:
|
|
552
|
+
bound: bi.current,
|
|
517
553
|
activeConversationId: n.activeConversationId,
|
|
518
554
|
conversations: n.conversations,
|
|
519
|
-
historyOn:
|
|
555
|
+
historyOn: ln()
|
|
520
556
|
});
|
|
521
|
-
if (r &&
|
|
522
|
-
let e = r ? "Opened the delete confirmation. Choose Delete or Cancel on screen." : "There is no conversation to delete.", t = r ?
|
|
523
|
-
|
|
524
|
-
id: `conversation-delete:${
|
|
557
|
+
if (r && Xi(r), t) {
|
|
558
|
+
let e = r ? "Opened the delete confirmation. Choose Delete or Cancel on screen." : "There is no conversation to delete.", t = r ? I("deleteConversation.opened", "Opened the delete confirmation. Choose Delete or Cancel on screen.") : I("deleteConversation.nothing", "There is no conversation to delete.");
|
|
559
|
+
Zi.current({
|
|
560
|
+
id: `conversation-delete:${F()}`,
|
|
525
561
|
text: t,
|
|
526
|
-
lang: t === e ? "en" :
|
|
562
|
+
lang: t === e ? "en" : H
|
|
527
563
|
});
|
|
528
|
-
} else r ||
|
|
564
|
+
} else r || $i(Date.now());
|
|
529
565
|
return !0;
|
|
530
566
|
}, [
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
]),
|
|
535
|
-
if (e.kind === "conversation-delete") return
|
|
536
|
-
let { theme: i, navigate: a } =
|
|
567
|
+
Xi,
|
|
568
|
+
H,
|
|
569
|
+
I
|
|
570
|
+
]), na = j((e, t, n, r = !1) => {
|
|
571
|
+
if (e.kind === "conversation-delete") return ta(n);
|
|
572
|
+
let { theme: i, navigate: a } = qi.current, o, s;
|
|
537
573
|
if (e.kind === "theme") {
|
|
538
574
|
if (!i) return !1;
|
|
539
|
-
let t =
|
|
575
|
+
let t = Pn(e.request, {
|
|
540
576
|
mode: i.mode,
|
|
541
577
|
resolvedTheme: i.resolvedTheme
|
|
542
578
|
});
|
|
543
579
|
if (!t.alreadyApplied) try {
|
|
544
580
|
i.setMode(t.mode);
|
|
545
581
|
} catch {}
|
|
546
|
-
o =
|
|
582
|
+
o = Ln(I, t, e.request.kind === "family"), s = {
|
|
547
583
|
kind: "theme",
|
|
548
584
|
mode: t.mode,
|
|
549
585
|
alreadyApplied: t.alreadyApplied
|
|
@@ -551,79 +587,79 @@ var Jn = ({ visible: Jn = !0, writeAccess: Yn = "unknown" }) => {
|
|
|
551
587
|
} else {
|
|
552
588
|
if (!a) return !1;
|
|
553
589
|
if (e.kind === "navigate") {
|
|
554
|
-
let { destination: t } = e, n =
|
|
555
|
-
n || a(t.path), o =
|
|
590
|
+
let { destination: t } = e, n = jn(t, window.location.pathname + window.location.search, Nn(qi.current.navItems));
|
|
591
|
+
n || a(t.path), o = In(I, t.label, n), s = {
|
|
556
592
|
kind: "navigate",
|
|
557
593
|
destinationId: t.id,
|
|
558
594
|
path: t.path,
|
|
559
595
|
alreadyHere: n
|
|
560
596
|
};
|
|
561
|
-
} else o =
|
|
597
|
+
} else o = Fn(I, e.candidates[0]?.label ?? e.query, e.candidates), s = {
|
|
562
598
|
kind: "choose-destination",
|
|
563
599
|
candidateIds: e.candidates.map((e) => e.id)
|
|
564
600
|
};
|
|
565
601
|
}
|
|
566
|
-
let c = (r ? null :
|
|
567
|
-
r &&
|
|
568
|
-
let l = (/* @__PURE__ */ new Date()).toISOString(), u =
|
|
569
|
-
|
|
602
|
+
let c = (r ? null : x.getState().activeConversationId) ?? ea();
|
|
603
|
+
r && Ci(c);
|
|
604
|
+
let l = (/* @__PURE__ */ new Date()).toISOString(), u = F();
|
|
605
|
+
K(c, {
|
|
570
606
|
id: u,
|
|
571
607
|
role: "user",
|
|
572
608
|
content: t,
|
|
573
609
|
timestamp: l,
|
|
574
610
|
metadata: {
|
|
575
611
|
localAction: s,
|
|
576
|
-
...
|
|
612
|
+
...D(n)
|
|
577
613
|
}
|
|
578
614
|
});
|
|
579
|
-
let d =
|
|
580
|
-
return
|
|
615
|
+
let d = F();
|
|
616
|
+
return K(c, {
|
|
581
617
|
id: d,
|
|
582
618
|
role: "assistant",
|
|
583
619
|
content: o.text,
|
|
584
620
|
timestamp: l,
|
|
585
621
|
metadata: {
|
|
586
|
-
lang: o.translated ?
|
|
622
|
+
lang: o.translated ? H : "en",
|
|
587
623
|
localAction: s,
|
|
588
|
-
...
|
|
624
|
+
...D(n)
|
|
589
625
|
}
|
|
590
|
-
}),
|
|
626
|
+
}), on.recordCommittedEntries(c, [u, d], "LOCAL_COMMAND", A()), Wi(c, d), !0;
|
|
591
627
|
}, [
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
]),
|
|
600
|
-
|
|
628
|
+
K,
|
|
629
|
+
Ci,
|
|
630
|
+
ea,
|
|
631
|
+
H,
|
|
632
|
+
ta,
|
|
633
|
+
Wi,
|
|
634
|
+
I
|
|
635
|
+
]), ra = j(async (e) => {
|
|
636
|
+
fi.current = !0;
|
|
601
637
|
try {
|
|
602
|
-
await
|
|
638
|
+
await J.declineForReply(e.conversationId, e.reason, e.origin);
|
|
603
639
|
} finally {
|
|
604
|
-
|
|
640
|
+
fi.current = !1;
|
|
605
641
|
}
|
|
606
642
|
if (e.commandText !== null) {
|
|
607
|
-
let t =
|
|
608
|
-
if (t &&
|
|
643
|
+
let t = Mn(e.commandText, Nn(qi.current.navItems), qi.current.options);
|
|
644
|
+
if (t && na(t, e.content, e.options.voiceSessionId)) return;
|
|
609
645
|
}
|
|
610
|
-
await
|
|
611
|
-
}, [
|
|
612
|
-
let r = n.voiceSessionId !== void 0, i =
|
|
613
|
-
if (r &&
|
|
614
|
-
let e =
|
|
646
|
+
await oa.current(e.content, e.attachments, e.options);
|
|
647
|
+
}, [na, J]), Z = j(async (e, t = [], n = {}) => {
|
|
648
|
+
let r = n.voiceSessionId !== void 0, i = x.getState(), a = !1, o = bi.current;
|
|
649
|
+
if (r && ze(o)) {
|
|
650
|
+
let e = We(o, i.activeConversationId, wi());
|
|
615
651
|
if (e.kind === "gone") return;
|
|
616
652
|
let t = n.voiceEntry ?? e;
|
|
617
|
-
t.kind === "adopt" &&
|
|
653
|
+
t.kind === "adopt" && Ci(t.conversationId), a = t.kind === "own", n = {
|
|
618
654
|
...n,
|
|
619
655
|
voiceEntry: t
|
|
620
656
|
};
|
|
621
657
|
}
|
|
622
|
-
let s = a ? null : i.activeConversationId, c = a ? null : i.activeConversationId ??
|
|
658
|
+
let s = a ? null : i.activeConversationId, c = a ? null : i.activeConversationId ?? U;
|
|
623
659
|
if (c) {
|
|
624
|
-
if (
|
|
660
|
+
if (ut(i.processingByConversationId[c]?.status)) {
|
|
625
661
|
let r = i.processingByConversationId[c]?.messageId ?? null;
|
|
626
|
-
r &&
|
|
662
|
+
r && zi.current.has(r) && (Bi.current = {
|
|
627
663
|
conversationId: c,
|
|
628
664
|
content: e,
|
|
629
665
|
attachments: t,
|
|
@@ -631,29 +667,29 @@ var Jn = ({ visible: Jn = !0, writeAccess: Yn = "unknown" }) => {
|
|
|
631
667
|
});
|
|
632
668
|
return;
|
|
633
669
|
}
|
|
634
|
-
if (
|
|
670
|
+
if (Ei.current.has(c)) return;
|
|
635
671
|
}
|
|
636
|
-
if (
|
|
637
|
-
let d = n.targetConversationId, ee = p(), m = (e) =>
|
|
672
|
+
if (di.current || g() !== null || fi.current) return;
|
|
673
|
+
let d = n.targetConversationId, ee = p(), m = (e) => nn(e) || tn(e, ee);
|
|
638
674
|
if (d !== void 0) {
|
|
639
675
|
let e = i.conversations.find((e) => e.id === d);
|
|
640
676
|
if (i.activeConversationId !== d || !e || e.mode !== i.mode || m(e)) return;
|
|
641
677
|
}
|
|
642
678
|
if (n.fromPerson && n.writeReplyBound === void 0) {
|
|
643
|
-
let r = d ?? s ?? null, i = n.voiceSessionId === void 0 ? "typed" : "spoken", a =
|
|
679
|
+
let r = d ?? s ?? null, i = n.voiceSessionId === void 0 ? "typed" : "spoken", a = Ut({
|
|
644
680
|
text: e,
|
|
645
|
-
locale: i === "spoken" ?
|
|
681
|
+
locale: i === "spoken" ? ur.input.code : H,
|
|
646
682
|
origin: i,
|
|
647
683
|
hasAttachments: t.length > 0,
|
|
648
|
-
live:
|
|
649
|
-
matchesLocalCommand: (e) =>
|
|
684
|
+
live: J.liveFor(r),
|
|
685
|
+
matchesLocalCommand: (e) => Mn(e, Nn(qi.current.navItems), qi.current.options) !== null
|
|
650
686
|
});
|
|
651
687
|
if (a.kind === "local_reply") {
|
|
652
|
-
r &&
|
|
688
|
+
r && Ji(r, e, a.line, a.values, n.voiceSessionId);
|
|
653
689
|
return;
|
|
654
690
|
}
|
|
655
691
|
let o = a.kind === "local" ? a.fallback : a.bound, c = a.declineAll;
|
|
656
|
-
if (c !== null && r) return
|
|
692
|
+
if (c !== null && r) return ra({
|
|
657
693
|
conversationId: r,
|
|
658
694
|
reason: c,
|
|
659
695
|
origin: i,
|
|
@@ -670,347 +706,361 @@ var Jn = ({ visible: Jn = !0, writeAccess: Yn = "unknown" }) => {
|
|
|
670
706
|
writeReplyBound: o
|
|
671
707
|
};
|
|
672
708
|
}
|
|
673
|
-
let
|
|
709
|
+
let h = n.writeReplyBound?.promptText ?? e;
|
|
674
710
|
if (n.fromPerson && t.length === 0 && n.writeReplyBound?.localCommands !== !1) {
|
|
675
|
-
let t =
|
|
676
|
-
if (t &&
|
|
711
|
+
let t = Mn(e, Nn(qi.current.navItems), qi.current.options);
|
|
712
|
+
if (t && na(t, e, n.voiceSessionId, a)) return;
|
|
677
713
|
}
|
|
678
|
-
let
|
|
714
|
+
let ne = s ? i.conversations.find((e) => e.id === s) : void 0, _ = m(ne) ? void 0 : ne, v = i.autoRouting && ui.current && d === void 0 ? f({
|
|
679
715
|
intent: n.autoIntent ?? l(e),
|
|
680
716
|
dictated: r,
|
|
681
|
-
voiceProposalBound: r &&
|
|
682
|
-
conversation:
|
|
683
|
-
mode:
|
|
684
|
-
routedBy:
|
|
685
|
-
hasHistory:
|
|
717
|
+
voiceProposalBound: r && or("api-calls") && re(i.acknowledgedWriteModes, "api-calls"),
|
|
718
|
+
conversation: _ ? {
|
|
719
|
+
mode: _.mode,
|
|
720
|
+
routedBy: _.routedBy,
|
|
721
|
+
hasHistory: en(_)
|
|
686
722
|
} : null
|
|
687
723
|
}) : null;
|
|
688
|
-
if (
|
|
689
|
-
|
|
724
|
+
if (v && ni.current.find((e) => e.id === v.mode)?.writeCapable && !re(i.acknowledgedWriteModes, v.mode)) {
|
|
725
|
+
di.current = {
|
|
690
726
|
content: e,
|
|
691
727
|
attachments: t,
|
|
692
728
|
options: n
|
|
693
|
-
},
|
|
729
|
+
}, hi(v.mode);
|
|
694
730
|
return;
|
|
695
731
|
}
|
|
696
|
-
let
|
|
697
|
-
mode:
|
|
698
|
-
backendSessionId:
|
|
732
|
+
let y = v ? v.mode : i.mode, b, oe, S = d ?? (a ? null : U), C = S ? x.getState().conversations.find((e) => e.id === S) : void 0, ce = v?.action === "escalate" && _ ? {
|
|
733
|
+
mode: _.mode,
|
|
734
|
+
backendSessionId: _.backendSessionId ?? null
|
|
699
735
|
} : null;
|
|
700
|
-
if (
|
|
736
|
+
if (v) v.action === "new" || !_ ? S = G(void 0, y, { routedBy: "auto" }) : (S = _.id, Mr(S, y));
|
|
701
737
|
else {
|
|
702
738
|
let e = i.autoRouting ? { routedBy: "auto" } : void 0;
|
|
703
|
-
!
|
|
739
|
+
!S || m(C) || C && C.mode !== y && en(C) ? S = G(void 0, y, e) : C && C.mode !== y && (e ? Mr(S, y) : _r(S, y));
|
|
704
740
|
}
|
|
705
|
-
if (!
|
|
706
|
-
r &&
|
|
707
|
-
let
|
|
708
|
-
accessToken:
|
|
709
|
-
workspaceToken:
|
|
710
|
-
userId:
|
|
711
|
-
organizationId:
|
|
712
|
-
},
|
|
713
|
-
|
|
714
|
-
accessToken:
|
|
715
|
-
workspaceToken:
|
|
716
|
-
userId:
|
|
717
|
-
organizationId:
|
|
741
|
+
if (!S) return;
|
|
742
|
+
r && bi.current !== void 0 && S !== i.activeConversationId && Ci(S), n.approvalFollowUp || (Ti.current[S] = t);
|
|
743
|
+
let de = () => x.getState().conversations.some((e) => e.id === S), w = A(), T = {
|
|
744
|
+
accessToken: B(),
|
|
745
|
+
workspaceToken: sr(),
|
|
746
|
+
userId: V,
|
|
747
|
+
organizationId: At()
|
|
748
|
+
}, he = (e, t) => {
|
|
749
|
+
de() || !w || ae(e, w, t, y, {
|
|
750
|
+
accessToken: B(),
|
|
751
|
+
workspaceToken: sr(),
|
|
752
|
+
userId: V,
|
|
753
|
+
organizationId: At()
|
|
718
754
|
});
|
|
719
|
-
},
|
|
720
|
-
id:
|
|
755
|
+
}, ge = {
|
|
756
|
+
id: F(),
|
|
721
757
|
role: "user",
|
|
722
758
|
content: e,
|
|
723
759
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
724
760
|
metadata: {
|
|
725
|
-
...t.length ? { attachments: t.map(
|
|
761
|
+
...t.length ? { attachments: t.map(Qe) } : {},
|
|
726
762
|
...n.approvalFollowUp ? {
|
|
727
763
|
approvalFollowUp: !0,
|
|
728
764
|
approvedReplyId: n.approvalFollowUp.approvedReplyId
|
|
729
765
|
} : {},
|
|
730
|
-
...
|
|
766
|
+
...D(n.voiceSessionId)
|
|
731
767
|
}
|
|
732
768
|
};
|
|
733
|
-
|
|
734
|
-
let
|
|
735
|
-
|
|
736
|
-
id:
|
|
769
|
+
K(S, ge);
|
|
770
|
+
let E = F();
|
|
771
|
+
K(S, {
|
|
772
|
+
id: E,
|
|
737
773
|
role: "assistant",
|
|
738
774
|
content: "",
|
|
739
775
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
740
776
|
metadata: {
|
|
741
|
-
lang:
|
|
742
|
-
...
|
|
777
|
+
lang: pr,
|
|
778
|
+
...D(n.voiceSessionId)
|
|
743
779
|
}
|
|
744
|
-
}),
|
|
780
|
+
}), wt(E, {
|
|
745
781
|
channel: r ? "voice" : "chat",
|
|
746
|
-
mode:
|
|
747
|
-
product:
|
|
748
|
-
language:
|
|
749
|
-
device:
|
|
750
|
-
routedByAuto: !!
|
|
751
|
-
}, n.voiceTiming), k(
|
|
752
|
-
let
|
|
753
|
-
turnId:
|
|
754
|
-
abortRequested:
|
|
755
|
-
activeTurnId:
|
|
756
|
-
conversationExists:
|
|
757
|
-
}),
|
|
758
|
-
|
|
782
|
+
mode: y,
|
|
783
|
+
product: L,
|
|
784
|
+
language: pr,
|
|
785
|
+
device: Tt(),
|
|
786
|
+
routedByAuto: !!v
|
|
787
|
+
}, n.voiceTiming), k(E, "accepted"), Sr(S, "provisioning", E, null), te(E);
|
|
788
|
+
let Oe = () => dt({
|
|
789
|
+
turnId: E,
|
|
790
|
+
abortRequested: zi.current.has(E),
|
|
791
|
+
activeTurnId: x.getState().processingByConversationId[S]?.messageId ?? null,
|
|
792
|
+
conversationExists: de()
|
|
793
|
+
}), ke = (e, t, r, i, a = !1, o = pr) => {
|
|
794
|
+
br(S, E, { content: _e(e) }), xr(S, E, {
|
|
759
795
|
lang: o,
|
|
760
796
|
...t?.length ? { artifacts: t } : {},
|
|
761
|
-
...t?.length || r || i ? { mode:
|
|
797
|
+
...t?.length || r || i ? { mode: y } : {},
|
|
762
798
|
...r ? { sessionId: r } : {},
|
|
763
799
|
...i ? { sandboxId: i } : {},
|
|
764
800
|
...a ? { incomplete: !0 } : {},
|
|
765
|
-
...
|
|
801
|
+
...D(n.voiceSessionId)
|
|
766
802
|
});
|
|
767
|
-
}, je = { session: null }, Me =
|
|
768
|
-
|
|
803
|
+
}, je = { session: null }, Me = !1, Ne = () => {
|
|
804
|
+
Me && (Me = !1, Ae.abort(E));
|
|
805
|
+
}, Fe = async (i = 1) => {
|
|
806
|
+
k(E, "attemptStarted");
|
|
769
807
|
let a = null, o = null, s = !1;
|
|
770
808
|
try {
|
|
771
|
-
let { sandboxId: i, sessionId: c, sessionIsNew: l, readAhead: u, sandboxIsNew: d, sandboxProbed: f, sandboxAdopted: p, deadSandboxProbe: ee } = await
|
|
772
|
-
turnId:
|
|
773
|
-
abortRequested:
|
|
774
|
-
activeTurnId:
|
|
775
|
-
conversationExists:
|
|
809
|
+
let { sandboxId: i, sessionId: c, sessionIsNew: l, readAhead: u, sandboxIsNew: d, sandboxProbed: f, sandboxAdopted: p, deadSandboxProbe: ee, sessionPreopened: m } = await Ni(S, E, y, w, T, { isAbandoned: () => dt({
|
|
810
|
+
turnId: E,
|
|
811
|
+
abortRequested: zi.current.has(E),
|
|
812
|
+
activeTurnId: x.getState().processingByConversationId[S]?.messageId ?? null,
|
|
813
|
+
conversationExists: de()
|
|
776
814
|
}).abandon });
|
|
777
|
-
if (a = i, k(
|
|
778
|
-
runtime: d ? "cold" : p ? "adopted" : f ? "probed" : l ? "new-session" : "warm",
|
|
815
|
+
if (a = i, k(E, "runtimeReady"), O(E, {
|
|
816
|
+
runtime: d ? "cold" : p ? "adopted" : f ? "probed" : m ? "preopened" : l ? "new-session" : "warm",
|
|
779
817
|
deadSandboxProbe: ee
|
|
780
818
|
}), o = c, je.session = {
|
|
781
819
|
sandboxId: i,
|
|
782
820
|
sessionId: c
|
|
783
|
-
},
|
|
821
|
+
}, ie(y, b, x.getState().acknowledgedWriteModes, {
|
|
784
822
|
dictated: r,
|
|
785
|
-
confirmsWrites:
|
|
786
|
-
proposalBound:
|
|
787
|
-
}) === "voice-in-write-mode") throw new
|
|
788
|
-
let
|
|
789
|
-
conversation:
|
|
823
|
+
confirmsWrites: fe(y),
|
|
824
|
+
proposalBound: or(y, i)
|
|
825
|
+
}) === "voice-in-write-mode") throw new ve("voice-in-write-mode", "Voice in a write mode");
|
|
826
|
+
let g = fn({
|
|
827
|
+
conversation: x.getState().conversations.find((e) => e.id === S),
|
|
790
828
|
content: e,
|
|
791
829
|
sessionIsNew: l,
|
|
792
|
-
sendingMode:
|
|
793
|
-
sendingModeConfig:
|
|
794
|
-
modes:
|
|
795
|
-
answerText: (e) =>
|
|
796
|
-
}),
|
|
797
|
-
|
|
798
|
-
let ne =
|
|
799
|
-
conversationId:
|
|
800
|
-
writeReply:
|
|
801
|
-
}, { prompt:
|
|
802
|
-
content:
|
|
830
|
+
sendingMode: y,
|
|
831
|
+
sendingModeConfig: b,
|
|
832
|
+
modes: ni.current,
|
|
833
|
+
answerText: (e) => bt(e).text
|
|
834
|
+
}), te = await _t(() => ue(i, w, c, y, T, { limit: 50 }), l, gt(u, i, c));
|
|
835
|
+
ji(S, E, "streaming", "thinking");
|
|
836
|
+
let ne = tr?.(), _ = Wt(x.getState().sandboxWriteCapabilities[i]), v = {
|
|
837
|
+
conversationId: S,
|
|
838
|
+
writeReply: _ === "proposal-v1" ? n.writeReplyBound?.writeReply ?? null : null
|
|
839
|
+
}, { prompt: re, parts: ae } = lt({
|
|
840
|
+
content: g ? `${g}${h}` : h,
|
|
803
841
|
attachments: t,
|
|
804
|
-
limits:
|
|
805
|
-
wrapPrompt: (e) =>
|
|
806
|
-
requestBytes: (e, t) =>
|
|
842
|
+
limits: Ze(b),
|
|
843
|
+
wrapPrompt: (e) => nr?.(y, e, dr, fr, r, { writeApproval: _ }) ?? e,
|
|
844
|
+
requestBytes: (e, t) => pe({
|
|
807
845
|
sandboxId: i,
|
|
808
|
-
workspaceId:
|
|
846
|
+
workspaceId: w,
|
|
809
847
|
sessionId: c,
|
|
810
|
-
mode:
|
|
848
|
+
mode: y,
|
|
811
849
|
prompt: e,
|
|
812
850
|
parts: t,
|
|
813
851
|
pageContext: ne,
|
|
814
|
-
authContext:
|
|
815
|
-
...
|
|
852
|
+
authContext: T,
|
|
853
|
+
...v
|
|
816
854
|
})
|
|
817
|
-
}),
|
|
818
|
-
s =
|
|
819
|
-
let
|
|
820
|
-
if (
|
|
821
|
-
|
|
855
|
+
}), C = Je(ae), ce = C > 0;
|
|
856
|
+
s = qe(t) > C;
|
|
857
|
+
let ye = Oe();
|
|
858
|
+
if (ye.abandon) {
|
|
859
|
+
ye.clearProcessing && Cr(S);
|
|
822
860
|
return;
|
|
823
861
|
}
|
|
824
862
|
try {
|
|
825
|
-
await
|
|
826
|
-
parts:
|
|
827
|
-
...
|
|
828
|
-
} :
|
|
863
|
+
await me(i, w, c, re, y, ne, T, ae?.length ? {
|
|
864
|
+
parts: ae,
|
|
865
|
+
...v
|
|
866
|
+
} : v);
|
|
829
867
|
} catch (e) {
|
|
830
|
-
if (!
|
|
831
|
-
await
|
|
868
|
+
if (!ae || !jt(e)) throw e;
|
|
869
|
+
await me(i, w, c, re, y, ne, T, v), s ||= ce;
|
|
832
870
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
871
|
+
let be = (e) => br(S, E, { content: e }), xe = (e) => s ? `${e}\n\n${I("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._")}` : e;
|
|
872
|
+
k(E, "promptSent");
|
|
873
|
+
let Ce = null, Te = !1, Ee = mt, D = ht([], te), Ne = Date.now() + oe.streamBudgetMs, Fe = Date.now(), Ie = Date.now();
|
|
874
|
+
for (; Date.now() < Ne;) {
|
|
875
|
+
he(i, c);
|
|
876
|
+
let e = Oe();
|
|
838
877
|
if (e.abandon) {
|
|
839
|
-
e.clearProcessing &&
|
|
878
|
+
e.clearProcessing && Cr(S);
|
|
840
879
|
return;
|
|
841
880
|
}
|
|
842
|
-
if (
|
|
881
|
+
if (D = ht(await ue(i, w, c, y, T, {
|
|
843
882
|
limit: 50,
|
|
844
|
-
sinceMs:
|
|
883
|
+
sinceMs: te,
|
|
845
884
|
surfaceTurnTerminal: !0
|
|
846
|
-
}),
|
|
885
|
+
}), te, { accumulateNarration: oe.accumulatesNarration }), br(S, E, { content: _e(D.content) }), D.hasRenderableOutput ? Te || (Te = !0, Ce !== null && k(E, "lastQuietPoll", Ce), k(E, "firstOutput")) : Ce = Dt(), oe.accumulatesNarration) D.hasText && k(E, "firstText");
|
|
847
886
|
else {
|
|
848
|
-
let e =
|
|
849
|
-
|
|
887
|
+
let e = yt(Ee, D, Dt());
|
|
888
|
+
Ee = e.tracker, e.confirmedAt !== null && k(E, "firstText", e.confirmedAt);
|
|
850
889
|
}
|
|
851
|
-
if (
|
|
852
|
-
k(
|
|
890
|
+
if (D.pendingWrite && !Ht(x.getState().sandboxWriteCapabilities[i]) && xr(S, E, { pendingWrite: D.pendingWrite }), D.done) {
|
|
891
|
+
k(E, "answerDone"), Y.current.markVerified(i);
|
|
853
892
|
break;
|
|
854
893
|
}
|
|
855
|
-
Date.now() -
|
|
894
|
+
Date.now() - Fe > 3e4 && (await se(i, w, 600, T).catch(() => void 0), Fe = Date.now()), await new Promise((e) => setTimeout(e, Pe(Date.now() - Ie)));
|
|
856
895
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
896
|
+
if (D.done && n.voiceSessionId !== void 0 && !Oe().abandon) {
|
|
897
|
+
let e = _e(xe(D.content));
|
|
898
|
+
e.trim() && (s && be(e), k(E, "speechQueued"), Me = !0, Ae.publish(E, {
|
|
899
|
+
conversationId: S,
|
|
900
|
+
channel: "voice",
|
|
901
|
+
voiceSessionId: n.voiceSessionId,
|
|
902
|
+
text: e,
|
|
903
|
+
lang: pr,
|
|
904
|
+
final: !0
|
|
905
|
+
}));
|
|
906
|
+
}
|
|
907
|
+
let Le = oe.producesArtifacts ? await le(i, w, c, y, T).then((e) => e).catch(() => []) : void 0;
|
|
908
|
+
D.usedTools !== void 0 && O(E, { usedTools: D.usedTools }), D.done || (O(E, { outcome: "timedOut" }), D = {
|
|
909
|
+
...D,
|
|
910
|
+
content: De(D.content, y, I, b)
|
|
911
|
+
}), s && (D = {
|
|
912
|
+
...D,
|
|
913
|
+
content: xe(D.content)
|
|
864
914
|
});
|
|
865
|
-
let
|
|
866
|
-
|
|
867
|
-
workspaceId:
|
|
915
|
+
let Re = !D.done;
|
|
916
|
+
ke(D.content, Le, c, i, Re), D.tokens && (br(S, E, { tokens: D.tokens }), (ir ? await we({
|
|
917
|
+
workspaceId: w,
|
|
868
918
|
sessionId: c,
|
|
869
|
-
messageId:
|
|
870
|
-
model:
|
|
871
|
-
tokens:
|
|
872
|
-
},
|
|
873
|
-
let
|
|
874
|
-
if (
|
|
875
|
-
|
|
919
|
+
messageId: D.messageId,
|
|
920
|
+
model: D.model,
|
|
921
|
+
tokens: D.tokens
|
|
922
|
+
}, ir, { ledger: Se("panel", L) }) : { ok: !0 }).ok && zn(L)), D.done || he(i, c);
|
|
923
|
+
let ze = Oe();
|
|
924
|
+
if (ze.abandon) {
|
|
925
|
+
ze.clearProcessing && Cr(S);
|
|
876
926
|
return;
|
|
877
927
|
}
|
|
878
|
-
k(
|
|
928
|
+
k(E, "complete"), O(E, { outcome: "answered" }), Sr(S, "complete", E, null), on.recordCommittedEntries(S, [ge.id, E], "TURN", w), Me = !1;
|
|
879
929
|
} catch (e) {
|
|
880
|
-
|
|
881
|
-
let t =
|
|
882
|
-
turnId:
|
|
883
|
-
abortRequested:
|
|
884
|
-
activeTurnId:
|
|
885
|
-
conversationExists:
|
|
930
|
+
Y.current.invalidate(a ?? x.getState().sandboxesByMode[y]?.sandboxId ?? null);
|
|
931
|
+
let t = dt({
|
|
932
|
+
turnId: E,
|
|
933
|
+
abortRequested: zi.current.has(E),
|
|
934
|
+
activeTurnId: x.getState().processingByConversationId[S]?.messageId ?? null,
|
|
935
|
+
conversationExists: de()
|
|
886
936
|
});
|
|
887
|
-
if (a && o &&
|
|
888
|
-
t.clearProcessing &&
|
|
937
|
+
if (a && o && he(a, o), t.abandon) {
|
|
938
|
+
t.clearProcessing && Cr(S);
|
|
889
939
|
return;
|
|
890
940
|
}
|
|
891
|
-
if (i === 1 &&
|
|
892
|
-
let e = a ??
|
|
893
|
-
return e && (
|
|
941
|
+
if (i === 1 && Mt(e)) {
|
|
942
|
+
let e = a ?? x.getState().sandboxesByMode[y]?.sandboxId ?? null;
|
|
943
|
+
return e && (X.current.add(e), Y.current.invalidate(e)), Tr(S), Dr(y), yr(S, E, ""), xr(S, E, { pendingWrite: void 0 }), e && J.retireSandbox(e), Ne(), Et(E), Fe(2);
|
|
894
944
|
}
|
|
895
945
|
throw e;
|
|
896
946
|
}
|
|
897
|
-
},
|
|
898
|
-
|
|
947
|
+
}, Ie = S;
|
|
948
|
+
Ei.current.add(Ie);
|
|
899
949
|
try {
|
|
900
|
-
if (!
|
|
950
|
+
if (!w) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
|
|
901
951
|
code: "UNAUTHENTICATED",
|
|
902
952
|
authFailure: "WORKSPACE_CONTEXT_MISSING"
|
|
903
953
|
} });
|
|
904
|
-
let e = await
|
|
905
|
-
|
|
906
|
-
let t =
|
|
954
|
+
let e = await ct(y, () => ni.current.find((e) => e.id === y), ti);
|
|
955
|
+
b = e.config, oe = e.capabilities;
|
|
956
|
+
let t = b, n = Oe();
|
|
907
957
|
if (n.abandon) {
|
|
908
|
-
n.clearProcessing &&
|
|
958
|
+
n.clearProcessing && Cr(S);
|
|
909
959
|
return;
|
|
910
960
|
}
|
|
911
|
-
let i =
|
|
961
|
+
let i = ie(y, t, x.getState().acknowledgedWriteModes, {
|
|
912
962
|
dictated: r,
|
|
913
|
-
confirmsWrites:
|
|
914
|
-
proposalBound:
|
|
963
|
+
confirmsWrites: fe(y),
|
|
964
|
+
proposalBound: or(y)
|
|
915
965
|
});
|
|
916
|
-
if (i) throw new
|
|
917
|
-
let a =
|
|
918
|
-
if (
|
|
919
|
-
let e = await
|
|
920
|
-
if (!e.ok) throw
|
|
921
|
-
let t =
|
|
966
|
+
if (i) throw new ve(i, i === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
|
|
967
|
+
let a = Se("panel", L);
|
|
968
|
+
if (ir && Ce(a, w)) {
|
|
969
|
+
let e = await Te(a, w, ir);
|
|
970
|
+
if (!e.ok) throw Ee(e.kind);
|
|
971
|
+
let t = Oe();
|
|
922
972
|
if (t.abandon) {
|
|
923
|
-
t.clearProcessing &&
|
|
973
|
+
t.clearProcessing && Cr(S);
|
|
924
974
|
return;
|
|
925
975
|
}
|
|
926
976
|
}
|
|
927
|
-
k(
|
|
977
|
+
k(E, "cleared"), await Fe();
|
|
928
978
|
} catch (e) {
|
|
929
|
-
if (
|
|
930
|
-
|
|
979
|
+
if (Y.current.invalidate(x.getState().sandboxesByMode[y]?.sandboxId ?? null), !de()) {
|
|
980
|
+
Cr(S);
|
|
931
981
|
return;
|
|
932
982
|
}
|
|
933
|
-
let t = je.session?.sandboxId ?? null, r =
|
|
934
|
-
mode:
|
|
935
|
-
capabilities: t ?
|
|
983
|
+
let t = je.session?.sandboxId ?? null, r = ye(e, { confirmsNoAction: be({
|
|
984
|
+
mode: y,
|
|
985
|
+
capabilities: t ? x.getState().sandboxWriteCapabilities[t] : null
|
|
936
986
|
}) });
|
|
937
|
-
O(
|
|
938
|
-
let i =
|
|
939
|
-
|
|
940
|
-
lang: i.translated ?
|
|
941
|
-
...
|
|
987
|
+
O(E, { outcome: r.kind === "temporary" ? "failed" : "refused" }), r.offersUpgrade && Rn(L, "sandbox");
|
|
988
|
+
let i = xe(r, I, { locale: H });
|
|
989
|
+
Sr(S, "error", E, i.headline), br(S, E, { content: i.text }), xr(S, E, {
|
|
990
|
+
lang: i.translated ? H : "en",
|
|
991
|
+
...D(n.voiceSessionId)
|
|
942
992
|
});
|
|
943
993
|
} finally {
|
|
944
|
-
|
|
945
|
-
let e =
|
|
946
|
-
t && (
|
|
994
|
+
Ei.current.delete(Ie), O(E, { outcome: "stopped" }), k(E, "complete"), Ne();
|
|
995
|
+
let e = x.getState(), t = u(ce, y, e.conversations.find((e) => e.id === Ie), (t) => !!e.sandboxesByMode[t]?.sandboxId);
|
|
996
|
+
t && (Mr(Ie, t.mode), t.backendSessionId && wr(Ie, t.backendSessionId)), je.session && de() && J.afterTurn({
|
|
947
997
|
...je.session,
|
|
948
|
-
conversationId:
|
|
949
|
-
},
|
|
950
|
-
let n =
|
|
951
|
-
|
|
998
|
+
conversationId: Ie
|
|
999
|
+
}, E);
|
|
1000
|
+
let n = Bi.current;
|
|
1001
|
+
Bi.current = null, n && n.conversationId === Ie && de() && oa.current(n.content, n.attachments, n.options);
|
|
952
1002
|
}
|
|
953
1003
|
}, [
|
|
954
|
-
|
|
1004
|
+
U,
|
|
1005
|
+
K,
|
|
1006
|
+
nr,
|
|
1007
|
+
Tr,
|
|
1008
|
+
Dr,
|
|
1009
|
+
mr,
|
|
955
1010
|
G,
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
Ui,
|
|
964
|
-
Qi,
|
|
965
|
-
V,
|
|
966
|
-
ar,
|
|
1011
|
+
Ni,
|
|
1012
|
+
J,
|
|
1013
|
+
Ji,
|
|
1014
|
+
ra,
|
|
1015
|
+
H,
|
|
1016
|
+
ur,
|
|
1017
|
+
or,
|
|
967
1018
|
tr,
|
|
968
|
-
|
|
969
|
-
z,
|
|
970
|
-
nr,
|
|
971
|
-
hr,
|
|
972
|
-
I,
|
|
973
|
-
Xr,
|
|
974
|
-
$n,
|
|
1019
|
+
B,
|
|
975
1020
|
sr,
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
Zi,
|
|
981
|
-
vi,
|
|
982
|
-
yi,
|
|
983
|
-
yr,
|
|
1021
|
+
br,
|
|
1022
|
+
L,
|
|
1023
|
+
ti,
|
|
1024
|
+
ir,
|
|
984
1025
|
fr,
|
|
1026
|
+
H,
|
|
1027
|
+
pr,
|
|
1028
|
+
dr,
|
|
1029
|
+
Mr,
|
|
1030
|
+
na,
|
|
1031
|
+
Ci,
|
|
1032
|
+
wi,
|
|
1033
|
+
wr,
|
|
985
1034
|
_r,
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1035
|
+
Sr,
|
|
1036
|
+
Cr,
|
|
1037
|
+
I,
|
|
1038
|
+
ji,
|
|
1039
|
+
yr,
|
|
1040
|
+
V
|
|
1041
|
+
]), ia = j((e, t) => {
|
|
1042
|
+
Z(e, [], t ? { autoIntent: t } : {});
|
|
1043
|
+
}, [Z]), aa = j(() => {
|
|
1044
|
+
let e = [...Pr.chat].reverse().find((e) => e.role === "user" && !e.metadata?.localAction);
|
|
995
1045
|
if (!e || e.metadata?.approvalFollowUp) return;
|
|
996
|
-
let t =
|
|
997
|
-
|
|
1046
|
+
let t = U ? Ti.current[U] ?? [] : [];
|
|
1047
|
+
Z(e.content, t);
|
|
998
1048
|
}, [
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
]),
|
|
1049
|
+
Fr,
|
|
1050
|
+
Z,
|
|
1051
|
+
U
|
|
1052
|
+
]), oa = N(Z);
|
|
1003
1053
|
M(() => {
|
|
1004
|
-
|
|
1005
|
-
}, [
|
|
1006
|
-
let
|
|
1007
|
-
if (
|
|
1008
|
-
for (let e =
|
|
1009
|
-
let t =
|
|
1010
|
-
if (t?.role !== "assistant" || !
|
|
1011
|
-
let n =
|
|
1054
|
+
oa.current = Z;
|
|
1055
|
+
}, [Z]);
|
|
1056
|
+
let sa = Gn(() => {
|
|
1057
|
+
if (Ir) return null;
|
|
1058
|
+
for (let e = Fr.length - 1; e >= 0; --e) {
|
|
1059
|
+
let t = Fr[e];
|
|
1060
|
+
if (t?.role !== "assistant" || !Oe(t) || zi.current.has(t.id)) continue;
|
|
1061
|
+
let n = pt(t, q, I);
|
|
1012
1062
|
if (n.kind !== "output") return null;
|
|
1013
|
-
let r =
|
|
1063
|
+
let r = bt(n.text).text.trim();
|
|
1014
1064
|
return r ? {
|
|
1015
1065
|
id: t.id,
|
|
1016
1066
|
text: r
|
|
@@ -1018,70 +1068,70 @@ var Jn = ({ visible: Jn = !0, writeAccess: Yn = "unknown" }) => {
|
|
|
1018
1068
|
}
|
|
1019
1069
|
return null;
|
|
1020
1070
|
}, [
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
]),
|
|
1026
|
-
sessionId:
|
|
1027
|
-
sandboxId:
|
|
1071
|
+
Fr,
|
|
1072
|
+
Ir,
|
|
1073
|
+
q,
|
|
1074
|
+
I
|
|
1075
|
+
]), ca = Gn(() => sa ? Fe(sa.text) : null, [sa]), la = Pr.chat, ua = x((e) => b(e)?.sandboxId ?? null), da = _(la, {
|
|
1076
|
+
sessionId: Nr?.backendSessionId,
|
|
1077
|
+
sandboxId: ua,
|
|
1028
1078
|
nowMs: Date.now()
|
|
1029
|
-
}),
|
|
1030
|
-
if (
|
|
1079
|
+
}), fa = v(la), pa = (e) => {
|
|
1080
|
+
if (Vt(e.metadata).length > 0) return !0;
|
|
1031
1081
|
let t = e.metadata?.sandboxId;
|
|
1032
|
-
return
|
|
1033
|
-
},
|
|
1034
|
-
let t =
|
|
1035
|
-
return t.length === 0 || !
|
|
1082
|
+
return Ht(t ? zr[t] : null);
|
|
1083
|
+
}, ma = (e) => {
|
|
1084
|
+
let t = Vt(e.metadata);
|
|
1085
|
+
return t.length === 0 || !U ? null : /* @__PURE__ */ P(Bt, {
|
|
1036
1086
|
refs: t,
|
|
1037
|
-
conversationId:
|
|
1038
|
-
panel:
|
|
1039
|
-
entries:
|
|
1040
|
-
capabilitiesOf: (e) =>
|
|
1041
|
-
turnInFlight:
|
|
1042
|
-
tr:
|
|
1043
|
-
onReview:
|
|
1044
|
-
retiredSandboxes:
|
|
1087
|
+
conversationId: U,
|
|
1088
|
+
panel: J,
|
|
1089
|
+
entries: Br,
|
|
1090
|
+
capabilitiesOf: (e) => zr[e],
|
|
1091
|
+
turnInFlight: Ir,
|
|
1092
|
+
tr: I,
|
|
1093
|
+
onReview: Hr.review,
|
|
1094
|
+
retiredSandboxes: Vr
|
|
1045
1095
|
});
|
|
1046
|
-
},
|
|
1096
|
+
}, ha = Hr.dialog.view ? Br[Hr.dialog.view.proposalId] : void 0, ga = da?.expiresAtMs ?? null;
|
|
1047
1097
|
M(() => {
|
|
1048
|
-
if (
|
|
1049
|
-
let e = window.setTimeout(() =>
|
|
1098
|
+
if (ga === null) return;
|
|
1099
|
+
let e = window.setTimeout(() => Ri((e) => e + 1), Math.max(0, ga - Date.now()));
|
|
1050
1100
|
return () => window.clearTimeout(e);
|
|
1051
|
-
}, [
|
|
1052
|
-
let Q =
|
|
1101
|
+
}, [ga, Li]);
|
|
1102
|
+
let Q = Gn(() => Pr.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
1053
1103
|
id: e.id,
|
|
1054
1104
|
role: e.role,
|
|
1055
|
-
text:
|
|
1056
|
-
sessionId:
|
|
1105
|
+
text: Ct(e, q, I),
|
|
1106
|
+
sessionId: ke(e),
|
|
1057
1107
|
timestamp: e.timestamp
|
|
1058
1108
|
})).filter((e) => e.text.length > 0), [
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
]),
|
|
1109
|
+
Pr.voice,
|
|
1110
|
+
q,
|
|
1111
|
+
I
|
|
1112
|
+
]), _a = j(() => {
|
|
1063
1113
|
if (Q.length === 0) return;
|
|
1064
1114
|
let e = /* @__PURE__ */ new Date();
|
|
1065
|
-
|
|
1066
|
-
title:
|
|
1067
|
-
savedAt:
|
|
1068
|
-
session:
|
|
1069
|
-
earlier:
|
|
1070
|
-
you:
|
|
1071
|
-
assistant:
|
|
1072
|
-
}, e),
|
|
1115
|
+
$t(Me(Q, {
|
|
1116
|
+
title: I("voiceSession.transcript", "Voice conversation"),
|
|
1117
|
+
savedAt: I("voiceSession.savedAt", "Saved"),
|
|
1118
|
+
session: I("voiceSession.sessionLabel", "Session"),
|
|
1119
|
+
earlier: I("voiceSession.earlierLabel", "Earlier"),
|
|
1120
|
+
you: I("voiceSession.speakerYou", "You"),
|
|
1121
|
+
assistant: I("voiceSession.speakerAssistant", "Assistant")
|
|
1122
|
+
}, e), Ne(L, e), "text/markdown");
|
|
1073
1123
|
}, [
|
|
1074
|
-
|
|
1124
|
+
L,
|
|
1075
1125
|
Q,
|
|
1076
|
-
|
|
1077
|
-
]),
|
|
1078
|
-
|
|
1079
|
-
let
|
|
1126
|
+
I
|
|
1127
|
+
]), va = Bn({ perFileChars: pi }), ya = N(va);
|
|
1128
|
+
ya.current = va;
|
|
1129
|
+
let ba = N(/* @__PURE__ */ new Set()), xa = N(() => !1), $ = kt({
|
|
1080
1130
|
onSubmit: j((e, t, n) => {
|
|
1081
|
-
let r =
|
|
1082
|
-
let a =
|
|
1083
|
-
if (!
|
|
1084
|
-
sessionLive:
|
|
1131
|
+
let r = bi.current, i = Ke(r), a = () => {
|
|
1132
|
+
let a = ya.current, o = x.getState();
|
|
1133
|
+
if (!Be({
|
|
1134
|
+
sessionLive: xa.current(t),
|
|
1085
1135
|
boundAtSubmit: r,
|
|
1086
1136
|
activeConversationId: o.activeConversationId,
|
|
1087
1137
|
boundConversationExists: o.conversations.some((e) => e.id === i)
|
|
@@ -1089,436 +1139,436 @@ var Jn = ({ visible: Jn = !0, writeAccess: Yn = "unknown" }) => {
|
|
|
1089
1139
|
a.clear();
|
|
1090
1140
|
return;
|
|
1091
1141
|
}
|
|
1092
|
-
let s =
|
|
1142
|
+
let s = Ye(a.attachments), c = {
|
|
1093
1143
|
...n,
|
|
1094
|
-
handedOver:
|
|
1144
|
+
handedOver: Dt()
|
|
1095
1145
|
};
|
|
1096
|
-
|
|
1146
|
+
oa.current(e, s, {
|
|
1097
1147
|
fromPerson: !0,
|
|
1098
1148
|
voiceSessionId: t,
|
|
1099
1149
|
voiceTiming: c
|
|
1100
1150
|
}), a.clear();
|
|
1101
1151
|
};
|
|
1102
|
-
if (!
|
|
1152
|
+
if (!ya.current.isBusy) {
|
|
1103
1153
|
a();
|
|
1104
1154
|
return;
|
|
1105
1155
|
}
|
|
1106
|
-
let o = Date.now(), s =
|
|
1107
|
-
|
|
1156
|
+
let o = Date.now(), s = ba.current, c = window.setInterval(() => {
|
|
1157
|
+
ya.current.isBusy && Date.now() - o < Xn || (window.clearInterval(c), s.delete(c), a());
|
|
1108
1158
|
}, 200);
|
|
1109
1159
|
s.add(c);
|
|
1110
1160
|
}, []),
|
|
1111
|
-
latestReply:
|
|
1112
|
-
language:
|
|
1161
|
+
latestReply: sa,
|
|
1162
|
+
language: Ie(cr, H).tag
|
|
1113
1163
|
});
|
|
1114
|
-
|
|
1115
|
-
let
|
|
1164
|
+
xa.current = $.isCurrentSession;
|
|
1165
|
+
let Sa = xi ? Q.filter((e) => e.sessionId !== void 0 && $.isCurrentSession(e.sessionId)) : Q, Ca = $.answerLocally;
|
|
1116
1166
|
M(() => {
|
|
1117
|
-
|
|
1118
|
-
}, [
|
|
1119
|
-
let
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
]), [
|
|
1167
|
+
Zi.current = Ca;
|
|
1168
|
+
}, [Ca]);
|
|
1169
|
+
let wa = $.active, Ta = Gn(() => it(Object.values(Br), U, Vr), [
|
|
1170
|
+
Br,
|
|
1171
|
+
U,
|
|
1172
|
+
Vr
|
|
1173
|
+
]), [Ea, Da] = Kn(null);
|
|
1124
1174
|
M(() => {
|
|
1125
|
-
|
|
1126
|
-
}, [
|
|
1127
|
-
let
|
|
1128
|
-
let e =
|
|
1175
|
+
wa || Da(null);
|
|
1176
|
+
}, [wa]);
|
|
1177
|
+
let Oa = Hr.review, ka = j(() => {
|
|
1178
|
+
let e = Ta[Ta.length - 1];
|
|
1129
1179
|
if (!e) return;
|
|
1130
1180
|
let { view: t } = e;
|
|
1131
|
-
if (
|
|
1132
|
-
|
|
1181
|
+
if (Lt(t) && It(t, zr[e.session.sandboxId]).offerConfirm) {
|
|
1182
|
+
Oa(t);
|
|
1133
1183
|
return;
|
|
1134
1184
|
}
|
|
1135
|
-
|
|
1185
|
+
Da(t.proposalId);
|
|
1136
1186
|
}, [
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
]),
|
|
1141
|
-
content: /* @__PURE__ */ P(
|
|
1187
|
+
Ta,
|
|
1188
|
+
zr,
|
|
1189
|
+
Oa
|
|
1190
|
+
]), Aa = wa ? tt(Ta) : null, ja = Ea ? Br[Ea] : void 0, Ma = wa && ja && ja.session.conversationId === U ? {
|
|
1191
|
+
content: /* @__PURE__ */ P(Bt, {
|
|
1142
1192
|
refs: [{
|
|
1143
|
-
proposalId:
|
|
1144
|
-
sandboxId:
|
|
1145
|
-
sessionId:
|
|
1193
|
+
proposalId: ja.view.proposalId,
|
|
1194
|
+
sandboxId: ja.session.sandboxId,
|
|
1195
|
+
sessionId: ja.session.sessionId
|
|
1146
1196
|
}],
|
|
1147
|
-
conversationId:
|
|
1148
|
-
panel:
|
|
1149
|
-
entries:
|
|
1150
|
-
capabilitiesOf: (e) =>
|
|
1151
|
-
turnInFlight:
|
|
1152
|
-
tr:
|
|
1153
|
-
onReview:
|
|
1154
|
-
retiredSandboxes:
|
|
1197
|
+
conversationId: ja.session.conversationId,
|
|
1198
|
+
panel: J,
|
|
1199
|
+
entries: Br,
|
|
1200
|
+
capabilitiesOf: (e) => zr[e],
|
|
1201
|
+
turnInFlight: Ir,
|
|
1202
|
+
tr: I,
|
|
1203
|
+
onReview: Oa,
|
|
1204
|
+
retiredSandboxes: Vr
|
|
1155
1205
|
}),
|
|
1156
|
-
closeLabel:
|
|
1157
|
-
onClose: () =>
|
|
1158
|
-
} : null,
|
|
1206
|
+
closeLabel: at(I, $e.trayClose),
|
|
1207
|
+
onClose: () => Da(null)
|
|
1208
|
+
} : null, Na = Hr.asking, Pa = Yi?.asking === !0, Fa = $.holdListening;
|
|
1159
1209
|
M(() => {
|
|
1160
|
-
|
|
1210
|
+
Fa(wa && (Na || Pa));
|
|
1161
1211
|
}, [
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1212
|
+
wa,
|
|
1213
|
+
Na,
|
|
1214
|
+
Pa,
|
|
1215
|
+
Fa
|
|
1166
1216
|
]);
|
|
1167
|
-
let
|
|
1217
|
+
let Ia = N(null), La = $.announce;
|
|
1168
1218
|
M(() => {
|
|
1169
|
-
if (!
|
|
1170
|
-
|
|
1219
|
+
if (!wa) {
|
|
1220
|
+
Ia.current = null;
|
|
1171
1221
|
return;
|
|
1172
1222
|
}
|
|
1173
|
-
let e =
|
|
1223
|
+
let e = Ia.current;
|
|
1174
1224
|
if (e === null) {
|
|
1175
|
-
|
|
1225
|
+
Ia.current = new Set(Object.keys(Br));
|
|
1176
1226
|
return;
|
|
1177
1227
|
}
|
|
1178
|
-
for (let { view: t, session: n } of
|
|
1228
|
+
for (let { view: t, session: n } of rt(Ta, e)) {
|
|
1179
1229
|
e.add(t.proposalId);
|
|
1180
|
-
let r =
|
|
1181
|
-
if (
|
|
1230
|
+
let r = zr[n.sandboxId];
|
|
1231
|
+
if (!et({
|
|
1182
1232
|
mode: "api-calls",
|
|
1183
|
-
productWriteApproval:
|
|
1233
|
+
productWriteApproval: z,
|
|
1184
1234
|
capabilities: r
|
|
1185
1235
|
})) continue;
|
|
1186
|
-
let i =
|
|
1187
|
-
|
|
1236
|
+
let i = ot(t, It(t, r).offerConfirm, I), a = t.proposalId;
|
|
1237
|
+
La({
|
|
1188
1238
|
id: `write-readback:${a}`,
|
|
1189
1239
|
text: i.text,
|
|
1190
|
-
lang: i.translated ?
|
|
1191
|
-
stillWanted: () =>
|
|
1240
|
+
lang: i.translated ? H : "en",
|
|
1241
|
+
stillWanted: () => J.entry(a)?.view.status === "pending"
|
|
1192
1242
|
});
|
|
1193
1243
|
}
|
|
1194
1244
|
}, [
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1245
|
+
wa,
|
|
1246
|
+
Ta,
|
|
1247
|
+
Br,
|
|
1248
|
+
zr,
|
|
1249
|
+
z,
|
|
1250
|
+
I,
|
|
1251
|
+
H,
|
|
1252
|
+
La,
|
|
1253
|
+
J
|
|
1204
1254
|
]);
|
|
1205
|
-
let
|
|
1255
|
+
let Ra = N(!1);
|
|
1206
1256
|
M(() => {
|
|
1207
|
-
|
|
1257
|
+
Ra.current = $.active;
|
|
1208
1258
|
}, [$.active]), M(() => ee((e) => {
|
|
1209
|
-
if (!
|
|
1210
|
-
let t =
|
|
1211
|
-
return typeof t == "string" ? t === e :
|
|
1259
|
+
if (!Ra.current) return !1;
|
|
1260
|
+
let t = bi.current;
|
|
1261
|
+
return typeof t == "string" ? t === e : x.getState().activeConversationId === e;
|
|
1212
1262
|
}), []);
|
|
1213
|
-
let
|
|
1214
|
-
let e =
|
|
1215
|
-
|
|
1263
|
+
let za = $.start, Ba = j(() => {
|
|
1264
|
+
let e = x.getState().activeConversationId, t = Ue(wi());
|
|
1265
|
+
Ci(Ge(t, e)), Pi(!0, t.kind === "own"), za();
|
|
1216
1266
|
}, [
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
]),
|
|
1222
|
-
let e =
|
|
1267
|
+
Ci,
|
|
1268
|
+
Pi,
|
|
1269
|
+
wi,
|
|
1270
|
+
za
|
|
1271
|
+
]), Va = Gn(() => St(Nr?.messages ?? []), [Nr?.messages]), Ha = xt(Pr.voice, q, I), Ua = xt(Va, q, I) > 0, Wa = j(() => {
|
|
1272
|
+
let e = x.getState().activeConversationId;
|
|
1223
1273
|
if (!e || Q.length === 0) return;
|
|
1224
|
-
let t = new Set(
|
|
1225
|
-
|
|
1274
|
+
let t = new Set(Va.map((e) => e.id)), n = F();
|
|
1275
|
+
K(e, {
|
|
1226
1276
|
id: n,
|
|
1227
1277
|
role: "system",
|
|
1228
1278
|
content: je(Q.filter((e) => t.has(e.id)), {
|
|
1229
|
-
intro:
|
|
1230
|
-
nothing:
|
|
1231
|
-
more: (e) =>
|
|
1279
|
+
intro: I("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
|
|
1280
|
+
nothing: I("voiceSession.continuedNothing", "Continued from a voice conversation."),
|
|
1281
|
+
more: (e) => I("voiceSession.continuedMore", "…and {{count}} more", { count: e })
|
|
1232
1282
|
}),
|
|
1233
1283
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1234
|
-
metadata: { continuedVoiceTurns:
|
|
1235
|
-
}),
|
|
1284
|
+
metadata: { continuedVoiceTurns: Ha }
|
|
1285
|
+
}), on.recordCommittedEntries(e, [n], "NOTE", A()), yi(!1), $.end();
|
|
1236
1286
|
}, [
|
|
1237
1287
|
Q,
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1288
|
+
Ha,
|
|
1289
|
+
Va,
|
|
1290
|
+
K,
|
|
1291
|
+
I,
|
|
1242
1292
|
$,
|
|
1243
|
-
|
|
1244
|
-
]),
|
|
1293
|
+
yi
|
|
1294
|
+
]), Ga = N({
|
|
1245
1295
|
conversationId: null,
|
|
1246
1296
|
count: 0
|
|
1247
1297
|
});
|
|
1248
1298
|
M(() => {
|
|
1249
|
-
$.active && (
|
|
1250
|
-
conversationId:
|
|
1251
|
-
count:
|
|
1299
|
+
$.active && (Ga.current = {
|
|
1300
|
+
conversationId: U,
|
|
1301
|
+
count: Ha
|
|
1252
1302
|
});
|
|
1253
1303
|
}, [$.active]);
|
|
1254
|
-
let
|
|
1255
|
-
let e =
|
|
1256
|
-
$.end(), t &&
|
|
1304
|
+
let Ka = j(() => {
|
|
1305
|
+
let e = Ga.current, t = Ha > (e.conversationId === U ? e.count : 0);
|
|
1306
|
+
$.end(), t && yi(!0);
|
|
1257
1307
|
}, [
|
|
1258
|
-
|
|
1259
|
-
|
|
1308
|
+
U,
|
|
1309
|
+
Ha,
|
|
1260
1310
|
$,
|
|
1261
|
-
|
|
1311
|
+
yi
|
|
1262
1312
|
]);
|
|
1263
1313
|
M(() => {
|
|
1264
|
-
(
|
|
1314
|
+
(!$n || !Ai) && $.active && $.end();
|
|
1265
1315
|
}, [
|
|
1266
|
-
|
|
1267
|
-
|
|
1316
|
+
$n,
|
|
1317
|
+
Ai,
|
|
1268
1318
|
$
|
|
1269
1319
|
]), M(() => {
|
|
1270
|
-
let e =
|
|
1320
|
+
let e = bi.current, t = Ke(e), n = x.getState(), r = He({
|
|
1271
1321
|
sessionLive: $.active,
|
|
1272
1322
|
bound: e,
|
|
1273
1323
|
activeConversationId: n.activeConversationId,
|
|
1274
1324
|
boundConversationExists: n.conversations.some((e) => e.id === t)
|
|
1275
1325
|
});
|
|
1276
|
-
|
|
1326
|
+
Ci(r.bound), r.end && $.end();
|
|
1277
1327
|
}, [
|
|
1278
1328
|
$,
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1329
|
+
U,
|
|
1330
|
+
mr,
|
|
1331
|
+
Ci
|
|
1282
1332
|
]);
|
|
1283
|
-
let
|
|
1333
|
+
let qa = N(Re);
|
|
1284
1334
|
M(() => {
|
|
1285
|
-
let e =
|
|
1286
|
-
activeConversationId:
|
|
1287
|
-
chatTurnCount:
|
|
1335
|
+
let e = Ve(qa.current, {
|
|
1336
|
+
activeConversationId: U,
|
|
1337
|
+
chatTurnCount: la.length,
|
|
1288
1338
|
voiceTurnCount: Q.length,
|
|
1289
1339
|
sessionLive: $.active,
|
|
1290
|
-
sessionBoundTo:
|
|
1291
|
-
turnInFlight:
|
|
1340
|
+
sessionBoundTo: bi.current,
|
|
1341
|
+
turnInFlight: Ir
|
|
1292
1342
|
});
|
|
1293
|
-
|
|
1343
|
+
qa.current = e.state, e.open && yi(!0);
|
|
1294
1344
|
}, [
|
|
1295
|
-
|
|
1296
|
-
|
|
1345
|
+
U,
|
|
1346
|
+
la.length,
|
|
1297
1347
|
Q.length,
|
|
1298
1348
|
$.active,
|
|
1299
|
-
|
|
1300
|
-
|
|
1349
|
+
Ir,
|
|
1350
|
+
yi
|
|
1301
1351
|
]), M(() => {
|
|
1302
1352
|
if (!$.active) {
|
|
1303
|
-
|
|
1304
|
-
for (let e of
|
|
1305
|
-
|
|
1353
|
+
ya.current.clear(), Bi.current = null;
|
|
1354
|
+
for (let e of ba.current) window.clearInterval(e);
|
|
1355
|
+
ba.current.clear();
|
|
1306
1356
|
}
|
|
1307
1357
|
}, [$.active]), M(() => {
|
|
1308
|
-
let e =
|
|
1358
|
+
let e = ba.current;
|
|
1309
1359
|
return () => {
|
|
1310
1360
|
for (let t of e) window.clearInterval(t);
|
|
1311
1361
|
e.clear();
|
|
1312
1362
|
};
|
|
1313
1363
|
}, []), M(() => {
|
|
1314
|
-
let e =
|
|
1315
|
-
return e &&
|
|
1364
|
+
let e = x.getState().consumePendingPrompt();
|
|
1365
|
+
return e && oa.current(e), x.subscribe((e, t) => {
|
|
1316
1366
|
if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
|
|
1317
|
-
let e =
|
|
1318
|
-
e &&
|
|
1367
|
+
let e = x.getState().consumePendingPrompt();
|
|
1368
|
+
e && oa.current(e);
|
|
1319
1369
|
}
|
|
1320
1370
|
});
|
|
1321
1371
|
}, []);
|
|
1322
|
-
let
|
|
1323
|
-
let t =
|
|
1324
|
-
if (t && t.mode !== e &&
|
|
1372
|
+
let Ja = j((e) => {
|
|
1373
|
+
let t = U ? x.getState().conversations.find((e) => e.id === U) : void 0;
|
|
1374
|
+
if (t && t.mode !== e && J.withdraw(t.id, "mode_switched"), t && en(t)) {
|
|
1325
1375
|
if (t.mode !== e) {
|
|
1326
|
-
let t = p(), n =
|
|
1327
|
-
n ?
|
|
1376
|
+
let t = p(), n = x.getState().conversations.find((n) => n.mode === e && rn(n, t) && !x.getState().processingByConversationId[n.id]);
|
|
1377
|
+
n ? vr(n.id) : G(void 0, e);
|
|
1328
1378
|
}
|
|
1329
|
-
} else
|
|
1330
|
-
let n =
|
|
1331
|
-
n ?
|
|
1379
|
+
} else U && _r(U, e);
|
|
1380
|
+
let n = x.getState().activeConversationId;
|
|
1381
|
+
n ? _r(n, e) : jr(!1), gr(e);
|
|
1332
1382
|
}, [
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
]),
|
|
1341
|
-
let e =
|
|
1383
|
+
U,
|
|
1384
|
+
G,
|
|
1385
|
+
vr,
|
|
1386
|
+
jr,
|
|
1387
|
+
_r,
|
|
1388
|
+
gr,
|
|
1389
|
+
J
|
|
1390
|
+
]), Ya = j(() => {
|
|
1391
|
+
let e = x.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
|
|
1342
1392
|
if (!t) {
|
|
1343
|
-
|
|
1393
|
+
jr(!0), gr(s);
|
|
1344
1394
|
return;
|
|
1345
1395
|
}
|
|
1346
1396
|
if (t.routedBy === "auto") {
|
|
1347
|
-
|
|
1397
|
+
jr(!0);
|
|
1348
1398
|
return;
|
|
1349
1399
|
}
|
|
1350
|
-
if (
|
|
1351
|
-
|
|
1400
|
+
if (!en(t)) {
|
|
1401
|
+
Mr(t.id, s);
|
|
1352
1402
|
return;
|
|
1353
1403
|
}
|
|
1354
|
-
|
|
1355
|
-
let n = p(), r = e.conversations.find((t) => t.routedBy === "auto" &&
|
|
1356
|
-
r ? (
|
|
1404
|
+
J.withdraw(t.id, "mode_switched");
|
|
1405
|
+
let n = p(), r = e.conversations.find((t) => t.routedBy === "auto" && rn(t, n) && !e.processingByConversationId[t.id]);
|
|
1406
|
+
r ? (vr(r.id), Mr(r.id, s)) : G(void 0, s, { routedBy: "auto" });
|
|
1357
1407
|
}, [
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
]),
|
|
1365
|
-
if (
|
|
1366
|
-
|
|
1408
|
+
G,
|
|
1409
|
+
Mr,
|
|
1410
|
+
vr,
|
|
1411
|
+
jr,
|
|
1412
|
+
gr,
|
|
1413
|
+
J
|
|
1414
|
+
]), Xa = j((e) => {
|
|
1415
|
+
if (R.find((t) => t.id === e)?.writeCapable && !re(x.getState().acknowledgedWriteModes, e)) {
|
|
1416
|
+
hi(e);
|
|
1367
1417
|
return;
|
|
1368
1418
|
}
|
|
1369
|
-
|
|
1370
|
-
}, [
|
|
1371
|
-
let e =
|
|
1372
|
-
if (
|
|
1373
|
-
let t =
|
|
1374
|
-
if (
|
|
1375
|
-
|
|
1419
|
+
Ja(e);
|
|
1420
|
+
}, [Ja, R]), Za = j(() => {
|
|
1421
|
+
let e = mi;
|
|
1422
|
+
if (hi(null), !e) return;
|
|
1423
|
+
let t = di.current;
|
|
1424
|
+
if (di.current = null, t) {
|
|
1425
|
+
kr(e), Z(t.content, t.attachments, t.options);
|
|
1376
1426
|
return;
|
|
1377
1427
|
}
|
|
1378
|
-
|
|
1428
|
+
kr(e), Ja(e);
|
|
1379
1429
|
}, [
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
]),
|
|
1385
|
-
|
|
1386
|
-
let e =
|
|
1387
|
-
|
|
1430
|
+
mi,
|
|
1431
|
+
kr,
|
|
1432
|
+
Ja,
|
|
1433
|
+
Z
|
|
1434
|
+
]), Qa = mi === null ? void 0 : R.find((e) => e.id === mi) ?? { id: mi }, $a = j(() => {
|
|
1435
|
+
hi(null);
|
|
1436
|
+
let e = di.current;
|
|
1437
|
+
di.current = null, e && Z(e.content, e.attachments, {
|
|
1388
1438
|
...e.options,
|
|
1389
1439
|
autoIntent: "read"
|
|
1390
1440
|
});
|
|
1391
|
-
}, [
|
|
1392
|
-
return /* @__PURE__ */
|
|
1441
|
+
}, [Z]);
|
|
1442
|
+
return /* @__PURE__ */ Jn("div", {
|
|
1393
1443
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
1394
1444
|
children: [
|
|
1395
|
-
/* @__PURE__ */
|
|
1445
|
+
/* @__PURE__ */ Jn("div", {
|
|
1396
1446
|
className: "contents",
|
|
1397
1447
|
inert: $.active || void 0,
|
|
1398
1448
|
children: [
|
|
1399
|
-
|
|
1400
|
-
Q.length > 0 && !$.active ? /* @__PURE__ */ P(
|
|
1449
|
+
Qr === null ? null : /* @__PURE__ */ P(Jt, { onDismiss: () => Zr(Qr) }),
|
|
1450
|
+
Q.length > 0 && !$.active ? /* @__PURE__ */ P(Kt, {
|
|
1401
1451
|
count: Q.length,
|
|
1402
|
-
onOpenTranscript: () =>
|
|
1452
|
+
onOpenTranscript: () => yi(!0)
|
|
1403
1453
|
}) : null,
|
|
1404
|
-
|
|
1405
|
-
state:
|
|
1406
|
-
onRetry:
|
|
1407
|
-
}) :
|
|
1454
|
+
la.length === 0 && (qr || Jr) ? /* @__PURE__ */ P(Yt, {
|
|
1455
|
+
state: qr ? "loading" : "failed",
|
|
1456
|
+
onRetry: ri
|
|
1457
|
+
}) : la.length === 0 && Nr?.sync?.hasOlder ? /* @__PURE__ */ P("div", {
|
|
1408
1458
|
className: "flex min-h-0 flex-1 flex-col",
|
|
1409
|
-
children: /* @__PURE__ */ P(
|
|
1410
|
-
onShowEarlier:
|
|
1411
|
-
disabled:
|
|
1459
|
+
children: /* @__PURE__ */ P(Zt, {
|
|
1460
|
+
onShowEarlier: ii,
|
|
1461
|
+
disabled: qr
|
|
1412
1462
|
})
|
|
1413
|
-
}) :
|
|
1414
|
-
mode:
|
|
1415
|
-
onSuggestionClick:
|
|
1416
|
-
explainsAuto:
|
|
1417
|
-
suggestions:
|
|
1418
|
-
}) : /* @__PURE__ */
|
|
1463
|
+
}) : la.length === 0 ? /* @__PURE__ */ P(sn, {
|
|
1464
|
+
mode: W,
|
|
1465
|
+
onSuggestionClick: ia,
|
|
1466
|
+
explainsAuto: li,
|
|
1467
|
+
suggestions: li && W === "assistant" ? c(R.find((e) => e.id === "assistant")?.suggestions ?? [], R.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
|
|
1468
|
+
}) : /* @__PURE__ */ Jn("div", {
|
|
1419
1469
|
className: "flex min-h-0 flex-1 flex-col",
|
|
1420
|
-
children: [
|
|
1421
|
-
onShowEarlier:
|
|
1422
|
-
disabled:
|
|
1423
|
-
}) : null, /* @__PURE__ */ P(
|
|
1424
|
-
onApprovePendingWrite:
|
|
1425
|
-
approvingWriteRef:
|
|
1426
|
-
approvableMessageId:
|
|
1427
|
-
retryableMessageId:
|
|
1428
|
-
messages:
|
|
1429
|
-
processing:
|
|
1430
|
-
streamingMessageId:
|
|
1431
|
-
failedMessageId:
|
|
1432
|
-
onRetry:
|
|
1433
|
-
renderWriteProposals:
|
|
1434
|
-
hidesLegacyWriteCard:
|
|
1470
|
+
children: [Nr?.sync?.hasOlder ? /* @__PURE__ */ P(Zt, {
|
|
1471
|
+
onShowEarlier: ii,
|
|
1472
|
+
disabled: qr
|
|
1473
|
+
}) : null, /* @__PURE__ */ P(mn, {
|
|
1474
|
+
onApprovePendingWrite: Hi,
|
|
1475
|
+
approvingWriteRef: Ii,
|
|
1476
|
+
approvableMessageId: da?.messageId ?? null,
|
|
1477
|
+
retryableMessageId: fa,
|
|
1478
|
+
messages: la,
|
|
1479
|
+
processing: q ?? null,
|
|
1480
|
+
streamingMessageId: Lr,
|
|
1481
|
+
failedMessageId: Rr,
|
|
1482
|
+
onRetry: Ii === null ? aa : void 0,
|
|
1483
|
+
renderWriteProposals: ma,
|
|
1484
|
+
hidesLegacyWriteCard: pa
|
|
1435
1485
|
})]
|
|
1436
1486
|
}),
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
tr:
|
|
1441
|
-
onDismiss: () =>
|
|
1487
|
+
Gr ? /* @__PURE__ */ P(Xt, { onStartNew: () => G() }) : null,
|
|
1488
|
+
Kr && U ? /* @__PURE__ */ P(qt, { onUnarchive: () => on.updateConversation(U, { archived: !1 }) }) : null,
|
|
1489
|
+
Qi === null ? null : /* @__PURE__ */ P(cn, {
|
|
1490
|
+
tr: I,
|
|
1491
|
+
onDismiss: () => $i(null)
|
|
1442
1492
|
}),
|
|
1443
|
-
|
|
1444
|
-
state:
|
|
1445
|
-
onRetry:
|
|
1493
|
+
la.length > 0 && (qr || Jr) ? /* @__PURE__ */ P(Yt, {
|
|
1494
|
+
state: qr ? "loading" : "failed",
|
|
1495
|
+
onRetry: ri,
|
|
1446
1496
|
compact: !0
|
|
1447
1497
|
}) : null,
|
|
1448
|
-
/* @__PURE__ */ P(
|
|
1449
|
-
onStartVoiceSession: $.available &&
|
|
1450
|
-
onSend: (e, t) => void
|
|
1451
|
-
onDraftStart:
|
|
1452
|
-
disabled:
|
|
1453
|
-
readOnly:
|
|
1454
|
-
placeholder:
|
|
1455
|
-
mode:
|
|
1456
|
-
writeAccessDenied:
|
|
1457
|
-
availableModes:
|
|
1458
|
-
attachmentCharsPerFile:
|
|
1459
|
-
onModeChange:
|
|
1460
|
-
auto:
|
|
1461
|
-
active:
|
|
1462
|
-
onSelect:
|
|
1498
|
+
/* @__PURE__ */ P(Vn, {
|
|
1499
|
+
onStartVoiceSession: $.available && Ai ? Ba : void 0,
|
|
1500
|
+
onSend: (e, t) => void Z(e, t, { fromPerson: !0 }),
|
|
1501
|
+
onDraftStart: Fi,
|
|
1502
|
+
disabled: Ir || Ii !== null || qr,
|
|
1503
|
+
readOnly: Gr,
|
|
1504
|
+
placeholder: W === "api-calls" ? I("chatArea.placeholderActions", "What would you like me to do?") : I("chatArea.placeholderGeneral", "Ask me anything…"),
|
|
1505
|
+
mode: W,
|
|
1506
|
+
writeAccessDenied: er === "denied" && !!Di?.writeCapable,
|
|
1507
|
+
availableModes: si,
|
|
1508
|
+
attachmentCharsPerFile: pi,
|
|
1509
|
+
onModeChange: Xa,
|
|
1510
|
+
auto: ci ? {
|
|
1511
|
+
active: li,
|
|
1512
|
+
onSelect: Ya
|
|
1463
1513
|
} : void 0
|
|
1464
1514
|
})
|
|
1465
1515
|
]
|
|
1466
1516
|
}),
|
|
1467
|
-
|
|
1517
|
+
vi && !$.active ? /* @__PURE__ */ P(Qt, {
|
|
1468
1518
|
turns: Q,
|
|
1469
|
-
onClose: () =>
|
|
1470
|
-
onSave:
|
|
1471
|
-
onContinueInChat:
|
|
1519
|
+
onClose: () => yi(!1),
|
|
1520
|
+
onSave: _a,
|
|
1521
|
+
onContinueInChat: Ua ? Wa : void 0,
|
|
1472
1522
|
closeOnEscape: !0,
|
|
1473
|
-
onShowEarlier:
|
|
1474
|
-
showEarlierDisabled:
|
|
1523
|
+
onShowEarlier: Nr?.sync?.hasOlder ? ii : void 0,
|
|
1524
|
+
showEarlierDisabled: qr
|
|
1475
1525
|
}) : null,
|
|
1476
|
-
$.active && /* @__PURE__ */ P(
|
|
1526
|
+
$.active && /* @__PURE__ */ P(hn, {
|
|
1477
1527
|
session: $.session,
|
|
1478
1528
|
notice: $.notice,
|
|
1479
1529
|
capturing: $.capturing,
|
|
1480
1530
|
interrupting: $.interrupting,
|
|
1481
1531
|
awaitingEndpoint: $.awaitingEndpoint,
|
|
1482
|
-
turns:
|
|
1532
|
+
turns: Sa,
|
|
1483
1533
|
spokenChunks: $.spokenChunks,
|
|
1484
|
-
attachments:
|
|
1485
|
-
onAttachFiles:
|
|
1486
|
-
onRemoveAttachment:
|
|
1487
|
-
onRetryAttachment:
|
|
1488
|
-
canAttachMore:
|
|
1489
|
-
preparingAttachments:
|
|
1490
|
-
onSaveTranscript:
|
|
1491
|
-
onContinueInChat:
|
|
1534
|
+
attachments: va.attachments,
|
|
1535
|
+
onAttachFiles: va.addFiles,
|
|
1536
|
+
onRemoveAttachment: va.remove,
|
|
1537
|
+
onRetryAttachment: va.retry,
|
|
1538
|
+
canAttachMore: va.canAddMore,
|
|
1539
|
+
preparingAttachments: va.preparingCount,
|
|
1540
|
+
onSaveTranscript: _a,
|
|
1541
|
+
onContinueInChat: Wa,
|
|
1492
1542
|
onInterrupt: () => {
|
|
1493
|
-
$.interrupt(),
|
|
1543
|
+
$.interrupt(), Vi();
|
|
1494
1544
|
},
|
|
1495
|
-
spoken:
|
|
1545
|
+
spoken: ca,
|
|
1496
1546
|
onToggleMute: $.toggleMute,
|
|
1497
|
-
onEnd:
|
|
1498
|
-
proposalChip:
|
|
1499
|
-
label:
|
|
1500
|
-
onOpen:
|
|
1547
|
+
onEnd: Ka,
|
|
1548
|
+
proposalChip: Aa ? {
|
|
1549
|
+
label: nt(Aa, I),
|
|
1550
|
+
onOpen: ka
|
|
1501
1551
|
} : null,
|
|
1502
|
-
proposalTray:
|
|
1552
|
+
proposalTray: Ma
|
|
1503
1553
|
}),
|
|
1504
|
-
/* @__PURE__ */ P(
|
|
1505
|
-
open:
|
|
1506
|
-
mode:
|
|
1507
|
-
currentMode:
|
|
1508
|
-
onConfirm:
|
|
1509
|
-
onCancel:
|
|
1554
|
+
/* @__PURE__ */ P(Un, {
|
|
1555
|
+
open: mi !== null,
|
|
1556
|
+
mode: Qa,
|
|
1557
|
+
currentMode: Di ?? { id: W },
|
|
1558
|
+
onConfirm: Za,
|
|
1559
|
+
onCancel: $a
|
|
1510
1560
|
}),
|
|
1511
|
-
/* @__PURE__ */ P(
|
|
1512
|
-
...
|
|
1513
|
-
view:
|
|
1514
|
-
serverNow:
|
|
1515
|
-
arrivedAt:
|
|
1516
|
-
capabilities:
|
|
1517
|
-
turnInFlight:
|
|
1518
|
-
tr:
|
|
1561
|
+
/* @__PURE__ */ P(Rt, {
|
|
1562
|
+
...Hr.dialog,
|
|
1563
|
+
view: ha?.view ?? Hr.dialog.view,
|
|
1564
|
+
serverNow: ha?.serverNow ?? NaN,
|
|
1565
|
+
arrivedAt: ha?.arrivedAt ?? NaN,
|
|
1566
|
+
capabilities: ha ? zr[ha.session.sandboxId] : null,
|
|
1567
|
+
turnInFlight: Ir,
|
|
1568
|
+
tr: I
|
|
1519
1569
|
})
|
|
1520
1570
|
]
|
|
1521
1571
|
});
|
|
1522
1572
|
};
|
|
1523
1573
|
//#endregion
|
|
1524
|
-
export {
|
|
1574
|
+
export { $n as AssistantChatArea };
|