@burdenoff/fe-libs 2026.915.1 → 2026.915.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 (29) hide show
  1. package/dist/shared/assistant/api.d.ts +38 -9
  2. package/dist/shared/assistant/api.d.ts.map +1 -1
  3. package/dist/shared/assistant/api.js +79 -74
  4. package/dist/shared/assistant/createSandboxAssistantTransport.d.ts.map +1 -1
  5. package/dist/shared/assistant/createSandboxAssistantTransport.js +3 -3
  6. package/dist/shared/assistant/i18nManifest.d.ts +4 -0
  7. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  8. package/dist/shared/assistant/i18nManifest.js +4 -0
  9. package/dist/shared/assistant/index.d.ts +2 -0
  10. package/dist/shared/assistant/index.d.ts.map +1 -1
  11. package/dist/shared/assistant/runtime.d.ts.map +1 -1
  12. package/dist/shared/assistant/runtime.js +3 -3
  13. package/dist/shared/assistant/store.d.ts +19 -0
  14. package/dist/shared/assistant/store.d.ts.map +1 -1
  15. package/dist/shared/assistant/store.js +9 -2
  16. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  17. package/dist/shared/assistant/ui/AssistantChatArea.js +288 -288
  18. package/dist/shared/assistant/ui/AssistantMessageItem.d.ts.map +1 -1
  19. package/dist/shared/assistant/ui/AssistantMessageItem.js +1 -1
  20. package/dist/shared/assistant/ui/AssistantOverlay.d.ts +111 -0
  21. package/dist/shared/assistant/ui/AssistantOverlay.d.ts.map +1 -0
  22. package/dist/shared/assistant/ui/AssistantOverlay.js +171 -0
  23. package/dist/shared/assistant/ui/assistantOverlayState.d.ts +184 -0
  24. package/dist/shared/assistant/ui/assistantOverlayState.d.ts.map +1 -0
  25. package/dist/shared/assistant/ui/assistantOverlayState.js +68 -0
  26. package/dist/shared/assistant/useAssistantHeartbeat.d.ts.map +1 -1
  27. package/dist/shared/assistant/useAssistantHeartbeat.js +8 -8
  28. package/dist/shared-assistant.js +113 -111
  29. package/package.json +1 -1
@@ -14,14 +14,14 @@ import { toCaptionText as ue } from "../voice/captionText.js";
14
14
  import { resolveAssistantLanguage as de } from "../voice/languages.js";
15
15
  import { resolveLanguagePair as fe } from "../voice/languagePair.js";
16
16
  import { buildPromptParts as pe, buildPromptWithAttachments as me, countInlineImageCandidates as he, countInlinedImageParts as ge, getSendableAttachments as _e, toMessageAttachment as ve } from "../attachments.js";
17
- import { useAssistantStore as y } from "../store.js";
18
- import { isTurnInFlight as b, planAbandonedTurn as ye, planTurnAbort as be } from "../turnState.js";
19
- import { getAssistantDisplayContent as xe } from "../displayContent.js";
20
- import { buildAssistantProgress as Se } from "../turnProgress.js";
21
- import { parseToolActivity as Ce } from "./AssistantToolActivity.js";
22
- import { countSpokenTurns as we, spokenTurnText as Te } from "../spokenTurns.js";
23
- import { useVoiceSession as Ee } from "./useVoiceSession.js";
24
- import { getOrganizationId as De, getWorkspaceId as Oe } from "../context.js";
17
+ import { resolveActiveModeSandbox as y, useAssistantStore as b } from "../store.js";
18
+ import { isTurnInFlight as ye, planAbandonedTurn as be, planTurnAbort as xe } from "../turnState.js";
19
+ import { getAssistantDisplayContent as Se } from "../displayContent.js";
20
+ import { buildAssistantProgress as Ce } from "../turnProgress.js";
21
+ import { parseToolActivity as we } from "./AssistantToolActivity.js";
22
+ import { countSpokenTurns as Te, spokenTurnText as Ee } from "../spokenTurns.js";
23
+ import { useVoiceSession as De } from "./useVoiceSession.js";
24
+ import { getOrganizationId as x, getWorkspaceId as Oe } from "../context.js";
25
25
  import { createReadinessTracker as ke } from "../sandboxReadiness.js";
26
26
  import { AssistantSpokenTurnsNotice as Ae } from "./AssistantSpokenTurnsNotice.js";
27
27
  import { VoiceTranscriptDrawer as je } from "./voice/VoiceTranscriptDrawer.js";
@@ -37,120 +37,120 @@ import { useAssistantAttachments as He } from "../useAssistantAttachments.js";
37
37
  import { AssistantComposer as Ue } from "./composer/AssistantComposer.js";
38
38
  import { isProdRuntime as We } from "../env.js";
39
39
  import { AssistantApiCallsConsentDialog as Ge } from "./AssistantApiCallsConsentDialog.js";
40
- import { useCallback as x, useEffect as S, useMemo as C, useRef as w, useState as Ke } from "react";
41
- import { jsx as T, jsxs as qe } from "react/jsx-runtime";
40
+ import { useCallback as S, useEffect as C, useMemo as w, useRef as T, useState as Ke } from "react";
41
+ import { jsx as E, jsxs as qe } from "react/jsx-runtime";
42
42
  //#region src/shared/assistant/ui/AssistantChatArea.tsx
43
43
  var Je = 600, Ye = 2e4;
