@burdenoff/fe-libs 2026.925.6 → 2026.925.8

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 (52) hide show
  1. package/dist/chrome/Footer.d.ts +1 -1
  2. package/dist/chrome/Footer.js +2 -2
  3. package/dist/chrome/MobileTabBar.js +6 -6
  4. package/dist/chrome/ProductSideNav.js +9 -9
  5. package/dist/chrome/ProductSwitcher.d.ts +1 -1
  6. package/dist/chrome/sideNavigation/useSideNavigationState.js +3 -3
  7. package/dist/chrome.js +8 -8
  8. package/dist/shared/assistant/autoRouting.d.ts +3 -0
  9. package/dist/shared/assistant/autoRouting.d.ts.map +1 -1
  10. package/dist/shared/assistant/autoRouting.js +1 -1
  11. package/dist/shared/assistant/conversation.d.ts +20 -0
  12. package/dist/shared/assistant/conversation.d.ts.map +1 -1
  13. package/dist/shared/assistant/i18nManifest.d.ts +11 -0
  14. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  15. package/dist/shared/assistant/i18nManifest.js +11 -0
  16. package/dist/shared/assistant/index.d.ts +2 -0
  17. package/dist/shared/assistant/index.d.ts.map +1 -1
  18. package/dist/shared/assistant/localUiCommandCopy.d.ts +26 -0
  19. package/dist/shared/assistant/localUiCommandCopy.d.ts.map +1 -0
  20. package/dist/shared/assistant/localUiCommandCopy.js +37 -0
  21. package/dist/shared/assistant/localUiCommands.d.ts +124 -0
  22. package/dist/shared/assistant/localUiCommands.d.ts.map +1 -0
  23. package/dist/shared/assistant/localUiCommands.js +173 -0
  24. package/dist/shared/assistant/product.d.ts +13 -1
  25. package/dist/shared/assistant/product.d.ts.map +1 -1
  26. package/dist/shared/assistant/product.js +8 -6
  27. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  28. package/dist/shared/assistant/ui/AssistantChatArea.js +615 -524
  29. package/dist/shared/assistant/ui/AssistantMessageItem.d.ts +6 -0
  30. package/dist/shared/assistant/ui/AssistantMessageItem.d.ts.map +1 -1
  31. package/dist/shared/assistant/ui/AssistantMessageItem.js +3 -3
  32. package/dist/shared/assistant/ui/AssistantMessageList.d.ts.map +1 -1
  33. package/dist/shared/assistant/ui/AssistantMessageList.js +14 -7
  34. package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts +9 -0
  35. package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts.map +1 -1
  36. package/dist/shared/assistant/ui/AssistantSpeechProvider.js +243 -196
  37. package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
  38. package/dist/shared/assistant/ui/useVoiceSession.js +44 -43
  39. package/dist/shared/assistant/voice/captionText.d.ts.map +1 -1
  40. package/dist/shared/assistant/voice/captionText.js +1 -1
  41. package/dist/shared/assistant/voice/speakableText.d.ts.map +1 -1
  42. package/dist/shared/assistant/voice/speakableText.js +63 -62
  43. package/dist/shared/config/products.js +1 -1
  44. package/dist/shared/hooks/shell/index.d.ts +1 -1
  45. package/dist/shared/hooks/shell/index.d.ts.map +1 -1
  46. package/dist/shared/providers/shell/ThemeProvider.d.ts +6 -0
  47. package/dist/shared/providers/shell/ThemeProvider.d.ts.map +1 -1
  48. package/dist/shared/providers/shell/ThemeProvider.js +28 -25
  49. package/dist/shared/types/index.d.ts +1 -1
  50. package/dist/shared-assistant.js +16 -14
  51. package/dist/shared-hooks-shell.js +12 -12
  52. package/package.json +1 -1
@@ -1,254 +1,260 @@
1
- import { useI18n as e } from "../../providers/shell/I18nProvider.js";
2
- import { useAuthToken as t } from "../../providers/shell/AuthTokenProvider.js";
1
+ import { useThemeOrNull as e } from "../../providers/shell/ThemeProvider.js";
2
+ import { useI18n as t } from "../../providers/shell/I18nProvider.js";
3
+ import { useAuthToken as n } from "../../providers/shell/AuthTokenProvider.js";
3
4
  import "../../../shared-providers-shell.js";
4
- import { useAssistantProduct as n } from "../product.js";
5
- import { useAssistantTr as r } from "../i18n.js";
6
- import { isAssistantModeId as i } from "../modeIds.js";
7
- import { abortAssistantTurn as a, approvePendingWrite as o, createAssistantSandbox as s, createAssistantSession as c, extendAssistantSandboxTTL as l, findExistingSandboxWithStatus as ee, getAssistantArtifacts as te, getAssistantMessages as u, getAssistantSession as d, modeRequiresConfirmWrites as f, promptGatewayRequestBytes as ne, releaseSupersededAssistantSandboxes as p, sendAssistantPromptAsync as re, waitForAssistantServiceReady as m, waitForSandboxRunning as ie } from "../api.js";
8
- import { sanitize as ae } from "../progress.js";
9
- import { withIncompleteTurnNotice as oe } from "../streamBudget.js";
10
- import { isVoiceTurn as h, voiceMarker as se, voiceSessionIdOf as g } from "../voice/turnVisibility.js";
11
- import { buildContinuedFromVoiceNote as ce, buildVoiceTranscriptMarkdown as _, voiceTranscriptFilename as le } from "../voice/voiceTranscript.js";
12
- import { pollDelayMs as ue } from "../voice/assistantPollSchedule.js";
13
- import { toCaptionText as de } from "../voice/captionText.js";
14
- import { resolveAssistantLanguage as v } from "../voice/languages.js";
5
+ import { useAssistantProduct as r } from "../product.js";
6
+ import { useAssistantTr as i } from "../i18n.js";
7
+ import { useAssistantNavigate as a } from "./AssistantMarkdownRenderer.js";
8
+ import { isAssistantModeId as o } from "../modeIds.js";
9
+ import { abortAssistantTurn as s, approvePendingWrite as c, createAssistantSandbox as l, createAssistantSession as u, extendAssistantSandboxTTL as d, findExistingSandboxWithStatus as f, getAssistantArtifacts as p, getAssistantMessages as ee, getAssistantSession as m, modeRequiresConfirmWrites as te, promptGatewayRequestBytes as ne, releaseSupersededAssistantSandboxes as h, sendAssistantPromptAsync as re, waitForAssistantServiceReady as g, waitForSandboxRunning as _ } from "../api.js";
10
+ import { sanitize as ie } from "../progress.js";
11
+ import { withIncompleteTurnNotice as ae } from "../streamBudget.js";
12
+ import { isVoiceTurn as oe, voiceMarker as v, voiceSessionIdOf as y } from "../voice/turnVisibility.js";
13
+ import { buildContinuedFromVoiceNote as se, buildVoiceTranscriptMarkdown as ce, voiceTranscriptFilename as b } 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";
15
17
  import { resolveLanguagePair as fe } from "../voice/languagePair.js";
16
18
  import { countInlineImageCandidates as pe, countInlinedImageParts as me, getSendableAttachments as he, largestInlineCharsPerFile as ge, resolveAssistantInlineLimits as _e, toMessageAttachment as ve } from "../attachments.js";
17
- import { AssistantSendRefusal as ye, classifyTurnFailure as be, turnOutcomeCopy as xe } from "../turnOutcome.js";
18
- import { createAdminModeAccessGate as y, resolveAssistantSendModeAfterAccess as Se } from "../adminModeSendGate.js";
19
+ import { AssistantSendRefusal as ye, classifyTurnFailure as x, turnOutcomeCopy as be } from "../turnOutcome.js";
20
+ import { createAdminModeAccessGate as xe, resolveAssistantSendModeAfterAccess as Se } from "../adminModeSendGate.js";
19
21
  import { buildBoundedAttachmentTurn as Ce } from "../attachmentTurn.js";
20
22
  import { isWriteModeAcknowledged as we, writeModeSendRefusalReason as Te } from "../writeModeConsent.js";
