@burdenoff/fe-libs 2026.906.4 → 2026.906.6

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.
@@ -2,69 +2,69 @@ import { useI18n as e } from "../../providers/shell/I18nProvider.js";
2
2
  import { useAuthToken as t } from "../../providers/shell/AuthTokenProvider.js";
3
3
  import "../../../shared-providers-shell.js";
4
4
  import { isQuotaExhaustedError as n } from "../quota.js";
5
- import { createAssistantSandbox as r, createAssistantSession as i, extendAssistantSandboxTTL as a, findExistingSandbox as o, getAssistantArtifacts as s, getAssistantMessages as c, getAssistantSession as l, sendAssistantPromptAsync as u, waitForAssistantServiceReady as d, waitForSandboxRunning as f } from "../api.js";
6
- import { getAssistantMedia as p, sanitize as ee } from "../progress.js";
5
+ import { createAssistantSandbox as r, createAssistantSession as i, extendAssistantSandboxTTL as a, findExistingSandbox as o, getAssistantArtifacts as s, getAssistantMessages as c, getAssistantSession as l, releaseSupersededAssistantSandboxes as u, sendAssistantPromptAsync as ee, waitForAssistantServiceReady as d, waitForSandboxRunning as f } from "../api.js";
6
+ import { getAssistantMedia as p, sanitize as te } from "../progress.js";
7
7
  import { isVoiceTurn as m, voiceMarker as h, voiceSessionIdOf as g } from "../voice/turnVisibility.js";
8
- import { buildContinuedFromVoiceNote as _, buildVoiceTranscriptMarkdown as v, voiceTranscriptFilename as te } from "../voice/voiceTranscript.js";
9
- import { pollDelayMs as ne } from "../voice/assistantPollSchedule.js";
8
+ import { buildContinuedFromVoiceNote as _, buildVoiceTranscriptMarkdown as ne, voiceTranscriptFilename as v } from "../voice/voiceTranscript.js";
9
+ import { pollDelayMs as re } from "../voice/assistantPollSchedule.js";
10
10
  import { toCaptionText as y } from "../voice/captionText.js";
11
- import { resolveAssistantLanguage as b } from "../voice/languages.js";
12
- import { resolveLanguagePair as re } from "../voice/languagePair.js";
13
- import { findPendingWrite as x } from "../pendingWrite.js";
14
- import { useAssistantProduct as ie } from "../product.js";
15
- import { useAssistantTr as ae } from "../i18n.js";
16
- import { buildPromptParts as oe, buildPromptWithAttachments as se, countInlineImageCandidates as ce, countInlinedImageParts as le, getSendableAttachments as ue, toMessageAttachment as de } from "../attachments.js";
17
- import { useAssistantStore as S } from "../store.js";
18
- import { isTurnInFlight as fe } from "../turnState.js";
19
- import { parseToolActivity as pe } from "./AssistantToolActivity.js";
20
- import { useVoiceSession as me } from "./useVoiceSession.js";
21
- import { getOrganizationId as he, getWorkspaceId as ge } from "../context.js";
22
- import { createReadinessTracker as _e } from "../sandboxReadiness.js";
23
- import { AssistantSpokenTurnsNotice as ve } from "./AssistantSpokenTurnsNotice.js";
24
- import { VoiceTranscriptDrawer as ye } from "./voice/VoiceTranscriptDrawer.js";
25
- import { downloadFile as be } from "../exportConversation.js";
26
- import { AssistantEmptyState as xe } from "./AssistantEmptyState.js";
27
- import { AssistantMessageList as Se } from "./AssistantMessageList.js";
28
- import { AssistantVoiceSession as Ce } from "./voice/AssistantVoiceSession.js";
29
- import { useAssistantApiAccess as we } from "../useAssistantApiAccess.js";
30
- import { useConversationTurns as Te } from "../useConversationTurns.js";
31
- import { isMultimodalBodyRejection as Ee, isRecoverableAssistantError as De } from "../transportErrors.js";
32
- import { dispatchAssistantQuotaExhausted as Oe, notifyAiCreditsUpdated as ke } from "../aiCredits.js";
33
- import { useAssistantAttachments as Ae } from "../useAssistantAttachments.js";
34
- import { AssistantComposer as je } from "./composer/AssistantComposer.js";
35
- import { isProdRuntime as Me } from "../env.js";
36
- import { AssistantApiCallsConsentDialog as Ne } from "./AssistantApiCallsConsentDialog.js";
37
- import { useCallback as C, useEffect as w, useMemo as T, useRef as E, useState as Pe } from "react";
38
- import { jsx as D, jsxs as Fe } from "react/jsx-runtime";
11
+ import { resolveAssistantLanguage as ie } from "../voice/languages.js";
12
+ import { resolveLanguagePair as b } from "../voice/languagePair.js";
13
+ import { findPendingWrite as ae } from "../pendingWrite.js";
14
+ import { useAssistantProduct as oe } from "../product.js";
15
+ import { useAssistantTr as se } from "../i18n.js";
16
+ import { buildPromptParts as ce, buildPromptWithAttachments as le, countInlineImageCandidates as ue, countInlinedImageParts as de, getSendableAttachments as fe, toMessageAttachment as pe } from "../attachments.js";
17
+ import { useAssistantStore as x } from "../store.js";
18
+ import { isTurnInFlight as me } from "../turnState.js";
19
+ import { parseToolActivity as he } from "./AssistantToolActivity.js";
20
+ import { useVoiceSession as ge } from "./useVoiceSession.js";
21
+ import { getOrganizationId as _e, getWorkspaceId as ve } from "../context.js";
22
+ import { createReadinessTracker as ye } from "../sandboxReadiness.js";
23
+ import { AssistantSpokenTurnsNotice as be } from "./AssistantSpokenTurnsNotice.js";
24
+ import { VoiceTranscriptDrawer as xe } from "./voice/VoiceTranscriptDrawer.js";
25
+ import { downloadFile as Se } from "../exportConversation.js";
26
+ import { AssistantEmptyState as Ce } from "./AssistantEmptyState.js";
27
+ import { AssistantMessageList as we } from "./AssistantMessageList.js";
28
+ import { AssistantVoiceSession as Te } from "./voice/AssistantVoiceSession.js";
29
+ import { useAssistantApiAccess as Ee } from "../useAssistantApiAccess.js";
30
+ import { useConversationTurns as De } from "../useConversationTurns.js";
31
+ import { isMultimodalBodyRejection as Oe, isRecoverableAssistantError as ke } from "../transportErrors.js";
32
+ import { dispatchAssistantQuotaExhausted as Ae, notifyAiCreditsUpdated as je } from "../aiCredits.js";
33
+ import { useAssistantAttachments as Me } from "../useAssistantAttachments.js";
34
+ import { AssistantComposer as Ne } from "./composer/AssistantComposer.js";
35
+ import { isProdRuntime as Pe } from "../env.js";
36
+ import { AssistantApiCallsConsentDialog as Fe } from "./AssistantApiCallsConsentDialog.js";
37
+ import { useCallback as S, useEffect as C, useMemo as w, useRef as T, useState as Ie } from "react";
38
+ import { jsx as E, jsxs as Le } from "react/jsx-runtime";
39
39
  //#region src/shared/assistant/ui/AssistantChatArea.tsx
