@burdenoff/fe-libs 2026.924.3 → 2026.925.1

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 (31) hide show
  1. package/dist/shared/assistant/adminModeSendGate.d.ts.map +1 -1
  2. package/dist/shared/assistant/adminModeSendGate.js +23 -20
  3. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  4. package/dist/shared/assistant/i18nManifest.js +21 -19
  5. package/dist/shared/assistant/index.d.ts +2 -0
  6. package/dist/shared/assistant/index.d.ts.map +1 -1
  7. package/dist/shared/assistant/modeCapabilities.d.ts +1 -1
  8. package/dist/shared/assistant/modeCapabilities.d.ts.map +1 -1
  9. package/dist/shared/assistant/modeCapabilities.js +29 -28
  10. package/dist/shared/assistant/permissionError.d.ts.map +1 -1
  11. package/dist/shared/assistant/permissionError.js +11 -10
  12. package/dist/shared/assistant/speech/hostedTtsProtocol.d.ts +7 -0
  13. package/dist/shared/assistant/speech/hostedTtsProtocol.d.ts.map +1 -1
  14. package/dist/shared/assistant/speech/hostedTtsProtocol.js +5 -2
  15. package/dist/shared/assistant/speech/hostedTtsSpeechEngine.d.ts.map +1 -1
  16. package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +2 -2
  17. package/dist/shared/assistant/speech/routingSpeechEngine.d.ts.map +1 -1
  18. package/dist/shared/assistant/speech/routingSpeechEngine.js +49 -31
  19. package/dist/shared/assistant/turnOutcome.d.ts +58 -0
  20. package/dist/shared/assistant/turnOutcome.d.ts.map +1 -0
  21. package/dist/shared/assistant/turnOutcome.js +79 -0
  22. package/dist/shared/assistant/turnOutcomeCopy.d.ts +62 -0
  23. package/dist/shared/assistant/turnOutcomeCopy.d.ts.map +1 -0
  24. package/dist/shared/assistant/turnOutcomeCopy.js +49 -0
  25. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  26. package/dist/shared/assistant/ui/AssistantChatArea.js +412 -423
  27. package/dist/shared/assistant/writeModeConsent.d.ts +15 -2
  28. package/dist/shared/assistant/writeModeConsent.d.ts.map +1 -1
  29. package/dist/shared/assistant/writeModeConsent.js +24 -19
  30. package/dist/shared-assistant.js +116 -114
  31. package/package.json +1 -1
@@ -3,448 +3,437 @@ import { useAuthToken as t } from "../../providers/shell/AuthTokenProvider.js";
3
3
  import "../../../shared-providers-shell.js";
4
4
  import { useAssistantProduct as n } from "../product.js";
5
5
  import { useAssistantTr as r } from "../i18n.js";
6
- import { describeQuotaError as i } from "../quota.js";
7
- import { isAssistantModeId as a } from "../modeIds.js";
8
- import { abortAssistantTurn as o, approvePendingWrite as s, createAssistantSandbox as c, createAssistantSession as l, extendAssistantSandboxTTL as u, findExistingSandbox as ee, getAssistantArtifacts as te, getAssistantMessages as ne, getAssistantSession as re, modeRequiresConfirmWrites as ie, promptGatewayRequestBytes as ae, releaseSupersededAssistantSandboxes as d, sendAssistantPromptAsync as oe, waitForAssistantServiceReady as f, waitForSandboxRunning as p } from "../api.js";
6
+ import { isAssistantModeId as i } from "../modeIds.js";
7
+ import { abortAssistantTurn as a, approvePendingWrite as o, createAssistantSandbox as s, createAssistantSession as c, extendAssistantSandboxTTL as ee, findExistingSandbox as te, getAssistantArtifacts as l, getAssistantMessages as ne, getAssistantSession as u, modeRequiresConfirmWrites as re, promptGatewayRequestBytes as ie, releaseSupersededAssistantSandboxes as d, sendAssistantPromptAsync as ae, waitForAssistantServiceReady as f, waitForSandboxRunning as oe } from "../api.js";
9
8
  import { getRawMessageCreatedAt as se, sanitize as ce } from "../progress.js";
10
9
  import { withIncompleteTurnNotice as le } from "../streamBudget.js";
11
- import { isVoiceTurn as m, voiceMarker as h, voiceSessionIdOf as g } from "../voice/turnVisibility.js";
12
- import { buildContinuedFromVoiceNote as ue, buildVoiceTranscriptMarkdown as _, voiceTranscriptFilename as de } from "../voice/voiceTranscript.js";
10
+ import { isVoiceTurn as p, voiceMarker as m, voiceSessionIdOf as h } from "../voice/turnVisibility.js";
11
+ import { buildContinuedFromVoiceNote as ue, buildVoiceTranscriptMarkdown as g, voiceTranscriptFilename as de } from "../voice/voiceTranscript.js";
13
12
  import { pollDelayMs as fe } from "../voice/assistantPollSchedule.js";