21
- import { AUTO_READ_MODE as b, autoCarryOverFor as Ee, autoSuggestions as De, classifyAssistantIntent as Oe, escalationToUndo as ke, isAutoRoutingOffered as Ae, resolveAutoRoute as je } from "../autoRouting.js";
22
- import { resolveActiveModeSandbox as Me, useAssistantStore as x } from "../store.js";
23
- import { isTurnInFlight as Ne, planAbandonedTurn as Pe, planTurnAbort as Fe } from "../turnState.js";
24
- import { getAssistantDisplayContent as Ie } from "../displayContent.js";
25
- import { NO_FIRST_TEXT as Le, buildAssistantProgress as Re, snapshotReplyFloor as ze, trackFirstText as Be } from "../turnProgress.js";
26
- import { parseToolActivity as Ve } from "./AssistantToolActivity.js";
27
- import { countSpokenTurns as He, spokenTurnText as Ue } from "../spokenTurns.js";
28
- import { beginTurn as We, describeTurn as S, detectTurnDevice as Ge, markTurn as C, restartAttempt as Ke, turnClockMs as qe } from "../turnTimeline.js";
29
- import { useVoiceSession as Je } from "./useVoiceSession.js";
30
- import { getOrganizationId as Ye, getWorkspaceId as Xe } from "../context.js";
31
- import { isMultimodalBodyRejection as Ze, isRecoverableAssistantError as Qe } from "../transportErrors.js";
32
- import { createReadinessTracker as $e, planAfterTransportFailure as et, planTrustedSandboxFailure as tt } from "../sandboxReadiness.js";
33
- import { AssistantSpokenTurnsNotice as nt } from "./AssistantSpokenTurnsNotice.js";
34
- import { VoiceTranscriptDrawer as rt } from "./voice/VoiceTranscriptDrawer.js";
35
- import { downloadFile as it } from "../exportConversation.js";
36
- import { AssistantEmptyState as at } from "./AssistantEmptyState.js";
37
- import { AssistantMessageList as ot } from "./AssistantMessageList.js";
38
- import { AssistantVoiceSession as st } from "./voice/AssistantVoiceSession.js";
39
- import { useAssistantApiAccess as ct } from "../useAssistantApiAccess.js";
40
- import { useConversationTurns as lt } from "../useConversationTurns.js";
41
- import { WarmCancelled as ut, consumeWarm as dt, prewarmTarget as ft, settleWarmBeforeSend as pt, startWarm as mt, warmState as ht } from "../prewarm.js";
42
- import { dispatchAssistantQuotaExhausted as gt, notifyAiCreditsUpdated as _t } from "../aiCredits.js";
43
- import { useAssistantAttachments as vt } from "../useAssistantAttachments.js";
44
- import { AssistantComposer as yt } from "./composer/AssistantComposer.js";
45
- import { isProdRuntime as bt } from "../env.js";
46
- import { AssistantApiCallsConsentDialog as xt } from "./AssistantApiCallsConsentDialog.js";
47
- import { useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as St } from "react";
48
- import { jsx as O, jsxs as Ct } from "react/jsx-runtime";
23
+ import { AUTO_READ_MODE as Ee, autoCarryOverFor as De, autoSuggestions as Oe, classifyAssistantIntent as ke, escalationToUndo as Ae, isAutoRoutingOffered as je, resolveAutoRoute as Me } from "../autoRouting.js";
24
+ import { resolveActiveModeSandbox as Ne, useAssistantStore as S } from "../store.js";
25
+ import { isTurnInFlight as Pe, planAbandonedTurn as Fe, planTurnAbort as Ie } from "../turnState.js";
26
+ import { getAssistantDisplayContent as Le } from "../displayContent.js";
27
+ import { NO_FIRST_TEXT as Re, buildAssistantProgress as ze, snapshotReplyFloor as Be, trackFirstText as Ve } from "../turnProgress.js";
28
+ import { parseToolActivity as He } from "./AssistantToolActivity.js";
29
+ import { countSpokenTurns as Ue, spokenTurnText as We } from "../spokenTurns.js";
30
+ import { beginTurn as Ge, describeTurn as C, detectTurnDevice as Ke, markTurn as w, restartAttempt as qe, turnClockMs as Je } from "../turnTimeline.js";
31
+ import { useAssistantSpeech as Ye } from "./AssistantSpeechProvider.js";
32
+ import { useVoiceSession as Xe } from "./useVoiceSession.js";
33
+ import { getOrganizationId as Ze, getWorkspaceId as Qe } from "../context.js";
34
+ import { isMultimodalBodyRejection as $e, isRecoverableAssistantError as et } from "../transportErrors.js";
35
+ import { createReadinessTracker as tt, planAfterTransportFailure as nt, planTrustedSandboxFailure as rt } from "../sandboxReadiness.js";
36
+ import { AssistantSpokenTurnsNotice as it } from "./AssistantSpokenTurnsNotice.js";
37
+ import { VoiceTranscriptDrawer as at } from "./voice/VoiceTranscriptDrawer.js";
38
+ import { downloadFile as ot } from "../exportConversation.js";
39
+ import { AssistantEmptyState as st } from "./AssistantEmptyState.js";
40
+ import { AssistantMessageList as ct } from "./AssistantMessageList.js";
41
+ import { AssistantVoiceSession as lt } from "./voice/AssistantVoiceSession.js";
42
+ import { useAssistantApiAccess as ut } from "../useAssistantApiAccess.js";
43
+ import { useConversationTurns as dt } from "../useConversationTurns.js";
44
+ import { WarmCancelled as ft, consumeWarm as pt, prewarmTarget as mt, settleWarmBeforeSend as ht, startWarm as gt, warmState as _t } from "../prewarm.js";
45
+ import { isAlreadyThere as vt, matchLocalUiCommand as yt, navDestinations as bt, planThemeChange as xt } from "../localUiCommands.js";
46
+ import { chooseDestinationCopy as St, navigationCommandCopy as Ct, themeCommandCopy as wt } from "../localUiCommandCopy.js";
47
+ import { dispatchAssistantQuotaExhausted as Tt, notifyAiCreditsUpdated as Et } from "../aiCredits.js";
48
+ import { useAssistantAttachments as Dt } from "../useAssistantAttachments.js";
49
+ import { AssistantComposer as Ot } from "./composer/AssistantComposer.js";
50
+ import { isProdRuntime as kt } from "../env.js";
51
+ import { AssistantApiCallsConsentDialog as At } from "./AssistantApiCallsConsentDialog.js";
52
+ import { useVisibleNavItems as jt } from "../../../chrome/mobileTabBar/useVisibleNavItems.js";
53
+ import { useCallback as T, useEffect as E, useMemo as D, useRef as O, useState as Mt } from "react";
54
+ import { jsx as k, jsxs as Nt } from "react/jsx-runtime";
49
55
  //#region src/shared/assistant/ui/AssistantChatArea.tsx
