@burdenoff/fe-libs 2026.926.5 → 2026.927.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/shared/assistant/conversation.d.ts +91 -3
  2. package/dist/shared/assistant/conversation.d.ts.map +1 -1
  3. package/dist/shared/assistant/gatewayClient.d.ts +15 -0
  4. package/dist/shared/assistant/gatewayClient.d.ts.map +1 -1
  5. package/dist/shared/assistant/gatewayClient.js +1 -1
  6. package/dist/shared/assistant/guardedStorage.d.ts +4 -2
  7. package/dist/shared/assistant/guardedStorage.d.ts.map +1 -1
  8. package/dist/shared/assistant/guardedStorage.js +1 -1
  9. package/dist/shared/assistant/history/historyApi.d.ts +38 -0
  10. package/dist/shared/assistant/history/historyApi.d.ts.map +1 -0
  11. package/dist/shared/assistant/history/historyApi.js +153 -0
  12. package/dist/shared/assistant/history/historyEngine.d.ts +96 -0
  13. package/dist/shared/assistant/history/historyEngine.d.ts.map +1 -0
  14. package/dist/shared/assistant/history/historyEngine.js +774 -0
  15. package/dist/shared/assistant/history/historyErrors.d.ts +72 -0
  16. package/dist/shared/assistant/history/historyErrors.d.ts.map +1 -0
  17. package/dist/shared/assistant/history/historyErrors.js +74 -0
  18. package/dist/shared/assistant/history/historyList.d.ts +115 -0
  19. package/dist/shared/assistant/history/historyList.d.ts.map +1 -0
  20. package/dist/shared/assistant/history/historyList.js +116 -0
  21. package/dist/shared/assistant/history/historyMapping.d.ts +65 -0
  22. package/dist/shared/assistant/history/historyMapping.d.ts.map +1 -0
  23. package/dist/shared/assistant/history/historyMapping.js +383 -0
  24. package/dist/shared/assistant/history/historyMerge.d.ts +65 -0
  25. package/dist/shared/assistant/history/historyMerge.d.ts.map +1 -0
  26. package/dist/shared/assistant/history/historyMerge.js +97 -0
  27. package/dist/shared/assistant/history/historyOperations.d.ts +24 -0
  28. package/dist/shared/assistant/history/historyOperations.d.ts.map +1 -0
  29. package/dist/shared/assistant/history/historyOperations.js +125 -0
  30. package/dist/shared/assistant/history/historyResume.d.ts +56 -0
  31. package/dist/shared/assistant/history/historyResume.d.ts.map +1 -0
  32. package/dist/shared/assistant/history/historyResume.js +55 -0
  33. package/dist/shared/assistant/history/historyStatus.d.ts +76 -0
  34. package/dist/shared/assistant/history/historyStatus.d.ts.map +1 -0
  35. package/dist/shared/assistant/history/historyStatus.js +47 -0
  36. package/dist/shared/assistant/history/historyStore.d.ts +192 -0
  37. package/dist/shared/assistant/history/historyStore.d.ts.map +1 -0
  38. package/dist/shared/assistant/history/historyStore.js +503 -0
  39. package/dist/shared/assistant/history/historyTimestamps.d.ts +11 -0
  40. package/dist/shared/assistant/history/historyTimestamps.d.ts.map +1 -0
  41. package/dist/shared/assistant/history/historyTimestamps.js +9 -0
  42. package/dist/shared/assistant/history/historyTypes.d.ts +256 -0
  43. package/dist/shared/assistant/history/historyTypes.d.ts.map +1 -0
  44. package/dist/shared/assistant/history/historyTypes.js +20 -0
  45. package/dist/shared/assistant/history/profileBoundStorage.d.ts +36 -0
  46. package/dist/shared/assistant/history/profileBoundStorage.d.ts.map +1 -0
  47. package/dist/shared/assistant/history/profileBoundStorage.js +74 -0
  48. package/dist/shared/assistant/history/stampRegistry.d.ts +84 -0
  49. package/dist/shared/assistant/history/stampRegistry.d.ts.map +1 -0
  50. package/dist/shared/assistant/history/stampRegistry.js +58 -0
  51. package/dist/shared/assistant/history/useAssistantServerHistory.d.ts +18 -0
  52. package/dist/shared/assistant/history/useAssistantServerHistory.d.ts.map +1 -0
  53. package/dist/shared/assistant/history/useAssistantServerHistory.js +12 -0
  54. package/dist/shared/assistant/i18nManifest.d.ts +18 -0
  55. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  56. package/dist/shared/assistant/i18nManifest.js +18 -0
  57. package/dist/shared/assistant/index.d.ts +16 -0
  58. package/dist/shared/assistant/index.d.ts.map +1 -1
  59. package/dist/shared/assistant/liveTurns.d.ts +7 -0
  60. package/dist/shared/assistant/liveTurns.d.ts.map +1 -1
  61. package/dist/shared/assistant/liveTurns.js +35 -32
  62. package/dist/shared/assistant/spokenTurns.d.ts +20 -0
  63. package/dist/shared/assistant/spokenTurns.d.ts.map +1 -1
  64. package/dist/shared/assistant/spokenTurns.js +13 -8
  65. package/dist/shared/assistant/store.d.ts +35 -1
  66. package/dist/shared/assistant/store.d.ts.map +1 -1
  67. package/dist/shared/assistant/store.js +93 -24
  68. package/dist/shared/assistant/ui/AIAssistantPanel.d.ts +16 -0
  69. package/dist/shared/assistant/ui/AIAssistantPanel.d.ts.map +1 -1
  70. package/dist/shared/assistant/ui/AIAssistantPanel.js +63 -60
  71. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  72. package/dist/shared/assistant/ui/AssistantChatArea.js +730 -672
  73. package/dist/shared/assistant/ui/AssistantConversationList.d.ts +17 -0
  74. package/dist/shared/assistant/ui/AssistantConversationList.d.ts.map +1 -1
  75. package/dist/shared/assistant/ui/AssistantConversationList.js +324 -145
  76. package/dist/shared/assistant/ui/AssistantHistoryNotices.d.ts +36 -0
  77. package/dist/shared/assistant/ui/AssistantHistoryNotices.d.ts.map +1 -0
  78. package/dist/shared/assistant/ui/AssistantHistoryNotices.js +103 -0
  79. package/dist/shared/assistant/ui/AssistantOverlay.d.ts +4 -0
  80. package/dist/shared/assistant/ui/AssistantOverlay.d.ts.map +1 -1
  81. package/dist/shared/assistant/ui/AssistantOverlay.js +97 -94
  82. package/dist/shared/assistant/ui/AssistantSpokenTurnsNotice.d.ts +5 -3
  83. package/dist/shared/assistant/ui/AssistantSpokenTurnsNotice.d.ts.map +1 -1
  84. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +6 -0
  85. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts.map +1 -1
  86. package/dist/shared/assistant/ui/composer/AssistantComposer.js +54 -54
  87. package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.d.ts +9 -0
  88. package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.d.ts.map +1 -1
  89. package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.js +37 -32
  90. package/dist/shared/assistant/voice/turnVisibility.d.ts +7 -5
  91. package/dist/shared/assistant/voice/turnVisibility.d.ts.map +1 -1
  92. package/dist/shared/assistant/voice/voiceTranscript.d.ts +3 -2
  93. package/dist/shared/assistant/voice/voiceTranscript.d.ts.map +1 -1
  94. package/dist/shared-assistant.js +153 -137
  95. package/package.json +1 -1
@@ -6,290 +6,308 @@ import { useAssistantProduct as r } from "../product.js";
6
6
  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
