@burdenoff/fe-libs 2026.1007.5 → 2026.1007.6

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