50
- var wt = 600, Tt = 2e4;
51
- function Et() {
56
+ var Pt = 600, Ft = 2e4;
57
+ function It() {
52
58
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
53
59
  }
54
- var Dt = ({ visible: Dt = !0, writeAccess: Ot = "unknown" }) => {
55
- let k = r(), { product: A, modes: j, gatherPageContext: kt, buildPrompt: At, reportTokenUsage: jt } = n(), { getAccessToken: M, getWorkspaceToken: N, userId: P } = t(), { locale: Mt } = e(), Nt = x((e) => e.assistantLanguage), Pt = x((e) => e.replyLanguage), Ft = E(() => fe(Nt, Pt, Mt), [
56
- Nt,
57
- Pt,
58
- Mt
59
- ]), It = Ft.reply.english, Lt = Ft.replyIsExplicit, Rt = Ft.reply.code, { conversations: zt, activeConversationId: F, mode: I, processingByConversationId: Bt, setMode: L, setConversationMode: Vt, setActiveConversation: Ht, createConversation: R, addMessage: z, updateMessage: Ut, patchMessage: Wt, mergeMessageMetadata: Gt, setConversationProcessing: Kt, clearConversationProcessing: qt, setBackendSessionId: Jt, clearBackendSessionId: Yt, setSandbox: B, clearSandbox: V, acknowledgedWriteModes: Xt, acknowledgeWriteMode: Zt, autoRouting: Qt, setAutoRouting: $t, routeConversation: H } = x(), en = zt.find((e) => e.id === F), tn = lt(en), nn = tn.all, U = F ? Bt[F] : void 0, rn = Ne(U?.status), an = rn ? U?.messageId ?? null : null, on = U?.status === "error" ? U.messageId : null, { canUseApiCalls: W, loading: sn } = ct(Ye()), G = D(y({
60
- loading: sn,
61
- canUseAdminModes: W
62
- })).current, cn = D(j);
63
- T(() => {
64
- cn.current = j;
65
- }, [j]), T(() => {
60
+ var Lt = ({ visible: Lt = !0, writeAccess: Rt = "unknown" }) => {
61
+ let A = i(), { product: j, modes: M, gatherPageContext: zt, buildPrompt: Bt, reportTokenUsage: Vt, localUiCommands: Ht } = r(), { getAccessToken: N, getWorkspaceToken: P, userId: F } = n(), { locale: I } = t(), Ut = S((e) => e.assistantLanguage), Wt = S((e) => e.replyLanguage), Gt = D(() => fe(Ut, Wt, I), [
62
+ Ut,
63
+ Wt,
64
+ I
65
+ ]), Kt = Gt.reply.english, qt = Gt.replyIsExplicit, Jt = Gt.reply.code, { conversations: Yt, activeConversationId: L, mode: R, processingByConversationId: Xt, setMode: z, setConversationMode: Zt, setActiveConversation: Qt, createConversation: B, addMessage: V, updateMessage: $t, patchMessage: en, mergeMessageMetadata: tn, setConversationProcessing: nn, clearConversationProcessing: rn, setBackendSessionId: an, clearBackendSessionId: on, setSandbox: H, clearSandbox: U, acknowledgedWriteModes: sn, acknowledgeWriteMode: cn, autoRouting: ln, setAutoRouting: un, routeConversation: dn } = S(), fn = Yt.find((e) => e.id === L), pn = dt(fn), mn = pn.all, W = L ? Xt[L] : void 0, hn = Pe(W?.status), gn = hn ? W?.messageId ?? null : null, _n = W?.status === "error" ? W.messageId : null, { canUseApiCalls: vn, loading: yn } = ut(Ze()), G = O(xe({
66
+ loading: yn,
67
+ canUseAdminModes: vn
68
+ })).current, bn = O(M);
69
+ E(() => {
70
+ bn.current = M;
71
+ }, [M]), E(() => {
66
72
  G.update({
67
- loading: sn,
68
- canUseAdminModes: W
73
+ loading: yn,
74
+ canUseAdminModes: vn
69
75
  });
70
76
  }, [
71
77
  G,
72
- sn,
73
- W
74
- ]), T(() => () => {
78
+ yn,
79
+ vn
80
+ ]), E(() => () => {
75
81
  G.abandon();
76
82
  }, [G]);
77
- let ln = E(() => j.filter((e) => !e.requiresAdmin || W), [j, W]), un = Ae(ln), dn = Qt && un, fn = D(un);
78
- T(() => {
79
- fn.current = un;
80
- }, [un]);
81
- let pn = D(null), mn = ge(j), [hn, gn] = St(null), [_n, vn] = St(!1), yn = D({}), K = D($e()), q = D(/* @__PURE__ */ new Set()), bn = D(/* @__PURE__ */ new Set()), J = E(() => j.find((e) => e.id === I), [j, I]), xn = I === "assistant" || J !== void 0 && !J.writeCapable && !f(I);
82
- T(() => {
83
- if (I !== "assistant" && J?.writeCapable && !we(Xt, I)) {
84
- L("assistant");
83
+ let xn = D(() => M.filter((e) => !e.requiresAdmin || vn), [M, vn]), Sn = je(xn), Cn = ln && Sn, wn = O(Sn);
84
+ E(() => {
85
+ wn.current = Sn;
86
+ }, [Sn]);
87
+ let Tn = O(null), En = ge(M), [Dn, On] = Mt(null), [kn, An] = Mt(!1), jn = O({}), K = O(tt()), q = O(/* @__PURE__ */ new Set()), Mn = O(/* @__PURE__ */ new Set()), J = D(() => M.find((e) => e.id === R), [M, R]), Nn = R === "assistant" || J !== void 0 && !J.writeCapable && !te(R);
88
+ E(() => {
89
+ if (R !== "assistant" && J?.writeCapable && !we(sn, R)) {
90
+ z("assistant");
85
91
  return;
86
92
  }
87
- sn || (!J || J.requiresAdmin && !W) && I !== "assistant" && L("assistant");
93
+ yn || (!J || J.requiresAdmin && !vn) && R !== "assistant" && z("assistant");
88
94
  }, [
89
- I,
95
+ R,
90
96
  J,
91
- W,
92
- sn,
93
- L,
94
- Xt
97
+ vn,
98
+ yn,
99
+ z,
100
+ sn
95
101
  ]);
96
- let Y = w((e, t, n, r) => {
97
- Kt(e, n, t, null, r);
98
- }, [Kt]), Sn = w(async (e, t, n, r, a, o = null) => {
99
- let c = (e, t) => {
100
- r && Y(r.conversationId, r.assistantMessageId, e, t), o && (o.step = t, o.onStep?.(t));
101
- }, l = (e) => {
102
- r && C(r.assistantMessageId, e);
103
- }, te = () => o !== null && (o.signal.aborted || Xe() !== t), u = () => {
104
- if (te()) throw new ut("cancelled");
105
- }, d = x.getState().sandboxesByMode[e]?.sandboxId ?? null, f = !1, ne = !1, re = !1, ae = !1, oe = !1, h = async (r) => {
106
- if (a && !q.current.has(r) && K.current.isFresh(r)) return f = !0, !0;
107
- re = !0;
108
- let i = !1;
102
+ let Y = T((e, t, n, r) => {
103
+ nn(e, n, t, null, r);
104
+ }, [nn]), Pn = T(async (e, t, n, r, i, a = null) => {
105
+ let s = (e, t) => {
106
+ r && Y(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
107
+ }, c = (e) => {
108
+ r && w(r.assistantMessageId, e);
109
+ }, u = () => a !== null && (a.signal.aborted || Qe() !== t), d = () => {
110
+ if (u()) throw new ft("cancelled");
111
+ }, p = S.getState().sandboxesByMode[e]?.sandboxId ?? null, ee = !1, m = !1, te = !1, ne = !1, re = !1, ie = async (r) => {
112
+ if (i && !q.current.has(r) && K.current.isFresh(r)) return ee = !0, !0;
113
+ te = !0;
114
+ let o = !1;
109
115
  try {
110
- await ie(r, t, n, 3e5), await m(r, t, e, n, 9e4, () => {
111
- i = !0;
116
+ await _(r, t, n, 3e5), await g(r, t, e, n, 9e4, () => {
117
+ o = !0;
112
118
  });
113
119
  } catch {
114
- if (te()) throw new ut("cancelled");
115
- return K.current.invalidate(r), q.current.add(r), o?.dead.push(r), oe = !0, !1;
120
+ if (u()) throw new ft("cancelled");
121
+ return K.current.invalidate(r), q.current.add(r), a?.dead.push(r), re = !0, !1;
116
122
  }
117
- return u(), K.current.markVerified(r), i && (ae = !0), !0;
123
+ return d(), K.current.markVerified(r), o && (ne = !0), !0;
118
124
  };
119
- if (d && (B(e, d, "provisioning"), c("provisioning", "reusingEnvironment"), await h(d) || (B(e, null, "provisioning"), d = null)), !d) {
120
- c("provisioning", "lookingForEnvironment");
121
- let r = await ee(t, A, e, bt(), n, q.current);
122
- u();
125
+ if (p && (H(e, p, "provisioning"), s("provisioning", "reusingEnvironment"), await ie(p) || (H(e, null, "provisioning"), p = null)), !p) {
126
+ s("provisioning", "lookingForEnvironment");
127
+ let r = await f(t, j, e, kt(), n, q.current);
128
+ d();
123
129
  let i = r?.id ?? null;
124
- i && (B(e, i, "provisioning"), c("provisioning", "reusingEnvironment"), await h(i) ? (d = i, (r?.status === "PROVISIONING" || r?.status === "PENDING") && (ae = !0)) : B(e, null, "provisioning"));
130
+ i && (H(e, i, "provisioning"), s("provisioning", "reusingEnvironment"), await ie(i) ? (p = i, (r?.status === "PROVISIONING" || r?.status === "PENDING") && (ne = !0)) : H(e, null, "provisioning"));
125
131
  }
126
- if (!d) {
127
- if (o && !o.mayCreate) throw new ut("no-create");
128
- if (l("provisionStarted"), e === "api-calls" && !M()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
129
- c("provisioning", "startingEnvironment"), B(e, null, "provisioning");
130
- let r = o ? [] : await p(t, A, e, bt(), n, q.current);
132
+ if (!p) {
133
+ if (a && !a.mayCreate) throw new ft("no-create");
134
+ if (c("provisionStarted"), e === "api-calls" && !N()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
135
+ s("provisioning", "startingEnvironment"), H(e, null, "provisioning");
136
+ let r = a ? [] : await h(t, j, e, kt(), n, q.current);
131
137
  if (r.length > 0) {
132
138
  let e = new Set(r);
133
139
  for (let e of r) K.current.invalidate(e), q.current.add(e);
134
- let t = x.getState().sandboxesByMode;
135
- for (let [n, r] of Object.entries(t)) i(n) && r?.sandboxId && e.has(r.sandboxId) && V(n);
140
+ let t = S.getState().sandboxesByMode;
141
+ for (let [n, r] of Object.entries(t)) o(n) && r?.sandboxId && e.has(r.sandboxId) && U(n);
136
142
  }
137
- l("createRequested");
138
- let a = o?.beginCreate();
143
+ c("createRequested");
144
+ let i = a?.beginCreate();
139
145
  try {
140
- d = await s(A, e, t, bt(), wt, n);
146
+ p = await l(j, e, t, kt(), Pt, n);
141
147
  } finally {
142
- a?.();
148
+ i?.();
143
149
  }
144
- ne = !0, u(), B(e, d, "provisioning"), await ie(d, t, n, 3e5), u(), l("sandboxRunning"), await m(d, t, e, n, 9e4), u(), l("serviceReady"), K.current.markVerified(d);
150
+ m = !0, d(), H(e, p, "provisioning"), await _(p, t, n, 3e5), d(), c("sandboxRunning"), await g(p, t, e, n, 9e4), d(), c("serviceReady"), K.current.markVerified(p);
145
151
  }
146
- return B(e, d, "running"), {
147
- sandboxId: d,
148
- sandboxIsNew: ne,
149
- sandboxProbed: re,
150
- sandboxAdopted: ae,
151
- deadSandboxProbe: oe,
152
- trustedFromCache: f
152
+ return H(e, p, "running"), {
153
+ sandboxId: p,
154
+ sandboxIsNew: m,
155
+ sandboxProbed: te,
156
+ sandboxAdopted: ne,
157
+ deadSandboxProbe: re,
158
+ trustedFromCache: ee
153
159
  };
154
160
  }, [
155
- V,
156
- M,
157
- A,
158
- B,
161
+ U,
162
+ N,
163
+ j,
164
+ H,
159
165
  Y
160
- ]), Cn = w(async function e(t, n, r, i, a, o = {}) {
161
- let s = await pt(i, r, (e) => Y(t, n, "provisioning", e));
166
+ ]), Fn = T(async function e(t, n, r, i, a, o = {}) {
167
+ let s = await ht(i, r, (e) => Y(t, n, "provisioning", e));
162
168
  for (let e of s.dead) K.current.invalidate(e), q.current.add(e);
163
- s.verified && !q.current.has(s.verified) && K.current.markVerified(s.verified), s.joined && S(n, { prewarm: s.joined });
164
- let { sandboxId: l, sandboxIsNew: te, sandboxProbed: u, sandboxAdopted: f, deadSandboxProbe: ne, trustedFromCache: p } = await Sn(r, i, a, {
169
+ s.verified && !q.current.has(s.verified) && K.current.markVerified(s.verified), s.joined && C(n, { prewarm: s.joined });
170
+ let { sandboxId: c, sandboxIsNew: l, sandboxProbed: d, sandboxAdopted: p, deadSandboxProbe: ee, trustedFromCache: te } = await Pn(r, i, a, {
165
171
  conversationId: t,
166
172
  assistantMessageId: n
167
- }, o.trustCache !== !1), re = dt(i, r, l);
168
- !s.joined && re && S(n, { prewarm: "hit" });
169
- let m = x.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, ie = !1;
170
- if (m) try {
171
- let e = await d(l, i, m, r, a);
173
+ }, o.trustCache !== !1), ne = pt(i, r, c);
174
+ !s.joined && ne && C(n, { prewarm: "hit" });
175
+ let h = S.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, re = !1;
176
+ if (h) try {
177
+ let e = await m(c, i, h, r, a);
172
178
  if (e.mode !== r) throw Error(`Session mode mismatch: expected ${r}, received ${e.mode}`);
173
179
  } catch {
174
- Yt(t), m = null;
180
+ on(t), h = null;
175
181
  }
176
- if (!m) {
182
+ if (!h) {
177
183
  Y(t, n, "connecting", "preparingSession");
178
184
  let s;
179
185
  try {
180
- s = await c(l, i, r, a);
186
+ s = await u(c, i, r, a);
181
187
  } catch (s) {
182
- if (p) {
183
- K.current.invalidate(l);
184
- let c = tt(s, o.isAbandoned?.() ?? !1), te = c === "check-network";
185
- if (c === "check-network" && (c = await et(() => ee(i, A, r, bt(), a, q.current))), c !== "rethrow" && o.isAbandoned?.() && (c = "rethrow"), c !== "rethrow") {
186
- te || S(n, { cacheProofFailed: !0 }), c === "replace" && (q.current.add(l), Yt(t), V(r));
188
+ if (te) {
189
+ K.current.invalidate(c);
190
+ let l = rt(s, o.isAbandoned?.() ?? !1), u = l === "check-network";
191
+ if (l === "check-network" && (l = await nt(() => f(i, j, r, kt(), a, q.current))), l !== "rethrow" && o.isAbandoned?.() && (l = "rethrow"), l !== "rethrow") {
192
+ u || C(n, { cacheProofFailed: !0 }), l === "replace" && (q.current.add(c), on(t), U(r));
187
193
  let s = await e(t, n, r, i, a, {
188
194
  ...o,
189
195
  trustCache: !1
190
196
  });
191
- return te && (s.deadSandboxProbe || s.sandboxId !== l) && S(n, { cacheProofFailed: !0 }), {
197
+ return u && (s.deadSandboxProbe || s.sandboxId !== c) && C(n, { cacheProofFailed: !0 }), {
192
198
  ...s,
193
- sandboxProbed: s.sandboxProbed || u,
194
- sandboxAdopted: s.sandboxAdopted || f,
195
- deadSandboxProbe: s.deadSandboxProbe || ne
199
+ sandboxProbed: s.sandboxProbed || d,
200
+ sandboxAdopted: s.sandboxAdopted || p,
201
+ deadSandboxProbe: s.deadSandboxProbe || ee
196
202
  };
197
203
  }
198
204
  }
199
205
  throw s;
200
206
  }
201
- m = s.sessionId, Jt(t, m), ie = !0;
207
+ h = s.sessionId, an(t, h), re = !0;
202
208
  }
203
209
  return {
204
- sandboxId: l,
205
- sessionId: m,
206
- sessionIsNew: ie,
207
- sandboxIsNew: te,
208
- sandboxProbed: u,
209
- sandboxAdopted: f,
210
- deadSandboxProbe: ne
210
+ sandboxId: c,
211
+ sessionId: h,
212
+ sessionIsNew: re,
213
+ sandboxIsNew: l,
214
+ sandboxProbed: d,
215
+ sandboxAdopted: p,
216
+ deadSandboxProbe: ee
211
217
  };
212
218
  }, [
213
- Sn,
214
- Yt,
215
- V,
216
- A,
217
- Jt,
219
+ Pn,
220
+ on,
221
+ U,
222
+ j,
223
+ an,
218
224
  Y
219
- ]), wn = w((e) => {
220
- let t = Xe();
225
+ ]), In = T((e) => {
226
+ let t = Qe();
221
227
  if (!t) return;
222
- let n = x.getState(), r = Date.now(), i = ft({
228
+ let n = S.getState(), r = Date.now(), i = mt({
223
229
  autoRouting: n.autoRouting,
224
- autoOffered: fn.current,
230
+ autoOffered: wn.current,
225
231
  active: n.activeConversationId ? n.conversations.find((e) => e.id === n.activeConversationId) : void 0,
226
232
  selectedMode: n.mode,
227
- autoReadMode: b,
228
- modes: cn.current,
233
+ autoReadMode: Ee,
234
+ modes: bn.current,
229
235
  acknowledgedWriteModes: n.acknowledgedWriteModes,
230
236
  adminAccess: G.read(),
231
237
  dictated: e,
232
- turnInFlight: Object.values(n.processingByConversationId).some((e) => Ne(e?.status)),
233
- ...ht(t),
238
+ turnInFlight: Object.values(n.processingByConversationId).some((e) => Pe(e?.status)),
239
+ ..._t(t),
234
240
  now: r
235
241
  });
236
242
  if (!i) return;
237
- let a = mt(t, i, r), o = {
238
- accessToken: M(),
239
- workspaceToken: N(),
240
- userId: P,
241
- organizationId: Ye()
243
+ let a = gt(t, i, r), o = {
244
+ accessToken: N(),
245
+ workspaceToken: P(),
246
+ userId: F,
247
+ organizationId: Ze()
242
248
  };
243
- Sn(i.mode, t, o, null, !0, a).then((e) => a.finish({
249
+ Pn(i.mode, t, o, null, !0, a).then((e) => a.finish({
244
250
  ok: !0,
245
251
  sandboxId: e.sandboxId,
246
252
  didWork: !e.trustedFromCache && (e.sandboxIsNew || e.sandboxProbed || e.sandboxAdopted),
247
253
  dead: a.dead
248
254
  }), (e) => {
249
- if (!(e instanceof ut) && !a.signal.aborted && Xe() === t) {
250
- let e = x.getState().sandboxesByMode[i.mode]?.sandboxId ?? null;
251
- e && (K.current.invalidate(e), q.current.add(e), a.dead.push(e), V(i.mode));
255
+ if (!(e instanceof ft) && !a.signal.aborted && Qe() === t) {
256
+ let e = S.getState().sandboxesByMode[i.mode]?.sandboxId ?? null;
257
+ e && (K.current.invalidate(e), q.current.add(e), a.dead.push(e), U(i.mode));
252
258
  }
253
259
  a.finish({
254
260
  ok: !1,
@@ -257,65 +263,144 @@ var Dt = ({ visible: Dt = !0, writeAccess: Ot = "unknown" }) => {
257
263
  });
258
264
  });
259
265
  }, [
260
- Sn,
266
+ Pn,
261
267
  G,
262
- V,
263
- M,
268
+ U,
264
269
  N,
265
- P
266
- ]), Tn = w(() => wn(!1), [wn]), [En, Dn] = St(null), On = D(/* @__PURE__ */ new Set()), kn = D(null), An = w(() => {
267
- let e = x.getState(), t = e.activeConversationId;
270
+ P,
271
+ F
272
+ ]), Ln = T(() => In(!1), [In]), [Rn, zn] = Mt(null), Bn = O(/* @__PURE__ */ new Set()), Vn = O(null), Hn = T(() => {
273
+ let e = S.getState(), t = e.activeConversationId;
268
274
  if (!t) return;
269
- let n = e.processingByConversationId[t], r = Ne(n?.status) ? n?.messageId ?? null : null;
270
- if (!Fe({
275
+ let n = e.processingByConversationId[t], r = Pe(n?.status) ? n?.messageId ?? null : null;
276
+ if (!Ie({
271
277
  interruptedTurnId: r,
272
278
  activeTurnId: r,
273
- alreadyRequested: r ? On.current.has(r) : !1
279
+ alreadyRequested: r ? Bn.current.has(r) : !1
274
280
  }).send || !r) return;
275
- On.current.add(r);
276
- let i = Me(e), o = Xe(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
277
- !i || !o || !s || a(i.sandboxId, o, s, i.mode, {
278
- accessToken: M(),
279
- workspaceToken: N(),
280
- userId: P,
281
- organizationId: Ye()
281
+ Bn.current.add(r);
282
+ let i = Ne(e), a = Qe(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
283
+ !i || !a || !o || s(i.sandboxId, a, o, i.mode, {
284
+ accessToken: N(),
285
+ workspaceToken: P(),
286
+ userId: F,
287
+ organizationId: Ze()
282
288
  });
283
289
  }, [
284
- P,
285
- M,
286
- N
287
- ]), jn = w(async (e) => {
288
- let t = x.getState(), n = Me(t), r = Xe(), i = t.activeConversationId;
290
+ F,
291
+ N,
292
+ P
293
+ ]), Un = T(async (e) => {
294
+ let t = S.getState(), n = Ne(t), r = Qe(), i = t.activeConversationId;
289
295
  if (!(!n || !r || !i)) {
290
- Dn(e);
296
+ zn(e);
291
297
  try {
292
- await o(n.sandboxId, r, e, n.mode, {
293
- accessToken: M(),
294
- workspaceToken: N(),
295
- userId: P,
296
- organizationId: Ye()
298
+ await c(n.sandboxId, r, e, n.mode, {
299
+ accessToken: N(),
300
+ workspaceToken: P(),
301
+ userId: F,
302
+ organizationId: Ze()
297
303
  });
298
304
  } catch (e) {
299
- Dn(null), z(i, {
300
- id: Et(),
305
+ zn(null), V(i, {
306
+ id: It(),
301
307
  role: "system",
302
308
  content: e instanceof Error ? e.message : "The change could not be approved.",
303
309
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
304
310
  });
305
311
  return;
306
312
  }
307
- Dn(null), Pn.current(k("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
313
+ zn(null), Qn.current(A("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
308
314
  }
309
315
  }, [
310
- P,
311
- z,
312
- k
313
- ]), X = w(async (e, t = [], n = {}) => {
314
- let r = n.voiceSessionId !== void 0, i = x.getState(), a = i.activeConversationId ?? F;
316
+ F,
317
+ V,
318
+ A
319
+ ]), Wn = e(), { speakFinishedReply: Gn } = Ye(), Kn = a(), { items: qn } = jt(), Jn = O({
320
+ theme: Wn,
321
+ navigate: Kn,
322
+ navItems: qn,
323
+ options: Ht ?? {}
324
+ });
325
+ E(() => {
326
+ Jn.current = {
327
+ theme: Wn,
328
+ navigate: Kn,
329
+ navItems: qn,
330
+ options: Ht ?? {}
331
+ };
332
+ }, [
333
+ Wn,
334
+ Kn,
335
+ qn,
336
+ Ht
337
+ ]);
338
+ let Yn = T((e, t, n) => {
339
+ let { theme: r, navigate: i } = Jn.current, a, o;
340
+ if (e.kind === "theme") {
341
+ if (!r) return !1;
342
+ let t = xt(e.request, {
343
+ mode: r.mode,
344
+ resolvedTheme: r.resolvedTheme
345
+ });
346
+ if (!t.alreadyApplied) try {
347
+ r.setMode(t.mode);
348
+ } catch {}
349
+ a = wt(A, t, e.request.kind === "family"), o = {
350
+ kind: "theme",
351
+ mode: t.mode,
352
+ alreadyApplied: t.alreadyApplied
353
+ };
354
+ } else {
355
+ if (!i) return !1;
356
+ if (e.kind === "navigate") {
357
+ let { destination: t } = e, n = vt(t, window.location.pathname + window.location.search, bt(Jn.current.navItems));
358
+ n || i(t.path), a = Ct(A, t.label, n), o = {
359
+ kind: "navigate",
360
+ destinationId: t.id,
361
+ path: t.path,
362
+ alreadyHere: n
363
+ };
364
+ } else a = St(A, e.candidates[0]?.label ?? e.query, e.candidates), o = {
365
+ kind: "choose-destination",
366
+ candidateIds: e.candidates.map((e) => e.id)
367
+ };
368
+ }
369
+ let s = S.getState(), c = s.activeConversationId ?? B(void 0, s.autoRouting && wn.current ? "assistant" : s.mode, s.autoRouting ? { routedBy: "auto" } : void 0), l = (/* @__PURE__ */ new Date()).toISOString();
370
+ V(c, {
371
+ id: It(),
372
+ role: "user",
373
+ content: t,
374
+ timestamp: l,
375
+ metadata: {
376
+ localAction: o,
377
+ ...v(n)
378
+ }
379
+ });
380
+ let u = It();
381
+ return V(c, {
382
+ id: u,
383
+ role: "assistant",
384
+ content: a.text,
385
+ timestamp: l,
386
+ metadata: {
387
+ lang: a.translated ? I : "en",
388
+ localAction: o,
389
+ ...v(n)
390
+ }
391
+ }), Gn(c, u), !0;
392
+ }, [
393
+ V,
394
+ B,
395
+ I,
396
+ Gn,
397
+ A
398
+ ]), X = T(async (e, t = [], n = {}) => {
399
+ let r = n.voiceSessionId !== void 0, i = S.getState(), a = i.activeConversationId ?? L;
315
400
  if (a) {
316
- if (Ne(i.processingByConversationId[a]?.status)) {
401
+ if (Pe(i.processingByConversationId[a]?.status)) {
317
402
  let r = i.processingByConversationId[a]?.messageId ?? null;
318
- r && On.current.has(r) && (kn.current = {
403
+ r && Bn.current.has(r) && (Vn.current = {
319
404
  conversationId: a,
320
405
  content: e,
321
406
  attachments: t,
@@ -323,11 +408,15 @@ var Dt = ({ visible: Dt = !0, writeAccess: Ot = "unknown" }) => {
323
408
  });
324
409
  return;
325
410
  }
326
- if (bn.current.has(a)) return;
411
+ if (Mn.current.has(a)) return;
327
412
  }
328
- if (pn.current) return;
329
- let o = i.activeConversationId ? i.conversations.find((e) => e.id === i.activeConversationId) : void 0, s = i.autoRouting && fn.current ? je({
330
- intent: n.autoIntent ?? Oe(e),
413
+ if (Tn.current) return;
414
+ if (n.fromPerson && t.length === 0) {
415
+ let t = yt(e, bt(Jn.current.navItems), Jn.current.options);
416
+ if (t && Yn(t, e, n.voiceSessionId)) return;
417
+ }
418
+ let o = i.activeConversationId ? i.conversations.find((e) => e.id === i.activeConversationId) : void 0, s = i.autoRouting && wn.current ? Me({
419
+ intent: n.autoIntent ?? ke(e),
331
420
  dictated: r,
332
421
  conversation: o ? {
333
422
  mode: o.mode,
@@ -335,255 +424,256 @@ var Dt = ({ visible: Dt = !0, writeAccess: Ot = "unknown" }) => {
335
424
  hasHistory: o.messages.length > 0 || !!o.backendSessionId
336
425
  } : null
337
426
  }) : null;
338
- if (s && cn.current.find((e) => e.id === s.mode)?.writeCapable && !we(i.acknowledgedWriteModes, s.mode)) {
339
- pn.current = {
427
+ if (s && bn.current.find((e) => e.id === s.mode)?.writeCapable && !we(i.acknowledgedWriteModes, s.mode)) {
428
+ Tn.current = {
340
429
  content: e,
341
430
  attachments: t,
342
431
  options: n
343
- }, gn(s.mode);
432
+ }, On(s.mode);
344
433
  return;
345
434
  }
346
- let c = s ? s.mode : i.mode, ee, d, p = F, m = p ? x.getState().conversations.find((e) => e.id === p) : void 0, ie = s?.action === "escalate" && o ? {
435
+ let c = s ? s.mode : i.mode, l, u, f = L, m = f ? S.getState().conversations.find((e) => e.id === f) : void 0, h = s?.action === "escalate" && o ? {
347
436
  mode: o.mode,
348
437
  backendSessionId: o.backendSessionId ?? null
349
438
  } : null;
350
- if (s) s.action === "new" || !o ? p = R(void 0, c, { routedBy: "auto" }) : (p = o.id, H(p, c));
439
+ if (s) s.action === "new" || !o ? f = B(void 0, c, { routedBy: "auto" }) : (f = o.id, dn(f, c));
351
440
  else {
352
441
  let e = i.autoRouting ? { routedBy: "auto" } : void 0;
353
- p ? m && m.mode !== c && (m.messages.length > 0 || m.backendSessionId) ? p = R(void 0, c, e) : m && m.mode !== c && (e ? H(p, c) : Vt(p, c)) : p = R(void 0, c, e);
442
+ f ? m && m.mode !== c && (m.messages.length > 0 || m.backendSessionId) ? f = B(void 0, c, e) : m && m.mode !== c && (e ? dn(f, c) : Zt(f, c)) : f = B(void 0, c, e);
354
443
  }
355
- if (!p) return;
356
- yn.current[p] = t;
357
- let h = Xe(), g = {
358
- accessToken: M(),
359
- workspaceToken: N(),
360
- userId: P,
361
- organizationId: Ye()
362
- }, ce = {
363
- id: Et(),
444
+ if (!f) return;
445
+ jn.current[f] = t;
446
+ let g = Qe(), _ = {
447
+ accessToken: N(),
448
+ workspaceToken: P(),
449
+ userId: F,
450
+ organizationId: Ze()
451
+ }, oe = {
452
+ id: It(),
364
453
  role: "user",
365
454
  content: e,
366
455
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
367
456
  metadata: {
368
457
  ...t.length ? { attachments: t.map(ve) } : {},
369
- ...se(n.voiceSessionId)
458
+ ...v(n.voiceSessionId)
370
459
  }
371
460
  };
372
- z(p, ce);
373
- let _ = Et();
374
- z(p, {
375
- id: _,
461
+ V(f, oe);
462
+ let y = It();
463
+ V(f, {
464
+ id: y,
376
465
  role: "assistant",
377
466
  content: "",
378
467
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
379
468
  metadata: {
380
- lang: Rt,
381
- ...se(n.voiceSessionId)
469
+ lang: Jt,
470
+ ...v(n.voiceSessionId)
382
471
  }
383
- }), We(_, {
472
+ }), Ge(y, {
384
473
  channel: r ? "voice" : "chat",
385
474
  mode: c,
386
- product: A,
387
- language: Rt,
388
- device: Ge(),
475
+ product: j,
476
+ language: Jt,
477
+ device: Ke(),
389
478
  routedByAuto: !!s
390
- }, n.voiceTiming), C(_, "accepted"), Kt(p, "provisioning", _, null);
391
- let le = (e, t, r, i, a = Rt) => {
392
- Wt(p, _, { content: ae(e) }), Gt(p, _, {
479
+ }, n.voiceTiming), w(y, "accepted"), nn(f, "provisioning", y, null);
480
+ let se = (e, t, r, i, a = Jt) => {
481
+ en(f, y, { content: ie(e) }), tn(f, y, {
393
482
  lang: a,
394
483
  ...t?.length ? { artifacts: t } : {},
395
484
  ...t?.length || r || i ? { mode: c } : {},
396
485
  ...r ? { sessionId: r } : {},
397
486
  ...i ? { sandboxId: i } : {},
398
- ...se(n.voiceSessionId)
487
+ ...v(n.voiceSessionId)
399
488
  });
400
- }, de = async (n = 1) => {
401
- C(_, "attemptStarted");
489
+ }, ce = async (n = 1) => {
490
+ w(y, "attemptStarted");
402
491
  let i = null, a = !1;
403
492
  try {
404
- let { sandboxId: n, sessionId: o, sessionIsNew: s, sandboxIsNew: f, sandboxProbed: m, sandboxAdopted: ie, deadSandboxProbe: se } = await Cn(p, _, c, h, g, { isAbandoned: () => Pe({
405
- turnId: _,
406
- abortRequested: On.current.has(_),
407
- activeTurnId: x.getState().processingByConversationId[p]?.messageId ?? null
493
+ let { sandboxId: n, sessionId: o, sessionIsNew: s, sandboxIsNew: m, sandboxProbed: te, sandboxAdopted: h, deadSandboxProbe: oe } = await Fn(f, y, c, g, _, { isAbandoned: () => Fe({
494
+ turnId: y,
495
+ abortRequested: Bn.current.has(y),
496
+ activeTurnId: S.getState().processingByConversationId[f]?.messageId ?? null
408
497
  }).abandon });
409
- i = n, C(_, "runtimeReady"), S(_, {
410
- runtime: f ? "cold" : ie ? "adopted" : m ? "probed" : s ? "new-session" : "warm",
411
- deadSandboxProbe: se
498
+ i = n, w(y, "runtimeReady"), C(y, {
499
+ runtime: m ? "cold" : h ? "adopted" : te ? "probed" : s ? "new-session" : "warm",
500
+ deadSandboxProbe: oe
412
501
  });
413
- let ce = Ee(x.getState().conversations.find((e) => e.id === p), e, s), de = await ze(() => u(n, h, o, c, g, { limit: 50 }), s);
414
- Y(p, _, "streaming", "thinking");
415
- let v = kt?.(), { prompt: fe, parts: he } = Ce({
416
- content: ce ? `${ce}${e}` : e,
502
+ let v = De(S.getState().conversations.find((e) => e.id === f), e, s), ce = await Be(() => ee(n, g, o, c, _, { limit: 50 }), s);
503
+ Y(f, y, "streaming", "thinking");
504
+ let b = zt?.(), { prompt: ue, parts: de } = Ce({
505
+ content: v ? `${v}${e}` : e,
417
506
  attachments: t,
418
- limits: _e(ee),
419
- wrapPrompt: (e) => At?.(c, e, It, Lt, r) ?? e,
507
+ limits: _e(l),
508
+ wrapPrompt: (e) => Bt?.(c, e, Kt, qt, r) ?? e,
420
509
  requestBytes: (e, t) => ne({
421
510
  sandboxId: n,
422
- workspaceId: h,
511
+ workspaceId: g,
423
512
  sessionId: o,
424
513
  mode: c,
425
514
  prompt: e,
426
515
  parts: t,
427
- pageContext: v,
428
- authContext: g
516
+ pageContext: b,
517
+ authContext: _
429
518
  })
430
- }), ge = me(he), ve = ge > 0;
431
- a = pe(t) > ge;
519
+ }), fe = me(de), he = fe > 0;
520
+ a = pe(t) > fe;
432
521
  try {
433
- await re(n, h, o, fe, c, v, g, he?.length ? { parts: he } : void 0);
522
+ await re(n, g, o, ue, c, b, _, de?.length ? { parts: de } : void 0);
434
523
  } catch (e) {
435
- if (!he || !Ze(e)) throw e;
436
- await re(n, h, o, fe, c, v, g, void 0), a ||= ve;
524
+ if (!de || !$e(e)) throw e;
525
+ await re(n, g, o, ue, c, b, _, void 0), a ||= he;
437
526
  }
438
- C(_, "promptSent");
439
- let ye = null, be = !1, xe = Le, y = Re([], de), Se = Date.now() + d.streamBudgetMs, we = Date.now(), Te = Date.now(), b = () => Pe({
440
- turnId: _,
441
- abortRequested: On.current.has(_),
442
- activeTurnId: x.getState().processingByConversationId[p]?.messageId ?? null
527
+ w(y, "promptSent");
528
+ let ge = null, ve = !1, ye = Re, x = ze([], ce), be = Date.now() + u.streamBudgetMs, xe = Date.now(), Se = Date.now(), we = () => Fe({
529
+ turnId: y,
530
+ abortRequested: Bn.current.has(y),
531
+ activeTurnId: S.getState().processingByConversationId[f]?.messageId ?? null
443
532
  });
444
- for (; Date.now() < Se;) {
445
- let e = b();
533
+ for (; Date.now() < be;) {
534
+ let e = we();
446
535
  if (e.abandon) {
447
- e.clearProcessing && qt(p);
536
+ e.clearProcessing && rn(f);
448
537
  return;
449
538
  }
450
- if (y = Re(await u(n, h, o, c, g, {
539
+ if (x = ze(await ee(n, g, o, c, _, {
451
540
  limit: 50,
452
- sinceMs: de
453
- }), de, { accumulateNarration: d.accumulatesNarration }), Wt(p, _, { content: ae(y.content) }), y.hasRenderableOutput ? be || (be = !0, ye !== null && C(_, "lastQuietPoll", ye), C(_, "firstOutput")) : ye = qe(), d.accumulatesNarration) y.hasText && C(_, "firstText");
541
+ sinceMs: ce
542
+ }), ce, { accumulateNarration: u.accumulatesNarration }), en(f, y, { content: ie(x.content) }), x.hasRenderableOutput ? ve || (ve = !0, ge !== null && w(y, "lastQuietPoll", ge), w(y, "firstOutput")) : ge = Je(), u.accumulatesNarration) x.hasText && w(y, "firstText");
454
543
  else {
455
- let e = Be(xe, y, qe());
456
- xe = e.tracker, e.confirmedAt !== null && C(_, "firstText", e.confirmedAt);
544
+ let e = Ve(ye, x, Je());
545
+ ye = e.tracker, e.confirmedAt !== null && w(y, "firstText", e.confirmedAt);
457
546
  }
458
- if (y.pendingWrite && Gt(p, _, { pendingWrite: y.pendingWrite }), y.done) {
459
- C(_, "answerDone"), K.current.markVerified(n);
547
+ if (x.pendingWrite && tn(f, y, { pendingWrite: x.pendingWrite }), x.done) {
548
+ w(y, "answerDone"), K.current.markVerified(n);
460
549
  break;
461
550
  }
462
- Date.now() - we > 3e4 && (await l(n, h, 600, g).catch(() => void 0), we = Date.now()), await new Promise((e) => setTimeout(e, ue(Date.now() - Te)));
551
+ Date.now() - xe > 3e4 && (await d(n, g, 600, _).catch(() => void 0), xe = Date.now()), await new Promise((e) => setTimeout(e, le(Date.now() - Se)));
463
552
  }
464
- let De = d.producesArtifacts ? await te(n, h, o, c, g).then((e) => e).catch(() => []) : void 0;
465
- if (y.usedTools !== void 0 && S(_, { usedTools: y.usedTools }), y.done || (S(_, { outcome: "timedOut" }), y = {
466
- ...y,
467
- content: oe(y.content, c, k, ee)
468
- }), a && (y = {
469
- ...y,
470
- content: `${y.content}\n\n${k("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._")}`
471
- }), le(y.content, De, o, n), y.tokens) {
472
- Wt(p, _, { tokens: y.tokens });
553
+ let Te = u.producesArtifacts ? await p(n, g, o, c, _).then((e) => e).catch(() => []) : void 0;
554
+ if (x.usedTools !== void 0 && C(y, { usedTools: x.usedTools }), x.done || (C(y, { outcome: "timedOut" }), x = {
555
+ ...x,
556
+ content: ae(x.content, c, A, l)
557
+ }), a && (x = {
558
+ ...x,
559
+ content: `${x.content}\n\n${A("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._")}`
560
+ }), se(x.content, Te, o, n), x.tokens) {
561
+ en(f, y, { tokens: x.tokens });
473
562
  try {
474
- await jt?.({
475
- workspaceId: h,
563
+ await Vt?.({
564
+ workspaceId: g,
476
565
  sessionId: o,
477
- messageId: y.messageId,
478
- model: y.model,
479
- tokens: y.tokens
480
- }), _t(A);
566
+ messageId: x.messageId,
567
+ model: x.model,
568
+ tokens: x.tokens
569
+ }), Et(j);
481
570
  } catch {}
482
571
  }
483
- let Oe = b();
484
- if (Oe.abandon) {
485
- Oe.clearProcessing && qt(p);
572
+ let Ee = we();
573
+ if (Ee.abandon) {
574
+ Ee.clearProcessing && rn(f);
486
575
  return;
487
576
  }
488
- C(_, "complete"), S(_, { outcome: "answered" }), Kt(p, "complete", _, null);
577
+ w(y, "complete"), C(y, { outcome: "answered" }), nn(f, "complete", y, null);
489
578
  } catch (e) {
490
- K.current.invalidate(i ?? x.getState().sandboxesByMode[c]?.sandboxId ?? null);
491
- let t = Pe({
492
- turnId: _,
493
- abortRequested: On.current.has(_),
494
- activeTurnId: x.getState().processingByConversationId[p]?.messageId ?? null
579
+ K.current.invalidate(i ?? S.getState().sandboxesByMode[c]?.sandboxId ?? null);
580
+ let t = Fe({
581
+ turnId: y,
582
+ abortRequested: Bn.current.has(y),
583
+ activeTurnId: S.getState().processingByConversationId[f]?.messageId ?? null
495
584
  });
496
585
  if (t.abandon) {
497
- t.clearProcessing && qt(p);
586
+ t.clearProcessing && rn(f);
498
587
  return;
499
588
  }
500
- if (n === 1 && Qe(e)) {
501
- let e = i ?? x.getState().sandboxesByMode[c]?.sandboxId ?? null;
502
- return e && (q.current.add(e), K.current.invalidate(e)), Yt(p), V(c), Ut(p, _, ""), Gt(p, _, { pendingWrite: void 0 }), Ke(_), de(2);
589
+ if (n === 1 && et(e)) {
590
+ let e = i ?? S.getState().sandboxesByMode[c]?.sandboxId ?? null;
591
+ return e && (q.current.add(e), K.current.invalidate(e)), on(f), U(c), $t(f, y, ""), tn(f, y, { pendingWrite: void 0 }), qe(y), ce(2);
503
592
  }
504
593
  throw e;
505
594
  }
506
- }, v = p;
507
- bn.current.add(v);
595
+ }, b = f;
596
+ Mn.current.add(b);
508
597
  try {
509
- if (!h) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
598
+ if (!g) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
510
599
  code: "UNAUTHENTICATED",
511
600
  authFailure: "WORKSPACE_CONTEXT_MISSING"
512
601
  } });
513
- let e = await Se(c, () => cn.current.find((e) => e.id === c), G);
514
- ee = e.config, d = e.capabilities;
515
- let t = Te(c, ee, x.getState().acknowledgedWriteModes, {
602
+ let e = await Se(c, () => bn.current.find((e) => e.id === c), G);
603
+ l = e.config, u = e.capabilities;
604
+ let t = Te(c, l, S.getState().acknowledgedWriteModes, {
516
605
  dictated: r,
517
- confirmsWrites: f(c)
606
+ confirmsWrites: te(c)
518
607
  });
519
608
  if (t) throw new ye(t, t === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
520
- C(_, "cleared"), await de();
609
+ w(y, "cleared"), await ce();
521
610
  } catch (e) {
522
- K.current.invalidate(x.getState().sandboxesByMode[c]?.sandboxId ?? null);
523
- let t = be(e);
524
- S(_, { outcome: t.kind === "temporary" ? "failed" : "refused" }), t.offersUpgrade && gt(A, "sandbox");
525
- let r = xe(t, k);
526
- Kt(p, "error", _, r.headline), Wt(p, _, { content: r.text }), Gt(p, _, {
527
- lang: r.translated ? Mt : "en",
528
- ...se(n.voiceSessionId)
611
+ K.current.invalidate(S.getState().sandboxesByMode[c]?.sandboxId ?? null);
612
+ let t = x(e);
613
+ C(y, { outcome: t.kind === "temporary" ? "failed" : "refused" }), t.offersUpgrade && Tt(j, "sandbox");
614
+ let r = be(t, A);
615
+ nn(f, "error", y, r.headline), en(f, y, { content: r.text }), tn(f, y, {
616
+ lang: r.translated ? I : "en",
617
+ ...v(n.voiceSessionId)
529
618
  });
530
619
  } finally {
531
- bn.current.delete(v), S(_, { outcome: "stopped" }), C(_, "complete");
532
- let e = x.getState(), t = ke(ie, c, e.conversations.find((e) => e.id === v), (t) => !!e.sandboxesByMode[t]?.sandboxId);
533
- t && (H(v, t.mode), t.backendSessionId && Jt(v, t.backendSessionId));
534
- let n = kn.current;
535
- kn.current = null, n && n.conversationId === v && Pn.current(n.content, n.attachments, n.options);
620
+ Mn.current.delete(b), C(y, { outcome: "stopped" }), w(y, "complete");
621
+ let e = S.getState(), t = Ae(h, c, e.conversations.find((e) => e.id === b), (t) => !!e.sandboxesByMode[t]?.sandboxId);
622
+ t && (dn(b, t.mode), t.backendSessionId && an(b, t.backendSessionId));
623
+ let n = Vn.current;
624
+ Vn.current = null, n && n.conversationId === b && Qn.current(n.content, n.attachments, n.options);
536
625
  }
537
626
  }, [
538
- F,
539
- z,
540
- At,
541
- Yt,
627
+ L,
542
628
  V,
629
+ Bt,
630
+ on,
631
+ U,
632
+ Yt,
633
+ B,
634
+ Fn,
543
635
  zt,
544
- R,
545
- Cn,
546
- kt,
547
- M,
548
636
  N,
549
- Wt,
550
- A,
637
+ P,
638
+ en,
639
+ j,
551
640
  G,
552
- jt,
553
- Lt,
554
- Mt,
555
- Rt,
556
- It,
557
- H,
558
- Jt,
559
641
  Vt,
560
- Kt,
561
642
  qt,
562
- k,
643
+ I,
644
+ Jt,
645
+ Kt,
646
+ dn,
647
+ Yn,
648
+ an,
649
+ Zt,
650
+ nn,
651
+ rn,
652
+ A,
563
653
  Y,
564
- Ut,
565
- P
566
- ]), Mn = w((e, t) => {
654
+ $t,
655
+ F
656
+ ]), Xn = T((e, t) => {
567
657
  X(e, [], t ? { autoIntent: t } : {});
568
- }, [X]), Nn = w(() => {
569
- let e = [...tn.chat].reverse().find((e) => e.role === "user"), t = F ? yn.current[F] ?? [] : [];
658
+ }, [X]), Zn = T(() => {
659
+ let e = [...pn.chat].reverse().find((e) => e.role === "user" && !e.metadata?.localAction), t = L ? jn.current[L] ?? [] : [];
570
660
  e && X(e.content, t);
571
661
  }, [
572
- nn,
662
+ mn,
573
663
  X,
574
- F
575
- ]), Pn = D(X);
576
- T(() => {
577
- Pn.current = X;
664
+ L
665
+ ]), Qn = O(X);
666
+ E(() => {
667
+ Qn.current = X;
578
668
  }, [X]);
579
- let Fn = E(() => {
580
- if (rn) return null;
581
- for (let e = nn.length - 1; e >= 0; --e) {
582
- let t = nn[e];
583
- if (t?.role !== "assistant" || !h(t) || On.current.has(t.id)) continue;
584
- let n = Ie(t, U, k);
669
+ let $n = D(() => {
670
+ if (hn) return null;
671
+ for (let e = mn.length - 1; e >= 0; --e) {
672
+ let t = mn[e];
673
+ if (t?.role !== "assistant" || !oe(t) || Bn.current.has(t.id)) continue;
674
+ let n = Le(t, W, A);
585
675
  if (n.kind !== "output") return null;
586
- let r = Ve(n.text).text.trim();
676
+ let r = He(n.text).text.trim();
587
677
  return r ? {
588
678
  id: t.id,
589
679
  text: r
@@ -591,227 +681,228 @@ var Dt = ({ visible: Dt = !0, writeAccess: Ot = "unknown" }) => {
591
681
  }
592
682
  return null;
593
683
  }, [
594
- nn,
595
- rn,
596
- U,
597
- k
598
- ]), In = E(() => Fn ? de(Fn.text) : null, [Fn]), Ln = tn.chat, Z = E(() => tn.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
684
+ mn,
685
+ hn,
686
+ W,
687
+ A
688
+ ]), er = D(() => $n ? ue($n.text) : null, [$n]), tr = pn.chat, Z = D(() => pn.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
599
689
  id: e.id,
600
690
  role: e.role,
601
- text: Ue(e, U, k),
602
- sessionId: g(e),
691
+ text: We(e, W, A),
692
+ sessionId: y(e),
603
693
  timestamp: e.timestamp
604
694
  })).filter((e) => e.text.length > 0), [
605
- tn.voice,
606
- U,
607
- k
608
- ]), Rn = w(() => {
695
+ pn.voice,
696
+ W,
697
+ A
698
+ ]), nr = T(() => {
609
699
  if (Z.length === 0) return;
610
700
  let e = /* @__PURE__ */ new Date();
611
- it(_(Z, {
612
- title: k("voiceSession.transcript", "Voice conversation"),
613
- savedAt: k("voiceSession.savedAt", "Saved"),
614
- session: k("voiceSession.sessionLabel", "Session"),
615
- earlier: k("voiceSession.earlierLabel", "Earlier"),
616
- you: k("voiceSession.speakerYou", "You"),
617
- assistant: k("voiceSession.speakerAssistant", "Assistant")
618
- }, e), le(A, e), "text/markdown");
701
+ ot(ce(Z, {
702
+ title: A("voiceSession.transcript", "Voice conversation"),
703
+ savedAt: A("voiceSession.savedAt", "Saved"),
704
+ session: A("voiceSession.sessionLabel", "Session"),
705
+ earlier: A("voiceSession.earlierLabel", "Earlier"),
706
+ you: A("voiceSession.speakerYou", "You"),
707
+ assistant: A("voiceSession.speakerAssistant", "Assistant")
708
+ }, e), b(j, e), "text/markdown");
619
709
  }, [
620
- A,
710
+ j,
621
711
  Z,
622
- k
623
- ]), Q = vt({ perFileChars: mn }), zn = D(Q);
624
- zn.current = Q;
625
- let $ = Je({
626
- onSubmit: w((e, t, n) => {
712
+ A
713
+ ]), Q = Dt({ perFileChars: En }), rr = O(Q);
714
+ rr.current = Q;
715
+ let $ = Xe({
716
+ onSubmit: T((e, t, n) => {
627
717
  let r = () => {
628
- let r = zn.current, i = he(r.attachments), a = {
718
+ let r = rr.current, i = he(r.attachments), a = {
629
719
  ...n,
630
- handedOver: qe()
720
+ handedOver: Je()
631
721
  };
632
- Pn.current(e, i, {
722
+ Qn.current(e, i, {
723
+ fromPerson: !0,
633
724
  voiceSessionId: t,
634
725
  voiceTiming: a
635
726
  }), r.clear();
636
727
  };
637
- if (!zn.current.isBusy) {
728
+ if (!rr.current.isBusy) {
638
729
  r();
639
730
  return;
640
731
  }
641
732
  let i = Date.now(), a = window.setInterval(() => {
642
- zn.current.isBusy && Date.now() - i < Tt || (window.clearInterval(a), r());
733
+ rr.current.isBusy && Date.now() - i < Ft || (window.clearInterval(a), r());
643
734
  }, 200);
644
735
  }, []),
645
- latestReply: Fn,
646
- language: v(Nt, Mt).tag
647
- }), Bn = $.start, Vn = w(() => {
648
- wn(!0), Bn();
649
- }, [wn, Bn]), Hn = E(() => (en?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [en?.messages]), Un = He(tn.voice, U, k), Wn = Un > Hn, Gn = w(() => {
650
- let e = x.getState().activeConversationId;
651
- !e || Z.length === 0 || (z(e, {
652
- id: Et(),
736
+ latestReply: $n,
737
+ language: de(Ut, I).tag
738
+ }), ir = $.start, ar = T(() => {
739
+ In(!0), ir();
740
+ }, [In, ir]), or = D(() => (fn?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [fn?.messages]), sr = Ue(pn.voice, W, A), cr = sr > or, lr = T(() => {
741
+ let e = S.getState().activeConversationId;
742
+ !e || Z.length === 0 || (V(e, {
743
+ id: It(),
653
744
  role: "system",
654
- content: ce(Z.slice(Hn), {
655
- intro: k("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
656
- nothing: k("voiceSession.continuedNothing", "Continued from a voice conversation."),
657
- more: (e) => k("voiceSession.continuedMore", "…and {{count}} more", { count: e })
745
+ content: se(Z.slice(or), {
746
+ intro: A("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
747
+ nothing: A("voiceSession.continuedNothing", "Continued from a voice conversation."),
748
+ more: (e) => A("voiceSession.continuedMore", "…and {{count}} more", { count: e })
658
749
  }),
659
750
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
660
- metadata: { continuedVoiceTurns: Un }
661
- }), vn(!1), $.end());
751
+ metadata: { continuedVoiceTurns: sr }
752
+ }), An(!1), $.end());
662
753
  }, [
663
754
  Z,
664
- Un,
665
- Hn,
666
- z,
667
- k,
755
+ sr,
756
+ or,
757
+ V,
758
+ A,
668
759
  $
669
- ]), Kn = D(0);
670
- T(() => {
671
- $.active && (Kn.current = Un);
760
+ ]), ur = O(0);
761
+ E(() => {
762
+ $.active && (ur.current = sr);
672
763
  }, [$.active]);
673
- let qn = w(() => {
674
- let e = Un > Kn.current;
675
- $.end(), e && vn(!0);
676
- }, [Un, $]);
677
- T(() => {
678
- (!Dt || !xn) && $.active && $.end();
764
+ let dr = T(() => {
765
+ let e = sr > ur.current;
766
+ $.end(), e && An(!0);
767
+ }, [sr, $]);
768
+ E(() => {
769
+ (!Lt || !Nn) && $.active && $.end();
679
770
  }, [
680
- Dt,
681
- xn,
771
+ Lt,
772
+ Nn,
682
773
  $
683
- ]), T(() => {
684
- $.active || (zn.current.clear(), kn.current = null);
685
- }, [$.active]), T(() => {
686
- let e = x.getState().consumePendingPrompt();
687
- return e && Pn.current(e), x.subscribe((e, t) => {
774
+ ]), E(() => {
775
+ $.active || (rr.current.clear(), Vn.current = null);
776
+ }, [$.active]), E(() => {
777
+ let e = S.getState().consumePendingPrompt();
778
+ return e && Qn.current(e), S.subscribe((e, t) => {
688
779
  if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
689
- let e = x.getState().consumePendingPrompt();
690
- e && Pn.current(e);
780
+ let e = S.getState().consumePendingPrompt();
781
+ e && Qn.current(e);
691
782
  }
692
783
  });
693
784
  }, []);
694
- let Jn = w((e) => {
695
- let t = F ? x.getState().conversations.find((e) => e.id === F) : void 0;
785
+ let fr = T((e) => {
786
+ let t = L ? S.getState().conversations.find((e) => e.id === L) : void 0;
696
787
  if (t && (t.messages.length > 0 || t.backendSessionId)) {
697
788
  if (t.mode !== e) {
698
- let t = x.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !x.getState().processingByConversationId[t.id]);
699
- t ? Ht(t.id) : R(void 0, e);
789
+ let t = S.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !S.getState().processingByConversationId[t.id]);
790
+ t ? Qt(t.id) : B(void 0, e);
700
791
  }
701
- } else F && Vt(F, e);
702
- let n = x.getState().activeConversationId;
703
- n ? Vt(n, e) : $t(!1), L(e);
792
+ } else L && Zt(L, e);
793
+ let n = S.getState().activeConversationId;
794
+ n ? Zt(n, e) : un(!1), z(e);
704
795
  }, [
705
- F,
706
- R,
707
- Ht,
708
- $t,
709
- Vt,
710
- L
711
- ]), Yn = w(() => {
712
- let e = x.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
796
+ L,
797
+ B,
798
+ Qt,
799
+ un,
800
+ Zt,
801
+ z
802
+ ]), pr = T(() => {
803
+ let e = S.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
713
804
  if (!t) {
714
- $t(!0), L(b);
805
+ un(!0), z(Ee);
715
806
  return;
716
807
  }
717
808
  if (t.routedBy === "auto") {
718
- $t(!0);
809
+ un(!0);
719
810
  return;
720
811
  }
721
812
  if (t.messages.length === 0 && !t.backendSessionId) {
722
- H(t.id, b);
813
+ dn(t.id, Ee);
723
814
  return;
724
815
  }
725
816
  let n = e.conversations.find((t) => t.routedBy === "auto" && t.messages.length === 0 && !t.backendSessionId && !e.processingByConversationId[t.id]);
726
- n ? (Ht(n.id), H(n.id, b)) : R(void 0, b, { routedBy: "auto" });
817
+ n ? (Qt(n.id), dn(n.id, Ee)) : B(void 0, Ee, { routedBy: "auto" });
727
818
  }, [
728
- R,
729
- H,
730
- Ht,
731
- $t,
732
- L
733
- ]), Xn = w((e) => {
734
- if (j.find((t) => t.id === e)?.writeCapable && !we(x.getState().acknowledgedWriteModes, e)) {
735
- gn(e);
819
+ B,
820
+ dn,
821
+ Qt,
822
+ un,
823
+ z
824
+ ]), mr = T((e) => {
825
+ if (M.find((t) => t.id === e)?.writeCapable && !we(S.getState().acknowledgedWriteModes, e)) {
826
+ On(e);
736
827
  return;
737
828
  }
738
- Jn(e);
739
- }, [Jn, j]), Zn = w(() => {
740
- let e = hn;
741
- if (gn(null), !e) return;
742
- let t = pn.current;
743
- if (pn.current = null, t) {
744
- Zt(e), X(t.content, t.attachments, t.options);
829
+ fr(e);
830
+ }, [fr, M]), hr = T(() => {
831
+ let e = Dn;
832
+ if (On(null), !e) return;
833
+ let t = Tn.current;
834
+ if (Tn.current = null, t) {
835
+ cn(e), X(t.content, t.attachments, t.options);
745
836
  return;
746
837
  }
747
- Zt(e), Jn(e);
838
+ cn(e), fr(e);
748
839
  }, [
749
- hn,
750
- Zt,
751
- Jn,
840
+ Dn,
841
+ cn,
842
+ fr,
752
843
  X
753
- ]), Qn = hn === null ? void 0 : j.find((e) => e.id === hn) ?? { id: hn }, $n = w(() => {
754
- gn(null);
755
- let e = pn.current;
756
- pn.current = null, e && X(e.content, e.attachments, {
844
+ ]), gr = Dn === null ? void 0 : M.find((e) => e.id === Dn) ?? { id: Dn }, _r = T(() => {
845
+ On(null);
846
+ let e = Tn.current;
847
+ Tn.current = null, e && X(e.content, e.attachments, {
757
848
  ...e.options,
758
849
  autoIntent: "read"
759
850
  });
760
851
  }, [X]);
761
- return /* @__PURE__ */ Ct("div", {
852
+ return /* @__PURE__ */ Nt("div", {
762
853
  className: "relative flex flex-1 flex-col overflow-hidden",
763
854
  children: [
764
- /* @__PURE__ */ Ct("div", {
855
+ /* @__PURE__ */ Nt("div", {
765
856
  className: "contents",
766
857
  inert: $.active || void 0,
767
858
  children: [
768
- Z.length > 0 && !$.active ? /* @__PURE__ */ O(nt, {
859
+ Z.length > 0 && !$.active ? /* @__PURE__ */ k(it, {
769
860
  count: Z.length,
770
- onOpenTranscript: () => vn(!0)
861
+ onOpenTranscript: () => An(!0)
771
862
  }) : null,
772
- Ln.length === 0 ? /* @__PURE__ */ O(at, {
773
- mode: I,
774
- onSuggestionClick: Mn,
775
- explainsAuto: dn,
776
- suggestions: dn && I === "assistant" ? De(j.find((e) => e.id === "assistant")?.suggestions ?? [], j.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
777
- }) : /* @__PURE__ */ O("div", {
863
+ tr.length === 0 ? /* @__PURE__ */ k(st, {
864
+ mode: R,
865
+ onSuggestionClick: Xn,
866
+ explainsAuto: Cn,
867
+ suggestions: Cn && R === "assistant" ? Oe(M.find((e) => e.id === "assistant")?.suggestions ?? [], M.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
868
+ }) : /* @__PURE__ */ k("div", {
778
869
  className: "flex min-h-0 flex-1 flex-col",
779
- children: /* @__PURE__ */ O(ot, {
780
- onApprovePendingWrite: jn,
781
- approvingWriteRef: En,
782
- messages: Ln,
783
- processing: U ?? null,
784
- streamingMessageId: an,
785
- failedMessageId: on,
786
- onRetry: Nn
870
+ children: /* @__PURE__ */ k(ct, {
871
+ onApprovePendingWrite: Un,
872
+ approvingWriteRef: Rn,
873
+ messages: tr,
874
+ processing: W ?? null,
875
+ streamingMessageId: gn,
876
+ failedMessageId: _n,
877
+ onRetry: Zn
787
878
  })
788
879
  }),
789
- /* @__PURE__ */ O(yt, {
790
- onStartVoiceSession: $.available && xn ? Vn : void 0,
791
- onSend: (e, t) => void X(e, t),
792
- onDraftStart: Tn,
793
- disabled: rn,
794
- placeholder: I === "api-calls" ? k("chatArea.placeholderActions", "What would you like me to do?") : k("chatArea.placeholderGeneral", "Ask me anything…"),
795
- mode: I,
796
- writeAccessDenied: Ot === "denied" && !!J?.writeCapable,
797
- availableModes: ln,
798
- attachmentCharsPerFile: mn,
799
- onModeChange: Xn,
800
- auto: un ? {
801
- active: dn,
802
- onSelect: Yn
880
+ /* @__PURE__ */ k(Ot, {
881
+ onStartVoiceSession: $.available && Nn ? ar : void 0,
882
+ onSend: (e, t) => void X(e, t, { fromPerson: !0 }),
883
+ onDraftStart: Ln,
884
+ disabled: hn,
885
+ placeholder: R === "api-calls" ? A("chatArea.placeholderActions", "What would you like me to do?") : A("chatArea.placeholderGeneral", "Ask me anything…"),
886
+ mode: R,
887
+ writeAccessDenied: Rt === "denied" && !!J?.writeCapable,
888
+ availableModes: xn,
889
+ attachmentCharsPerFile: En,
890
+ onModeChange: mr,
891
+ auto: Sn ? {
892
+ active: Cn,
893
+ onSelect: pr
803
894
  } : void 0
804
895
  })
805
896
  ]
806
897
  }),
807
- _n && !$.active ? /* @__PURE__ */ O(rt, {
898
+ kn && !$.active ? /* @__PURE__ */ k(at, {
808
899
  turns: Z,
809
- onClose: () => vn(!1),
810
- onSave: Rn,
811
- onContinueInChat: Wn ? Gn : void 0,
900
+ onClose: () => An(!1),
901
+ onSave: nr,
902
+ onContinueInChat: cr ? lr : void 0,
812
903
  closeOnEscape: !0
813
904
  }) : null,
814
- $.active && /* @__PURE__ */ O(st, {
905
+ $.active && /* @__PURE__ */ k(lt, {
815
906
  session: $.session,
816
907
  notice: $.notice,
817
908
  capturing: $.capturing,
@@ -825,24 +916,24 @@ var Dt = ({ visible: Dt = !0, writeAccess: Ot = "unknown" }) => {
825
916
  onRetryAttachment: Q.retry,
826
917
  canAttachMore: Q.canAddMore,
827
918
  preparingAttachments: Q.preparingCount,
828
- onSaveTranscript: Rn,
829
- onContinueInChat: Gn,
919
+ onSaveTranscript: nr,
920
+ onContinueInChat: lr,
830
921
  onInterrupt: () => {
831
- $.interrupt(), An();
922
+ $.interrupt(), Hn();
832
923
  },
833
- spoken: In,
924
+ spoken: er,
834
925
  onToggleMute: $.toggleMute,
835
- onEnd: qn
926
+ onEnd: dr
836
927
  }),
837
- /* @__PURE__ */ O(xt, {
838
- open: hn !== null,
839
- mode: Qn,
840
- currentMode: J ?? { id: I },
841
- onConfirm: Zn,
842
- onCancel: $n
928
+ /* @__PURE__ */ k(At, {
929
+ open: Dn !== null,
930
+ mode: gr,
931
+ currentMode: J ?? { id: R },
932
+ onConfirm: hr,
933
+ onCancel: _r
843
934
  })
844
935
  ]
845
936
  });
846
937
  };
847
938
  //#endregion
848
- export { Dt as AssistantChatArea };
939
+ export { Lt as AssistantChatArea };