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