44
- function Xe() {
44
+ function D() {
45
45
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
46
46
  }
47
- var Ze = ({ visible: Ze = !0, writeAccess: Qe = "unknown" }) => {
48
- let E = r(), { product: D, modes: O, gatherPageContext: $e, buildPrompt: et, reportTokenUsage: tt } = n(), { getAccessToken: k, getWorkspaceToken: A, userId: j } = t(), { locale: nt } = e(), rt = y((e) => e.assistantLanguage), it = y((e) => e.replyLanguage), at = C(() => fe(rt, it, nt), [
47
+ var Xe = ({ visible: Xe = !0, writeAccess: Ze = "unknown" }) => {
48
+ let O = r(), { product: k, modes: A, gatherPageContext: Qe, buildPrompt: $e, reportTokenUsage: et } = n(), { getAccessToken: j, getWorkspaceToken: M, userId: N } = t(), { locale: tt } = e(), nt = b((e) => e.assistantLanguage), rt = b((e) => e.replyLanguage), it = w(() => fe(nt, rt, tt), [
49
+ nt,
49
50
  rt,
50
- it,
51
- nt
52
- ]), ot = at.reply.english, st = at.replyIsExplicit, ct = at.reply.code, { conversations: lt, activeConversationId: M, mode: N, processingByConversationId: ut, setMode: dt, setConversationMode: ft, setActiveConversation: pt, createConversation: P, addMessage: F, updateMessage: mt, patchMessage: I, mergeMessageMetadata: ht, setConversationProcessing: L, clearConversationProcessing: gt, setBackendSessionId: _t, clearBackendSessionId: vt, setSandbox: R, clearSandbox: yt, acknowledgeApiCalls: bt } = y(), xt = lt.find((e) => e.id === M), z = Le(xt), St = z.all, B = M ? ut[M] : void 0, Ct = b(B?.status), wt = Ct ? B?.messageId ?? null : null, Tt = B?.status === "error" ? B.messageId : null, { canUseApiCalls: Et, loading: Dt } = Ie(De()), Ot = C(() => O.filter((e) => !e.requiresAdmin || Et), [O, Et]), [kt, At] = Ke(null), [jt, V] = Ke(!1), Mt = w({}), H = w(ke()), Nt = w(/* @__PURE__ */ new Set()), U = C(() => O.find((e) => e.id === N), [O, N]);
53
- S(() => {
54
- Dt || (!U || U.requiresAdmin && !Et) && N !== "assistant" && dt("assistant");
51
+ tt
52
+ ]), at = it.reply.english, ot = it.replyIsExplicit, st = it.reply.code, { conversations: ct, activeConversationId: P, mode: F, processingByConversationId: lt, setMode: I, setConversationMode: ut, setActiveConversation: dt, createConversation: L, addMessage: R, updateMessage: ft, patchMessage: z, mergeMessageMetadata: pt, setConversationProcessing: B, clearConversationProcessing: mt, setBackendSessionId: ht, clearBackendSessionId: gt, setSandbox: V, clearSandbox: _t, acknowledgeApiCalls: vt } = b(), yt = ct.find((e) => e.id === P), H = Le(yt), bt = H.all, U = P ? lt[P] : void 0, xt = ye(U?.status), St = xt ? U?.messageId ?? null : null, Ct = U?.status === "error" ? U.messageId : null, { canUseApiCalls: wt, loading: Tt } = Ie(x()), Et = w(() => A.filter((e) => !e.requiresAdmin || wt), [A, wt]), [Dt, Ot] = Ke(null), [kt, At] = Ke(!1), jt = T({}), Mt = T(ke()), Nt = T(/* @__PURE__ */ new Set()), Pt = w(() => A.find((e) => e.id === F), [A, F]);
53
+ C(() => {
54
+ Tt || (!Pt || Pt.requiresAdmin && !wt) && F !== "assistant" && I("assistant");
55
55
  }, [
56
- N,
57
- U,
58
- Et,
59
- Dt,
60
- dt
56
+ F,
57
+ Pt,
58
+ wt,
59
+ Tt,
60
+ I
61
61
  ]);
62
- let W = x((e, t, n, r) => {
63
- L(e, n, t, null, r);
64
- }, [L]), Pt = x(async (e, t, n, r, i) => {
65
- let a = y.getState().sandboxesByMode[n]?.sandboxId ?? null, o = async (e) => {
66
- if (H.current.isFresh(e)) return !0;
62
+ let W = S((e, t, n, r) => {
63
+ B(e, n, t, null, r);
64
+ }, [B]), Ft = S(async (e, t, n, r, i) => {
65
+ let a = b.getState().sandboxesByMode[n]?.sandboxId ?? null, o = async (e) => {
66
+ if (Mt.current.isFresh(e)) return !0;
67
67
  try {
68
- return await m(e, r, i, 3e5), await p(e, r, i, 9e4), H.current.markVerified(e), !0;
68
+ return await m(e, r, i, 3e5), await p(e, r, n, i, 9e4), Mt.current.markVerified(e), !0;
69
69
  } catch {
70
- return H.current.invalidate(e), !1;
70
+ return Mt.current.invalidate(e), !1;
71
71
  }
72
72
  };
73
- if (a && (R(n, a, "provisioning"), W(e, t, "provisioning", "reusingEnvironment"), await o(a) || (R(n, null, "provisioning"), a = null)), !a) {
73
+ if (a && (V(n, a, "provisioning"), W(e, t, "provisioning", "reusingEnvironment"), await o(a) || (V(n, null, "provisioning"), a = null)), !a) {
74
74
  W(e, t, "provisioning", "lookingForEnvironment");
75
- let s = await u(r, D, n, We(), i);
76
- s && (R(n, s, "provisioning"), W(e, t, "provisioning", "reusingEnvironment"), await o(s) ? a = s : R(n, null, "provisioning"));
75
+ let s = await u(r, k, n, We(), i);
76
+ s && (V(n, s, "provisioning"), W(e, t, "provisioning", "reusingEnvironment"), await o(s) ? a = s : V(n, null, "provisioning"));
77
77
  }
78
78
  if (!a) {
79
- if (n === "api-calls" && !k()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
80
- W(e, t, "provisioning", "startingEnvironment"), R(n, null, "provisioning"), await f(r, D, n, We(), i), a = await s(D, n, r, We(), Je, i), R(n, a, "provisioning"), await m(a, r, i, 3e5), await p(a, r, i, 9e4);
79
+ if (n === "api-calls" && !j()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
80
+ W(e, t, "provisioning", "startingEnvironment"), V(n, null, "provisioning"), await f(r, k, n, We(), i), a = await s(k, n, r, We(), Je, i), V(n, a, "provisioning"), await m(a, r, i, 3e5), await p(a, r, n, i, 9e4);
81
81
  }
82
- R(n, a, "running");
83
- let l = y.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null;
82
+ V(n, a, "running");
83
+ let l = b.getState().conversations.find((t) => t.id === e)?.backendSessionId ?? null;
84
84
  if (l) try {
85
- let e = await d(a, r, l, i);
85
+ let e = await d(a, r, l, n, i);
86
86
  if (e.mode !== n) throw Error(`Session mode mismatch: expected ${n}, received ${e.mode}`);
87
87
  } catch {
88
- vt(e), l = null;
88
+ gt(e), l = null;
89
89
  }
90
- return l || (W(e, t, "connecting", "preparingSession"), l = (await c(a, r, n, i)).sessionId, _t(e, l)), {
90
+ return l || (W(e, t, "connecting", "preparingSession"), l = (await c(a, r, n, i)).sessionId, ht(e, l)), {
91
91
  sandboxId: a,
92
92
  sessionId: l
93
93
  };
94
94
  }, [
95
- vt,
95
+ gt,
96
+ j,
96
97
  k,
97
- D,
98
- _t,
99
- R,
98
+ ht,
99
+ V,
100
100
  W
101
- ]), [Ft, It] = Ke(null), G = w(/* @__PURE__ */ new Set()), Lt = w(null), Rt = x(() => {
102
- let e = y.getState(), t = e.activeConversationId;
101
+ ]), [It, Lt] = Ke(null), G = T(/* @__PURE__ */ new Set()), Rt = T(null), zt = S(() => {
102
+ let e = b.getState(), t = e.activeConversationId;
103
103
  if (!t) return;
104
- let n = e.processingByConversationId[t], r = b(n?.status) ? n?.messageId ?? null : null;
105
- if (!be({
104
+ let n = e.processingByConversationId[t], r = ye(n?.status) ? n?.messageId ?? null : null;
105
+ if (!xe({
106
106
  interruptedTurnId: r,
107
107
  activeTurnId: r,
108
108
  alreadyRequested: r ? G.current.has(r) : !1
109
109
  }).send || !r) return;
110
110
  G.current.add(r);
111
- let i = e.sandboxesByMode[e.mode]?.sandboxId, o = Oe(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
112
- !i || !o || !s || a(i, o, s, {
113
- accessToken: k(),
114
- workspaceToken: A(),
115
- userId: j,
116
- organizationId: De()
111
+ let i = y(e), o = Oe(), s = e.conversations.find((e) => e.id === t)?.backendSessionId;
112
+ !i || !o || !s || a(i.sandboxId, o, s, i.mode, {
113
+ accessToken: j(),
114
+ workspaceToken: M(),
115
+ userId: N,
116
+ organizationId: x()
117
117
  });
118
118
  }, [
119
+ N,
119
120
  j,
120
- k,
121
- A
122
- ]), zt = x(async (e) => {
123
- let t = y.getState(), n = t.sandboxesByMode[t.mode]?.sandboxId, r = Oe(), i = t.activeConversationId;
121
+ M
122
+ ]), Bt = S(async (e) => {
123
+ let t = b.getState(), n = y(t), r = Oe(), i = t.activeConversationId;
124
124
  if (!(!n || !r || !i)) {
125
- It(e);
125
+ Lt(e);
126
126
  try {
127
- await o(n, r, e, {
128
- accessToken: k(),
129
- workspaceToken: A(),
130
- userId: j,
131
- organizationId: De()
127
+ await o(n.sandboxId, r, e, n.mode, {
128
+ accessToken: j(),
129
+ workspaceToken: M(),
130
+ userId: N,
131
+ organizationId: x()
132
132
  });
133
133
  } catch (e) {
134
- It(null), F(i, {
135
- id: Xe(),
134
+ Lt(null), R(i, {
135
+ id: D(),
136
136
  role: "system",
137
137
  content: e instanceof Error ? e.message : "The change could not be approved.",
138
138
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
139
139
  });
140
140
  return;
141
141
  }
142
- It(null), q.current(E("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
142
+ Lt(null), q.current(O("pendingWrite.approvedPrompt", "I approved that change — go ahead."));
143
143
  }
144
144
  }, [
145
- j,
146
- F,
147
- E
148
- ]), K = x(async (e, t = [], n = {}) => {
149
- let r = n.voiceSessionId !== void 0, a = y.getState(), o = a.activeConversationId ?? M;
145
+ N,
146
+ R,
147
+ O
148
+ ]), K = S(async (e, t = [], n = {}) => {
149
+ let r = n.voiceSessionId !== void 0, a = b.getState(), o = a.activeConversationId ?? P;
150
150
  if (o) {
151
- if (b(a.processingByConversationId[o]?.status)) {
151
+ if (ye(a.processingByConversationId[o]?.status)) {
152
152
  let r = a.processingByConversationId[o]?.messageId ?? null;
153
- r && G.current.has(r) && (Lt.current = {
153
+ r && G.current.has(r) && (Rt.current = {
154
154
  conversationId: o,
155
155
  content: e,
156
156
  attachments: t,
@@ -160,16 +160,16 @@ var Ze = ({ visible: Ze = !0, writeAccess: Qe = "unknown" }) => {
160
160
  }
161
161
  if (Nt.current.has(o)) return;
162
162
  }
163
- let s = a.mode, c = M, u = c ? y.getState().conversations.find((e) => e.id === c) : void 0;
164
- if (c ? u && u.mode !== s && (u.messages.length > 0 || u.backendSessionId) ? c = P(void 0, s) : u && u.mode !== s && ft(c, s) : c = P(void 0, s), !c) return;
165
- Mt.current[c] = t;
163
+ let s = a.mode, c = P, u = c ? b.getState().conversations.find((e) => e.id === c) : void 0;
164
+ if (c ? u && u.mode !== s && (u.messages.length > 0 || u.backendSessionId) ? c = L(void 0, s) : u && u.mode !== s && ut(c, s) : c = L(void 0, s), !c) return;
165
+ jt.current[c] = t;
166
166
  let d = Oe(), f = {
167
- accessToken: k(),
168
- workspaceToken: A(),
169
- userId: j,
170
- organizationId: De()
167
+ accessToken: j(),
168
+ workspaceToken: M(),
169
+ userId: N,
170
+ organizationId: x()
171
171
  }, p = {
172
- id: Xe(),
172
+ id: D(),
173
173
  role: "user",
174
174
  content: e,
175
175
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -178,20 +178,20 @@ var Ze = ({ visible: Ze = !0, writeAccess: Qe = "unknown" }) => {
178
178
  ...h(n.voiceSessionId)
179
179
  }
180
180
  };
181
- F(c, p);
182
- let m = Xe();
183
- F(c, {
181
+ R(c, p);
182
+ let m = D();
183
+ R(c, {
184
184
  id: m,
185
185
  role: "assistant",
186
186
  content: "",
187
187
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
188
188
  metadata: {
189
- lang: ct,
189
+ lang: st,
190
190
  ...h(n.voiceSessionId)
191
191
  }
192
- }), L(c, "provisioning", m, null);
193
- let se = (e, t, r, i, a = ct) => {
194
- I(c, m, { content: ie(e) }), ht(c, m, {
192
+ }), B(c, "provisioning", m, null);
193
+ let se = (e, t, r, i, a = st) => {
194
+ z(c, m, { content: ie(e) }), pt(c, m, {
195
195
  lang: a,
196
196
  ...t?.length ? { artifacts: t } : {},
197
197
  ...t?.length || r || i ? { mode: s } : {},
@@ -202,9 +202,9 @@ var Ze = ({ visible: Ze = !0, writeAccess: Qe = "unknown" }) => {
202
202
  }, g = async (n = 1) => {
203
203
  let i = !1;
204
204
  try {
205
- let { sandboxId: n, sessionId: a } = await Pt(c, m, s, d, f), o = (await te(n, d, a, f, { limit: 50 }).catch(() => [])).reduce((e, t) => Math.max(e, re(t)), 0);
205
+ let { sandboxId: n, sessionId: a } = await Ft(c, m, s, d, f), o = (await te(n, d, a, s, f, { limit: 50 }).catch(() => [])).reduce((e, t) => Math.max(e, re(t)), 0);
206
206
  W(c, m, "streaming", "thinking");
207
- let u = me(e, t), p = et?.(s, u, ot, st, r) ?? u, h = pe(p, t), g = ge(h), _ = g > 0, ce = $e?.();
207
+ let u = me(e, t), p = $e?.(s, u, at, ot, r) ?? u, h = pe(p, t), g = ge(h), _ = g > 0, ce = Qe?.();
208
208
  i = he(t) > g;
209
209
  try {
210
210
  await ne(n, d, a, p, s, ce, f, h?.length ? { parts: h } : void 0);
@@ -212,59 +212,59 @@ var Ze = ({ visible: Ze = !0, writeAccess: Qe = "unknown" }) => {
212
212
  if (!h || !Re(e)) throw e;
213
213
  await ne(n, d, a, p, s, ce, f, void 0), i ||= _;
214
214
  }
215
- let v = Se([], o), ue = Date.now() + ae(s), de = Date.now(), fe = Date.now(), _e = () => ye({
215
+ let v = Ce([], o), ue = Date.now() + ae(s), de = Date.now(), fe = Date.now(), _e = () => be({
216
216
  turnId: m,
217
217
  abortRequested: G.current.has(m),
218
- activeTurnId: y.getState().processingByConversationId[c]?.messageId ?? null
218
+ activeTurnId: b.getState().processingByConversationId[c]?.messageId ?? null
219
219
  });
220
220
  for (; Date.now() < ue;) {
221
221
  let e = _e();
222
222
  if (e.abandon) {
223
- e.clearProcessing && gt(c);
223
+ e.clearProcessing && mt(c);
224
224
  return;
225
225
  }
226
- if (v = Se(await te(n, d, a, f, {
226
+ if (v = Ce(await te(n, d, a, s, f, {
227
227
  limit: 50,
228
228
  sinceMs: o
229
- }), o), I(c, m, { content: ie(v.content) }), v.pendingWrite && ht(c, m, { pendingWrite: v.pendingWrite }), v.done) break;
229
+ }), o), z(c, m, { content: ie(v.content) }), v.pendingWrite && pt(c, m, { pendingWrite: v.pendingWrite }), v.done) break;
230
230
  Date.now() - de > 3e4 && (await l(n, d, 600, f).catch(() => void 0), de = Date.now()), await new Promise((e) => setTimeout(e, le(Date.now() - fe)));
231
231
  }
232
- let ve = s === "vibe-plugins" ? await ee(n, d, a, f).then((e) => e).catch(() => []) : void 0;
232
+ let ve = s === "vibe-plugins" ? await ee(n, d, a, s, f).then((e) => e).catch(() => []) : void 0;
233
233
  if (v.done || (v = {
234
234
  ...v,
235
- content: oe(v.content, s, E)
235
+ content: oe(v.content, s, O)
236
236
  }), i && (v = {
237
237
  ...v,
238
- 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._")}`
238
+ content: `${v.content}\n\n${O("attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
239
239
  }), se(v.content, ve, a, n), v.tokens) {
240
- I(c, m, { tokens: v.tokens });
240
+ z(c, m, { tokens: v.tokens });
241
241
  try {
242
- await tt?.({
242
+ await et?.({
243
243
  workspaceId: d,
244
244
  sessionId: a,
245
245
  messageId: v.messageId,
246
246
  model: v.model,
247
247
  tokens: v.tokens
248
- }), Ve(D);
248
+ }), Ve(k);
249
249
  } catch {}
250
250
  }
251
- let b = _e();
252
- if (b.abandon) {
253
- b.clearProcessing && gt(c);
251
+ let y = _e();
252
+ if (y.abandon) {
253
+ y.clearProcessing && mt(c);
254
254
  return;
255
255
  }
256
- L(c, "complete", m, null);
256
+ B(c, "complete", m, null);
257
257
  } catch (e) {
258
- let t = ye({
258
+ let t = be({
259
259
  turnId: m,
260
260
  abortRequested: G.current.has(m),
261
- activeTurnId: y.getState().processingByConversationId[c]?.messageId ?? null
261
+ activeTurnId: b.getState().processingByConversationId[c]?.messageId ?? null
262
262
  });
263
263
  if (t.abandon) {
264
- t.clearProcessing && gt(c);
264
+ t.clearProcessing && mt(c);
265
265
  return;
266
266
  }
267
- if (n === 1 && ze(e)) return vt(c), yt(s), mt(c, m, ""), ht(c, m, { pendingWrite: void 0 }), g(2);
267
+ if (n === 1 && ze(e)) return gt(c), _t(s), ft(c, m, ""), pt(c, m, { pendingWrite: void 0 }), g(2);
268
268
  throw e;
269
269
  }
270
270
  }, _ = c;
@@ -273,71 +273,71 @@ var Ze = ({ visible: Ze = !0, writeAccess: Qe = "unknown" }) => {
273
273
  if (!d) throw Error("Assistant backend is unavailable without an active workspace context.");
274
274
  await g();
275
275
  } catch (e) {
276
- H.current.invalidate(y.getState().sandboxesByMode[s]?.sandboxId ?? null);
276
+ Mt.current.invalidate(b.getState().sandboxesByMode[s]?.sandboxId ?? null);
277
277
  let t = i(e);
278
278
  if (t) {
279
- t.refusal === "exhausted" && Be(D, "sandbox");
279
+ t.refusal === "exhausted" && Be(k, "sandbox");
280
280
  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.";
281
- se(e ? `${n}\n\n${e}` : n, void 0, void 0, void 0, "en"), L(c, "error", m, null);
281
+ se(e ? `${n}\n\n${e}` : n, void 0, void 0, void 0, "en"), B(c, "error", m, null);
282
282
  return;
283
283
  }
284
284
  let r = e instanceof Error ? e.message : "Something went wrong";
285
- L(c, "error", m, r), I(c, m, { content: `Sorry, an error occurred: ${r}. Please try again.` }), ht(c, m, {
285
+ B(c, "error", m, r), z(c, m, { content: `Sorry, an error occurred: ${r}. Please try again.` }), pt(c, m, {
286
286
  lang: "en",
287
287
  ...h(n.voiceSessionId)
288
288
  });
289
289
  } finally {
290
290
  Nt.current.delete(_);
291
- let e = Lt.current;
292
- Lt.current = null, e && e.conversationId === _ && q.current(e.content, e.attachments, e.options);
291
+ let e = Rt.current;
292
+ Rt.current = null, e && e.conversationId === _ && q.current(e.content, e.attachments, e.options);
293
293
  }
294
294
  }, [
295
- M,
296
- F,
297
- et,
298
- vt,
299
- yt,
300
- lt,
301
295
  P,
302
- Pt,
296
+ R,
303
297
  $e,
304
- k,
305
- A,
306
- I,
307
- D,
308
- tt,
309
- st,
310
- ct,
311
- ot,
298
+ gt,
312
299
  _t,
313
- ft,
300
+ ct,
314
301
  L,
315
- gt,
316
- E,
317
- W,
302
+ Ft,
303
+ Qe,
304
+ j,
305
+ M,
306
+ z,
307
+ k,
308
+ et,
309
+ ot,
310
+ st,
311
+ at,
312
+ ht,
313
+ ut,
314
+ B,
318
315
  mt,
319
- j
320
- ]), Bt = x((e) => {
316
+ O,
317
+ W,
318
+ ft,
319
+ N
320
+ ]), Vt = S((e) => {
321
321
  K(e);
322
- }, [K]), Vt = x(() => {
323
- let e = [...z.chat].reverse().find((e) => e.role === "user"), t = M ? Mt.current[M] ?? [] : [];
322
+ }, [K]), Ht = S(() => {
323
+ let e = [...H.chat].reverse().find((e) => e.role === "user"), t = P ? jt.current[P] ?? [] : [];
324
324
  e && K(e.content, t);
325
325
  }, [
326
- St,
326
+ bt,
327
327
  K,
328
- M
329
- ]), q = w(K);
330
- S(() => {
328
+ P
329
+ ]), q = T(K);
330
+ C(() => {
331
331
  q.current = K;
332
332
  }, [K]);
333
- let J = C(() => {
334
- if (Ct) return null;
335
- for (let e = St.length - 1; e >= 0; --e) {
336
- let t = St[e];
333
+ let Ut = w(() => {
334
+ if (xt) return null;
335
+ for (let e = bt.length - 1; e >= 0; --e) {
336
+ let t = bt[e];
337
337
  if (t?.role !== "assistant" || !se(t) || G.current.has(t.id)) continue;
338
- let n = xe(t, B, E);
338
+ let n = Se(t, U, O);
339
339
  if (n.kind !== "output") return null;
340
- let r = Ce(n.text).text.trim();
340
+ let r = we(n.text).text.trim();
341
341
  return r ? {
342
342
  id: t.id,
343
343
  text: r
@@ -345,200 +345,200 @@ var Ze = ({ visible: Ze = !0, writeAccess: Qe = "unknown" }) => {
345
345
  }
346
346
  return null;
347
347
  }, [
348
- St,
349
- Ct,
350
- B,
351
- E
352
- ]), Ht = C(() => J ? ue(J.text) : null, [J]), Ut = z.chat, Y = C(() => z.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
348
+ bt,
349
+ xt,
350
+ U,
351
+ O
352
+ ]), Wt = w(() => Ut ? ue(Ut.text) : null, [Ut]), Gt = H.chat, J = w(() => H.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
353
353
  id: e.id,
354
354
  role: e.role,
355
- text: Te(e, B, E),
355
+ text: Ee(e, U, O),
356
356
  sessionId: g(e),
357
357
  timestamp: e.timestamp
358
358
  })).filter((e) => e.text.length > 0), [
359
- z.voice,
360
- B,
361
- E
362
- ]), Wt = x(() => {
363
- if (Y.length === 0) return;
359
+ H.voice,
360
+ U,
361
+ O
362
+ ]), Kt = S(() => {
363
+ if (J.length === 0) return;
364
364
  let e = /* @__PURE__ */ new Date();
365
- Me(ce(Y, {
366
- title: E("voiceSession.transcript", "Voice conversation"),
367
- savedAt: E("voiceSession.savedAt", "Saved"),
368
- session: E("voiceSession.sessionLabel", "Session"),
369
- earlier: E("voiceSession.earlierLabel", "Earlier"),
370
- you: E("voiceSession.speakerYou", "You"),
371
- assistant: E("voiceSession.speakerAssistant", "Assistant")
372
- }, e), v(D, e), "text/markdown");
365
+ Me(ce(J, {
366
+ title: O("voiceSession.transcript", "Voice conversation"),
367
+ savedAt: O("voiceSession.savedAt", "Saved"),
368
+ session: O("voiceSession.sessionLabel", "Session"),
369
+ earlier: O("voiceSession.earlierLabel", "Earlier"),
370
+ you: O("voiceSession.speakerYou", "You"),
371
+ assistant: O("voiceSession.speakerAssistant", "Assistant")
372
+ }, e), v(k, e), "text/markdown");
373
373
  }, [
374
- D,
375
- Y,
376
- E
377
- ]), X = He(), Z = w(X);
378
- Z.current = X;
379
- let Q = Ee({
380
- onSubmit: x((e, t) => {
374
+ k,
375
+ J,
376
+ O
377
+ ]), Y = He(), X = T(Y);
378
+ X.current = Y;
379
+ let Z = De({
380
+ onSubmit: S((e, t) => {
381
381
  let n = () => {
382
- let n = Z.current, r = _e(n.attachments);
382
+ let n = X.current, r = _e(n.attachments);
383
383
  q.current(e, r, { voiceSessionId: t }), n.clear();
384
384
  };
385
- if (!Z.current.isBusy) {
385
+ if (!X.current.isBusy) {
386
386
  n();
387
387
  return;
388
388
  }
389
389
  let r = Date.now(), i = window.setInterval(() => {
390
- Z.current.isBusy && Date.now() - r < Ye || (window.clearInterval(i), n());
390
+ X.current.isBusy && Date.now() - r < Ye || (window.clearInterval(i), n());
391
391
  }, 200);
392
392
  }, []),
393
- latestReply: J,
394
- language: de(rt, nt).tag
395
- }), Gt = C(() => (xt?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [xt?.messages]), $ = we(z.voice, B, E), Kt = $ > Gt, qt = x(() => {
396
- let e = y.getState().activeConversationId;
397
- !e || Y.length === 0 || (F(e, {
398
- id: Xe(),
393
+ latestReply: Ut,
394
+ language: de(nt, tt).tag
395
+ }), qt = w(() => (yt?.messages ?? []).reduce((e, t) => Math.max(e, t.metadata?.continuedVoiceTurns ?? 0), 0), [yt?.messages]), Q = Te(H.voice, U, O), Jt = Q > qt, Yt = S(() => {
396
+ let e = b.getState().activeConversationId;
397
+ !e || J.length === 0 || (R(e, {
398
+ id: D(),
399
399
  role: "system",
400
- content: _(Y.slice(Gt), {
401
- intro: E("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
402
- nothing: E("voiceSession.continuedNothing", "Continued from a voice conversation."),
403
- more: (e) => E("voiceSession.continuedMore", "…and {{count}} more", { count: e })
400
+ content: _(J.slice(qt), {
401
+ intro: O("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
402
+ nothing: O("voiceSession.continuedNothing", "Continued from a voice conversation."),
403
+ more: (e) => O("voiceSession.continuedMore", "…and {{count}} more", { count: e })
404
404
  }),
405
405
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
406
- metadata: { continuedVoiceTurns: $ }
407
- }), V(!1), Q.end());
406
+ metadata: { continuedVoiceTurns: Q }
407
+ }), At(!1), Z.end());
408
408
  }, [
409
- Y,
410
- $,
411
- Gt,
412
- F,
413
- E,
414
- Q
415
- ]), Jt = w(0);
416
- S(() => {
417
- Q.active && (Jt.current = $);
418
- }, [Q.active]);
419
- let Yt = x(() => {
420
- let e = $ > Jt.current;
421
- Q.end(), e && V(!0);
422
- }, [$, Q]);
423
- S(() => {
424
- !Ze && Q.active && Q.end();
425
- }, [Ze, Q]), S(() => {
426
- Q.active || (Z.current.clear(), Lt.current = null);
427
- }, [Q.active]), S(() => {
428
- let e = y.getState().consumePendingPrompt();
429
- return e && q.current(e), y.subscribe((e, t) => {
409
+ J,
410
+ Q,
411
+ qt,
412
+ R,
413
+ O,
414
+ Z
415
+ ]), Xt = T(0);
416
+ C(() => {
417
+ Z.active && (Xt.current = Q);
418
+ }, [Z.active]);
419
+ let Zt = S(() => {
420
+ let e = Q > Xt.current;
421
+ Z.end(), e && At(!0);
422
+ }, [Q, Z]);
423
+ C(() => {
424
+ !Xe && Z.active && Z.end();
425
+ }, [Xe, Z]), C(() => {
426
+ Z.active || (X.current.clear(), Rt.current = null);
427
+ }, [Z.active]), C(() => {
428
+ let e = b.getState().consumePendingPrompt();
429
+ return e && q.current(e), b.subscribe((e, t) => {
430
430
  if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
431
- let e = y.getState().consumePendingPrompt();
431
+ let e = b.getState().consumePendingPrompt();
432
432
  e && q.current(e);
433
433
  }
434
434
  });
435
435
  }, []);
436
- let Xt = x((e) => {
437
- let t = M ? y.getState().conversations.find((e) => e.id === M) : void 0;
436
+ let $ = S((e) => {
437
+ let t = P ? b.getState().conversations.find((e) => e.id === P) : void 0;
438
438
  if (t && (t.messages.length > 0 || t.backendSessionId)) {
439
439
  if (t.mode !== e) {
440
- let t = y.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !y.getState().processingByConversationId[t.id]);
441
- t ? pt(t.id) : P(void 0, e);
440
+ let t = b.getState().conversations.find((t) => t.mode === e && t.messages.length === 0 && !t.backendSessionId && !b.getState().processingByConversationId[t.id]);
441
+ t ? dt(t.id) : L(void 0, e);
442
442
  }
443
- } else M && ft(M, e);
444
- dt(e);
443
+ } else P && ut(P, e);
444
+ I(e);
445
445
  }, [
446
- M,
447
446
  P,
448
- pt,
449
- ft,
450
- dt
451
- ]), Zt = x((e) => {
452
- if (O.find((t) => t.id === e)?.writeCapable && !y.getState().apiCallsAcknowledged) {
453
- At(e);
447
+ L,
448
+ dt,
449
+ ut,
450
+ I
451
+ ]), Qt = S((e) => {
452
+ if (A.find((t) => t.id === e)?.writeCapable && !b.getState().apiCallsAcknowledged) {
453
+ Ot(e);
454
454
  return;
455
455
  }
456
- Xt(e);
457
- }, [Xt, O]), Qt = x(() => {
458
- let e = kt;
459
- At(null), bt(), e && Xt(e);
456
+ $(e);
457
+ }, [$, A]), $t = S(() => {
458
+ let e = Dt;
459
+ Ot(null), vt(), e && $(e);
460
460
  }, [
461
- kt,
462
- bt,
463
- Xt
464
- ]), $t = x(() => {
465
- At(null);
461
+ Dt,
462
+ vt,
463
+ $
464
+ ]), en = S(() => {
465
+ Ot(null);
466
466
  }, []);
467
467
  return /* @__PURE__ */ qe("div", {
468
468
  className: "relative flex flex-1 flex-col overflow-hidden",
469
469
  children: [
470
470
  /* @__PURE__ */ qe("div", {
471
471
  className: "contents",
472
- inert: Q.active || void 0,
472
+ inert: Z.active || void 0,
473
473
  children: [
474
- Y.length > 0 && !Q.active ? /* @__PURE__ */ T(Ae, {
475
- count: Y.length,
476
- onOpenTranscript: () => V(!0)
474
+ J.length > 0 && !Z.active ? /* @__PURE__ */ E(Ae, {
475
+ count: J.length,
476
+ onOpenTranscript: () => At(!0)
477
477
  }) : null,
478
- Ut.length === 0 ? /* @__PURE__ */ T(Ne, {
479
- mode: N,
480
- onSuggestionClick: Bt
481
- }) : /* @__PURE__ */ T("div", {
478
+ Gt.length === 0 ? /* @__PURE__ */ E(Ne, {
479
+ mode: F,
480
+ onSuggestionClick: Vt
481
+ }) : /* @__PURE__ */ E("div", {
482
482
  className: "flex min-h-0 flex-1 flex-col",
483
- children: /* @__PURE__ */ T(Pe, {
484
- onApprovePendingWrite: zt,
485
- approvingWriteRef: Ft,
486
- messages: Ut,
487
- processing: B ?? null,
488
- streamingMessageId: wt,
489
- failedMessageId: Tt,
490
- onRetry: Vt
483
+ children: /* @__PURE__ */ E(Pe, {
484
+ onApprovePendingWrite: Bt,
485
+ approvingWriteRef: It,
486
+ messages: Gt,
487
+ processing: U ?? null,
488
+ streamingMessageId: St,
489
+ failedMessageId: Ct,
490
+ onRetry: Ht
491
491
  })
492
492
  }),
493
- /* @__PURE__ */ T(Ue, {
494
- onStartVoiceSession: Q.available && N !== "api-calls" ? Q.start : void 0,
493
+ /* @__PURE__ */ E(Ue, {
494
+ onStartVoiceSession: Z.available && F !== "api-calls" ? Z.start : void 0,
495
495
  onSend: (e, t) => void K(e, t),
496
- disabled: Ct,
497
- placeholder: N === "api-calls" ? E("chatArea.placeholderActions", "What would you like me to do?") : E("chatArea.placeholderGeneral", "Ask me anything…"),
498
- mode: N,
499
- writeAccessDenied: Qe === "denied" && !!U?.writeCapable,
500
- availableModes: Ot,
501
- onModeChange: Zt
496
+ disabled: xt,
497
+ placeholder: F === "api-calls" ? O("chatArea.placeholderActions", "What would you like me to do?") : O("chatArea.placeholderGeneral", "Ask me anything…"),
498
+ mode: F,
499
+ writeAccessDenied: Ze === "denied" && !!Pt?.writeCapable,
500
+ availableModes: Et,
501
+ onModeChange: Qt
502
502
  })
503
503
  ]
504
504
  }),
505
- jt && !Q.active ? /* @__PURE__ */ T(je, {
506
- turns: Y,
507
- onClose: () => V(!1),
508
- onSave: Wt,
509
- onContinueInChat: Kt ? qt : void 0,
505
+ kt && !Z.active ? /* @__PURE__ */ E(je, {
506
+ turns: J,
507
+ onClose: () => At(!1),
508
+ onSave: Kt,
509
+ onContinueInChat: Jt ? Yt : void 0,
510
510
  closeOnEscape: !0
511
511
  }) : null,
512
- Q.active && /* @__PURE__ */ T(Fe, {
513
- session: Q.session,
514
- notice: Q.notice,
515
- capturing: Q.capturing,
516
- interrupting: Q.interrupting,
517
- awaitingEndpoint: Q.awaitingEndpoint,
518
- turns: Y,
519
- spokenChunks: Q.spokenChunks,
520
- attachments: X.attachments,
521
- onAttachFiles: X.addFiles,
522
- onRemoveAttachment: X.remove,
523
- onRetryAttachment: X.retry,
524
- canAttachMore: X.canAddMore,
525
- preparingAttachments: X.preparingCount,
526
- onSaveTranscript: Wt,
527
- onContinueInChat: qt,
512
+ Z.active && /* @__PURE__ */ E(Fe, {
513
+ session: Z.session,
514
+ notice: Z.notice,
515
+ capturing: Z.capturing,
516
+ interrupting: Z.interrupting,
517
+ awaitingEndpoint: Z.awaitingEndpoint,
518
+ turns: J,
519
+ spokenChunks: Z.spokenChunks,
520
+ attachments: Y.attachments,
521
+ onAttachFiles: Y.addFiles,
522
+ onRemoveAttachment: Y.remove,
523
+ onRetryAttachment: Y.retry,
524
+ canAttachMore: Y.canAddMore,
525
+ preparingAttachments: Y.preparingCount,
526
+ onSaveTranscript: Kt,
527
+ onContinueInChat: Yt,
528
528
  onInterrupt: () => {
529
- Q.interrupt(), Rt();
529
+ Z.interrupt(), zt();
530
530
  },
531
- spoken: Ht,
532
- onToggleMute: Q.toggleMute,
533
- onEnd: Yt
531
+ spoken: Wt,
532
+ onToggleMute: Z.toggleMute,
533
+ onEnd: Zt
534
534
  }),
535
- /* @__PURE__ */ T(Ge, {
536
- open: kt !== null,
537
- onConfirm: Qt,
538
- onCancel: $t
535
+ /* @__PURE__ */ E(Ge, {
536
+ open: Dt !== null,
537
+ onConfirm: $t,
538
+ onCancel: en
539
539
  })
540
540
  ]
541
541
  });
542
542
  };
543
543
  //#endregion
544
- export { Ze as AssistantChatArea };
544
+ export { Xe as AssistantChatArea };