14
- import { toCaptionText as v } from "../voice/captionText.js";
15
- import { resolveAssistantLanguage as y } from "../voice/languages.js";
16
- import { resolveLanguagePair as pe } from "../voice/languagePair.js";
17
- import { countInlineImageCandidates as me, countInlinedImageParts as he, getSendableAttachments as ge, largestInlineCharsPerFile as _e, resolveAssistantInlineLimits as ve, toMessageAttachment as ye } from "../attachments.js";
18
- import { createAdminModeAccessGate as be, resolveAssistantSendModeAfterAccess as xe } from "../adminModeSendGate.js";
19
- import { buildBoundedAttachmentTurn as Se } from "../attachmentTurn.js";
20
- import { isWriteModeAcknowledged as Ce, writeModeSendRefusal as we } from "../writeModeConsent.js";
21
- 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";
22
- import { resolveActiveModeSandbox as Me, useAssistantStore as b } from "../store.js";
23
- import { isTurnInFlight as Ne, planAbandonedTurn as Pe, planTurnAbort as Fe } from "../turnState.js";
24
- import { getAssistantDisplayContent as Ie } from "../displayContent.js";
25
- import { buildAssistantProgress as Le } from "../turnProgress.js";
26
- import { parseToolActivity as Re } from "./AssistantToolActivity.js";
27
- import { countSpokenTurns as ze, spokenTurnText as Be } from "../spokenTurns.js";
28
- import { useVoiceSession as Ve } from "./useVoiceSession.js";
29
- import { getOrganizationId as He, getWorkspaceId as Ue } from "../context.js";
30
- import { createReadinessTracker as We } from "../sandboxReadiness.js";
31
- import { AssistantSpokenTurnsNotice as Ge } from "./AssistantSpokenTurnsNotice.js";
32
- import { VoiceTranscriptDrawer as Ke } from "./voice/VoiceTranscriptDrawer.js";
33
- import { downloadFile as qe } from "../exportConversation.js";
34
- import { AssistantEmptyState as Je } from "./AssistantEmptyState.js";
35
- import { AssistantMessageList as Ye } from "./AssistantMessageList.js";
36
- import { AssistantVoiceSession as Xe } from "./voice/AssistantVoiceSession.js";
37
- import { useAssistantApiAccess as Ze } from "../useAssistantApiAccess.js";
38
- import { useConversationTurns as Qe } from "../useConversationTurns.js";
39
- import { isMultimodalBodyRejection as $e, isRecoverableAssistantError as et } from "../transportErrors.js";
40
- import { describePermissionError as tt, permissionRefusalMessage as nt } from "../permissionError.js";
41
- import { dispatchAssistantQuotaExhausted as rt, notifyAiCreditsUpdated as it } from "../aiCredits.js";
42
- import { useAssistantAttachments as at } from "../useAssistantAttachments.js";
43
- import { AssistantComposer as ot } from "./composer/AssistantComposer.js";
44
- import { isProdRuntime as st } from "../env.js";
45
- import { AssistantApiCallsConsentDialog as ct } from "./AssistantApiCallsConsentDialog.js";
46
- import { useCallback as x, useEffect as S, useMemo as C, useRef as w, useState as lt } from "react";
47
- import { jsx as T, jsxs as ut } from "react/jsx-runtime";
13
+ import { toCaptionText as pe } from "../voice/captionText.js";
14
+ import { resolveAssistantLanguage as _ } from "../voice/languages.js";
15
+ import { resolveLanguagePair as me } from "../voice/languagePair.js";
16
+ import { countInlineImageCandidates as he, countInlinedImageParts as ge, getSendableAttachments as _e, largestInlineCharsPerFile as ve, resolveAssistantInlineLimits as ye, toMessageAttachment as be } from "../attachments.js";
17
+ import { AssistantSendRefusal as xe, classifyTurnFailure as Se, turnOutcomeCopy as Ce } from "../turnOutcome.js";
18
+ import { createAdminModeAccessGate as we, resolveAssistantSendModeAfterAccess as Te } from "../adminModeSendGate.js";
19
+ import { buildBoundedAttachmentTurn as Ee } from "../attachmentTurn.js";
20
+ import { isWriteModeAcknowledged as De, writeModeSendRefusalReason as Oe } from "../writeModeConsent.js";
21
+ import { AUTO_READ_MODE as ke, autoCarryOverFor as Ae, autoSuggestions as je, classifyAssistantIntent as Me, escalationToUndo as Ne, isAutoRoutingOffered as Pe, resolveAutoRoute as Fe } from "../autoRouting.js";
22
+ import { resolveActiveModeSandbox as Ie, useAssistantStore as v } from "../store.js";
23
+ import { isTurnInFlight as Le, planAbandonedTurn as Re, planTurnAbort as ze } from "../turnState.js";
24
+ import { getAssistantDisplayContent as Be } from "../displayContent.js";
25
+ import { buildAssistantProgress as Ve } from "../turnProgress.js";
26
+ import { parseToolActivity as He } from "./AssistantToolActivity.js";
27
+ import { countSpokenTurns as Ue, spokenTurnText as We } from "../spokenTurns.js";
28
+ import { useVoiceSession as Ge } from "./useVoiceSession.js";
29
+ import { getOrganizationId as Ke, getWorkspaceId as qe } from "../context.js";
30
+ import { createReadinessTracker as Je } from "../sandboxReadiness.js";
31
+ import { AssistantSpokenTurnsNotice as Ye } from "./AssistantSpokenTurnsNotice.js";
32
+ import { VoiceTranscriptDrawer as Xe } from "./voice/VoiceTranscriptDrawer.js";
33
+ import { downloadFile as Ze } from "../exportConversation.js";
34
+ import { AssistantEmptyState as Qe } from "./AssistantEmptyState.js";
35
+ import { AssistantMessageList as $e } from "./AssistantMessageList.js";
36
+ import { AssistantVoiceSession as et } from "./voice/AssistantVoiceSession.js";
37
+ import { useAssistantApiAccess as tt } from "../useAssistantApiAccess.js";
38
+ import { useConversationTurns as nt } from "../useConversationTurns.js";
39
+ import { isMultimodalBodyRejection as rt, isRecoverableAssistantError as it } from "../transportErrors.js";
40
+ import { dispatchAssistantQuotaExhausted as at, notifyAiCreditsUpdated as ot } from "../aiCredits.js";
41
+ import { useAssistantAttachments as st } from "../useAssistantAttachments.js";
42
+ import { AssistantComposer as ct } from "./composer/AssistantComposer.js";
43
+ import { isProdRuntime as lt } from "../env.js";
44
+ import { AssistantApiCallsConsentDialog as ut } from "./AssistantApiCallsConsentDialog.js";
45
+ import { useCallback as y, useEffect as b, useMemo as x, useRef as S, useState as dt } from "react";
46
+ import { jsx as C, jsxs as ft } from "react/jsx-runtime";
48
47
  //#region src/shared/assistant/ui/AssistantChatArea.tsx
