@burdenoff/fe-libs 2026.1004.5 → 2026.1004.6

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