- import { abortAssistantTurn as s, approvePendingWrite as c, createAssistantSandbox as l, createAssistantSession as u, extendAssistantSandboxTTL as ee, findExistingSandboxWithStatus as te, getAssistantArtifacts as d, getAssistantMessages as f, getAssistantSession as p, modeRequiresConfirmWrites as m, promptGatewayRequestBytes as ne, releaseSupersededAssistantSandboxes as h, sendAssistantPromptAsync as g, waitForAssistantServiceReady as _, waitForSandboxRunning as re } from "../api.js";
10
- import { sanitize as ie } from "../progress.js";
11
- import { withIncompleteTurnNotice as ae } from "../streamBudget.js";
12
- import { chatTurns as v, isVoiceTurn as y, voiceMarker as oe, voiceSessionIdOf as b } from "../voice/turnVisibility.js";
13
- import { buildContinuedFromVoiceNote as se, buildVoiceTranscriptMarkdown as ce, voiceTranscriptFilename as x } from "../voice/voiceTranscript.js";
14
- import { pollDelayMs as le } from "../voice/assistantPollSchedule.js";
15
- import { toCaptionText as ue } from "../voice/captionText.js";
16
- import { resolveAssistantLanguage as de } from "../voice/languages.js";
17
- import { resolveLanguagePair as fe } from "../voice/languagePair.js";
18
- import { INITIAL_TRANSCRIPT_AUTO_OPEN as S, maySendSpokenTurn as pe, planTranscriptAutoOpen as me, planVoiceSessionBinding as he } from "../voice/voiceReopen.js";
19
- import { beginApprovalInFlight as ge, endApprovalInFlight as _e, getApprovalInFlight as ve, markLiveTurn as ye, newestModelReplyId as be, resolveApprovablePendingWrite as C, resolveRetryableMessageId as xe, subscribeApprovalInFlight as Se } from "../liveTurns.js";
20
- import { countInlineImageCandidates as Ce, countInlinedImageParts as we, getSendableAttachments as Te, largestInlineCharsPerFile as Ee, resolveAssistantInlineLimits as De, toMessageAttachment as Oe } from "../attachments.js";
21
- import { AssistantSendRefusal as ke, classifyTurnFailure as Ae, turnOutcomeCopy as je } from "../turnOutcome.js";
22
- import { createAdminModeAccessGate as Me, resolveAssistantSendModeAfterAccess as Ne } from "../adminModeSendGate.js";
23
- import { buildBoundedAttachmentTurn as Pe } from "../attachmentTurn.js";
24
- import { isWriteModeAcknowledged as Fe, writeModeSendRefusalReason as Ie } from "../writeModeConsent.js";
25
- import { AUTO_READ_MODE as Le, autoCarryOverFor as Re, autoSuggestions as ze, classifyAssistantIntent as Be, escalationToUndo as Ve, isAutoRoutingOffered as He, resolveAutoRoute as Ue } from "../autoRouting.js";
26
- import { resolveActiveModeSandbox as We, useAssistantStore as w } from "../store.js";
27
- import { isTurnInFlight as Ge, planAbandonedTurn as Ke, planTurnAbort as qe } from "../turnState.js";
28
- import { getAssistantDisplayContent as Je } from "../displayContent.js";
29
- import { NO_FIRST_TEXT as Ye, buildAssistantProgress as Xe, readAheadFor as Ze, snapshotReplyFloor as Qe, startSessionReadAhead as $e, trackFirstText as et } from "../turnProgress.js";
30
- import { parseToolActivity as tt } from "./AssistantToolActivity.js";
31
- import { countSpokenTurns as nt, spokenTurnText as rt } from "../spokenTurns.js";
32
- import { beginTurn as it, describeTurn as T, detectTurnDevice as at, markTurn as E, restartAttempt as ot, turnClockMs as st } from "../turnTimeline.js";
33
- import { useAssistantSpeech as ct } from "./AssistantSpeechProvider.js";
34
- import { useVoiceSession as lt } from "./useVoiceSession.js";
35
- import { getOrganizationId as ut, getWorkspaceId as dt } from "../context.js";
36
- import { isMultimodalBodyRejection as ft, isRecoverableAssistantError as pt } from "../transportErrors.js";
37
- import { createReadinessTracker as mt, planAfterTransportFailure as ht, planTrustedSandboxFailure as gt } from "../sandboxReadiness.js";
38
- import { AssistantSpokenTurnsNotice as _t } from "./AssistantSpokenTurnsNotice.js";
39
- import { VoiceTranscriptDrawer as vt } from "./voice/VoiceTranscriptDrawer.js";
40
- import { downloadFile as yt } from "../exportConversation.js";
41
- import { AssistantEmptyState as bt } from "./AssistantEmptyState.js";
42
- import { AssistantMessageList as xt } from "./AssistantMessageList.js";
43
- import { AssistantVoiceSession as St } from "./voice/AssistantVoiceSession.js";
44
- import { useAssistantApiAccess as Ct } from "../useAssistantApiAccess.js";
45
- import { useConversationTurns as wt } from "../useConversationTurns.js";
46
- import { sendAssistantTurnTimings as Tt, startTurnTimingReporting as Et } from "../turnTimingReporter.js";
47
- import { WarmCancelled as Dt, consumeWarm as Ot, prewarmTarget as kt, settleWarmBeforeSend as At, startWarm as jt, warmState as Mt } from "../prewarm.js";
48
- import { isAlreadyThere as Nt, matchLocalUiCommand as Pt, navDestinations as Ft, planThemeChange as It } from "../localUiCommands.js";
49
- import { chooseDestinationCopy as Lt, navigationCommandCopy as Rt, themeCommandCopy as zt } from "../localUiCommandCopy.js";
50
- import { dispatchAssistantQuotaExhausted as Bt, notifyAiCreditsUpdated as Vt } from "../aiCredits.js";
51
- import { useAssistantAttachments as Ht } from "../useAssistantAttachments.js";
52
- import { AssistantComposer as Ut } from "./composer/AssistantComposer.js";
53
- import { isProdRuntime as Wt } from "../env.js";
54
- import { AssistantApiCallsConsentDialog as Gt } from "./AssistantApiCallsConsentDialog.js";
55
- import { useVisibleNavItems as Kt } from "../../../chrome/mobileTabBar/useVisibleNavItems.js";
56
- import { useCallback as D, useEffect as O, useMemo as qt, useRef as k, useState as Jt, useSyncExternalStore as Yt } from "react";
57
- import { jsx as A, jsxs as Xt } from "react/jsx-runtime";
9
+ import { abortAssistantTurn as s, approvePendingWrite as c, createAssistantSandbox as l, createAssistantSession as u, extendAssistantSandboxTTL as ee, findExistingSandboxWithStatus as d, getAssistantArtifacts as f, getAssistantMessages as p, getAssistantSession as m, modeRequiresConfirmWrites as te, promptGatewayRequestBytes as ne, releaseSupersededAssistantSandboxes as h, sendAssistantPromptAsync as g, waitForAssistantServiceReady as _, waitForSandboxRunning as v } from "../api.js";
10
+ import { sanitize as re } from "../progress.js";
11
+ import { withIncompleteTurnNotice as ie } from "../streamBudget.js";
12
+ import { chatTurns as y, isVoiceTurn as b, voiceMarker as x, voiceSessionIdOf as ae } from "../voice/turnVisibility.js";
13
+ import { buildContinuedFromVoiceNote as oe, buildVoiceTranscriptMarkdown as S, voiceTranscriptFilename as C } from "../voice/voiceTranscript.js";
14
+ import { pollDelayMs as se } from "../voice/assistantPollSchedule.js";
15
+ import { toCaptionText as ce } from "../voice/captionText.js";
16
+ import { resolveAssistantLanguage as le } from "../voice/languages.js";
17
+ import { resolveLanguagePair as w } from "../voice/languagePair.js";
18
+ import { INITIAL_TRANSCRIPT_AUTO_OPEN as ue, maySendSpokenTurn as de, planTranscriptAutoOpen as fe, planVoiceSessionBinding as T } from "../voice/voiceReopen.js";
19
+ import { beginApprovalInFlight as pe, endApprovalInFlight as me, getApprovalInFlight as he, markLiveTurn as ge, newestModelReplyId as _e, resolveApprovablePendingWrite as ve, resolveRetryableMessageId as E, subscribeApprovalInFlight as ye } from "../liveTurns.js";
20
+ import { countInlineImageCandidates as be, countInlinedImageParts as xe, getSendableAttachments as Se, largestInlineCharsPerFile as Ce, resolveAssistantInlineLimits as we, toMessageAttachment as Te } from "../attachments.js";
21
+ import { AssistantSendRefusal as Ee, classifyTurnFailure as De, turnOutcomeCopy as Oe } from "../turnOutcome.js";
22
+ import { createAdminModeAccessGate as ke, resolveAssistantSendModeAfterAccess as Ae } from "../adminModeSendGate.js";
23
+ import { buildBoundedAttachmentTurn as je } from "../attachmentTurn.js";
24
+ import { isWriteModeAcknowledged as Me, writeModeSendRefusalReason as Ne } from "../writeModeConsent.js";
25
+ import { AUTO_READ_MODE as Pe, autoSuggestions as Fe, classifyAssistantIntent as Ie, escalationToUndo as Le, isAutoRoutingOffered as Re, resolveAutoRoute as ze } from "../autoRouting.js";
26
+ import { getHistoryStamp as Be, setHistoryBusyProbe as Ve } from "../history/stampRegistry.js";
27
+ import { resolveActiveModeSandbox as He, useAssistantStore as D } from "../store.js";
28
+ import { isTurnInFlight as Ue, planAbandonedTurn as We, planTurnAbort as Ge } from "../turnState.js";
29
+ import { getAssistantDisplayContent as Ke } from "../displayContent.js";
30
+ import { NO_FIRST_TEXT as qe, buildAssistantProgress as Je, readAheadFor as Ye, snapshotReplyFloor as Xe, startSessionReadAhead as Ze, trackFirstText as Qe } from "../turnProgress.js";
31
+ import { parseToolActivity as $e } from "./AssistantToolActivity.js";
32
+ import { countSpokenTurns as et, spokenMessagesSinceContinueNote as tt, spokenTurnText as nt } from "../spokenTurns.js";
33
+ import { beginTurn as rt, describeTurn as O, detectTurnDevice as it, markTurn as k, restartAttempt as at, turnClockMs as ot } from "../turnTimeline.js";
34
+ import { useAssistantSpeech as st } from "./AssistantSpeechProvider.js";
35
+ import { useVoiceSession as ct } from "./useVoiceSession.js";
36
+ import { getOrganizationId as lt, getWorkspaceId as A } from "../context.js";
37
+ import { isMultimodalBodyRejection as ut, isRecoverableAssistantError as dt } from "../transportErrors.js";
38
+ import { createReadinessTracker as ft, planAfterTransportFailure as pt, planTrustedSandboxFailure as mt } from "../sandboxReadiness.js";
39
+ import { AssistantSpokenTurnsNotice as ht } from "./AssistantSpokenTurnsNotice.js";
40
+ import { AssistantHistoryDeletedNotice as gt, AssistantHistoryLoadState as _t, AssistantHistoryReadOnlyBanner as vt, AssistantHistoryShowEarlier as yt } from "./AssistantHistoryNotices.js";
41
+ import { VoiceTranscriptDrawer as bt } from "./voice/VoiceTranscriptDrawer.js";
42
+ import { downloadFile as xt } from "../exportConversation.js";
43
+ import { conversationHasHistory as St, isOtherScopeHistoryConversation as Ct, isReadOnlyHistoryConversation as wt, isReusableHistoryDraft as Tt } from "../history/historyList.js";
44
+ import { useAssistantHistoryStatus as Et } from "../history/historyStatus.js";
45
+ import { assistantHistory as Dt } from "../history/historyEngine.js";
46
+ import { AssistantEmptyState as Ot } from "./AssistantEmptyState.js";
47
+ import { resumeContextFor as kt } from "../history/historyResume.js";
48
+ import { AssistantMessageList as At } from "./AssistantMessageList.js";
49
+ import { AssistantVoiceSession as jt } from "./voice/AssistantVoiceSession.js";
50
+ import { useAssistantApiAccess as Mt } from "../useAssistantApiAccess.js";
51
+ import { useConversationTurns as Nt } from "../useConversationTurns.js";
52
+ import { sendAssistantTurnTimings as Pt, startTurnTimingReporting as Ft } from "../turnTimingReporter.js";
53
+ import { WarmCancelled as It, consumeWarm as Lt, prewarmTarget as Rt, settleWarmBeforeSend as zt, startWarm as Bt, warmState as Vt } from "../prewarm.js";
54
+ import { isAlreadyThere as Ht, matchLocalUiCommand as Ut, navDestinations as Wt, planThemeChange as Gt } from "../localUiCommands.js";
55
+ import { chooseDestinationCopy as Kt, navigationCommandCopy as qt, themeCommandCopy as Jt } from "../localUiCommandCopy.js";
56
+ import { dispatchAssistantQuotaExhausted as Yt, notifyAiCreditsUpdated as Xt } from "../aiCredits.js";
57
+ import { useAssistantAttachments as Zt } from "../useAssistantAttachments.js";
58
+ import { AssistantComposer as Qt } from "./composer/AssistantComposer.js";
59
+ import { isProdRuntime as $t } from "../env.js";
60
+ import { AssistantApiCallsConsentDialog as en } from "./AssistantApiCallsConsentDialog.js";
61
+ import { useVisibleNavItems as tn } from "../../../chrome/mobileTabBar/useVisibleNavItems.js";
62
+ import { useCallback as j, useEffect as M, useMemo as nn, useRef as N, useState as rn, useSyncExternalStore as an } from "react";
63
+ import { jsx as P, jsxs as on } from "react/jsx-runtime";
58
64
  //#region src/shared/assistant/ui/AssistantChatArea.tsx
