@burdenoff/fe-libs 2026.1004.5 → 2026.1004.7

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