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