@burdenoff/fe-libs 2026.925.9 → 2026.926.2

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