59
- var Zt = 600, Qt = 2e4;
60
- function $t() {
65
+ var sn = 600, cn = 2e4, ln = 1e4;
66
+ function un() {
61
67
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
62
68
  }
63
- var en = ({ visible: en = !0, writeAccess: tn = "unknown" }) => {
64
- let j = i(), { product: M, modes: N, gatherPageContext: nn, buildPrompt: rn, reportTurnTimings: an, reportTokenUsage: on, localUiCommands: sn } = r(), { getAccessToken: P, getWorkspaceToken: F, userId: I } = n(), { locale: L } = t(), cn = w((e) => e.assistantLanguage), ln = w((e) => e.replyLanguage), un = qt(() => fe(cn, ln, L), [
65
- cn,
66
- ln,
67
- L
68
- ]), dn = un.reply.english, fn = un.replyIsExplicit, pn = un.reply.code, { conversations: mn, activeConversationId: R, mode: z, processingByConversationId: hn, setMode: gn, setConversationMode: _n, setActiveConversation: vn, createConversation: B, addMessage: V, updateMessage: yn, patchMessage: bn, mergeMessageMetadata: xn, setConversationProcessing: Sn, clearConversationProcessing: Cn, setBackendSessionId: wn, clearBackendSessionId: Tn, setSandbox: H, clearSandbox: U, acknowledgedWriteModes: En, acknowledgeWriteMode: Dn, autoRouting: On, setAutoRouting: kn, routeConversation: An } = w(), jn = mn.find((e) => e.id === R), Mn = wt(jn), Nn = Mn.all, W = R ? hn[R] : void 0, Pn = Ge(W?.status), Fn = Pn ? W?.messageId ?? null : null, In = W?.status === "error" ? W.messageId : null, { canUseApiCalls: Ln, loading: Rn } = Ct(ut()), G = k(Me({
69
- loading: Rn,
70
- canUseAdminModes: Ln
71
- })).current, zn = k(N);
72
- O(() => {
73
- zn.current = N;
74
- }, [N]);
75
- let Bn = k(P);
76
- O(() => {
77
- Bn.current = P;
78
- }, [P]);
79
- let Vn = !!M && an !== !1;
80
- O(() => {
81
- if (Vn) return Et({ send: (e) => Tt(e, {
82
- workspaceId: dt(),
69
+ var dn = ({ visible: dn = !0, writeAccess: fn = "unknown" }) => {
70
+ let F = i(), { product: I, modes: L, gatherPageContext: pn, buildPrompt: mn, reportTurnTimings: hn, reportTokenUsage: gn, localUiCommands: _n } = r(), { getAccessToken: R, getWorkspaceToken: z, userId: B } = n(), { locale: vn } = t(), yn = D((e) => e.assistantLanguage), bn = D((e) => e.replyLanguage), xn = nn(() => w(yn, bn, vn), [
71
+ yn,
72
+ bn,
73
+ vn
74
+ ]), Sn = xn.reply.english, Cn = xn.replyIsExplicit, wn = xn.reply.code, { conversations: Tn, activeConversationId: V, mode: H, processingByConversationId: En, setMode: Dn, setConversationMode: On, setActiveConversation: kn, createConversation: U, addMessage: W, updateMessage: An, patchMessage: jn, mergeMessageMetadata: Mn, setConversationProcessing: Nn, clearConversationProcessing: Pn, setBackendSessionId: Fn, clearBackendSessionId: In, setSandbox: G, clearSandbox: K, acknowledgedWriteModes: Ln, acknowledgeWriteMode: Rn, autoRouting: zn, setAutoRouting: Bn, routeConversation: Vn } = D(), Hn = Tn.find((e) => e.id === V), Un = Nt(Hn), Wn = Un.all, q = V ? En[V] : void 0, Gn = Ue(q?.status), Kn = Gn ? q?.messageId ?? null : null, qn = q?.status === "error" ? q.messageId : null, Jn = wt(Hn), Yn = Et((e) => V !== null && V in e.loadingIds), Xn = Et((e) => V !== null && V in e.loadErrorIds), Zn = Et((e) => e.remoteDelete), [Qn, $n] = rn(() => Et.getState().remoteDelete?.at ?? null), er = Zn?.wasActive === !0 && Zn.at !== Qn ? Zn.at : null;
75
+ M(() => {
76
+ if (er === null) return;
77
+ let e = window.setTimeout(() => $n(er), ln);
78
+ return () => window.clearTimeout(e);
79
+ }, [er]);
80
+ let { canUseApiCalls: tr, loading: nr } = Mt(lt()), rr = N(ke({
81
+ loading: nr,
82
+ canUseAdminModes: tr
83
+ })).current, ir = N(L);
84
+ M(() => {
85
+ ir.current = L;
86
+ }, [L]);
87
+ let ar = () => {
88
+ let e = D.getState().activeConversationId;
89
+ e && Dt.openConversation(e, { modes: ir.current });
90
+ }, or = () => {
91
+ let e = D.getState().activeConversationId;
92
+ e && Dt.loadEarlier(e);
93
+ }, sr = N(R);
94
+ M(() => {
95
+ sr.current = R;
96
+ }, [R]);
97
+ let cr = !!I && hn !== !1;
98
+ M(() => {
99
+ if (cr) return Ft({ send: (e) => Pt(e, {
100
+ workspaceId: A(),
83
101
  authContext: {
84
- accessToken: Bn.current(),
85
- organizationId: ut()
102
+ accessToken: sr.current(),
103
+ organizationId: lt()
86
104
  }
87
105
  }) });
88
- }, [Vn]), O(() => {
89
- G.update({
90
- loading: Rn,
91
- canUseAdminModes: Ln
106
+ }, [cr]), M(() => {
107
+ rr.update({
108
+ loading: nr,
109
+ canUseAdminModes: tr
92
110
  });
93
111
  }, [
94
- G,
95
- Rn,
96
- Ln
97
- ]), O(() => () => {
98
- G.abandon();
99
- }, [G]);
100
- let Hn = qt(() => N.filter((e) => !e.requiresAdmin || Ln), [N, Ln]), Un = He(Hn), Wn = On && Un, Gn = k(Un);
101
- O(() => {
102
- Gn.current = Un;
103
- }, [Un]);
104
- let Kn = k(null), qn = Ee(N), [Jn, Yn] = Jt(null), [Xn, Zn] = Jt(null), Qn = Xn !== null && Xn === R, K = D((e) => {
105
- Zn(e ? w.getState().activeConversationId : null);
112
+ rr,
113
+ nr,
114
+ tr
115
+ ]), M(() => () => {
116
+ rr.abandon();
117
+ }, [rr]);
118
+ let lr = nn(() => L.filter((e) => !e.requiresAdmin || tr), [L, tr]), ur = Re(lr), dr = zn && ur, fr = N(ur);
119
+ M(() => {
120
+ fr.current = ur;
121
+ }, [ur]);
122
+ let pr = N(null), mr = Ce(L), [hr, gr] = rn(null), [_r, vr] = rn(null), yr = _r !== null && _r === V, br = j((e) => {
123
+ vr(e ? D.getState().activeConversationId : null);
106
124
  }, []);
107
- O(() => {
108
- Zn((e) => e !== null && e !== R ? null : e);
109
- }, [R]);
110
- let $n = k(void 0), er = k({}), q = k(mt()), J = k(/* @__PURE__ */ new Set()), tr = k(/* @__PURE__ */ new Set()), Y = qt(() => N.find((e) => e.id === z), [N, z]), nr = z === "assistant" || Y !== void 0 && !Y.writeCapable && !m(z);
111
- O(() => {
112
- if (z !== "assistant" && Y?.writeCapable && !Fe(En, z)) {
113
- gn("assistant");
125
+ M(() => {
126
+ vr((e) => e !== null && e !== V ? null : e);
127
+ }, [V]);
128
+ let xr = N(void 0), Sr = N({}), J = N(ft()), Y = N(/* @__PURE__ */ new Set()), Cr = N(/* @__PURE__ */ new Set()), wr = nn(() => L.find((e) => e.id === H), [L, H]), Tr = H === "assistant" || wr !== void 0 && !wr.writeCapable && !te(H);
129
+ M(() => {
130
+ if (H !== "assistant" && wr?.writeCapable && !Me(Ln, H)) {
131
+ Dn("assistant");
114
132
  return;
115
133
  }
116
- Rn || (!Y || Y.requiresAdmin && !Ln) && z !== "assistant" && gn("assistant");
134
+ nr || (!wr || wr.requiresAdmin && !tr) && H !== "assistant" && Dn("assistant");
117
135
  }, [
118
- z,
119
- Y,
120
- Ln,
121
- Rn,
122
- gn,
123
- En
136
+ H,
137
+ wr,
138
+ tr,
139
+ nr,
140
+ Dn,
141
+ Ln
124
142
  ]);
125
- let rr = D((e, t, n, r) => {
126
- Sn(e, n, t, null, r);
127
- }, [Sn]), ir = D(async (e, t, n, r, i, a = null) => {
143
+ let Er = j((e, t, n, r) => {
144
+ Nn(e, n, t, null, r);
145
+ }, [Nn]), Dr = j(async (e, t, n, r, i, a = null) => {
128
146
  let s = (e, t) => {
129
- r && rr(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
147
+ r && Er(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
130
148
  }, c = (e) => {
131
- r && E(r.assistantMessageId, e);
149
+ r && k(r.assistantMessageId, e);
132
150
  }, u = () => {
133
151
  c("bootAdopted"), a?.beginBoot();
134
- }, ee = () => a !== null && (a.signal.aborted || dt() !== t), d = () => {
135
- if (ee()) throw new Dt("cancelled");
136
- }, f = w.getState().sandboxesByMode[e]?.sandboxId ?? null, p = !1, m = !1, ne = !1, g = !1, ie = !1, ae = async (r) => {
137
- if (i && !J.current.has(r) && q.current.isFresh(r)) return p = !0, !0;
152
+ }, ee = () => a !== null && (a.signal.aborted || A() !== t), f = () => {
153
+ if (ee()) throw new It("cancelled");
154
+ }, p = D.getState().sandboxesByMode[e]?.sandboxId ?? null, m = !1, te = !1, ne = !1, g = !1, re = !1, ie = async (r) => {
155
+ if (i && !Y.current.has(r) && J.current.isFresh(r)) return m = !0, !0;
138
156
  ne = !0;
139
157
  let o = !1;
140
158
  try {
141
- await re(r, t, n, 3e5), await _(r, t, e, n, 9e4, () => {
159
+ await v(r, t, n, 3e5), await _(r, t, e, n, 9e4, () => {
142
160
  o = !0, u();
143
161
  });
144
162
  } catch {
145
- if (ee()) throw new Dt("cancelled");
146
- return q.current.invalidate(r), J.current.add(r), a?.dead.push(r), ie = !0, !1;
163
+ if (ee()) throw new It("cancelled");
164
+ return J.current.invalidate(r), Y.current.add(r), a?.dead.push(r), re = !0, !1;
147
165
  }
148
- return d(), q.current.markVerified(r), o && (g = !0), !0;
166
+ return f(), J.current.markVerified(r), o && (g = !0), !0;
149
167
  };
150
- if (f && (H(e, f, "provisioning"), s("provisioning", "reusingEnvironment"), await ae(f) || (H(e, null, "provisioning"), f = null)), !f) {
168
+ if (p && (G(e, p, "provisioning"), s("provisioning", "reusingEnvironment"), await ie(p) || (G(e, null, "provisioning"), p = null)), !p) {
151
169
  s("provisioning", "lookingForEnvironment");
152
- let r = await te(t, M, e, Wt(), n, J.current);
153
- d();
170
+ let r = await d(t, I, e, $t(), n, Y.current);
171
+ f();
154
172
  let i = r?.id ?? null;
155
173
  if (i) {
156
- H(e, i, "provisioning"), s("provisioning", "reusingEnvironment");
174
+ G(e, i, "provisioning"), s("provisioning", "reusingEnvironment");
157
175
  let t = r?.status === "PROVISIONING" || r?.status === "PENDING";
158
- t && u(), await ae(i) ? (f = i, t && (g = !0)) : H(e, null, "provisioning");
176
+ t && u(), await ie(i) ? (p = i, t && (g = !0)) : G(e, null, "provisioning");
159
177
  }
160
178
  }
161
- if (!f) {
162
- if (a && !a.mayCreate) throw new Dt("no-create");
163
- if (c("provisionStarted"), e === "api-calls" && !P()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
164
- s("provisioning", "startingEnvironment"), H(e, null, "provisioning");
165
- let r = a ? [] : await h(t, M, e, Wt(), n, J.current);
179
+ if (!p) {
180
+ if (a && !a.mayCreate) throw new It("no-create");
181
+ if (c("provisionStarted"), e === "api-calls" && !R()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
182
+ s("provisioning", "startingEnvironment"), G(e, null, "provisioning");
183
+ let r = a ? [] : await h(t, I, e, $t(), n, Y.current);
166
184
  if (r.length > 0) {
167
185
  let e = new Set(r);
168
- for (let e of r) q.current.invalidate(e), J.current.add(e);
169
- let t = w.getState().sandboxesByMode;
170
- for (let [n, r] of Object.entries(t)) o(n) && r?.sandboxId && e.has(r.sandboxId) && U(n);
186
+ for (let e of r) J.current.invalidate(e), Y.current.add(e);
187
+ let t = D.getState().sandboxesByMode;
188
+ for (let [n, r] of Object.entries(t)) o(n) && r?.sandboxId && e.has(r.sandboxId) && K(n);
171
189
  }
172
190
  c("createRequested");
173
191
  let i = a?.beginCreate();
174
192
  try {
175
- f = await l(M, e, t, Wt(), Zt, n);
193
+ p = await l(I, e, t, $t(), sn, n);
176
194
  } finally {
177
195
  i?.();
178
196
  }
179
- m = !0, d(), H(e, f, "provisioning"), await re(f, t, n, 3e5), d(), c("sandboxRunning"), await _(f, t, e, n, 9e4), d(), c("serviceReady"), q.current.markVerified(f);
197
+ te = !0, f(), G(e, p, "provisioning"), await v(p, t, n, 3e5), f(), c("sandboxRunning"), await _(p, t, e, n, 9e4), f(), c("serviceReady"), J.current.markVerified(p);
180
198
  }
181
- return H(e, f, "running"), {
182
- sandboxId: f,
183
- sandboxIsNew: m,
199
+ return G(e, p, "running"), {
200
+ sandboxId: p,
201
+ sandboxIsNew: te,
184
202
  sandboxProbed: ne,
185
203
  sandboxAdopted: g,
186
- deadSandboxProbe: ie,
187
- trustedFromCache: p
204
+ deadSandboxProbe: re,
205
+ trustedFromCache: m
188
206
  };
189
207
  }, [
190
- U,
191
- P,
192
- M,
193
- H,
194
- rr
195
- ]), ar = D(async function e(t, n, r, i, a, o = {}) {
196
- let s = await At(i, r, (e) => rr(t, n, "provisioning", e), () => E(n, "prewarmJoined"));
197
- for (let e of s.dead) q.current.invalidate(e), J.current.add(e);
198
- s.verified && !J.current.has(s.verified) && q.current.markVerified(s.verified), s.joined && T(n, { prewarm: s.joined });
199
- let { sandboxId: c, sandboxIsNew: l, sandboxProbed: ee, sandboxAdopted: d, deadSandboxProbe: m, trustedFromCache: ne } = await ir(r, i, a, {
208
+ K,
209
+ R,
210
+ I,
211
+ G,
212
+ Er
213
+ ]), Or = j(async function e(t, n, r, i, a, o = {}) {
214
+ let s = await zt(i, r, (e) => Er(t, n, "provisioning", e), () => k(n, "prewarmJoined"));
215
+ for (let e of s.dead) J.current.invalidate(e), Y.current.add(e);
216
+ s.verified && !Y.current.has(s.verified) && J.current.markVerified(s.verified), s.joined && O(n, { prewarm: s.joined });
217
+ let { sandboxId: c, sandboxIsNew: l, sandboxProbed: ee, sandboxAdopted: f, deadSandboxProbe: te, trustedFromCache: ne } = await Dr(r, i, a, {
200
218
  conversationId: t,
201
219
  assistantMessageId: n
202
- }, o.trustCache !== !1), h = Ot(i, r, c);
203
- !s.waited && h && T(n, { prewarm: "hit" });
204
- let g = w.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, _ = !1, re = null;
220
+ }, o.trustCache !== !1), h = Lt(i, r, c);
221
+ !s.waited && h && O(n, { prewarm: "hit" });
222
+ let g = D.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, _ = !1, v = null;
205
223
  if (g) {
206
- let e = $e(c, g, (e, t) => f(e, i, t, r, a, { limit: 50 }));
224
+ let e = Ze(c, g, (e, t) => p(e, i, t, r, a, { limit: 50 }));
207
225
  try {
208
- let t = await p(c, i, g, r, a);
226
+ let t = await m(c, i, g, r, a);
209
227
  if (t.mode !== r) throw Error(`Session mode mismatch: expected ${r}, received ${t.mode}`);
210
- re = e;
228
+ v = e;
211
229
  } catch {
212
- Tn(t), g = null;
230
+ In(t), g = null;
213
231
  }
214
232
  }
215
233
  if (!g) {
216
- rr(t, n, "connecting", "preparingSession");
234
+ Er(t, n, "connecting", "preparingSession");
217
235
  let s;
218
236
  try {
219
237
  s = await u(c, i, r, a);
220
238
  } catch (s) {
221
239
  if (ne) {
222
- q.current.invalidate(c);
223
- let l = gt(s, o.isAbandoned?.() ?? !1), u = l === "check-network";
224
- if (l === "check-network" && (l = await ht(() => te(i, M, r, Wt(), a, J.current))), l !== "rethrow" && o.isAbandoned?.() && (l = "rethrow"), l !== "rethrow") {
225
- u || T(n, { cacheProofFailed: !0 }), l === "replace" && (J.current.add(c), Tn(t), U(r));
240
+ J.current.invalidate(c);
241
+ let l = mt(s, o.isAbandoned?.() ?? !1), u = l === "check-network";
242
+ if (l === "check-network" && (l = await pt(() => d(i, I, r, $t(), a, Y.current))), l !== "rethrow" && o.isAbandoned?.() && (l = "rethrow"), l !== "rethrow") {
243
+ u || O(n, { cacheProofFailed: !0 }), l === "replace" && (Y.current.add(c), In(t), K(r));
226
244
  let s = await e(t, n, r, i, a, {
227
245
  ...o,
228
246
  trustCache: !1
229
247
  });
230
- return u && (s.deadSandboxProbe || s.sandboxId !== c) && T(n, { cacheProofFailed: !0 }), {
248
+ return u && (s.deadSandboxProbe || s.sandboxId !== c) && O(n, { cacheProofFailed: !0 }), {
231
249
  ...s,
232
250
  sandboxProbed: s.sandboxProbed || ee,
233
- sandboxAdopted: s.sandboxAdopted || d,
234
- deadSandboxProbe: s.deadSandboxProbe || m
251
+ sandboxAdopted: s.sandboxAdopted || f,
252
+ deadSandboxProbe: s.deadSandboxProbe || te
235
253
  };
236
254
  }
237
255
  }
238
256
  throw s;
239
257
  }
240
- g = s.sessionId, wn(t, g), _ = !0;
258
+ g = s.sessionId, Fn(t, g), _ = !0;
241
259
  }
242
260
  return {
243
261
  sandboxId: c,
244
262
  sessionId: g,
245
263
  sessionIsNew: _,
246
- readAhead: re,
264
+ readAhead: v,
247
265
  sandboxIsNew: l,
248
266
  sandboxProbed: ee,
249
- sandboxAdopted: d,
250
- deadSandboxProbe: m
267
+ sandboxAdopted: f,
268
+ deadSandboxProbe: te
251
269
  };
252
270
  }, [
253
- ir,
254
- Tn,
255
- U,
256
- M,
257
- wn,
258
- rr
259
- ]), or = D((e) => {
260
- let t = dt();
271
+ Dr,
272
+ In,
273
+ K,
274
+ I,
275
+ Fn,
276
+ Er
277
+ ]), kr = j((e) => {
278
+ let t = A();
261
279
  if (!t) return;
262
- let n = w.getState(), r = Date.now(), i = kt({
280
+ let n = D.getState(), r = Date.now(), i = Rt({
263
281
  autoRouting: n.autoRouting,
264
- autoOffered: Gn.current,
282
+ autoOffered: fr.current,
265
283
  active: n.activeConversationId ? n.conversations.find((e) => e.id === n.activeConversationId) : void 0,
266
284
  selectedMode: n.mode,
267
- autoReadMode: Le,
268
- modes: zn.current,
285
+ autoReadMode: Pe,
286
+ modes: ir.current,
269
287
  acknowledgedWriteModes: n.acknowledgedWriteModes,
270
- adminAccess: G.read(),
288
+ adminAccess: rr.read(),
271
289
  dictated: e,
272
- turnInFlight: Object.values(n.processingByConversationId).some((e) => Ge(e?.status)),
273
- ...Mt(t),
290
+ turnInFlight: Object.values(n.processingByConversationId).some((e) => Ue(e?.status)),
291
+ ...Vt(t),
274
292
  now: r
275
293
  });
276
294
  if (!i) return;
277
- let a = jt(t, i, r), o = {
278
- accessToken: P(),
279
- workspaceToken: F(),
280
- userId: I,
281
- organizationId: ut()
295
+ let a = Bt(t, i, r), o = {
296
+ accessToken: R(),
297
+ workspaceToken: z(),
298
+ userId: B,
299
+ organizationId: lt()
282
300
  };
283
- ir(i.mode, t, o, null, !0, a).then((e) => a.finish({
301
+ Dr(i.mode, t, o, null, !0, a).then((e) => a.finish({
284
302
  ok: !0,
285
303
  sandboxId: e.sandboxId,
286
304
  didWork: !e.trustedFromCache && (e.sandboxIsNew || e.sandboxProbed || e.sandboxAdopted),
287
305
  booted: e.sandboxIsNew || e.sandboxAdopted,
288
306
  dead: a.dead
289
307
  }), (e) => {
290
- if (!(e instanceof Dt) && !a.signal.aborted && dt() === t) {
291
- let e = w.getState().sandboxesByMode[i.mode]?.sandboxId ?? null;
292
- e && (q.current.invalidate(e), J.current.add(e), a.dead.push(e), U(i.mode));
308
+ if (!(e instanceof It) && !a.signal.aborted && A() === t) {
309
+ let e = D.getState().sandboxesByMode[i.mode]?.sandboxId ?? null;
310
+ e && (J.current.invalidate(e), Y.current.add(e), a.dead.push(e), K(i.mode));
293
311
  }
294
312
  a.finish({
295
313
  ok: !1,
@@ -299,108 +317,108 @@ var en = ({ visible: en = !0, writeAccess: tn = "unknown" }) => {
299
317
  });
300
318
  });
301
319
  }, [
302
- ir,
303
- G,
304
- U,
305
- P,
306
- F,
307
- I
308
- ]), sr = D(() => or(!1), [or]), cr = Yt(Se, ve, ve)?.reference ?? null, [lr, ur] = Jt(0), dr = k(/* @__PURE__ */ new Set()), fr = k(null), pr = D(() => {
309
- let e = w.getState(), t = e.activeConversationId;
320
+ Dr,
321
+ rr,
322
+ K,
323
+ R,
324
+ z,
325
+ B
326
+ ]), Ar = j(() => kr(!1), [kr]), jr = an(ye, he, he)?.reference ?? null, [Mr, Nr] = rn(0), Pr = N(/* @__PURE__ */ new Set()), Fr = N(null), Ir = j(() => {
327
+ let e = D.getState(), t = e.activeConversationId;
310
328
  if (!t) return;
311
- let n = e.processingByConversationId[t], r = Ge(n?.status) ? n?.messageId ?? null : null;
312
- if (!qe({
329
+ let n = e.processingByConversationId[t], r = Ue(n?.status) ? n?.messageId ?? null : null;
330
+ if (!Ge({
313
331
  interruptedTurnId: r,
314
332
  activeTurnId: r,
315
- alreadyRequested: r ? dr.current.has(r) : !1
333
+ alreadyRequested: r ? Pr.current.has(r) : !1
316
334
  }).send || !r) return;
317
- dr.current.add(r);
318
- let i = We(e), a = dt(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
335
+ Pr.current.add(r);
336
+ let i = He(e), a = A(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
319
337
  !i || !a || !o || s(i.sandboxId, a, o, i.mode, {
320
- accessToken: P(),
321
- workspaceToken: F(),
322
- userId: I,
323
- organizationId: ut()
338
+ accessToken: R(),
339
+ workspaceToken: z(),
340
+ userId: B,
341
+ organizationId: lt()
324
342
  });
325
343
  }, [
326
- I,
327
- P,
328
- F
329
- ]), mr = D(async (e) => {
330
- let t = w.getState(), n = We(t), r = dt(), i = t.activeConversationId;
344
+ B,
345
+ R,
346
+ z
347
+ ]), Lr = j(async (e) => {
348
+ let t = D.getState(), n = He(t), r = A(), i = t.activeConversationId;
331
349
  if (!n || !r || !i) return;
332
- let a = t.conversations.find((e) => e.id === i), o = a ? C(v(a.messages), {
350
+ let a = t.conversations.find((e) => e.id === i), o = a ? ve(y(a.messages), {
333
351
  sessionId: a.backendSessionId,
334
352
  sandboxId: n.sandboxId,
335
353
  nowMs: Date.now()
336
354
  }) : null;
337
355
  if (o?.reference !== e) {
338
- ur((e) => e + 1);
356
+ Nr((e) => e + 1);
339
357
  return;
340
358
  }
341
359
  let s = {
342
360
  conversationId: i,
343
361
  reference: e
344
362
  };
345
- if (!ge(s)) return;
363
+ if (!pe(s)) return;
346
364
  try {
347
365
  await c(n.sandboxId, r, e, n.mode, {
348
- accessToken: P(),
349
- workspaceToken: F(),
350
- userId: I,
351
- organizationId: ut()
366
+ accessToken: R(),
367
+ workspaceToken: z(),
368
+ userId: B,
369
+ organizationId: lt()
352
370
  });
353
371
  } catch (e) {
354
- _e(s), V(i, {
355
- id: $t(),
372
+ me(s), W(i, {
373
+ id: un(),
356
374
  role: "system",
357
375
  content: e instanceof Error ? e.message : "The change could not be approved.",
358
376
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
359
377
  });
360
378
  return;
361
379
  }
362
- _e(s), xn(i, o.messageId, { pendingWriteApprovedAt: (/* @__PURE__ */ new Date()).toISOString() });
363
- let l = w.getState(), u = l.conversations.find((e) => e.id === i);
364
- l.activeConversationId !== i || !u || l.mode !== n.mode || u.backendSessionId !== a?.backendSessionId || We(l)?.sandboxId !== n.sandboxId || Ge(l.processingByConversationId[i]?.status) || be(v(u.messages)) !== o.messageId || Cr.current(j("pendingWrite.approvedPrompt", "I approved that change — go ahead."), [], {
380
+ me(s), Mn(i, o.messageId, { pendingWriteApprovedAt: (/* @__PURE__ */ new Date()).toISOString() });
381
+ let l = D.getState(), u = l.conversations.find((e) => e.id === i);
382
+ l.activeConversationId !== i || !u || l.mode !== n.mode || u.backendSessionId !== a?.backendSessionId || He(l)?.sandboxId !== n.sandboxId || Ue(l.processingByConversationId[i]?.status) || _e(y(u.messages)) !== o.messageId || Kr.current(F("pendingWrite.approvedPrompt", "I approved that change — go ahead."), [], {
365
383
  approvalFollowUp: { approvedReplyId: o.messageId },
366
384
  targetConversationId: i
367
385
  });
368
386
  }, [
369
- I,
370
- V,
371
- xn,
372
- j
373
- ]), hr = e(), { speakFinishedReply: gr } = ct(), _r = a(), { items: vr } = Kt(), yr = k({
374
- theme: hr,
375
- navigate: _r,
376
- navItems: vr,
377
- options: sn ?? {}
387
+ B,
388
+ W,
389
+ Mn,
390
+ F
391
+ ]), Rr = e(), { speakFinishedReply: zr } = st(), Br = a(), { items: Vr } = tn(), Hr = N({
392
+ theme: Rr,
393
+ navigate: Br,
394
+ navItems: Vr,
395
+ options: _n ?? {}
378
396
  });
379
- O(() => {
380
- yr.current = {
381
- theme: hr,
382
- navigate: _r,
383
- navItems: vr,
384
- options: sn ?? {}
397
+ M(() => {
398
+ Hr.current = {
399
+ theme: Rr,
400
+ navigate: Br,
401
+ navItems: Vr,
402
+ options: _n ?? {}
385
403
  };
386
404
  }, [
387
- hr,
388
- _r,
389
- vr,
390
- sn
405
+ Rr,
406
+ Br,
407
+ Vr,
408
+ _n
391
409
  ]);
392
- let br = D((e, t, n) => {
393
- let { theme: r, navigate: i } = yr.current, a, o;
410
+ let Ur = j((e, t, n) => {
411
+ let { theme: r, navigate: i } = Hr.current, a, o;
394
412
  if (e.kind === "theme") {
395
413
  if (!r) return !1;
396
- let t = It(e.request, {
414
+ let t = Gt(e.request, {
397
415
  mode: r.mode,
398
416
  resolvedTheme: r.resolvedTheme
399
417
  });
400
418
  if (!t.alreadyApplied) try {
401
419
  r.setMode(t.mode);
402
420
  } catch {}
403
- a = zt(j, t, e.request.kind === "family"), o = {
421
+ a = Jt(F, t, e.request.kind === "family"), o = {
404
422
  kind: "theme",
405
423
  mode: t.mode,
406
424
  alreadyApplied: t.alreadyApplied
@@ -408,53 +426,53 @@ var en = ({ visible: en = !0, writeAccess: tn = "unknown" }) => {
408
426
  } else {
409
427
  if (!i) return !1;
410
428
  if (e.kind === "navigate") {
411
- let { destination: t } = e, n = Nt(t, window.location.pathname + window.location.search, Ft(yr.current.navItems));
412
- n || i(t.path), a = Rt(j, t.label, n), o = {
429
+ let { destination: t } = e, n = Ht(t, window.location.pathname + window.location.search, Wt(Hr.current.navItems));
430
+ n || i(t.path), a = qt(F, t.label, n), o = {
413
431
  kind: "navigate",
414
432
  destinationId: t.id,
415
433
  path: t.path,
416
434
  alreadyHere: n
417
435
  };
418
- } else a = Lt(j, e.candidates[0]?.label ?? e.query, e.candidates), o = {
436
+ } else a = Kt(F, e.candidates[0]?.label ?? e.query, e.candidates), o = {
419
437
  kind: "choose-destination",
420
438
  candidateIds: e.candidates.map((e) => e.id)
421
439
  };
422
440
  }
423
- let s = w.getState(), c = s.activeConversationId ?? B(void 0, s.autoRouting && Gn.current ? "assistant" : s.mode, s.autoRouting ? { routedBy: "auto" } : void 0), l = (/* @__PURE__ */ new Date()).toISOString();
424
- V(c, {
425
- id: $t(),
441
+ let s = D.getState(), c = s.activeConversationId ?? U(void 0, s.autoRouting && fr.current ? "assistant" : s.mode, s.autoRouting ? { routedBy: "auto" } : void 0), l = (/* @__PURE__ */ new Date()).toISOString(), u = un();
442
+ W(c, {
443
+ id: u,
426
444
  role: "user",
427
445
  content: t,
428
446
  timestamp: l,
429
447
  metadata: {
430
448
  localAction: o,
431
- ...oe(n)
449
+ ...x(n)
432
450
  }
433
451
  });
434
- let u = $t();
435
- return V(c, {
436
- id: u,
452
+ let ee = un();
453
+ return W(c, {
454
+ id: ee,
437
455
  role: "assistant",
438
456
  content: a.text,
439
457
  timestamp: l,
440
458
  metadata: {
441
- lang: a.translated ? L : "en",
459
+ lang: a.translated ? vn : "en",
442
460
  localAction: o,
443
- ...oe(n)
461
+ ...x(n)
444
462
  }
445
- }), gr(c, u), !0;
463
+ }), Dt.recordCommittedEntries(c, [u, ee], "LOCAL_COMMAND", A()), zr(c, ee), !0;
446
464
  }, [
447
- V,
448
- B,
449
- L,
450
- gr,
451
- j
452
- ]), X = D(async (e, t = [], n = {}) => {
453
- let r = n.voiceSessionId !== void 0, i = w.getState(), a = i.activeConversationId ?? R;
465
+ W,
466
+ U,
467
+ vn,
468
+ zr,
469
+ F
470
+ ]), X = j(async (e, t = [], n = {}) => {
471
+ let r = n.voiceSessionId !== void 0, i = D.getState(), a = i.activeConversationId ?? V;
454
472
  if (a) {
455
- if (Ge(i.processingByConversationId[a]?.status)) {
473
+ if (Ue(i.processingByConversationId[a]?.status)) {
456
474
  let r = i.processingByConversationId[a]?.messageId ?? null;
457
- r && dr.current.has(r) && (fr.current = {
475
+ r && Pr.current.has(r) && (Fr.current = {
458
476
  conversationId: a,
459
477
  content: e,
460
478
  attachments: t,
@@ -462,311 +480,319 @@ var en = ({ visible: en = !0, writeAccess: tn = "unknown" }) => {
462
480
  });
463
481
  return;
464
482
  }
465
- if (tr.current.has(a)) return;
483
+ if (Cr.current.has(a)) return;
466
484
  }
467
- if (Kn.current || ve() !== null) return;
468
- let o = n.targetConversationId;
485
+ if (pr.current || he() !== null) return;
486
+ let o = n.targetConversationId, c = Be(), l = (e) => wt(e) || Ct(e, c);
469
487
  if (o !== void 0) {
470
488
  let e = i.conversations.find((e) => e.id === o);
471
- if (i.activeConversationId !== o || !e || e.mode !== i.mode) return;
489
+ if (i.activeConversationId !== o || !e || e.mode !== i.mode || l(e)) return;
472
490
  }
473
491
  if (n.fromPerson && t.length === 0) {
474
- let t = Pt(e, Ft(yr.current.navItems), yr.current.options);
475
- if (t && br(t, e, n.voiceSessionId)) return;
492
+ let t = Ut(e, Wt(Hr.current.navItems), Hr.current.options);
493
+ if (t && Ur(t, e, n.voiceSessionId)) return;
476
494
  }
477
- let c = i.activeConversationId ? i.conversations.find((e) => e.id === i.activeConversationId) : void 0, l = i.autoRouting && Gn.current && o === void 0 ? Ue({
478
- intent: n.autoIntent ?? Be(e),
495
+ let u = i.activeConversationId ? i.conversations.find((e) => e.id === i.activeConversationId) : void 0, d = l(u) ? void 0 : u, m = i.autoRouting && fr.current && o === void 0 ? ze({
496
+ intent: n.autoIntent ?? Ie(e),
479
497
  dictated: r,
480
- conversation: c ? {
481
- mode: c.mode,
482
- routedBy: c.routedBy,
483
- hasHistory: c.messages.length > 0 || !!c.backendSessionId
498
+ conversation: d ? {
499
+ mode: d.mode,
500
+ routedBy: d.routedBy,
501
+ hasHistory: St(d)
484
502
  } : null
485
503
  }) : null;
486
- if (l && zn.current.find((e) => e.id === l.mode)?.writeCapable && !Fe(i.acknowledgedWriteModes, l.mode)) {
487
- Kn.current = {
504
+ if (m && ir.current.find((e) => e.id === m.mode)?.writeCapable && !Me(i.acknowledgedWriteModes, m.mode)) {
505
+ pr.current = {
488
506
  content: e,
489
507
  attachments: t,
490
508
  options: n
491
- }, Yn(l.mode);
509
+ }, gr(m.mode);
492
510
  return;
493
511
  }
494
- let u = l ? l.mode : i.mode, te, p, h = o ?? R, _ = h ? w.getState().conversations.find((e) => e.id === h) : void 0, re = l?.action === "escalate" && c ? {
495
- mode: c.mode,
496
- backendSessionId: c.backendSessionId ?? null
512
+ let h = m ? m.mode : i.mode, _, v, y = o ?? V, b = y ? D.getState().conversations.find((e) => e.id === y) : void 0, ae = m?.action === "escalate" && d ? {
513
+ mode: d.mode,
514
+ backendSessionId: d.backendSessionId ?? null
497
515
  } : null;
498
- if (l) l.action === "new" || !c ? h = B(void 0, u, { routedBy: "auto" }) : (h = c.id, An(h, u));
516
+ if (m) m.action === "new" || !d ? y = U(void 0, h, { routedBy: "auto" }) : (y = d.id, Vn(y, h));
499
517
  else {
500
518
  let e = i.autoRouting ? { routedBy: "auto" } : void 0;
501
- h ? _ && _.mode !== u && (_.messages.length > 0 || _.backendSessionId) ? h = B(void 0, u, e) : _ && _.mode !== u && (e ? An(h, u) : _n(h, u)) : h = B(void 0, u, e);
519
+ !y || l(b) || b && b.mode !== h && St(b) ? y = U(void 0, h, e) : b && b.mode !== h && (e ? Vn(y, h) : On(y, h));
502
520
  }
503
- if (!h) return;
504
- r && $n.current !== void 0 && h !== i.activeConversationId && ($n.current = h), n.approvalFollowUp || (er.current[h] = t);
505
- let v = () => w.getState().conversations.some((e) => e.id === h), y = dt(), b = {
506
- accessToken: P(),
507
- workspaceToken: F(),
508
- userId: I,
509
- organizationId: ut()
510
- }, se = (e, t) => {
511
- v() || !y || s(e, y, t, u, {
512
- accessToken: P(),
513
- workspaceToken: F(),
514
- userId: I,
515
- organizationId: ut()
521
+ if (!y) return;
522
+ r && xr.current !== void 0 && y !== i.activeConversationId && (xr.current = y), n.approvalFollowUp || (Sr.current[y] = t);
523
+ let oe = () => D.getState().conversations.some((e) => e.id === y), S = A(), C = {
524
+ accessToken: R(),
525
+ workspaceToken: z(),
526
+ userId: B,
527
+ organizationId: lt()
528
+ }, ce = (e, t) => {
529
+ oe() || !S || s(e, S, t, h, {
530
+ accessToken: R(),
531
+ workspaceToken: z(),
532
+ userId: B,
533
+ organizationId: lt()
516
534
  });
517
- }, ce = {
518
- id: $t(),
535
+ }, le = {
536
+ id: un(),
519
537
  role: "user",
520
538
  content: e,
521
539
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
522
540
  metadata: {
523
- ...t.length ? { attachments: t.map(Oe) } : {},
541
+ ...t.length ? { attachments: t.map(Te) } : {},
524
542
  ...n.approvalFollowUp ? {
525
543
  approvalFollowUp: !0,
526
544
  approvedReplyId: n.approvalFollowUp.approvedReplyId
527
545
  } : {},
528
- ...oe(n.voiceSessionId)
546
+ ...x(n.voiceSessionId)
529
547
  }
530
548
  };
531
- V(h, ce);
532
- let x = $t();
533
- V(h, {
534
- id: x,
549
+ W(y, le);
550
+ let w = un();
551
+ W(y, {
552
+ id: w,
535
553
  role: "assistant",
536
554
  content: "",
537
555
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
538
556
  metadata: {
539
- lang: pn,
540
- ...oe(n.voiceSessionId)
557
+ lang: wn,
558
+ ...x(n.voiceSessionId)
541
559
  }
542
- }), it(x, {
560
+ }), rt(w, {
543
561
  channel: r ? "voice" : "chat",
544
- mode: u,
545
- product: M,
546
- language: pn,
547
- device: at(),
548
- routedByAuto: !!l
549
- }, n.voiceTiming), E(x, "accepted"), Sn(h, "provisioning", x, null), ye(x);
550
- let ue = () => Ke({
551
- turnId: x,
552
- abortRequested: dr.current.has(x),
553
- activeTurnId: w.getState().processingByConversationId[h]?.messageId ?? null,
554
- conversationExists: v()
555
- }), de = (e, t, r, i, a = !1, o = pn) => {
556
- bn(h, x, { content: ie(e) }), xn(h, x, {
562
+ mode: h,
563
+ product: I,
564
+ language: wn,
565
+ device: it(),
566
+ routedByAuto: !!m
567
+ }, n.voiceTiming), k(w, "accepted"), Nn(y, "provisioning", w, null), ge(w);
568
+ let ue = () => We({
569
+ turnId: w,
570
+ abortRequested: Pr.current.has(w),
571
+ activeTurnId: D.getState().processingByConversationId[y]?.messageId ?? null,
572
+ conversationExists: oe()
573
+ }), de = (e, t, r, i, a = !1, o = wn) => {
574
+ jn(y, w, { content: re(e) }), Mn(y, w, {
557
575
  lang: o,
558
576
  ...t?.length ? { artifacts: t } : {},
559
- ...t?.length || r || i ? { mode: u } : {},
577
+ ...t?.length || r || i ? { mode: h } : {},
560
578
  ...r ? { sessionId: r } : {},
561
579
  ...i ? { sandboxId: i } : {},
562
580
  ...a ? { incomplete: !0 } : {},
563
- ...oe(n.voiceSessionId)
581
+ ...x(n.voiceSessionId)
564
582
  });
565
583
  }, fe = async (n = 1) => {
566
- E(x, "attemptStarted");
584
+ k(w, "attemptStarted");
567
585
  let i = null, a = null, o = !1;
568
586
  try {
569
- let { sandboxId: n, sessionId: s, sessionIsNew: c, readAhead: l, sandboxIsNew: m, sandboxProbed: _, sandboxAdopted: re, deadSandboxProbe: oe } = await ar(h, x, u, y, b, { isAbandoned: () => Ke({
570
- turnId: x,
571
- abortRequested: dr.current.has(x),
572
- activeTurnId: w.getState().processingByConversationId[h]?.messageId ?? null,
573
- conversationExists: v()
587
+ let { sandboxId: n, sessionId: s, sessionIsNew: c, readAhead: l, sandboxIsNew: u, sandboxProbed: d, sandboxAdopted: m, deadSandboxProbe: te } = await Or(y, w, h, S, C, { isAbandoned: () => We({
588
+ turnId: w,
589
+ abortRequested: Pr.current.has(w),
590
+ activeTurnId: D.getState().processingByConversationId[y]?.messageId ?? null,
591
+ conversationExists: oe()
574
592
  }).abandon });
575
- i = n, E(x, "runtimeReady"), T(x, {
576
- runtime: m ? "cold" : re ? "adopted" : _ ? "probed" : c ? "new-session" : "warm",
577
- deadSandboxProbe: oe
593
+ i = n, k(w, "runtimeReady"), O(w, {
594
+ runtime: u ? "cold" : m ? "adopted" : d ? "probed" : c ? "new-session" : "warm",
595
+ deadSandboxProbe: te
578
596
  }), a = s;
579
- let ce = Re(w.getState().conversations.find((e) => e.id === h), e, c), fe = await Qe(() => f(n, y, s, u, b, { limit: 50 }), c, Ze(l, n, s));
580
- rr(h, x, "streaming", "thinking");
581
- let S = nn?.(), { prompt: pe, parts: me } = Pe({
582
- content: ce ? `${ce}${e}` : e,
597
+ let b = kt({
598
+ conversation: D.getState().conversations.find((e) => e.id === y),
599
+ content: e,
600
+ sessionIsNew: c,
601
+ sendingMode: h,
602
+ sendingModeConfig: _,
603
+ modes: ir.current,
604
+ answerText: (e) => $e(e).text
605
+ }), x = await Xe(() => p(n, S, s, h, C, { limit: 50 }), c, Ye(l, n, s));
606
+ Er(y, w, "streaming", "thinking");
607
+ let ae = pn?.(), { prompt: fe, parts: T } = je({
608
+ content: b ? `${b}${e}` : e,
583
609
  attachments: t,
584
- limits: De(te),
585
- wrapPrompt: (e) => rn?.(u, e, dn, fn, r) ?? e,
610
+ limits: we(_),
611
+ wrapPrompt: (e) => mn?.(h, e, Sn, Cn, r) ?? e,
586
612
  requestBytes: (e, t) => ne({
587
613
  sandboxId: n,
588
- workspaceId: y,
614
+ workspaceId: S,
589
615
  sessionId: s,
590
- mode: u,
616
+ mode: h,
591
617
  prompt: e,
592
618
  parts: t,
593
- pageContext: S,
594
- authContext: b
619
+ pageContext: ae,
620
+ authContext: C
595
621
  })
596
- }), he = we(me), ge = he > 0;
597
- o = Ce(t) > he;
598
- let _e = ue();
599
- if (_e.abandon) {
600
- _e.clearProcessing && Cn(h);
622
+ }), pe = xe(T), me = pe > 0;
623
+ o = be(t) > pe;
624
+ let he = ue();
625
+ if (he.abandon) {
626
+ he.clearProcessing && Pn(y);
601
627
  return;
602
628
  }
603
629
  try {
604
- await g(n, y, s, pe, u, S, b, me?.length ? { parts: me } : void 0);
630
+ await g(n, S, s, fe, h, ae, C, T?.length ? { parts: T } : void 0);
605
631
  } catch (e) {
606
- if (!me || !ft(e)) throw e;
607
- await g(n, y, s, pe, u, S, b, void 0), o ||= ge;
632
+ if (!T || !ut(e)) throw e;
633
+ await g(n, S, s, fe, h, ae, C, void 0), o ||= me;
608
634
  }
609
- E(x, "promptSent");
610
- let ve = null, ye = !1, be = Ye, C = Xe([], fe), xe = Date.now() + p.streamBudgetMs, Se = Date.now(), Te = Date.now();
611
- for (; Date.now() < xe;) {
612
- se(n, s);
635
+ k(w, "promptSent");
636
+ let ge = null, _e = !1, ve = qe, E = Je([], x), ye = Date.now() + v.streamBudgetMs, Se = Date.now(), Ce = Date.now();
637
+ for (; Date.now() < ye;) {
638
+ ce(n, s);
613
639
  let e = ue();
614
640
  if (e.abandon) {
615
- e.clearProcessing && Cn(h);
641
+ e.clearProcessing && Pn(y);
616
642
  return;
617
643
  }
618
- if (C = Xe(await f(n, y, s, u, b, {
644
+ if (E = Je(await p(n, S, s, h, C, {
619
645
  limit: 50,
620
- sinceMs: fe
621
- }), fe, { accumulateNarration: p.accumulatesNarration }), bn(h, x, { content: ie(C.content) }), C.hasRenderableOutput ? ye || (ye = !0, ve !== null && E(x, "lastQuietPoll", ve), E(x, "firstOutput")) : ve = st(), p.accumulatesNarration) C.hasText && E(x, "firstText");
646
+ sinceMs: x
647
+ }), x, { accumulateNarration: v.accumulatesNarration }), jn(y, w, { content: re(E.content) }), E.hasRenderableOutput ? _e || (_e = !0, ge !== null && k(w, "lastQuietPoll", ge), k(w, "firstOutput")) : ge = ot(), v.accumulatesNarration) E.hasText && k(w, "firstText");
622
648
  else {
623
- let e = et(be, C, st());
624
- be = e.tracker, e.confirmedAt !== null && E(x, "firstText", e.confirmedAt);
649
+ let e = Qe(ve, E, ot());
650
+ ve = e.tracker, e.confirmedAt !== null && k(w, "firstText", e.confirmedAt);
625
651
  }
626
- if (C.pendingWrite && xn(h, x, { pendingWrite: C.pendingWrite }), C.done) {
627
- E(x, "answerDone"), q.current.markVerified(n);
652
+ if (E.pendingWrite && Mn(y, w, { pendingWrite: E.pendingWrite }), E.done) {
653
+ k(w, "answerDone"), J.current.markVerified(n);
628
654
  break;
629
655
  }
630
- Date.now() - Se > 3e4 && (await ee(n, y, 600, b).catch(() => void 0), Se = Date.now()), await new Promise((e) => setTimeout(e, le(Date.now() - Te)));
656
+ Date.now() - Se > 3e4 && (await ee(n, S, 600, C).catch(() => void 0), Se = Date.now()), await new Promise((e) => setTimeout(e, se(Date.now() - Ce)));
631
657
  }
632
- let Ee = p.producesArtifacts ? await d(n, y, s, u, b).then((e) => e).catch(() => []) : void 0;
633
- C.usedTools !== void 0 && T(x, { usedTools: C.usedTools }), C.done || (T(x, { outcome: "timedOut" }), C = {
634
- ...C,
635
- content: ae(C.content, u, j, te)
636
- }), o && (C = {
637
- ...C,
638
- content: `${C.content}\n\n${j("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._")}`
658
+ let Te = v.producesArtifacts ? await f(n, S, s, h, C).then((e) => e).catch(() => []) : void 0;
659
+ E.usedTools !== void 0 && O(w, { usedTools: E.usedTools }), E.done || (O(w, { outcome: "timedOut" }), E = {
660
+ ...E,
661
+ content: ie(E.content, h, F, _)
662
+ }), o && (E = {
663
+ ...E,
664
+ content: `${E.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._")}`
639
665
  });
640
- let Oe = !C.done;
641
- if (de(C.content, Ee, s, n, Oe), C.tokens) {
642
- bn(h, x, { tokens: C.tokens });
666
+ let Ee = !E.done;
667
+ if (de(E.content, Te, s, n, Ee), E.tokens) {
668
+ jn(y, w, { tokens: E.tokens });
643
669
  try {
644
- await on?.({
645
- workspaceId: y,
670
+ await gn?.({
671
+ workspaceId: S,
646
672
  sessionId: s,
647
- messageId: C.messageId,
648
- model: C.model,
649
- tokens: C.tokens
650
- }), Vt(M);
673
+ messageId: E.messageId,
674
+ model: E.model,
675
+ tokens: E.tokens
676
+ }), Xt(I);
651
677
  } catch {}
652
678
  }
653
- C.done || se(n, s);
654
- let ke = ue();
655
- if (ke.abandon) {
656
- ke.clearProcessing && Cn(h);
679
+ E.done || ce(n, s);
680
+ let De = ue();
681
+ if (De.abandon) {
682
+ De.clearProcessing && Pn(y);
657
683
  return;
658
684
  }
659
- E(x, "complete"), T(x, { outcome: "answered" }), Sn(h, "complete", x, null);
685
+ k(w, "complete"), O(w, { outcome: "answered" }), Nn(y, "complete", w, null), Dt.recordCommittedEntries(y, [le.id, w], "TURN", S);
660
686
  } catch (e) {
661
- q.current.invalidate(i ?? w.getState().sandboxesByMode[u]?.sandboxId ?? null);
662
- let t = Ke({
663
- turnId: x,
664
- abortRequested: dr.current.has(x),
665
- activeTurnId: w.getState().processingByConversationId[h]?.messageId ?? null,
666
- conversationExists: v()
687
+ J.current.invalidate(i ?? D.getState().sandboxesByMode[h]?.sandboxId ?? null);
688
+ let t = We({
689
+ turnId: w,
690
+ abortRequested: Pr.current.has(w),
691
+ activeTurnId: D.getState().processingByConversationId[y]?.messageId ?? null,
692
+ conversationExists: oe()
667
693
  });
668
- if (i && a && se(i, a), t.abandon) {
669
- t.clearProcessing && Cn(h);
694
+ if (i && a && ce(i, a), t.abandon) {
695
+ t.clearProcessing && Pn(y);
670
696
  return;
671
697
  }
672
- if (n === 1 && pt(e)) {
673
- let e = i ?? w.getState().sandboxesByMode[u]?.sandboxId ?? null;
674
- return e && (J.current.add(e), q.current.invalidate(e)), Tn(h), U(u), yn(h, x, ""), xn(h, x, { pendingWrite: void 0 }), ot(x), fe(2);
698
+ if (n === 1 && dt(e)) {
699
+ let e = i ?? D.getState().sandboxesByMode[h]?.sandboxId ?? null;
700
+ return e && (Y.current.add(e), J.current.invalidate(e)), In(y), K(h), An(y, w, ""), Mn(y, w, { pendingWrite: void 0 }), at(w), fe(2);
675
701
  }
676
702
  throw e;
677
703
  }
678
- }, S = h;
679
- tr.current.add(S);
704
+ }, T = y;
705
+ Cr.current.add(T);
680
706
  try {
681
- if (!y) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
707
+ if (!S) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
682
708
  code: "UNAUTHENTICATED",
683
709
  authFailure: "WORKSPACE_CONTEXT_MISSING"
684
710
  } });
685
- let e = await Ne(u, () => zn.current.find((e) => e.id === u), G);
686
- te = e.config, p = e.capabilities;
687
- let t = te, n = ue();
711
+ let e = await Ae(h, () => ir.current.find((e) => e.id === h), rr);
712
+ _ = e.config, v = e.capabilities;
713
+ let t = _, n = ue();
688
714
  if (n.abandon) {
689
- n.clearProcessing && Cn(h);
715
+ n.clearProcessing && Pn(y);
690
716
  return;
691
717
  }
692
- let i = Ie(u, t, w.getState().acknowledgedWriteModes, {
718
+ let i = Ne(h, t, D.getState().acknowledgedWriteModes, {
693
719
  dictated: r,
694
- confirmsWrites: m(u)
720
+ confirmsWrites: te(h)
695
721
  });
696
- if (i) throw new ke(i, i === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
697
- E(x, "cleared"), await fe();
722
+ if (i) throw new Ee(i, i === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
723
+ k(w, "cleared"), await fe();
698
724
  } catch (e) {
699
- if (q.current.invalidate(w.getState().sandboxesByMode[u]?.sandboxId ?? null), !v()) {
700
- Cn(h);
725
+ if (J.current.invalidate(D.getState().sandboxesByMode[h]?.sandboxId ?? null), !oe()) {
726
+ Pn(y);
701
727
  return;
702
728
  }
703
- let t = Ae(e);
704
- T(x, { outcome: t.kind === "temporary" ? "failed" : "refused" }), t.offersUpgrade && Bt(M, "sandbox");
705
- let r = je(t, j);
706
- Sn(h, "error", x, r.headline), bn(h, x, { content: r.text }), xn(h, x, {
707
- lang: r.translated ? L : "en",
708
- ...oe(n.voiceSessionId)
729
+ let t = De(e);
730
+ O(w, { outcome: t.kind === "temporary" ? "failed" : "refused" }), t.offersUpgrade && Yt(I, "sandbox");
731
+ let r = Oe(t, F);
732
+ Nn(y, "error", w, r.headline), jn(y, w, { content: r.text }), Mn(y, w, {
733
+ lang: r.translated ? vn : "en",
734
+ ...x(n.voiceSessionId)
709
735
  });
710
736
  } finally {
711
- tr.current.delete(S), T(x, { outcome: "stopped" }), E(x, "complete");
712
- let e = w.getState(), t = Ve(re, u, e.conversations.find((e) => e.id === S), (t) => !!e.sandboxesByMode[t]?.sandboxId);
713
- t && (An(S, t.mode), t.backendSessionId && wn(S, t.backendSessionId));
714
- let n = fr.current;
715
- fr.current = null, n && n.conversationId === S && v() && Cr.current(n.content, n.attachments, n.options);
737
+ Cr.current.delete(T), O(w, { outcome: "stopped" }), k(w, "complete");
738
+ let e = D.getState(), t = Le(ae, h, e.conversations.find((e) => e.id === T), (t) => !!e.sandboxesByMode[t]?.sandboxId);
739
+ t && (Vn(T, t.mode), t.backendSessionId && Fn(T, t.backendSessionId));
740
+ let n = Fr.current;
741
+ Fr.current = null, n && n.conversationId === T && oe() && Kr.current(n.content, n.attachments, n.options);
716
742
  }
717
743
  }, [
718
- R,
719
744
  V,
720
- rn,
745
+ W,
746
+ mn,
747
+ In,
748
+ K,
721
749
  Tn,
722
750
  U,
723
- mn,
724
- B,
725
- ar,
726
- nn,
727
- P,
728
- F,
729
- bn,
730
- M,
731
- G,
732
- on,
733
- fn,
734
- L,
751
+ Or,
735
752
  pn,
736
- dn,
737
- An,
738
- br,
753
+ R,
754
+ z,
755
+ jn,
756
+ I,
757
+ rr,
758
+ gn,
759
+ Cn,
760
+ vn,
739
761
  wn,
740
- _n,
741
762
  Sn,
742
- Cn,
743
- j,
744
- rr,
745
- yn,
746
- I
747
- ]), xr = D((e, t) => {
763
+ Vn,
764
+ Ur,
765
+ Fn,
766
+ On,
767
+ Nn,
768
+ Pn,
769
+ F,
770
+ Er,
771
+ An,
772
+ B
773
+ ]), Wr = j((e, t) => {
748
774
  X(e, [], t ? { autoIntent: t } : {});
749
- }, [X]), Sr = D(() => {
750
- let e = [...Mn.chat].reverse().find((e) => e.role === "user" && !e.metadata?.localAction);
775
+ }, [X]), Gr = j(() => {
776
+ let e = [...Un.chat].reverse().find((e) => e.role === "user" && !e.metadata?.localAction);
751
777
  if (!e || e.metadata?.approvalFollowUp) return;
752
- let t = R ? er.current[R] ?? [] : [];
778
+ let t = V ? Sr.current[V] ?? [] : [];
753
779
  X(e.content, t);
754
780
  }, [
755
- Nn,
781
+ Wn,
756
782
  X,
757
- R
758
- ]), Cr = k(X);
759
- O(() => {
760
- Cr.current = X;
783
+ V
784
+ ]), Kr = N(X);
785
+ M(() => {
786
+ Kr.current = X;
761
787
  }, [X]);
762
- let wr = qt(() => {
763
- if (Pn) return null;
764
- for (let e = Nn.length - 1; e >= 0; --e) {
765
- let t = Nn[e];
766
- if (t?.role !== "assistant" || !y(t) || dr.current.has(t.id)) continue;
767
- let n = Je(t, W, j);
788
+ let qr = nn(() => {
789
+ if (Gn) return null;
790
+ for (let e = Wn.length - 1; e >= 0; --e) {
791
+ let t = Wn[e];
792
+ if (t?.role !== "assistant" || !b(t) || Pr.current.has(t.id)) continue;
793
+ let n = Ke(t, q, F);
768
794
  if (n.kind !== "output") return null;
769
- let r = tt(n.text).text.trim();
795
+ let r = $e(n.text).text.trim();
770
796
  return r ? {
771
797
  id: t.id,
772
798
  text: r
@@ -774,53 +800,53 @@ var en = ({ visible: en = !0, writeAccess: tn = "unknown" }) => {
774
800
  }
775
801
  return null;
776
802
  }, [
777
- Nn,
778
- Pn,
779
- W,
780
- j
781
- ]), Tr = qt(() => wr ? ue(wr.text) : null, [wr]), Er = Mn.chat, Dr = w((e) => We(e)?.sandboxId ?? null), Or = C(Er, {
782
- sessionId: jn?.backendSessionId,
783
- sandboxId: Dr,
803
+ Wn,
804
+ Gn,
805
+ q,
806
+ F
807
+ ]), Jr = nn(() => qr ? ce(qr.text) : null, [qr]), Z = Un.chat, Yr = D((e) => He(e)?.sandboxId ?? null), Xr = ve(Z, {
808
+ sessionId: Hn?.backendSessionId,
809
+ sandboxId: Yr,
784
810
  nowMs: Date.now()
785
- }), kr = xe(Er), Ar = Or?.expiresAtMs ?? null;
786
- O(() => {
787
- if (Ar === null) return;
788
- let e = window.setTimeout(() => ur((e) => e + 1), Math.max(0, Ar - Date.now()));
811
+ }), Zr = E(Z), Qr = Xr?.expiresAtMs ?? null;
812
+ M(() => {
813
+ if (Qr === null) return;
814
+ let e = window.setTimeout(() => Nr((e) => e + 1), Math.max(0, Qr - Date.now()));
789
815
  return () => window.clearTimeout(e);
790
- }, [Ar, lr]);
791
- let Z = qt(() => Mn.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
816
+ }, [Qr, Mr]);
817
+ let Q = nn(() => Un.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
792
818
  id: e.id,
793
819
  role: e.role,
794
- text: rt(e, W, j),
795
- sessionId: b(e),
820
+ text: nt(e, q, F),
821
+ sessionId: ae(e),
796
822
  timestamp: e.timestamp
797
823
  })).filter((e) => e.text.length > 0), [
798
- Mn.voice,
799
- W,
800
- j
801
- ]), jr = D(() => {
802
- if (Z.length === 0) return;
824
+ Un.voice,
825
+ q,
826
+ F
827
+ ]), $r = j(() => {
828
+ if (Q.length === 0) return;
803
829
  let e = /* @__PURE__ */ new Date();
804
- yt(ce(Z, {
805
- title: j("voiceSession.transcript", "Voice conversation"),
806
- savedAt: j("voiceSession.savedAt", "Saved"),
807
- session: j("voiceSession.sessionLabel", "Session"),
808
- earlier: j("voiceSession.earlierLabel", "Earlier"),
809
- you: j("voiceSession.speakerYou", "You"),
810
- assistant: j("voiceSession.speakerAssistant", "Assistant")
811
- }, e), x(M, e), "text/markdown");
830
+ xt(S(Q, {
831
+ title: F("voiceSession.transcript", "Voice conversation"),
832
+ savedAt: F("voiceSession.savedAt", "Saved"),
833
+ session: F("voiceSession.sessionLabel", "Session"),
834
+ earlier: F("voiceSession.earlierLabel", "Earlier"),
835
+ you: F("voiceSession.speakerYou", "You"),
836
+ assistant: F("voiceSession.speakerAssistant", "Assistant")
837
+ }, e), C(I, e), "text/markdown");
812
838
  }, [
813
- M,
814
- Z,
815
- j
816
- ]), Q = Ht({ perFileChars: qn }), Mr = k(Q);
817
- Mr.current = Q;
818
- let Nr = k(/* @__PURE__ */ new Set()), Pr = k(() => !1), $ = lt({
819
- onSubmit: D((e, t, n) => {
820
- let r = $n.current, i = () => {
821
- let i = Mr.current, a = w.getState();
822
- if (!pe({
823
- sessionLive: Pr.current(t),
839
+ I,
840
+ Q,
841
+ F
842
+ ]), ei = Zt({ perFileChars: mr }), ti = N(ei);
843
+ ti.current = ei;
844
+ let ni = N(/* @__PURE__ */ new Set()), ri = N(() => !1), $ = ct({
845
+ onSubmit: j((e, t, n) => {
846
+ let r = xr.current, i = () => {
847
+ let i = ti.current, a = D.getState();
848
+ if (!de({
849
+ sessionLive: ri.current(t),
824
850
  boundAtSubmit: r,
825
851
  activeConversationId: a.activeConversationId,
826
852
  boundConversationExists: a.conversations.some((e) => e.id === r)
@@ -828,276 +854,308 @@ var en = ({ visible: en = !0, writeAccess: tn = "unknown" }) => {
828
854
  i.clear();
829
855
  return;
830
856
  }
831
- let o = Te(i.attachments), s = {
857
+ let o = Se(i.attachments), s = {
832
858
  ...n,
833
- handedOver: st()
859
+ handedOver: ot()
834
860
  };
835
- Cr.current(e, o, {
861
+ Kr.current(e, o, {
836
862
  fromPerson: !0,
837
863
  voiceSessionId: t,
838
864
  voiceTiming: s
839
865
  }), i.clear();
840
866
  };
841
- if (!Mr.current.isBusy) {
867
+ if (!ti.current.isBusy) {
842
868
  i();
843
869
  return;
844
870
  }
845
- let a = Date.now(), o = Nr.current, s = window.setInterval(() => {
846
- Mr.current.isBusy && Date.now() - a < Qt || (window.clearInterval(s), o.delete(s), i());
871
+ let a = Date.now(), o = ni.current, s = window.setInterval(() => {
872
+ ti.current.isBusy && Date.now() - a < cn || (window.clearInterval(s), o.delete(s), i());
847
873
  }, 200);
848
874
  o.add(s);
849
875
  }, []),
850
- latestReply: wr,
851
- language: de(cn, L).tag
876
+ latestReply: qr,
877
+ language: le(yn, vn).tag
852
878
  });
853
- Pr.current = $.isCurrentSession;
854
- let Fr = $.start, Ir = D(() => {
855
- or(!0), Fr();
856
- }, [or, Fr]), Lr = qt(() => (jn?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [jn?.messages]), Rr = nt(Mn.voice, W, j), zr = Rr > Lr, Br = D(() => {
857
- let e = w.getState().activeConversationId;
858
- !e || Z.length === 0 || (V(e, {
859
- id: $t(),
879
+ ri.current = $.isCurrentSession;
880
+ let ii = N(!1);
881
+ M(() => {
882
+ ii.current = $.active;
883
+ }, [$.active]), M(() => Ve((e) => {
884
+ if (!ii.current) return !1;
885
+ let t = xr.current;
886
+ return typeof t == "string" ? t === e : D.getState().activeConversationId === e;
887
+ }), []);
888
+ let ai = $.start, oi = j(() => {
889
+ kr(!0), ai();
890
+ }, [kr, ai]), si = nn(() => tt(Hn?.messages ?? []), [Hn?.messages]), ci = et(Un.voice, q, F), li = et(si, q, F) > 0, ui = j(() => {
891
+ let e = D.getState().activeConversationId;
892
+ if (!e || Q.length === 0) return;
893
+ let t = new Set(si.map((e) => e.id)), n = un();
894
+ W(e, {
895
+ id: n,
860
896
  role: "system",
861
- content: se(Z.slice(Lr), {
862
- intro: j("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
863
- nothing: j("voiceSession.continuedNothing", "Continued from a voice conversation."),
864
- more: (e) => j("voiceSession.continuedMore", "…and {{count}} more", { count: e })
897
+ content: oe(Q.filter((e) => t.has(e.id)), {
898
+ intro: F("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
899
+ nothing: F("voiceSession.continuedNothing", "Continued from a voice conversation."),
900
+ more: (e) => F("voiceSession.continuedMore", "…and {{count}} more", { count: e })
865
901
  }),
866
902
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
867
- metadata: { continuedVoiceTurns: Rr }
868
- }), K(!1), $.end());
903
+ metadata: { continuedVoiceTurns: ci }
904
+ }), Dt.recordCommittedEntries(e, [n], "NOTE", A()), br(!1), $.end();
869
905
  }, [
870
- Z,
871
- Rr,
872
- Lr,
873
- V,
874
- j,
906
+ Q,
907
+ ci,
908
+ si,
909
+ W,
910
+ F,
875
911
  $,
876
- K
877
- ]), Vr = k(0);
878
- O(() => {
879
- $.active && (Vr.current = Rr);
912
+ br
913
+ ]), di = N(0);
914
+ M(() => {
915
+ $.active && (di.current = ci);
880
916
  }, [$.active]);
881
- let Hr = D(() => {
882
- let e = Rr > Vr.current;
883
- $.end(), e && K(!0);
917
+ let fi = j(() => {
918
+ let e = ci > di.current;
919
+ $.end(), e && br(!0);
884
920
  }, [
885
- Rr,
921
+ ci,
886
922
  $,
887
- K
923
+ br
888
924
  ]);
889
- O(() => {
890
- (!en || !nr) && $.active && $.end();
925
+ M(() => {
926
+ (!dn || !Tr) && $.active && $.end();
891
927
  }, [
892
- en,
893
- nr,
928
+ dn,
929
+ Tr,
894
930
  $
895
- ]), O(() => {
896
- let e = $n.current, t = w.getState(), n = he({
931
+ ]), M(() => {
932
+ let e = xr.current, t = D.getState(), n = T({
897
933
  sessionLive: $.active,
898
934
  bound: e,
899
935
  activeConversationId: t.activeConversationId,
900
936
  boundConversationExists: t.conversations.some((t) => t.id === e)
901
937
  });
902
- $n.current = n.bound, n.end && $.end();
938
+ xr.current = n.bound, n.end && $.end();
903
939
  }, [
904
940
  $,
905
- R,
906
- mn
941
+ V,
942
+ Tn
907
943
  ]);
908
- let Ur = k(S);
909
- O(() => {
910
- let e = me(Ur.current, {
911
- activeConversationId: R,
912
- chatTurnCount: Er.length,
913
- voiceTurnCount: Z.length,
944
+ let pi = N(ue);
945
+ M(() => {
946
+ let e = fe(pi.current, {
947
+ activeConversationId: V,
948
+ chatTurnCount: Z.length,
949
+ voiceTurnCount: Q.length,
914
950
  sessionLive: $.active,
915
- sessionBoundTo: $n.current,
916
- turnInFlight: Pn
951
+ sessionBoundTo: xr.current,
952
+ turnInFlight: Gn
917
953
  });
918
- Ur.current = e.state, e.open && K(!0);
954
+ pi.current = e.state, e.open && br(!0);
919
955
  }, [
920
- R,
921
- Er.length,
956
+ V,
922
957
  Z.length,
958
+ Q.length,
923
959
  $.active,
924
- Pn,
925
- K
926
- ]), O(() => {
960
+ Gn,
961
+ br
962
+ ]), M(() => {
927
963
  if (!$.active) {
928
- Mr.current.clear(), fr.current = null;
929
- for (let e of Nr.current) window.clearInterval(e);
930
- Nr.current.clear();
964
+ ti.current.clear(), Fr.current = null;
965
+ for (let e of ni.current) window.clearInterval(e);
966
+ ni.current.clear();
931
967
  }
932
- }, [$.active]), O(() => {
933
- let e = Nr.current;
968
+ }, [$.active]), M(() => {
969
+ let e = ni.current;
934
970
  return () => {
935
971
  for (let t of e) window.clearInterval(t);
936
972
  e.clear();
937
973
  };
938
- }, []), O(() => {
939
- let e = w.getState().consumePendingPrompt();
940
- return e && Cr.current(e), w.subscribe((e, t) => {
974
+ }, []), M(() => {
975
+ let e = D.getState().consumePendingPrompt();
976
+ return e && Kr.current(e), D.subscribe((e, t) => {
941
977
  if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
942
- let e = w.getState().consumePendingPrompt();
943
- e && Cr.current(e);
978
+ let e = D.getState().consumePendingPrompt();
979
+ e && Kr.current(e);
944
980
  }
945
981
  });
946
982
  }, []);
947
- let Wr = D((e) => {
948
- let t = R ? w.getState().conversations.find((e) => e.id === R) : void 0;
949
- if (t && (t.messages.length > 0 || t.backendSessionId)) {
983
+ let mi = j((e) => {
984
+ let t = V ? D.getState().conversations.find((e) => e.id === V) : void 0;
985
+ if (t && St(t)) {
950
986
  if (t.mode !== e) {
951
- let t = w.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !w.getState().processingByConversationId[t.id]);
952
- t ? vn(t.id) : B(void 0, e);
987
+ let t = Be(), n = D.getState().conversations.find((n) => n.mode === e && Tt(n, t) && !D.getState().processingByConversationId[n.id]);
988
+ n ? kn(n.id) : U(void 0, e);
953
989
  }
954
- } else R && _n(R, e);
955
- let n = w.getState().activeConversationId;
956
- n ? _n(n, e) : kn(!1), gn(e);
990
+ } else V && On(V, e);
991
+ let n = D.getState().activeConversationId;
992
+ n ? On(n, e) : Bn(!1), Dn(e);
957
993
  }, [
958
- R,
959
- B,
960
- vn,
994
+ V,
995
+ U,
961
996
  kn,
962
- _n,
963
- gn
964
- ]), Gr = D(() => {
965
- let e = w.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
997
+ Bn,
998
+ On,
999
+ Dn
1000
+ ]), hi = j(() => {
1001
+ let e = D.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
966
1002
  if (!t) {
967
- kn(!0), gn(Le);
1003
+ Bn(!0), Dn(Pe);
968
1004
  return;
969
1005
  }
970
1006
  if (t.routedBy === "auto") {
971
- kn(!0);
1007
+ Bn(!0);
972
1008
  return;
973
1009
  }
974
- if (t.messages.length === 0 && !t.backendSessionId) {
975
- An(t.id, Le);
1010
+ if (!St(t)) {
1011
+ Vn(t.id, Pe);
976
1012
  return;
977
1013
  }
978
- let n = e.conversations.find((t) => t.routedBy === "auto" && t.messages.length === 0 && !t.backendSessionId && !e.processingByConversationId[t.id]);
979
- n ? (vn(n.id), An(n.id, Le)) : B(void 0, Le, { routedBy: "auto" });
1014
+ let n = Be(), r = e.conversations.find((t) => t.routedBy === "auto" && Tt(t, n) && !e.processingByConversationId[t.id]);
1015
+ r ? (kn(r.id), Vn(r.id, Pe)) : U(void 0, Pe, { routedBy: "auto" });
980
1016
  }, [
981
- B,
982
- An,
983
- vn,
1017
+ U,
1018
+ Vn,
984
1019
  kn,
985
- gn
986
- ]), Kr = D((e) => {
987
- if (N.find((t) => t.id === e)?.writeCapable && !Fe(w.getState().acknowledgedWriteModes, e)) {
988
- Yn(e);
1020
+ Bn,
1021
+ Dn
1022
+ ]), gi = j((e) => {
1023
+ if (L.find((t) => t.id === e)?.writeCapable && !Me(D.getState().acknowledgedWriteModes, e)) {
1024
+ gr(e);
989
1025
  return;
990
1026
  }
991
- Wr(e);
992
- }, [Wr, N]), qr = D(() => {
993
- let e = Jn;
994
- if (Yn(null), !e) return;
995
- let t = Kn.current;
996
- if (Kn.current = null, t) {
997
- Dn(e), X(t.content, t.attachments, t.options);
1027
+ mi(e);
1028
+ }, [mi, L]), _i = j(() => {
1029
+ let e = hr;
1030
+ if (gr(null), !e) return;
1031
+ let t = pr.current;
1032
+ if (pr.current = null, t) {
1033
+ Rn(e), X(t.content, t.attachments, t.options);
998
1034
  return;
999
1035
  }
1000
- Dn(e), Wr(e);
1036
+ Rn(e), mi(e);
1001
1037
  }, [
1002
- Jn,
1003
- Dn,
1004
- Wr,
1038
+ hr,
1039
+ Rn,
1040
+ mi,
1005
1041
  X
1006
- ]), Jr = Jn === null ? void 0 : N.find((e) => e.id === Jn) ?? { id: Jn }, Yr = D(() => {
1007
- Yn(null);
1008
- let e = Kn.current;
1009
- Kn.current = null, e && X(e.content, e.attachments, {
1042
+ ]), vi = hr === null ? void 0 : L.find((e) => e.id === hr) ?? { id: hr }, yi = j(() => {
1043
+ gr(null);
1044
+ let e = pr.current;
1045
+ pr.current = null, e && X(e.content, e.attachments, {
1010
1046
  ...e.options,
1011
1047
  autoIntent: "read"
1012
1048
  });
1013
1049
  }, [X]);
1014
- return /* @__PURE__ */ Xt("div", {
1050
+ return /* @__PURE__ */ on("div", {
1015
1051
  className: "relative flex flex-1 flex-col overflow-hidden",
1016
1052
  children: [
1017
- /* @__PURE__ */ Xt("div", {
1053
+ /* @__PURE__ */ on("div", {
1018
1054
  className: "contents",
1019
1055
  inert: $.active || void 0,
1020
1056
  children: [
1021
- Z.length > 0 && !$.active ? /* @__PURE__ */ A(_t, {
1022
- count: Z.length,
1023
- onOpenTranscript: () => K(!0)
1057
+ er === null ? null : /* @__PURE__ */ P(gt, { onDismiss: () => $n(er) }),
1058
+ Q.length > 0 && !$.active ? /* @__PURE__ */ P(ht, {
1059
+ count: Q.length,
1060
+ onOpenTranscript: () => br(!0)
1024
1061
  }) : null,
1025
- Er.length === 0 ? /* @__PURE__ */ A(bt, {
1026
- mode: z,
1027
- onSuggestionClick: xr,
1028
- explainsAuto: Wn,
1029
- suggestions: Wn && z === "assistant" ? ze(N.find((e) => e.id === "assistant")?.suggestions ?? [], N.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
1030
- }) : /* @__PURE__ */ A("div", {
1062
+ Z.length === 0 && (Yn || Xn) ? /* @__PURE__ */ P(_t, {
1063
+ state: Yn ? "loading" : "failed",
1064
+ onRetry: ar
1065
+ }) : Z.length === 0 && Hn?.sync?.hasOlder ? /* @__PURE__ */ P("div", {
1031
1066
  className: "flex min-h-0 flex-1 flex-col",
1032
- children: /* @__PURE__ */ A(xt, {
1033
- onApprovePendingWrite: mr,
1034
- approvingWriteRef: cr,
1035
- approvableMessageId: Or?.messageId ?? null,
1036
- retryableMessageId: kr,
1037
- messages: Er,
1038
- processing: W ?? null,
1039
- streamingMessageId: Fn,
1040
- failedMessageId: In,
1041
- onRetry: cr === null ? Sr : void 0
1067
+ children: /* @__PURE__ */ P(yt, {
1068
+ onShowEarlier: or,
1069
+ disabled: Yn
1042
1070
  })
1071
+ }) : Z.length === 0 ? /* @__PURE__ */ P(Ot, {
1072
+ mode: H,
1073
+ onSuggestionClick: Wr,
1074
+ explainsAuto: dr,
1075
+ suggestions: dr && H === "assistant" ? Fe(L.find((e) => e.id === "assistant")?.suggestions ?? [], L.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
1076
+ }) : /* @__PURE__ */ on("div", {
1077
+ className: "flex min-h-0 flex-1 flex-col",
1078
+ children: [Hn?.sync?.hasOlder ? /* @__PURE__ */ P(yt, {
1079
+ onShowEarlier: or,
1080
+ disabled: Yn
1081
+ }) : null, /* @__PURE__ */ P(At, {
1082
+ onApprovePendingWrite: Lr,
1083
+ approvingWriteRef: jr,
1084
+ approvableMessageId: Xr?.messageId ?? null,
1085
+ retryableMessageId: Zr,
1086
+ messages: Z,
1087
+ processing: q ?? null,
1088
+ streamingMessageId: Kn,
1089
+ failedMessageId: qn,
1090
+ onRetry: jr === null ? Gr : void 0
1091
+ })]
1043
1092
  }),
1044
- /* @__PURE__ */ A(Ut, {
1045
- onStartVoiceSession: $.available && nr ? Ir : void 0,
1093
+ Jn ? /* @__PURE__ */ P(vt, { onStartNew: () => U() }) : null,
1094
+ Z.length > 0 && (Yn || Xn) ? /* @__PURE__ */ P(_t, {
1095
+ state: Yn ? "loading" : "failed",
1096
+ onRetry: ar,
1097
+ compact: !0
1098
+ }) : null,
1099
+ /* @__PURE__ */ P(Qt, {
1100
+ onStartVoiceSession: $.available && Tr ? oi : void 0,
1046
1101
  onSend: (e, t) => void X(e, t, { fromPerson: !0 }),
1047
- onDraftStart: sr,
1048
- disabled: Pn || cr !== null,
1049
- placeholder: z === "api-calls" ? j("chatArea.placeholderActions", "What would you like me to do?") : j("chatArea.placeholderGeneral", "Ask me anything…"),
1050
- mode: z,
1051
- writeAccessDenied: tn === "denied" && !!Y?.writeCapable,
1052
- availableModes: Hn,
1053
- attachmentCharsPerFile: qn,
1054
- onModeChange: Kr,
1055
- auto: Un ? {
1056
- active: Wn,
1057
- onSelect: Gr
1102
+ onDraftStart: Ar,
1103
+ disabled: Gn || jr !== null || Yn,
1104
+ readOnly: Jn,
1105
+ placeholder: H === "api-calls" ? F("chatArea.placeholderActions", "What would you like me to do?") : F("chatArea.placeholderGeneral", "Ask me anything…"),
1106
+ mode: H,
1107
+ writeAccessDenied: fn === "denied" && !!wr?.writeCapable,
1108
+ availableModes: lr,
1109
+ attachmentCharsPerFile: mr,
1110
+ onModeChange: gi,
1111
+ auto: ur ? {
1112
+ active: dr,
1113
+ onSelect: hi
1058
1114
  } : void 0
1059
1115
  })
1060
1116
  ]
1061
1117
  }),
1062
- Qn && !$.active ? /* @__PURE__ */ A(vt, {
1063
- turns: Z,
1064
- onClose: () => K(!1),
1065
- onSave: jr,
1066
- onContinueInChat: zr ? Br : void 0,
1067
- closeOnEscape: !0
1118
+ yr && !$.active ? /* @__PURE__ */ P(bt, {
1119
+ turns: Q,
1120
+ onClose: () => br(!1),
1121
+ onSave: $r,
1122
+ onContinueInChat: li ? ui : void 0,
1123
+ closeOnEscape: !0,
1124
+ onShowEarlier: Hn?.sync?.hasOlder ? or : void 0,
1125
+ showEarlierDisabled: Yn
1068
1126
  }) : null,
1069
- $.active && /* @__PURE__ */ A(St, {
1127
+ $.active && /* @__PURE__ */ P(jt, {
1070
1128
  session: $.session,
1071
1129
  notice: $.notice,
1072
1130
  capturing: $.capturing,
1073
1131
  interrupting: $.interrupting,
1074
1132
  awaitingEndpoint: $.awaitingEndpoint,
1075
- turns: Z,
1133
+ turns: Q,
1076
1134
  spokenChunks: $.spokenChunks,
1077
- attachments: Q.attachments,
1078
- onAttachFiles: Q.addFiles,
1079
- onRemoveAttachment: Q.remove,
1080
- onRetryAttachment: Q.retry,
1081
- canAttachMore: Q.canAddMore,
1082
- preparingAttachments: Q.preparingCount,
1083
- onSaveTranscript: jr,
1084
- onContinueInChat: Br,
1135
+ attachments: ei.attachments,
1136
+ onAttachFiles: ei.addFiles,
1137
+ onRemoveAttachment: ei.remove,
1138
+ onRetryAttachment: ei.retry,
1139
+ canAttachMore: ei.canAddMore,
1140
+ preparingAttachments: ei.preparingCount,
1141
+ onSaveTranscript: $r,
1142
+ onContinueInChat: ui,
1085
1143
  onInterrupt: () => {
1086
- $.interrupt(), pr();
1144
+ $.interrupt(), Ir();
1087
1145
  },
1088
- spoken: Tr,
1146
+ spoken: Jr,
1089
1147
  onToggleMute: $.toggleMute,
1090
- onEnd: Hr
1148
+ onEnd: fi
1091
1149
  }),
1092
- /* @__PURE__ */ A(Gt, {
1093
- open: Jn !== null,
1094
- mode: Jr,
1095
- currentMode: Y ?? { id: z },
1096
- onConfirm: qr,
1097
- onCancel: Yr
1150
+ /* @__PURE__ */ P(en, {
1151
+ open: hr !== null,
1152
+ mode: vi,
1153
+ currentMode: wr ?? { id: H },
1154
+ onConfirm: _i,
1155
+ onCancel: yi
1098
1156
  })
1099
1157
  ]
1100
1158
  });
1101
1159
  };
1102
1160
  //#endregion
1103
- export { en as AssistantChatArea };
1161
+ export { dn as AssistantChatArea };