@burdenoff/fe-libs 2026.1003.1 → 2026.1003.2

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