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