@burdenoff/fe-libs 2026.1001.3 → 2026.1001.5

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