@burdenoff/fe-libs 2026.925.5 → 2026.925.7

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