@burdenoff/fe-libs 2026.1001.2 → 2026.1001.4

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