@burdenoff/fe-libs 2026.1004.8 → 2026.1005.1

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