@burdenoff/fe-libs 2026.1003.1 → 2026.1003.3

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