40
- var Ie = {
40
+ var Re = {
41
41
  general: 18e4,
42
42
  assistant: 18e4,
43
43
  "api-calls": 18e4,
44
44
  "vibe-plugins": 6e5
45
- }, Le = 18e4, Re = 600, ze = 2e4;
46
- function Be() {
45
+ }, ze = 18e4, Be = 600, Ve = 2e4;
46
+ function He() {
47
47
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
48
48
  }
49
- function Ve(e) {
49
+ function Ue(e) {
50
50
  return e.info?.time?.created ?? 0;
51
51
  }
52
- function O(e) {
52
+ function D(e) {
53
53
  return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
54
54
  }
55
- function k(e) {
55
+ function O(e) {
56
56
  return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
57
57
  let t = e.state?.status ?? "running", n = e.tool ?? "tool";
58
58
  return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
59
59
  });
60
60
  }
61
- function He(e, t) {
62
- let n = e.filter((e) => e.info?.role === "assistant" && Ve(e) > t).sort((e, t) => Ve(e) - Ve(t));
61
+ function We(e, t) {
62
+ let n = e.filter((e) => e.info?.role === "assistant" && Ue(e) > t).sort((e, t) => Ue(e) - Ue(t));
63
63
  if (n.length === 0) return {
64
64
  content: "Thinking...",
65
65
  done: !1
66
66
  };
67
- let r = n[n.length - 1], i = O(r.parts), a = p(r.parts), o = k(r.parts), s = x(r.parts), c = [
67
+ let r = n[n.length - 1], i = D(r.parts), a = p(r.parts), o = O(r.parts), s = ae(r.parts), c = [
68
68
  i,
69
69
  ...a,
70
70
  ...o
@@ -78,7 +78,7 @@ function He(e, t) {
78
78
  ...s ? { pendingWrite: s } : {}
79
79
  };
80
80
  }
81
- function Ue(e) {
81
+ function Ge(e) {
82
82
  switch (e) {
83
83
  case "provisioning": return "Starting assistant environment...";
84
84
  case "connecting": return "Connecting to assistant...";
@@ -86,25 +86,25 @@ function Ue(e) {
86
86
  default: return "";
87
87
  }
88
88
  }
89
- var A = ({ visible: p = !0, writeAccess: x = "unknown" }) => {
90
- let O = ae(), { product: k, modes: A, gatherPageContext: We, buildPrompt: Ge, reportTokenUsage: Ke } = ie(), { getAccessToken: j, getWorkspaceToken: qe, userId: Je } = t(), { locale: Ye } = e(), Xe = S((e) => e.assistantLanguage), Ze = S((e) => e.replyLanguage), Qe = T(() => re(Xe, Ze, Ye), [
91
- Xe,
92
- Ze,
93
- Ye
94
- ]), $e = Qe.reply.english, et = Qe.replyIsExplicit, tt = Qe.reply.code, { conversations: nt, activeConversationId: M, mode: N, processingByConversationId: rt, setMode: it, setConversationMode: at, setActiveConversation: ot, createConversation: P, addMessage: F, updateMessage: st, patchMessage: I, mergeMessageMetadata: ct, setConversationProcessing: L, setBackendSessionId: lt, clearBackendSessionId: R, setSandbox: z, clearSandbox: ut, acknowledgeApiCalls: dt } = S(), ft = nt.find((e) => e.id === M), B = Te(ft), V = B.all, H = M ? rt[M] : void 0, U = fe(H?.status), pt = U ? H?.messageId ?? null : null, mt = H?.status === "error" ? H.messageId : null, { canUseApiCalls: W, loading: ht } = we(he()), gt = T(() => A.filter((e) => !e.requiresAdmin || W), [A, W]), [_t, vt] = Pe(null), [yt, G] = Pe(!1), bt = E({}), K = E(_e()), xt = E(/* @__PURE__ */ new Set()), St = T(() => A.find((e) => e.id === N), [A, N]);
95
- w(() => {
96
- ht || (!St || St.requiresAdmin && !W) && N !== "assistant" && it("assistant");
89
+ var k = ({ visible: p = !0, writeAccess: ae = "unknown" }) => {
90
+ let D = se(), { product: O, modes: k, gatherPageContext: Ke, buildPrompt: qe, reportTokenUsage: Je } = oe(), { getAccessToken: A, getWorkspaceToken: Ye, userId: Xe } = t(), { locale: Ze } = e(), Qe = x((e) => e.assistantLanguage), $e = x((e) => e.replyLanguage), et = w(() => b(Qe, $e, Ze), [
91
+ Qe,
92
+ $e,
93
+ Ze
94
+ ]), tt = et.reply.english, nt = et.replyIsExplicit, rt = et.reply.code, { conversations: it, activeConversationId: j, mode: M, processingByConversationId: at, setMode: ot, setConversationMode: N, setActiveConversation: st, createConversation: P, addMessage: F, updateMessage: ct, patchMessage: I, mergeMessageMetadata: lt, setConversationProcessing: L, setBackendSessionId: ut, clearBackendSessionId: R, setSandbox: z, clearSandbox: dt, acknowledgeApiCalls: ft } = x(), pt = it.find((e) => e.id === j), B = De(pt), V = B.all, H = j ? at[j] : void 0, U = me(H?.status), mt = U ? H?.messageId ?? null : null, ht = H?.status === "error" ? H.messageId : null, { canUseApiCalls: W, loading: gt } = Ee(_e()), _t = w(() => k.filter((e) => !e.requiresAdmin || W), [k, W]), [vt, yt] = Ie(null), [bt, G] = Ie(!1), xt = T({}), K = T(ye()), St = T(/* @__PURE__ */ new Set()), q = w(() => k.find((e) => e.id === M), [k, M]);
95
+ C(() => {
96
+ gt || (!q || q.requiresAdmin && !W) && M !== "assistant" && ot("assistant");
97
97
  }, [
98
- N,
99
- St,
98
+ M,
99
+ q,
100
100
  W,
101
- ht,
102
- it
101
+ gt,
102
+ ot
103
103
  ]);
104
- let q = C((e, t, n, r) => {
105
- L(e, n, t, null), r ? st(e, t, r) : st(e, t, Ue(n));
106
- }, [L, st]), Ct = C(async (e, t, n, a, s) => {
107
- let c = S.getState().sandboxesByMode[n]?.sandboxId ?? null, u = async (e) => {
104
+ let J = S((e, t, n, r) => {
105
+ L(e, n, t, null), r ? ct(e, t, r) : ct(e, t, Ge(n));
106
+ }, [L, ct]), Ct = S(async (e, t, n, a, s) => {
107
+ let c = x.getState().sandboxesByMode[n]?.sandboxId ?? null, ee = async (e) => {
108
108
  if (K.current.isFresh(e)) return !0;
109
109
  try {
110
110
  return await f(e, a, s, 3e5), await d(e, a, s, 9e4), K.current.markVerified(e), !0;
@@ -112,339 +112,339 @@ var A = ({ visible: p = !0, writeAccess: x = "unknown" }) => {
112
112
  return K.current.invalidate(e), !1;
113
113
  }
114
114
  };
115
- if (c && (z(n, c, "provisioning"), q(e, t, "provisioning", "Reusing assistant environment..."), await u(c) || (z(n, null, "provisioning"), c = null)), !c) {
116
- q(e, t, "provisioning", "Looking for existing environment...");
117
- let r = await o(a, k, n, Me(), s);
118
- r && (z(n, r, "provisioning"), q(e, t, "provisioning", "Reusing assistant environment..."), await u(r) ? c = r : z(n, null, "provisioning"));
115
+ if (c && (z(n, c, "provisioning"), J(e, t, "provisioning", "Reusing assistant environment..."), await ee(c) || (z(n, null, "provisioning"), c = null)), !c) {
116
+ J(e, t, "provisioning", "Looking for existing environment...");
117
+ let r = await o(a, O, n, Pe(), s);
118
+ r && (z(n, r, "provisioning"), J(e, t, "provisioning", "Reusing assistant environment..."), await ee(r) ? c = r : z(n, null, "provisioning"));
119
119
  }
120
120
  if (!c) {
121
- if (n === "api-calls" && !j()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
122
- q(e, t, "provisioning", "Starting assistant environment..."), z(n, null, "provisioning"), c = await r(k, n, a, Me(), Re, s), z(n, c, "provisioning"), await f(c, a, s, 3e5), await d(c, a, s, 9e4);
121
+ if (n === "api-calls" && !A()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
122
+ J(e, t, "provisioning", "Starting assistant environment..."), z(n, null, "provisioning"), await u(a, O, n, Pe(), s), c = await r(O, n, a, Pe(), Be, s), z(n, c, "provisioning"), await f(c, a, s, 3e5), await d(c, a, s, 9e4);
123
123
  }
124
124
  z(n, c, "running");
125
- let p = S.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null;
125
+ let p = x.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null;
126
126
  if (p) try {
127
127
  let e = await l(c, a, p, s);
128
128
  if (e.mode !== n) throw Error(`Session mode mismatch: expected ${n}, received ${e.mode}`);
129
129
  } catch {
130
130
  R(e), p = null;
131
131
  }
132
- return p || (q(e, t, "connecting", "Preparing session..."), p = (await i(c, a, n, s)).sessionId, lt(e, p)), {
132
+ return p || (J(e, t, "connecting", "Preparing session..."), p = (await i(c, a, n, s)).sessionId, ut(e, p)), {
133
133
  sandboxId: c,
134
134
  sessionId: p
135
135
  };
136
136
  }, [
137
137
  R,
138
- j,
139
- k,
140
- lt,
138
+ A,
139
+ O,
140
+ ut,
141
141
  z,
142
- q
143
- ]), J = C(async (e, t = [], r = {}) => {
144
- let i = r.voiceSessionId !== void 0, o = S.getState(), l = o.activeConversationId ?? M;
145
- if (l && (fe(o.processingByConversationId[l]?.status) || xt.current.has(l))) return;
146
- let d = o.mode, f = M, p = f ? S.getState().conversations.find((e) => e.id === f) : void 0;
147
- if (f ? p && p.mode !== d && (p.messages.length > 0 || p.backendSessionId) ? f = P(void 0, d) : p && p.mode !== d && at(f, d) : f = P(void 0, d), !f) return;
148
- bt.current[f] = t;
149
- let m = ge(), g = {
150
- accessToken: j(),
151
- workspaceToken: qe(),
152
- userId: Je,
153
- organizationId: he()
154
- }, _ = {
155
- id: Be(),
142
+ J
143
+ ]), Y = S(async (e, t = [], r = {}) => {
144
+ let i = r.voiceSessionId !== void 0, o = x.getState(), l = o.activeConversationId ?? j;
145
+ if (l && (me(o.processingByConversationId[l]?.status) || St.current.has(l))) return;
146
+ let u = o.mode, d = j, f = d ? x.getState().conversations.find((e) => e.id === d) : void 0;
147
+ if (d ? f && f.mode !== u && (f.messages.length > 0 || f.backendSessionId) ? d = P(void 0, u) : f && f.mode !== u && N(d, u) : d = P(void 0, u), !d) return;
148
+ xt.current[d] = t;
149
+ let p = ve(), m = {
150
+ accessToken: A(),
151
+ workspaceToken: Ye(),
152
+ userId: Xe,
153
+ organizationId: _e()
154
+ }, g = {
155
+ id: He(),
156
156
  role: "user",
157
157
  content: e,
158
158
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
159
159
  metadata: {
160
- ...t.length ? { attachments: t.map(de) } : {},
160
+ ...t.length ? { attachments: t.map(pe) } : {},
161
161
  ...h(r.voiceSessionId)
162
162
  }
163
163
  };
164
- F(f, _);
165
- let v = Be();
166
- F(f, {
167
- id: v,
164
+ F(d, g);
165
+ let _ = He();
166
+ F(d, {
167
+ id: _,
168
168
  role: "assistant",
169
169
  content: "",
170
170
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
171
171
  metadata: {
172
- lang: tt,
172
+ lang: rt,
173
173
  ...h(r.voiceSessionId)
174
174
  }
175
- }), L(f, "provisioning", v, null);
176
- let te = (e, t, n, i, a = tt) => {
177
- I(f, v, { content: ee(e) }), ct(f, v, {
175
+ }), L(d, "provisioning", _, null);
176
+ let ne = (e, t, n, i, a = rt) => {
177
+ I(d, _, { content: te(e) }), lt(d, _, {
178
178
  lang: a,
179
179
  ...t?.length ? { artifacts: t } : {},
180
- ...t?.length || n || i ? { mode: d } : {},
180
+ ...t?.length || n || i ? { mode: u } : {},
181
181
  ...n ? { sessionId: n } : {},
182
182
  ...i ? { sandboxId: i } : {},
183
183
  ...h(r.voiceSessionId)
184
184
  });
185
- }, y = async (n = 1) => {
185
+ }, v = async (n = 1) => {
186
186
  let r = !1;
187
187
  try {
188
- let { sandboxId: n, sessionId: o } = await Ct(f, v, d, m, g), l = (await c(n, m, o, g, { limit: 50 }).catch(() => [])).reduce((e, t) => Math.max(e, Ve(t)), 0);
189
- q(f, v, "streaming", "Thinking...");
190
- let p = se(e, t), h = Ge?.(d, p, $e, et, i) ?? p, _ = oe(h, t), y = le(_), b = y > 0, re = We?.();
191
- r = ce(t) > y;
188
+ let { sandboxId: n, sessionId: o } = await Ct(d, _, u, p, m), l = (await c(n, p, o, m, { limit: 50 }).catch(() => [])).reduce((e, t) => Math.max(e, Ue(t)), 0);
189
+ J(d, _, "streaming", "Thinking...");
190
+ let f = le(e, t), h = qe?.(u, f, tt, nt, i) ?? f, g = ce(h, t), v = de(g), y = v > 0, ie = Ke?.();
191
+ r = ue(t) > v;
192
192
  try {
193
- await u(n, m, o, h, d, re, g, _?.length ? { parts: _ } : void 0);
193
+ await ee(n, p, o, h, u, ie, m, g?.length ? { parts: g } : void 0);
194
194
  } catch (e) {
195
- if (!_ || !Ee(e)) throw e;
196
- await u(n, m, o, h, d, re, g, void 0), r ||= b;
195
+ if (!g || !Oe(e)) throw e;
196
+ await ee(n, p, o, h, u, ie, m, void 0), r ||= y;
197
197
  }
198
- let x = He([], l), ie = Date.now() + (Ie[d] ?? Le), ae = Date.now(), ue = Date.now();
199
- for (; Date.now() < ie && (x = He(await c(n, m, o, g, {
198
+ let b = We([], l), ae = Date.now() + (Re[u] ?? ze), oe = Date.now(), se = Date.now();
199
+ for (; Date.now() < ae && (b = We(await c(n, p, o, m, {
200
200
  limit: 50,
201
201
  sinceMs: l
202
- }), l), I(f, v, { content: ee(x.content) }), x.pendingWrite && ct(f, v, { pendingWrite: x.pendingWrite }), !x.done);) Date.now() - ae > 3e4 && (await a(n, m, 600, g).catch(() => void 0), ae = Date.now()), await new Promise((e) => setTimeout(e, ne(Date.now() - ue)));
203
- if (!x.done && d !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
204
- let de = d === "vibe-plugins" ? await s(n, m, o, g).then((e) => e).catch(() => []) : void 0;
205
- if (x.done || (x = {
206
- ...x,
207
- content: `${x.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
208
- }), r && (x = {
209
- ...x,
210
- content: `${x.content}\n\n${O("attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
211
- }), te(x.content, de, o, n), x.tokens) {
212
- I(f, v, { tokens: x.tokens });
202
+ }), l), I(d, _, { content: te(b.content) }), b.pendingWrite && lt(d, _, { pendingWrite: b.pendingWrite }), !b.done);) Date.now() - oe > 3e4 && (await a(n, p, 600, m).catch(() => void 0), oe = Date.now()), await new Promise((e) => setTimeout(e, re(Date.now() - se)));
203
+ if (!b.done && u !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
204
+ let fe = u === "vibe-plugins" ? await s(n, p, o, m).then((e) => e).catch(() => []) : void 0;
205
+ if (b.done || (b = {
206
+ ...b,
207
+ content: `${b.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
208
+ }), r && (b = {
209
+ ...b,
210
+ content: `${b.content}\n\n${D("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._")}`
211
+ }), ne(b.content, fe, o, n), b.tokens) {
212
+ I(d, _, { tokens: b.tokens });
213
213
  try {
214
- await Ke?.({
215
- workspaceId: m,
214
+ await Je?.({
215
+ workspaceId: p,
216
216
  sessionId: o,
217
- messageId: x.messageId,
218
- model: x.model,
219
- tokens: x.tokens
220
- }), ke(k);
217
+ messageId: b.messageId,
218
+ model: b.model,
219
+ tokens: b.tokens
220
+ }), je(O);
221
221
  } catch {}
222
222
  }
223
- L(f, "complete", v, null);
223
+ L(d, "complete", _, null);
224
224
  } catch (e) {
225
- if (n === 1 && De(e)) return R(f), ut(d), y(2);
225
+ if (n === 1 && ke(e)) return R(d), dt(u), v(2);
226
226
  throw e;
227
227
  }
228
- }, b = f;
229
- xt.current.add(b);
228
+ }, y = d;
229
+ St.current.add(y);
230
230
  try {
231
- if (!m) throw Error("Assistant backend is unavailable without an active workspace context.");
232
- await y();
231
+ if (!p) throw Error("Assistant backend is unavailable without an active workspace context.");
232
+ await v();
233
233
  } catch (e) {
234
- if (K.current.invalidate(S.getState().sandboxesByMode[d]?.sandboxId ?? null), n(e)) {
235
- Oe(k, "sandbox"), te("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant.", void 0, void 0, void 0, "en"), L(f, "error", v, null);
234
+ if (K.current.invalidate(x.getState().sandboxesByMode[u]?.sandboxId ?? null), n(e)) {
235
+ Ae(O, "sandbox"), ne("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant.", void 0, void 0, void 0, "en"), L(d, "error", _, null);
236
236
  return;
237
237
  }
238
238
  let t = e instanceof Error ? e.message : "Something went wrong";
239
- L(f, "error", v, t), I(f, v, { content: `Sorry, an error occurred: ${t}. Please try again.` }), ct(f, v, {
239
+ L(d, "error", _, t), I(d, _, { content: `Sorry, an error occurred: ${t}. Please try again.` }), lt(d, _, {
240
240
  lang: "en",
241
241
  ...h(r.voiceSessionId)
242
242
  });
243
243
  } finally {
244
- xt.current.delete(b);
244
+ St.current.delete(y);
245
245
  }
246
246
  }, [
247
- M,
247
+ j,
248
248
  F,
249
- Ge,
249
+ qe,
250
250
  R,
251
- ut,
252
- nt,
251
+ dt,
252
+ it,
253
253
  P,
254
254
  Ct,
255
- We,
256
- j,
257
- qe,
258
- I,
259
- k,
260
255
  Ke,
261
- et,
256
+ A,
257
+ Ye,
258
+ I,
259
+ O,
260
+ Je,
261
+ nt,
262
+ rt,
262
263
  tt,
263
- $e,
264
- lt,
265
- at,
264
+ ut,
265
+ N,
266
266
  L,
267
- O,
268
- q,
269
- Je
270
- ]), wt = C((e) => {
271
- J(e);
272
- }, [J]), Tt = C(() => {
273
- let e = [...B.chat].reverse().find((e) => e.role === "user"), t = M ? bt.current[M] ?? [] : [];
274
- e && J(e.content, t);
267
+ D,
268
+ J,
269
+ Xe
270
+ ]), wt = S((e) => {
271
+ Y(e);
272
+ }, [Y]), Tt = S(() => {
273
+ let e = [...B.chat].reverse().find((e) => e.role === "user"), t = j ? xt.current[j] ?? [] : [];
274
+ e && Y(e.content, t);
275
275
  }, [
276
276
  V,
277
- J,
278
- M
279
- ]), Y = E(J);
280
- w(() => {
281
- Y.current = J;
282
- }, [J]);
283
- let Et = T(() => {
277
+ Y,
278
+ j
279
+ ]), Et = T(Y);
280
+ C(() => {
281
+ Et.current = Y;
282
+ }, [Y]);
283
+ let Dt = w(() => {
284
284
  if (U) return null;
285
285
  for (let e = V.length - 1; e >= 0; --e) {
286
286
  let t = V[e];
287
287
  if (t?.role !== "assistant" || !m(t)) continue;
288
- let n = pe(t.content).text.trim();
288
+ let n = he(t.content).text.trim();
289
289
  return n ? {
290
290
  id: t.id,
291
291
  text: n
292
292
  } : null;
293
293
  }
294
294
  return null;
295
- }, [V, U]), Dt = T(() => Et ? y(Et.text) : null, [Et]), Ot = B.chat, X = T(() => B.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
295
+ }, [V, U]), Ot = w(() => Dt ? y(Dt.text) : null, [Dt]), kt = B.chat, X = w(() => B.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
296
296
  id: e.id,
297
297
  role: e.role,
298
- text: pe(e.content).text.trim(),
298
+ text: he(e.content).text.trim(),
299
299
  sessionId: g(e),
300
300
  timestamp: e.timestamp
301
- })).filter((e) => e.text.length > 0), [B.voice]), kt = C(() => {
301
+ })).filter((e) => e.text.length > 0), [B.voice]), At = S(() => {
302
302
  if (X.length === 0) return;
303
303
  let e = /* @__PURE__ */ new Date();
304
- be(v(X, {
305
- title: O("voiceSession.transcript", "Voice conversation"),
306
- savedAt: O("voiceSession.savedAt", "Saved"),
307
- session: O("voiceSession.sessionLabel", "Session"),
308
- earlier: O("voiceSession.earlierLabel", "Earlier"),
309
- you: O("voiceSession.speakerYou", "You"),
310
- assistant: O("voiceSession.speakerAssistant", "Assistant")
311
- }, e), te(k, e), "text/markdown");
304
+ Se(ne(X, {
305
+ title: D("voiceSession.transcript", "Voice conversation"),
306
+ savedAt: D("voiceSession.savedAt", "Saved"),
307
+ session: D("voiceSession.sessionLabel", "Session"),
308
+ earlier: D("voiceSession.earlierLabel", "Earlier"),
309
+ you: D("voiceSession.speakerYou", "You"),
310
+ assistant: D("voiceSession.speakerAssistant", "Assistant")
311
+ }, e), v(O, e), "text/markdown");
312
312
  }, [
313
- k,
313
+ O,
314
314
  X,
315
- O
316
- ]), Z = Ae(), Q = E(Z);
315
+ D
316
+ ]), Z = Me(), Q = T(Z);
317
317
  Q.current = Z;
318
- let $ = me({
319
- onSubmit: C((e, t) => {
318
+ let $ = ge({
319
+ onSubmit: S((e, t) => {
320
320
  let n = () => {
321
- let n = Q.current, r = ue(n.attachments);
322
- Y.current(e, r, { voiceSessionId: t }), n.clear();
321
+ let n = Q.current, r = fe(n.attachments);
322
+ Et.current(e, r, { voiceSessionId: t }), n.clear();
323
323
  };
324
324
  if (!Q.current.isBusy) {
325
325
  n();
326
326
  return;
327
327
  }
328
328
  let r = Date.now(), i = window.setInterval(() => {
329
- Q.current.isBusy && Date.now() - r < ze || (window.clearInterval(i), n());
329
+ Q.current.isBusy && Date.now() - r < Ve || (window.clearInterval(i), n());
330
330
  }, 200);
331
331
  }, []),
332
- latestReply: Et,
333
- language: b(Xe, Ye).tag
334
- }), At = T(() => (ft?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [ft?.messages]), jt = X.length > At, Mt = C(() => {
335
- let e = S.getState().activeConversationId;
332
+ latestReply: Dt,
333
+ language: ie(Qe, Ze).tag
334
+ }), jt = w(() => (pt?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [pt?.messages]), Mt = X.length > jt, Nt = S(() => {
335
+ let e = x.getState().activeConversationId;
336
336
  !e || X.length === 0 || (F(e, {
337
- id: Be(),
337
+ id: He(),
338
338
  role: "system",
339
- content: _(X.slice(At), {
340
- intro: O("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
341
- nothing: O("voiceSession.continuedNothing", "Continued from a voice conversation."),
342
- more: (e) => O("voiceSession.continuedMore", "…and {{count}} more", { count: e })
339
+ content: _(X.slice(jt), {
340
+ intro: D("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
341
+ nothing: D("voiceSession.continuedNothing", "Continued from a voice conversation."),
342
+ more: (e) => D("voiceSession.continuedMore", "…and {{count}} more", { count: e })
343
343
  }),
344
344
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
345
345
  metadata: { continuedVoiceTurns: X.length }
346
346
  }), G(!1), $.end());
347
347
  }, [
348
348
  X,
349
- At,
349
+ jt,
350
350
  F,
351
- O,
351
+ D,
352
352
  $
353
- ]), Nt = E(0);
354
- w(() => {
355
- $.active && (Nt.current = X.length);
353
+ ]), Pt = T(0);
354
+ C(() => {
355
+ $.active && (Pt.current = X.length);
356
356
  }, [$.active]);
357
- let Pt = C(() => {
358
- let e = X.length > Nt.current;
357
+ let Ft = S(() => {
358
+ let e = X.length > Pt.current;
359
359
  $.end(), e && G(!0);
360
360
  }, [X, $]);
361
- w(() => {
361
+ C(() => {
362
362
  !p && $.active && $.end();
363
- }, [p, $]), w(() => {
363
+ }, [p, $]), C(() => {
364
364
  $.active || Q.current.clear();
365
- }, [$.active]), w(() => {
366
- let e = S.getState().consumePendingPrompt();
367
- return e && Y.current(e), S.subscribe((e, t) => {
365
+ }, [$.active]), C(() => {
366
+ let e = x.getState().consumePendingPrompt();
367
+ return e && Et.current(e), x.subscribe((e, t) => {
368
368
  if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
369
- let e = S.getState().consumePendingPrompt();
370
- e && Y.current(e);
369
+ let e = x.getState().consumePendingPrompt();
370
+ e && Et.current(e);
371
371
  }
372
372
  });
373
373
  }, []);
374
- let Ft = C((e) => {
375
- let t = M ? S.getState().conversations.find((e) => e.id === M) : void 0;
374
+ let It = S((e) => {
375
+ let t = j ? x.getState().conversations.find((e) => e.id === j) : void 0;
376
376
  if (t && (t.messages.length > 0 || t.backendSessionId)) {
377
377
  if (t.mode !== e) {
378
- let t = S.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !S.getState().processingByConversationId[t.id]);
379
- t ? ot(t.id) : P(void 0, e);
378
+ let t = x.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !x.getState().processingByConversationId[t.id]);
379
+ t ? st(t.id) : P(void 0, e);
380
380
  }
381
- } else M && at(M, e);
382
- it(e);
381
+ } else j && N(j, e);
382
+ ot(e);
383
383
  }, [
384
- M,
384
+ j,
385
385
  P,
386
- ot,
387
- at,
388
- it
389
- ]), It = C((e) => {
390
- if (A.find((t) => t.id === e)?.writeCapable && !S.getState().apiCallsAcknowledged) {
391
- vt(e);
386
+ st,
387
+ N,
388
+ ot
389
+ ]), Lt = S((e) => {
390
+ if (k.find((t) => t.id === e)?.writeCapable && !x.getState().apiCallsAcknowledged) {
391
+ yt(e);
392
392
  return;
393
393
  }
394
- Ft(e);
395
- }, [Ft, A]), Lt = C(() => {
396
- let e = _t;
397
- vt(null), dt(), e && Ft(e);
394
+ It(e);
395
+ }, [It, k]), Rt = S(() => {
396
+ let e = vt;
397
+ yt(null), ft(), e && It(e);
398
398
  }, [
399
- _t,
400
- dt,
401
- Ft
402
- ]), Rt = C(() => {
403
- vt(null);
399
+ vt,
400
+ ft,
401
+ It
402
+ ]), zt = S(() => {
403
+ yt(null);
404
404
  }, []);
405
- return /* @__PURE__ */ Fe("div", {
405
+ return /* @__PURE__ */ Le("div", {
406
406
  className: "relative flex flex-1 flex-col overflow-hidden",
407
407
  children: [
408
- /* @__PURE__ */ Fe("div", {
408
+ /* @__PURE__ */ Le("div", {
409
409
  className: "contents",
410
410
  inert: $.active || void 0,
411
411
  children: [
412
- X.length > 0 && !$.active ? /* @__PURE__ */ D(ve, {
412
+ X.length > 0 && !$.active ? /* @__PURE__ */ E(be, {
413
413
  count: X.length,
414
414
  onOpenTranscript: () => G(!0)
415
415
  }) : null,
416
- Ot.length === 0 ? /* @__PURE__ */ D(xe, {
417
- mode: N,
416
+ kt.length === 0 ? /* @__PURE__ */ E(Ce, {
417
+ mode: M,
418
418
  onSuggestionClick: wt
419
- }) : /* @__PURE__ */ D("div", {
419
+ }) : /* @__PURE__ */ E("div", {
420
420
  className: "flex min-h-0 flex-1 flex-col",
421
- children: /* @__PURE__ */ D(Se, {
422
- messages: Ot,
423
- streamingMessageId: pt,
424
- failedMessageId: mt,
421
+ children: /* @__PURE__ */ E(we, {
422
+ messages: kt,
423
+ streamingMessageId: mt,
424
+ failedMessageId: ht,
425
425
  onRetry: Tt
426
426
  })
427
427
  }),
428
- /* @__PURE__ */ D(je, {
429
- onStartVoiceSession: $.available && N !== "api-calls" ? $.start : void 0,
430
- onSend: (e, t) => void J(e, t),
428
+ /* @__PURE__ */ E(Ne, {
429
+ onStartVoiceSession: $.available && M !== "api-calls" ? $.start : void 0,
430
+ onSend: (e, t) => void Y(e, t),
431
431
  disabled: U,
432
- placeholder: N === "api-calls" ? O("chatArea.placeholderActions", "What would you like me to do?") : O("chatArea.placeholderGeneral", "Ask me anything…"),
433
- mode: N,
434
- writeAccessDenied: x === "denied" && !!St?.writeCapable,
435
- availableModes: gt,
436
- onModeChange: It
432
+ placeholder: M === "api-calls" ? D("chatArea.placeholderActions", "What would you like me to do?") : D("chatArea.placeholderGeneral", "Ask me anything…"),
433
+ mode: M,
434
+ writeAccessDenied: ae === "denied" && !!q?.writeCapable,
435
+ availableModes: _t,
436
+ onModeChange: Lt
437
437
  })
438
438
  ]
439
439
  }),
440
- yt && !$.active ? /* @__PURE__ */ D(ye, {
440
+ bt && !$.active ? /* @__PURE__ */ E(xe, {
441
441
  turns: X,
442
442
  onClose: () => G(!1),
443
- onSave: kt,
444
- onContinueInChat: jt ? Mt : void 0,
443
+ onSave: At,
444
+ onContinueInChat: Mt ? Nt : void 0,
445
445
  closeOnEscape: !0
446
446
  }) : null,
447
- $.active && /* @__PURE__ */ D(Ce, {
447
+ $.active && /* @__PURE__ */ E(Te, {
448
448
  session: $.session,
449
449
  notice: $.notice,
450
450
  capturing: $.capturing,
@@ -458,20 +458,20 @@ var A = ({ visible: p = !0, writeAccess: x = "unknown" }) => {
458
458
  onRetryAttachment: Z.retry,
459
459
  canAttachMore: Z.canAddMore,
460
460
  preparingAttachments: Z.preparingCount,
461
- onSaveTranscript: kt,
462
- onContinueInChat: Mt,
461
+ onSaveTranscript: At,
462
+ onContinueInChat: Nt,
463
463
  onInterrupt: $.interrupt,
464
- spoken: Dt,
464
+ spoken: Ot,
465
465
  onToggleMute: $.toggleMute,
466
- onEnd: Pt
466
+ onEnd: Ft
467
467
  }),
468
- /* @__PURE__ */ D(Ne, {
469
- open: _t !== null,
470
- onConfirm: Lt,
471
- onCancel: Rt
468
+ /* @__PURE__ */ E(Fe, {
469
+ open: vt !== null,
470
+ onConfirm: Rt,
471
+ onCancel: zt
472
472
  })
473
473
  ]
474
474
  });
475
475
  };
476
476
  //#endregion
477
- export { A as AssistantChatArea };
477
+ export { k as AssistantChatArea };