@burdenoff/fe-libs 2026.926.2 → 2026.926.3

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