49
- var dt = 600, ft = 2e4;
50
- function pt() {
48
+ var pt = 600, mt = 2e4;
49
+ function ht() {
51
50
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
52
51
  }
53
- var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
54
- let E = r(), { product: D, modes: O, gatherPageContext: gt, buildPrompt: _t, reportTokenUsage: vt } = n(), { getAccessToken: k, getWorkspaceToken: yt, userId: A } = t(), { locale: bt } = e(), xt = b((e) => e.assistantLanguage), St = b((e) => e.replyLanguage), Ct = C(() => pe(xt, St, bt), [
55
- xt,
52
+ var gt = ({ visible: gt = !0, writeAccess: _t = "unknown" }) => {
53
+ let w = r(), { product: T, modes: E, gatherPageContext: vt, buildPrompt: yt, reportTokenUsage: bt } = n(), { getAccessToken: D, getWorkspaceToken: O, userId: k } = t(), { locale: xt } = e(), St = v((e) => e.assistantLanguage), Ct = v((e) => e.replyLanguage), wt = x(() => me(St, Ct, xt), [
56
54
  St,
57
- bt
58
- ]), wt = Ct.reply.english, Tt = Ct.replyIsExplicit, Et = Ct.reply.code, { conversations: Dt, activeConversationId: j, mode: M, processingByConversationId: Ot, setMode: N, setConversationMode: kt, setActiveConversation: At, createConversation: P, addMessage: F, updateMessage: jt, patchMessage: Mt, mergeMessageMetadata: Nt, setConversationProcessing: I, clearConversationProcessing: Pt, setBackendSessionId: Ft, clearBackendSessionId: It, setSandbox: L, clearSandbox: Lt, acknowledgedWriteModes: Rt, acknowledgeWriteMode: zt, autoRouting: Bt, setAutoRouting: Vt, routeConversation: R } = b(), Ht = Dt.find((e) => e.id === j), z = Qe(Ht), Ut = z.all, B = j ? Ot[j] : void 0, Wt = Ne(B?.status), Gt = Wt ? B?.messageId ?? null : null, Kt = B?.status === "error" ? B.messageId : null, { canUseApiCalls: V, loading: qt } = Ze(He()), H = w(be({
59
- loading: qt,
60
- canUseAdminModes: V
61
- })).current, Jt = w(O);
62
- S(() => {
63
- Jt.current = O;
64
- }, [O]), S(() => {
65
- H.update({
66
- loading: qt,
67
- canUseAdminModes: V
55
+ Ct,
56
+ xt
57
+ ]), Tt = wt.reply.english, Et = wt.replyIsExplicit, Dt = wt.reply.code, { conversations: Ot, activeConversationId: A, mode: j, processingByConversationId: kt, setMode: M, setConversationMode: At, setActiveConversation: jt, createConversation: N, addMessage: P, updateMessage: Mt, patchMessage: Nt, mergeMessageMetadata: Pt, setConversationProcessing: F, clearConversationProcessing: Ft, setBackendSessionId: It, clearBackendSessionId: Lt, setSandbox: I, clearSandbox: Rt, acknowledgedWriteModes: zt, acknowledgeWriteMode: Bt, autoRouting: Vt, setAutoRouting: Ht, routeConversation: L } = v(), Ut = Ot.find((e) => e.id === A), R = nt(Ut), Wt = R.all, z = A ? kt[A] : void 0, Gt = Le(z?.status), Kt = Gt ? z?.messageId ?? null : null, qt = z?.status === "error" ? z.messageId : null, { canUseApiCalls: B, loading: Jt } = tt(Ke()), V = S(we({
58
+ loading: Jt,
59
+ canUseAdminModes: B
60
+ })).current, Yt = S(E);
61
+ b(() => {
62
+ Yt.current = E;
63
+ }, [E]), b(() => {
64
+ V.update({
65
+ loading: Jt,
66
+ canUseAdminModes: B
68
67
  });
69
68
  }, [
70
- H,
71
- qt,
72
- V
73
- ]), S(() => () => {
74
- H.abandon();
75
- }, [H]);
76
- let Yt = C(() => O.filter((e) => !e.requiresAdmin || V), [O, V]), Xt = Ae(Yt), Zt = Bt && Xt, Qt = w(Xt);
77
- S(() => {
78
- Qt.current = Xt;
79
- }, [Xt]);
80
- let U = w(null), $t = _e(O), [W, en] = lt(null), [tn, nn] = lt(!1), rn = w({}), G = w(We()), an = w(/* @__PURE__ */ new Set()), on = w(/* @__PURE__ */ new Set()), K = C(() => O.find((e) => e.id === M), [O, M]), sn = M === "assistant" || K !== void 0 && !K.writeCapable && !ie(M);
81
- S(() => {
82
- if (M !== "assistant" && K?.writeCapable && !Ce(Rt, M)) {
83
- N("assistant");
69
+ V,
70
+ Jt,
71
+ B
72
+ ]), b(() => () => {
73
+ V.abandon();
74
+ }, [V]);
75
+ let Xt = x(() => E.filter((e) => !e.requiresAdmin || B), [E, B]), Zt = Pe(Xt), Qt = Vt && Zt, $t = S(Zt);
76
+ b(() => {
77
+ $t.current = Zt;
78
+ }, [Zt]);
79
+ let H = S(null), en = ve(E), [U, tn] = dt(null), [nn, rn] = dt(!1), an = S({}), W = S(Je()), on = S(/* @__PURE__ */ new Set()), sn = S(/* @__PURE__ */ new Set()), G = x(() => E.find((e) => e.id === j), [E, j]), cn = j === "assistant" || G !== void 0 && !G.writeCapable && !re(j);
80
+ b(() => {
81
+ if (j !== "assistant" && G?.writeCapable && !De(zt, j)) {
82
+ M("assistant");
84
83
  return;
85
84
  }
86
- qt || (!K || K.requiresAdmin && !V) && M !== "assistant" && N("assistant");
85
+ Jt || (!G || G.requiresAdmin && !B) && j !== "assistant" && M("assistant");
87
86
  }, [
87
+ j,
88
+ G,
89
+ B,
90
+ Jt,
88
91
  M,
89
- K,
90
- V,
91
- qt,
92
- N,
93
- Rt
92
+ zt
94
93
  ]);
95
- let q = x((e, t, n, r) => {
96
- I(e, n, t, null, r);
97
- }, [I]), cn = x(async (e, t, n, r, i) => {
98
- let o = b.getState().sandboxesByMode[n]?.sandboxId ?? null, s = async (e) => {
99
- if (G.current.isFresh(e)) return !0;
94
+ let K = y((e, t, n, r) => {
95
+ F(e, n, t, null, r);
96
+ }, [F]), ln = y(async (e, t, n, r, a) => {
97
+ let o = v.getState().sandboxesByMode[n]?.sandboxId ?? null, ee = async (e) => {
98
+ if (W.current.isFresh(e)) return !0;
100
99
  try {
101
- return await p(e, r, i, 3e5), await f(e, r, n, i, 9e4), G.current.markVerified(e), !0;
100
+ return await oe(e, r, a, 3e5), await f(e, r, n, a, 9e4), W.current.markVerified(e), !0;
102
101
  } catch {
103
- return G.current.invalidate(e), an.current.add(e), !1;
102
+ return W.current.invalidate(e), on.current.add(e), !1;
104
103
  }
105
104
  };
106
- if (o && (L(n, o, "provisioning"), q(e, t, "provisioning", "reusingEnvironment"), await s(o) || (L(n, null, "provisioning"), o = null)), !o) {
107
- q(e, t, "provisioning", "lookingForEnvironment");
108
- let a = await ee(r, D, n, st(), i, an.current);
109
- a && (L(n, a, "provisioning"), q(e, t, "provisioning", "reusingEnvironment"), await s(a) ? o = a : L(n, null, "provisioning"));
105
+ if (o && (I(n, o, "provisioning"), K(e, t, "provisioning", "reusingEnvironment"), await ee(o) || (I(n, null, "provisioning"), o = null)), !o) {
106
+ K(e, t, "provisioning", "lookingForEnvironment");
107
+ let i = await te(r, T, n, lt(), a, on.current);
108
+ i && (I(n, i, "provisioning"), K(e, t, "provisioning", "reusingEnvironment"), await ee(i) ? o = i : I(n, null, "provisioning"));
110
109
  }
111
110
  if (!o) {
112
- if (n === "api-calls" && !k()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
113
- q(e, t, "provisioning", "startingEnvironment"), L(n, null, "provisioning");
114
- let s = await d(r, D, n, st(), i, an.current);
115
- if (s.length > 0) {
116
- let e = new Set(s);
117
- for (let e of s) G.current.invalidate(e), an.current.add(e);
118
- let t = b.getState().sandboxesByMode;
119
- for (let [n, r] of Object.entries(t)) a(n) && r?.sandboxId && e.has(r.sandboxId) && Lt(n);
111
+ if (n === "api-calls" && !D()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
112
+ K(e, t, "provisioning", "startingEnvironment"), I(n, null, "provisioning");
113
+ let c = await d(r, T, n, lt(), a, on.current);
114
+ if (c.length > 0) {
115
+ let e = new Set(c);
116
+ for (let e of c) W.current.invalidate(e), on.current.add(e);
117
+ let t = v.getState().sandboxesByMode;
118
+ for (let [n, r] of Object.entries(t)) i(n) && r?.sandboxId && e.has(r.sandboxId) && Rt(n);
120
119
  }
121
- o = await c(D, n, r, st(), dt, i), L(n, o, "provisioning"), await p(o, r, i, 3e5), await f(o, r, n, i, 9e4);
120
+ o = await s(T, n, r, lt(), pt, a), I(n, o, "provisioning"), await oe(o, r, a, 3e5), await f(o, r, n, a, 9e4);
122
121
  }
123
- L(n, o, "running");
124
- let u = b.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null, te = !1;
125
- if (u) try {
126
- let e = await re(o, r, u, n, i);
122
+ I(n, o, "running");
123
+ let l = v.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null, ne = !1;
124
+ if (l) try {
125
+ let e = await u(o, r, l, n, a);
127
126
  if (e.mode !== n) throw Error(`Session mode mismatch: expected ${n}, received ${e.mode}`);
128
127
  } catch {
129
- It(e), u = null;
128
+ Lt(e), l = null;
130
129
  }
131
- return u || (q(e, t, "connecting", "preparingSession"), u = (await l(o, r, n, i)).sessionId, Ft(e, u), te = !0), {
130
+ return l || (K(e, t, "connecting", "preparingSession"), l = (await c(o, r, n, a)).sessionId, It(e, l), ne = !0), {
132
131
  sandboxId: o,
133
- sessionId: u,
134
- sessionIsNew: te
132
+ sessionId: l,
133
+ sessionIsNew: ne
135
134
  };
136
135
  }, [
137
- It,
138
136
  Lt,
139
- k,
137
+ Rt,
140
138
  D,
141
- Ft,
142
- L,
143
- q
144
- ]), [ln, un] = lt(null), dn = w(/* @__PURE__ */ new Set()), fn = w(null), pn = x(() => {
145
- let e = b.getState(), t = e.activeConversationId;
139
+ T,
140
+ It,
141
+ I,
142
+ K
143
+ ]), [un, dn] = dt(null), q = S(/* @__PURE__ */ new Set()), fn = S(null), pn = y(() => {
144
+ let e = v.getState(), t = e.activeConversationId;
146
145
  if (!t) return;
147
- let n = e.processingByConversationId[t], r = Ne(n?.status) ? n?.messageId ?? null : null;
148
- if (!Fe({
146
+ let n = e.processingByConversationId[t], r = Le(n?.status) ? n?.messageId ?? null : null;
147
+ if (!ze({
149
148
  interruptedTurnId: r,
150
149
  activeTurnId: r,
151
- alreadyRequested: r ? dn.current.has(r) : !1
150
+ alreadyRequested: r ? q.current.has(r) : !1
152
151
  }).send || !r) return;
153
- dn.current.add(r);
154
- let i = Me(e), a = Ue(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
155
- !i || !a || !s || o(i.sandboxId, a, s, i.mode, {
156
- accessToken: k(),
157
- workspaceToken: yt(),
158
- userId: A,
159
- organizationId: He()
152
+ q.current.add(r);
153
+ let i = Ie(e), o = qe(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
154
+ !i || !o || !s || a(i.sandboxId, o, s, i.mode, {
155
+ accessToken: D(),
156
+ workspaceToken: O(),
157
+ userId: k,
158
+ organizationId: Ke()
160
159
  });
161
160
  }, [
162
- A,
163
161
  k,
164
- yt
165
- ]), mn = x(async (e) => {
166
- let t = b.getState(), n = Me(t), r = Ue(), i = t.activeConversationId;
162
+ D,
163
+ O
164
+ ]), mn = y(async (e) => {
165
+ let t = v.getState(), n = Ie(t), r = qe(), i = t.activeConversationId;
167
166
  if (!(!n || !r || !i)) {
168
- un(e);
167
+ dn(e);
169
168
  try {
170
- await s(n.sandboxId, r, e, n.mode, {
171
- accessToken: k(),
172
- workspaceToken: yt(),
173
- userId: A,
174
- organizationId: He()
169
+ await o(n.sandboxId, r, e, n.mode, {
170
+ accessToken: D(),
171
+ workspaceToken: O(),
172
+ userId: k,
173
+ organizationId: Ke()
175
174
  });
176
175
  } catch (e) {
177
- un(null), F(i, {
178
- id: pt(),
176
+ dn(null), P(i, {
177
+ id: ht(),
179
178
  role: "system",
180
179
  content: e instanceof Error ? e.message : "The change could not be approved.",
181
180
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
182
181
  });
183
182
  return;
184
183
  }
185
- un(null), Y.current(E("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
184
+ dn(null), Y.current(w("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
186
185
  }
187
186
  }, [
188
- A,
189
- F,
190
- E
191
- ]), J = x(async (e, t = [], n = {}) => {
192
- let r = n.voiceSessionId !== void 0, a = b.getState(), o = a.activeConversationId ?? j;
193
- if (o) {
194
- if (Ne(a.processingByConversationId[o]?.status)) {
195
- let r = a.processingByConversationId[o]?.messageId ?? null;
196
- r && dn.current.has(r) && (fn.current = {
197
- conversationId: o,
187
+ k,
188
+ P,
189
+ w
190
+ ]), J = y(async (e, t = [], n = {}) => {
191
+ let r = n.voiceSessionId !== void 0, i = v.getState(), a = i.activeConversationId ?? A;
192
+ if (a) {
193
+ if (Le(i.processingByConversationId[a]?.status)) {
194
+ let r = i.processingByConversationId[a]?.messageId ?? null;
195
+ r && q.current.has(r) && (fn.current = {
196
+ conversationId: a,
198
197
  content: e,
199
198
  attachments: t,
200
199
  options: n
201
200
  });
202
201
  return;
203
202
  }
204
- if (on.current.has(o)) return;
203
+ if (sn.current.has(a)) return;
205
204
  }
206
- if (U.current) return;
207
- let s = a.activeConversationId ? a.conversations.find((e) => e.id === a.activeConversationId) : void 0, c = a.autoRouting && Qt.current ? je({
208
- intent: n.autoIntent ?? Oe(e),
205
+ if (H.current) return;
206
+ let o = i.activeConversationId ? i.conversations.find((e) => e.id === i.activeConversationId) : void 0, s = i.autoRouting && $t.current ? Fe({
207
+ intent: n.autoIntent ?? Me(e),
209
208
  dictated: r,
210
- conversation: s ? {
211
- mode: s.mode,
212
- routedBy: s.routedBy,
213
- hasHistory: s.messages.length > 0 || !!s.backendSessionId
209
+ conversation: o ? {
210
+ mode: o.mode,
211
+ routedBy: o.routedBy,
212
+ hasHistory: o.messages.length > 0 || !!o.backendSessionId
214
213
  } : null
215
214
  }) : null;
216
- if (c && Jt.current.find((e) => e.id === c.mode)?.writeCapable && !Ce(a.acknowledgedWriteModes, c.mode)) {
217
- U.current = {
215
+ if (s && Yt.current.find((e) => e.id === s.mode)?.writeCapable && !De(i.acknowledgedWriteModes, s.mode)) {
216
+ H.current = {
218
217
  content: e,
219
218
  attachments: t,
220
219
  options: n
221
- }, en(c.mode);
220
+ }, tn(s.mode);
222
221
  return;
223
222
  }
224
- let l = c ? c.mode : a.mode, ee, re, d = j, f = d ? b.getState().conversations.find((e) => e.id === d) : void 0, p = c?.action === "escalate" && s ? {
225
- mode: s.mode,
226
- backendSessionId: s.backendSessionId ?? null
223
+ let c = s ? s.mode : i.mode, te, u, d = A, f = d ? v.getState().conversations.find((e) => e.id === d) : void 0, oe = s?.action === "escalate" && o ? {
224
+ mode: o.mode,
225
+ backendSessionId: o.backendSessionId ?? null
227
226
  } : null;
228
- if (c) c.action === "new" || !s ? d = P(void 0, l, { routedBy: "auto" }) : (d = s.id, R(d, l));
227
+ if (s) s.action === "new" || !o ? d = N(void 0, c, { routedBy: "auto" }) : (d = o.id, L(d, c));
229
228
  else {
230
- let e = a.autoRouting ? { routedBy: "auto" } : void 0;
231
- d ? f && f.mode !== l && (f.messages.length > 0 || f.backendSessionId) ? d = P(void 0, l, e) : f && f.mode !== l && (e ? R(d, l) : kt(d, l)) : d = P(void 0, l, e);
229
+ let e = i.autoRouting ? { routedBy: "auto" } : void 0;
230
+ d ? f && f.mode !== c && (f.messages.length > 0 || f.backendSessionId) ? d = N(void 0, c, e) : f && f.mode !== c && (e ? L(d, c) : At(d, c)) : d = N(void 0, c, e);
232
231
  }
233
232
  if (!d) return;
234
- rn.current[d] = t;
235
- let m = Ue(), g = {
236
- accessToken: k(),
237
- workspaceToken: yt(),
238
- userId: A,
239
- organizationId: He()
233
+ an.current[d] = t;
234
+ let p = qe(), h = {
235
+ accessToken: D(),
236
+ workspaceToken: O(),
237
+ userId: k,
238
+ organizationId: Ke()
240
239
  }, ue = {
241
- id: pt(),
240
+ id: ht(),
242
241
  role: "user",
243
242
  content: e,
244
243
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
245
244
  metadata: {
246
- ...t.length ? { attachments: t.map(ye) } : {},
247
- ...h(n.voiceSessionId)
245
+ ...t.length ? { attachments: t.map(be) } : {},
246
+ ...m(n.voiceSessionId)
248
247
  }
249
248
  };
250
- F(d, ue);
251
- let _ = pt();
252
- F(d, {
253
- id: _,
249
+ P(d, ue);
250
+ let g = ht();
251
+ P(d, {
252
+ id: g,
254
253
  role: "assistant",
255
254
  content: "",
256
255
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
257
256
  metadata: {
258
- lang: Et,
259
- ...h(n.voiceSessionId)
257
+ lang: Dt,
258
+ ...m(n.voiceSessionId)
260
259
  }
261
- }), I(d, "provisioning", _, null);
262
- let de = (e, t, r, i, a = Et) => {
263
- Mt(d, _, { content: ce(e) }), Nt(d, _, {
260
+ }), F(d, "provisioning", g, null);
261
+ let de = (e, t, r, i, a = Dt) => {
262
+ Nt(d, g, { content: ce(e) }), Pt(d, g, {
264
263
  lang: a,
265
264
  ...t?.length ? { artifacts: t } : {},
266
- ...t?.length || r || i ? { mode: l } : {},
265
+ ...t?.length || r || i ? { mode: c } : {},
267
266
  ...r ? { sessionId: r } : {},
268
267
  ...i ? { sandboxId: i } : {},
269
- ...h(n.voiceSessionId)
268
+ ...m(n.voiceSessionId)
270
269
  });
271
- }, v = async (n = 1) => {
270
+ }, pe = async (n = 1) => {
272
271
  let i = !1;
273
272
  try {
274
- let { sandboxId: n, sessionId: a, sessionIsNew: o } = await cn(d, _, l, m, g), s = Ee(b.getState().conversations.find((e) => e.id === d), e, o), c = (await ne(n, m, a, l, g, { limit: 50 }).catch(() => [])).reduce((e, t) => Math.max(e, se(t)), 0);
275
- q(d, _, "streaming", "thinking");
276
- let ie = gt?.(), { prompt: f, parts: p } = Se({
273
+ let { sandboxId: n, sessionId: a, sessionIsNew: o } = await ln(d, g, c, p, h), s = Ae(v.getState().conversations.find((e) => e.id === d), e, o), re = (await ne(n, p, a, c, h, { limit: 50 }).catch(() => [])).reduce((e, t) => Math.max(e, se(t)), 0);
274
+ K(d, g, "streaming", "thinking");
275
+ let f = vt?.(), { prompt: oe, parts: m } = Ee({
277
276
  content: s ? `${s}${e}` : e,
278
277
  attachments: t,
279
- limits: ve(ee),
280
- wrapPrompt: (e) => _t?.(l, e, wt, Tt, r) ?? e,
281
- requestBytes: (e, t) => ae({
278
+ limits: ye(te),
279
+ wrapPrompt: (e) => yt?.(c, e, Tt, Et, r) ?? e,
280
+ requestBytes: (e, t) => ie({
282
281
  sandboxId: n,
283
- workspaceId: m,
282
+ workspaceId: p,
284
283
  sessionId: a,
285
- mode: l,
284
+ mode: c,
286
285
  prompt: e,
287
286
  parts: t,
288
- pageContext: ie,
289
- authContext: g
287
+ pageContext: f,
288
+ authContext: h
290
289
  })
291
- }), h = he(p), ue = h > 0;
292
- i = me(t) > h;
290
+ }), ue = ge(m), pe = ue > 0;
291
+ i = he(t) > ue;
293
292
  try {
294
- await oe(n, m, a, f, l, ie, g, p?.length ? { parts: p } : void 0);
293
+ await ae(n, p, a, oe, c, f, h, m?.length ? { parts: m } : void 0);
295
294
  } catch (e) {
296
- if (!p || !$e(e)) throw e;
297
- await oe(n, m, a, f, l, ie, g, void 0), i ||= ue;
295
+ if (!m || !rt(e)) throw e;
296
+ await ae(n, p, a, oe, c, f, h, void 0), i ||= pe;
298
297
  }
299
- let v = Le([], c), y = Date.now() + re.streamBudgetMs, pe = Date.now(), ge = Date.now(), _e = () => Pe({
300
- turnId: _,
301
- abortRequested: dn.current.has(_),
302
- activeTurnId: b.getState().processingByConversationId[d]?.messageId ?? null
298
+ let _ = Ve([], re), me = Date.now() + u.streamBudgetMs, _e = Date.now(), ve = Date.now(), be = () => Re({
299
+ turnId: g,
300
+ abortRequested: q.current.has(g),
301
+ activeTurnId: v.getState().processingByConversationId[d]?.messageId ?? null
303
302
  });
304
- for (; Date.now() < y;) {
305
- let e = _e();
303
+ for (; Date.now() < me;) {
304
+ let e = be();
306
305
  if (e.abandon) {
307
- e.clearProcessing && Pt(d);
306
+ e.clearProcessing && Ft(d);
308
307
  return;
309
308
  }
310
- if (v = Le(await ne(n, m, a, l, g, {
309
+ if (_ = Ve(await ne(n, p, a, c, h, {
311
310
  limit: 50,
312
- sinceMs: c
313
- }), c, { accumulateNarration: re.accumulatesNarration }), Mt(d, _, { content: ce(v.content) }), v.pendingWrite && Nt(d, _, { pendingWrite: v.pendingWrite }), v.done) break;
314
- Date.now() - pe > 3e4 && (await u(n, m, 600, g).catch(() => void 0), pe = Date.now()), await new Promise((e) => setTimeout(e, fe(Date.now() - ge)));
311
+ sinceMs: re
312
+ }), re, { accumulateNarration: u.accumulatesNarration }), Nt(d, g, { content: ce(_.content) }), _.pendingWrite && Pt(d, g, { pendingWrite: _.pendingWrite }), _.done) break;
313
+ Date.now() - _e > 3e4 && (await ee(n, p, 600, h).catch(() => void 0), _e = Date.now()), await new Promise((e) => setTimeout(e, fe(Date.now() - ve)));
315
314
  }
316
- let ye = re.producesArtifacts ? await te(n, m, a, l, g).then((e) => e).catch(() => []) : void 0;
317
- if (v.done || (v = {
318
- ...v,
319
- content: le(v.content, l, E, ee)
320
- }), i && (v = {
321
- ...v,
322
- content: `${v.content}\n\n${E("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._")}`
323
- }), de(v.content, ye, a, n), v.tokens) {
324
- Mt(d, _, { tokens: v.tokens });
315
+ let xe = u.producesArtifacts ? await l(n, p, a, c, h).then((e) => e).catch(() => []) : void 0;
316
+ if (_.done || (_ = {
317
+ ..._,
318
+ content: le(_.content, c, w, te)
319
+ }), i && (_ = {
320
+ ..._,
321
+ content: `${_.content}\n\n${w("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._")}`
322
+ }), de(_.content, xe, a, n), _.tokens) {
323
+ Nt(d, g, { tokens: _.tokens });
325
324
  try {
326
- await vt?.({
327
- workspaceId: m,
325
+ await bt?.({
326
+ workspaceId: p,
328
327
  sessionId: a,
329
- messageId: v.messageId,
330
- model: v.model,
331
- tokens: v.tokens
332
- }), it(D);
328
+ messageId: _.messageId,
329
+ model: _.model,
330
+ tokens: _.tokens
331
+ }), ot(T);
333
332
  } catch {}
334
333
  }
335
- let be = _e();
336
- if (be.abandon) {
337
- be.clearProcessing && Pt(d);
334
+ let Se = be();
335
+ if (Se.abandon) {
336
+ Se.clearProcessing && Ft(d);
338
337
  return;
339
338
  }
340
- I(d, "complete", _, null);
339
+ F(d, "complete", g, null);
341
340
  } catch (e) {
342
- let t = Pe({
343
- turnId: _,
344
- abortRequested: dn.current.has(_),
345
- activeTurnId: b.getState().processingByConversationId[d]?.messageId ?? null
341
+ let t = Re({
342
+ turnId: g,
343
+ abortRequested: q.current.has(g),
344
+ activeTurnId: v.getState().processingByConversationId[d]?.messageId ?? null
346
345
  });
347
346
  if (t.abandon) {
348
- t.clearProcessing && Pt(d);
347
+ t.clearProcessing && Ft(d);
349
348
  return;
350
349
  }
351
- if (n === 1 && et(e)) {
352
- let e = b.getState().sandboxesByMode[l]?.sandboxId ?? null;
353
- return e && (an.current.add(e), G.current.invalidate(e)), It(d), Lt(l), jt(d, _, ""), Nt(d, _, { pendingWrite: void 0 }), v(2);
350
+ if (n === 1 && it(e)) {
351
+ let e = v.getState().sandboxesByMode[c]?.sandboxId ?? null;
352
+ return e && (on.current.add(e), W.current.invalidate(e)), Lt(d), Rt(c), Mt(d, g, ""), Pt(d, g, { pendingWrite: void 0 }), pe(2);
354
353
  }
355
354
  throw e;
356
355
  }
357
- }, y = d;
358
- on.current.add(y);
356
+ }, _ = d;
357
+ sn.current.add(_);
359
358
  try {
360
- if (!m) throw Error("Assistant backend is unavailable without an active workspace context.");
361
- let e = await xe(l, () => Jt.current.find((e) => e.id === l), H);
362
- ee = e.config, re = e.capabilities;
363
- let t = we(l, ee, b.getState().acknowledgedWriteModes, {
359
+ if (!p) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
360
+ code: "UNAUTHENTICATED",
361
+ authFailure: "WORKSPACE_CONTEXT_MISSING"
362
+ } });
363
+ let e = await Te(c, () => Yt.current.find((e) => e.id === c), V);
364
+ te = e.config, u = e.capabilities;
365
+ let t = Oe(c, te, v.getState().acknowledgedWriteModes, {
364
366
  dictated: r,
365
- confirmsWrites: ie(l)
367
+ confirmsWrites: re(c)
366
368
  });
367
- if (t) throw Error(t);
368
- await v();
369
+ if (t) throw new xe(t, t === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
370
+ await pe();
369
371
  } catch (e) {
370
- G.current.invalidate(b.getState().sandboxesByMode[l]?.sandboxId ?? null);
371
- let t = i(e);
372
- if (t) {
373
- t.refusal === "exhausted" && rt(D, "sandbox");
374
- let e = [t.quotaName, t.traceId ? `reference ${t.traceId}` : null].filter(Boolean).join(" · "), n = t.refusal === "exhausted" ? "You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant." : "This workspace has no sandbox allowance provisioned, so the AI assistant cannot start. Upgrading will not help — ask an administrator to provision it.";
375
- de(e ? `${n}\n\n${e}` : n, void 0, void 0, void 0, "en"), I(d, "error", _, null);
376
- return;
377
- }
378
- let r = tt(e);
379
- if (r) {
380
- let e = nt(r);
381
- I(d, "error", _, e), Mt(d, _, { content: e }), Nt(d, _, {
382
- lang: "en",
383
- ...h(n.voiceSessionId)
384
- });
385
- return;
386
- }
387
- let a = e instanceof Error ? e.message : "Something went wrong";
388
- I(d, "error", _, a), Mt(d, _, { content: `Sorry, an error occurred: ${a}. Please try again.` }), Nt(d, _, {
389
- lang: "en",
390
- ...h(n.voiceSessionId)
372
+ W.current.invalidate(v.getState().sandboxesByMode[c]?.sandboxId ?? null);
373
+ let t = Se(e);
374
+ t.offersUpgrade && at(T, "sandbox");
375
+ let r = Ce(t, w);
376
+ F(d, "error", g, r.headline), Nt(d, g, { content: r.text }), Pt(d, g, {
377
+ lang: r.translated ? xt : "en",
378
+ ...m(n.voiceSessionId)
391
379
  });
392
380
  } finally {
393
- on.current.delete(y);
394
- let e = b.getState(), t = ke(p, l, e.conversations.find((e) => e.id === y), (t) => !!e.sandboxesByMode[t]?.sandboxId);
395
- t && (R(y, t.mode), t.backendSessionId && Ft(y, t.backendSessionId));
381
+ sn.current.delete(_);
382
+ let e = v.getState(), t = Ne(oe, c, e.conversations.find((e) => e.id === _), (t) => !!e.sandboxesByMode[t]?.sandboxId);
383
+ t && (L(_, t.mode), t.backendSessionId && It(_, t.backendSessionId));
396
384
  let n = fn.current;
397
- fn.current = null, n && n.conversationId === y && Y.current(n.content, n.attachments, n.options);
385
+ fn.current = null, n && n.conversationId === _ && Y.current(n.content, n.attachments, n.options);
398
386
  }
399
387
  }, [
400
- j,
401
- F,
402
- _t,
403
- It,
404
- Lt,
405
- Dt,
388
+ A,
406
389
  P,
407
- cn,
408
- gt,
409
- k,
410
390
  yt,
411
- Mt,
412
- D,
413
- H,
391
+ Lt,
392
+ Rt,
393
+ Ot,
394
+ N,
395
+ ln,
414
396
  vt,
415
- Tt,
397
+ D,
398
+ O,
399
+ Nt,
400
+ T,
401
+ V,
402
+ bt,
416
403
  Et,
417
- wt,
418
- R,
404
+ xt,
405
+ Dt,
406
+ Tt,
407
+ L,
408
+ It,
409
+ At,
410
+ F,
419
411
  Ft,
420
- kt,
421
- I,
422
- Pt,
423
- E,
424
- q,
425
- jt,
426
- A
427
- ]), hn = x((e, t) => {
412
+ w,
413
+ K,
414
+ Mt,
415
+ k
416
+ ]), hn = y((e, t) => {
428
417
  J(e, [], t ? { autoIntent: t } : {});
429
- }, [J]), gn = x(() => {
430
- let e = [...z.chat].reverse().find((e) => e.role === "user"), t = j ? rn.current[j] ?? [] : [];
418
+ }, [J]), gn = y(() => {
419
+ let e = [...R.chat].reverse().find((e) => e.role === "user"), t = A ? an.current[A] ?? [] : [];
431
420
  e && J(e.content, t);
432
421
  }, [
433
- Ut,
422
+ Wt,
434
423
  J,
435
- j
436
- ]), Y = w(J);
437
- S(() => {
424
+ A
425
+ ]), Y = S(J);
426
+ b(() => {
438
427
  Y.current = J;
439
428
  }, [J]);
440
- let _n = C(() => {
441
- if (Wt) return null;
442
- for (let e = Ut.length - 1; e >= 0; --e) {
443
- let t = Ut[e];
444
- if (t?.role !== "assistant" || !m(t) || dn.current.has(t.id)) continue;
445
- let n = Ie(t, B, E);
429
+ let _n = x(() => {
430
+ if (Gt) return null;
431
+ for (let e = Wt.length - 1; e >= 0; --e) {
432
+ let t = Wt[e];
433
+ if (t?.role !== "assistant" || !p(t) || q.current.has(t.id)) continue;
434
+ let n = Be(t, z, w);
446
435
  if (n.kind !== "output") return null;
447
- let r = Re(n.text).text.trim();
436
+ let r = He(n.text).text.trim();
448
437
  return r ? {
449
438
  id: t.id,
450
439
  text: r
@@ -452,41 +441,41 @@ var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
452
441
  }
453
442
  return null;
454
443
  }, [
455
- Ut,
456
444
  Wt,
457
- B,
458
- E
459
- ]), vn = C(() => _n ? v(_n.text) : null, [_n]), yn = z.chat, X = C(() => z.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
445
+ Gt,
446
+ z,
447
+ w
448
+ ]), vn = x(() => _n ? pe(_n.text) : null, [_n]), yn = R.chat, X = x(() => R.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
460
449
  id: e.id,
461
450
  role: e.role,
462
- text: Be(e, B, E),
463
- sessionId: g(e),
451
+ text: We(e, z, w),
452
+ sessionId: h(e),
464
453
  timestamp: e.timestamp
465
454
  })).filter((e) => e.text.length > 0), [
466
- z.voice,
467
- B,
468
- E
469
- ]), bn = x(() => {
455
+ R.voice,
456
+ z,
457
+ w
458
+ ]), bn = y(() => {
470
459
  if (X.length === 0) return;
471
460
  let e = /* @__PURE__ */ new Date();
472
- qe(_(X, {
473
- title: E("voiceSession.transcript", "Voice conversation"),
474
- savedAt: E("voiceSession.savedAt", "Saved"),
475
- session: E("voiceSession.sessionLabel", "Session"),
476
- earlier: E("voiceSession.earlierLabel", "Earlier"),
477
- you: E("voiceSession.speakerYou", "You"),
478
- assistant: E("voiceSession.speakerAssistant", "Assistant")
479
- }, e), de(D, e), "text/markdown");
461
+ Ze(g(X, {
462
+ title: w("voiceSession.transcript", "Voice conversation"),
463
+ savedAt: w("voiceSession.savedAt", "Saved"),
464
+ session: w("voiceSession.sessionLabel", "Session"),
465
+ earlier: w("voiceSession.earlierLabel", "Earlier"),
466
+ you: w("voiceSession.speakerYou", "You"),
467
+ assistant: w("voiceSession.speakerAssistant", "Assistant")
468
+ }, e), de(T, e), "text/markdown");
480
469
  }, [
481
- D,
470
+ T,
482
471
  X,
483
- E
484
- ]), Z = at({ perFileChars: $t }), xn = w(Z);
472
+ w
473
+ ]), Z = st({ perFileChars: en }), xn = S(Z);
485
474
  xn.current = Z;
486
- let Q = Ve({
487
- onSubmit: x((e, t) => {
475
+ let Q = Ge({
476
+ onSubmit: y((e, t) => {
488
477
  let n = () => {
489
- let n = xn.current, r = ge(n.attachments);
478
+ let n = xn.current, r = _e(n.attachments);
490
479
  Y.current(e, r, { voiceSessionId: t }), n.clear();
491
480
  };
492
481
  if (!xn.current.isBusy) {
@@ -494,176 +483,176 @@ var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
494
483
  return;
495
484
  }
496
485
  let r = Date.now(), i = window.setInterval(() => {
497
- xn.current.isBusy && Date.now() - r < ft || (window.clearInterval(i), n());
486
+ xn.current.isBusy && Date.now() - r < mt || (window.clearInterval(i), n());
498
487
  }, 200);
499
488
  }, []),
500
489
  latestReply: _n,
501
- language: y(xt, bt).tag
502
- }), Sn = C(() => (Ht?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [Ht?.messages]), $ = ze(z.voice, B, E), Cn = $ > Sn, wn = x(() => {
503
- let e = b.getState().activeConversationId;
504
- !e || X.length === 0 || (F(e, {
505
- id: pt(),
490
+ language: _(St, xt).tag
491
+ }), Sn = x(() => (Ut?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [Ut?.messages]), $ = Ue(R.voice, z, w), Cn = $ > Sn, wn = y(() => {
492
+ let e = v.getState().activeConversationId;
493
+ !e || X.length === 0 || (P(e, {
494
+ id: ht(),
506
495
  role: "system",
507
496
  content: ue(X.slice(Sn), {
508
- intro: E("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
509
- nothing: E("voiceSession.continuedNothing", "Continued from a voice conversation."),
510
- more: (e) => E("voiceSession.continuedMore", "…and {{count}} more", { count: e })
497
+ intro: w("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
498
+ nothing: w("voiceSession.continuedNothing", "Continued from a voice conversation."),
499
+ more: (e) => w("voiceSession.continuedMore", "…and {{count}} more", { count: e })
511
500
  }),
512
501
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
513
502
  metadata: { continuedVoiceTurns: $ }
514
- }), nn(!1), Q.end());
503
+ }), rn(!1), Q.end());
515
504
  }, [
516
505
  X,
517
506
  $,
518
507
  Sn,
519
- F,
520
- E,
508
+ P,
509
+ w,
521
510
  Q
522
- ]), Tn = w(0);
523
- S(() => {
511
+ ]), Tn = S(0);
512
+ b(() => {
524
513
  Q.active && (Tn.current = $);
525
514
  }, [Q.active]);
526
- let En = x(() => {
515
+ let En = y(() => {
527
516
  let e = $ > Tn.current;
528
- Q.end(), e && nn(!0);
517
+ Q.end(), e && rn(!0);
529
518
  }, [$, Q]);
530
- S(() => {
531
- (!mt || !sn) && Q.active && Q.end();
519
+ b(() => {
520
+ (!gt || !cn) && Q.active && Q.end();
532
521
  }, [
533
- mt,
534
- sn,
522
+ gt,
523
+ cn,
535
524
  Q
536
- ]), S(() => {
525
+ ]), b(() => {
537
526
  Q.active || (xn.current.clear(), fn.current = null);
538
- }, [Q.active]), S(() => {
539
- let e = b.getState().consumePendingPrompt();
540
- return e && Y.current(e), b.subscribe((e, t) => {
527
+ }, [Q.active]), b(() => {
528
+ let e = v.getState().consumePendingPrompt();
529
+ return e && Y.current(e), v.subscribe((e, t) => {
541
530
  if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
542
- let e = b.getState().consumePendingPrompt();
531
+ let e = v.getState().consumePendingPrompt();
543
532
  e && Y.current(e);
544
533
  }
545
534
  });
546
535
  }, []);
547
- let Dn = x((e) => {
548
- let t = j ? b.getState().conversations.find((e) => e.id === j) : void 0;
536
+ let Dn = y((e) => {
537
+ let t = A ? v.getState().conversations.find((e) => e.id === A) : void 0;
549
538
  if (t && (t.messages.length > 0 || t.backendSessionId)) {
550
539
  if (t.mode !== e) {
551
- let t = b.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !b.getState().processingByConversationId[t.id]);
552
- t ? At(t.id) : P(void 0, e);
540
+ let t = v.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !v.getState().processingByConversationId[t.id]);
541
+ t ? jt(t.id) : N(void 0, e);
553
542
  }
554
- } else j && kt(j, e);
555
- let n = b.getState().activeConversationId;
556
- n ? kt(n, e) : Vt(!1), N(e);
543
+ } else A && At(A, e);
544
+ let n = v.getState().activeConversationId;
545
+ n ? At(n, e) : Ht(!1), M(e);
557
546
  }, [
558
- j,
559
- P,
547
+ A,
548
+ N,
549
+ jt,
550
+ Ht,
560
551
  At,
561
- Vt,
562
- kt,
563
- N
564
- ]), On = x(() => {
565
- let e = b.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
552
+ M
553
+ ]), On = y(() => {
554
+ let e = v.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
566
555
  if (!t) {
567
- Vt(!0), N(Te);
556
+ Ht(!0), M(ke);
568
557
  return;
569
558
  }
570
559
  if (t.routedBy === "auto") {
571
- Vt(!0);
560
+ Ht(!0);
572
561
  return;
573
562
  }
574
563
  if (t.messages.length === 0 && !t.backendSessionId) {
575
- R(t.id, Te);
564
+ L(t.id, ke);
576
565
  return;
577
566
  }
578
567
  let n = e.conversations.find((t) => t.routedBy === "auto" && t.messages.length === 0 && !t.backendSessionId && !e.processingByConversationId[t.id]);
579
- n ? (At(n.id), R(n.id, Te)) : P(void 0, Te, { routedBy: "auto" });
568
+ n ? (jt(n.id), L(n.id, ke)) : N(void 0, ke, { routedBy: "auto" });
580
569
  }, [
581
- P,
582
- R,
583
- At,
584
- Vt,
585
- N
586
- ]), kn = x((e) => {
587
- if (O.find((t) => t.id === e)?.writeCapable && !Ce(b.getState().acknowledgedWriteModes, e)) {
588
- en(e);
570
+ N,
571
+ L,
572
+ jt,
573
+ Ht,
574
+ M
575
+ ]), kn = y((e) => {
576
+ if (E.find((t) => t.id === e)?.writeCapable && !De(v.getState().acknowledgedWriteModes, e)) {
577
+ tn(e);
589
578
  return;
590
579
  }
591
580
  Dn(e);
592
- }, [Dn, O]), An = x(() => {
593
- let e = W;
594
- if (en(null), !e) return;
595
- let t = U.current;
596
- if (U.current = null, t) {
597
- zt(e), J(t.content, t.attachments, t.options);
581
+ }, [Dn, E]), An = y(() => {
582
+ let e = U;
583
+ if (tn(null), !e) return;
584
+ let t = H.current;
585
+ if (H.current = null, t) {
586
+ Bt(e), J(t.content, t.attachments, t.options);
598
587
  return;
599
588
  }
600
- zt(e), Dn(e);
589
+ Bt(e), Dn(e);
601
590
  }, [
602
- W,
603
- zt,
591
+ U,
592
+ Bt,
604
593
  Dn,
605
594
  J
606
- ]), jn = W === null ? void 0 : O.find((e) => e.id === W) ?? { id: W }, Mn = x(() => {
607
- en(null);
608
- let e = U.current;
609
- U.current = null, e && J(e.content, e.attachments, {
595
+ ]), jn = U === null ? void 0 : E.find((e) => e.id === U) ?? { id: U }, Mn = y(() => {
596
+ tn(null);
597
+ let e = H.current;
598
+ H.current = null, e && J(e.content, e.attachments, {
610
599
  ...e.options,
611
600
  autoIntent: "read"
612
601
  });
613
602
  }, [J]);
614
- return /* @__PURE__ */ ut("div", {
603
+ return /* @__PURE__ */ ft("div", {
615
604
  className: "relative flex flex-1 flex-col overflow-hidden",
616
605
  children: [
617
- /* @__PURE__ */ ut("div", {
606
+ /* @__PURE__ */ ft("div", {
618
607
  className: "contents",
619
608
  inert: Q.active || void 0,
620
609
  children: [
621
- X.length > 0 && !Q.active ? /* @__PURE__ */ T(Ge, {
610
+ X.length > 0 && !Q.active ? /* @__PURE__ */ C(Ye, {
622
611
  count: X.length,
623
- onOpenTranscript: () => nn(!0)
612
+ onOpenTranscript: () => rn(!0)
624
613
  }) : null,
625
- yn.length === 0 ? /* @__PURE__ */ T(Je, {
626
- mode: M,
614
+ yn.length === 0 ? /* @__PURE__ */ C(Qe, {
615
+ mode: j,
627
616
  onSuggestionClick: hn,
628
- explainsAuto: Zt,
629
- suggestions: Zt && M === "assistant" ? De(O.find((e) => e.id === "assistant")?.suggestions ?? [], O.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
630
- }) : /* @__PURE__ */ T("div", {
617
+ explainsAuto: Qt,
618
+ suggestions: Qt && j === "assistant" ? je(E.find((e) => e.id === "assistant")?.suggestions ?? [], E.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
619
+ }) : /* @__PURE__ */ C("div", {
631
620
  className: "flex min-h-0 flex-1 flex-col",
632
- children: /* @__PURE__ */ T(Ye, {
621
+ children: /* @__PURE__ */ C($e, {
633
622
  onApprovePendingWrite: mn,
634
- approvingWriteRef: ln,
623
+ approvingWriteRef: un,
635
624
  messages: yn,
636
- processing: B ?? null,
637
- streamingMessageId: Gt,
638
- failedMessageId: Kt,
625
+ processing: z ?? null,
626
+ streamingMessageId: Kt,
627
+ failedMessageId: qt,
639
628
  onRetry: gn
640
629
  })
641
630
  }),
642
- /* @__PURE__ */ T(ot, {
643
- onStartVoiceSession: Q.available && sn ? Q.start : void 0,
631
+ /* @__PURE__ */ C(ct, {
632
+ onStartVoiceSession: Q.available && cn ? Q.start : void 0,
644
633
  onSend: (e, t) => void J(e, t),
645
- disabled: Wt,
646
- placeholder: M === "api-calls" ? E("chatArea.placeholderActions", "What would you like me to do?") : E("chatArea.placeholderGeneral", "Ask me anything…"),
647
- mode: M,
648
- writeAccessDenied: ht === "denied" && !!K?.writeCapable,
649
- availableModes: Yt,
650
- attachmentCharsPerFile: $t,
634
+ disabled: Gt,
635
+ placeholder: j === "api-calls" ? w("chatArea.placeholderActions", "What would you like me to do?") : w("chatArea.placeholderGeneral", "Ask me anything…"),
636
+ mode: j,
637
+ writeAccessDenied: _t === "denied" && !!G?.writeCapable,
638
+ availableModes: Xt,
639
+ attachmentCharsPerFile: en,
651
640
  onModeChange: kn,
652
- auto: Xt ? {
653
- active: Zt,
641
+ auto: Zt ? {
642
+ active: Qt,
654
643
  onSelect: On
655
644
  } : void 0
656
645
  })
657
646
  ]
658
647
  }),
659
- tn && !Q.active ? /* @__PURE__ */ T(Ke, {
648
+ nn && !Q.active ? /* @__PURE__ */ C(Xe, {
660
649
  turns: X,
661
- onClose: () => nn(!1),
650
+ onClose: () => rn(!1),
662
651
  onSave: bn,
663
652
  onContinueInChat: Cn ? wn : void 0,
664
653
  closeOnEscape: !0
665
654
  }) : null,
666
- Q.active && /* @__PURE__ */ T(Xe, {
655
+ Q.active && /* @__PURE__ */ C(et, {
667
656
  session: Q.session,
668
657
  notice: Q.notice,
669
658
  capturing: Q.capturing,
@@ -686,10 +675,10 @@ var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
686
675
  onToggleMute: Q.toggleMute,
687
676
  onEnd: En
688
677
  }),
689
- /* @__PURE__ */ T(ct, {
690
- open: W !== null,
678
+ /* @__PURE__ */ C(ut, {
679
+ open: U !== null,
691
680
  mode: jn,
692
- currentMode: K ?? { id: M },
681
+ currentMode: G ?? { id: j },
693
682
  onConfirm: An,
694
683
  onCancel: Mn
695
684
  })
@@ -697,4 +686,4 @@ var mt = ({ visible: mt = !0, writeAccess: ht = "unknown" }) => {
697
686
  });
698
687
  };
699
688
  //#endregion
700
- export { mt as AssistantChatArea };
689
+ export { gt as AssistantChatArea };