@burdenoff/fe-libs 2026.1003.2 → 2026.1003.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 (40) hide show
  1. package/dist/chrome/mobileTabBar/selectTabs.d.ts.map +1 -1
  2. package/dist/chrome/mobileTabBar/selectTabs.js +9 -8
  3. package/dist/chrome/sideNavigation/NavItemRenderer.d.ts.map +1 -1
  4. package/dist/chrome/sideNavigation/NavItemRenderer.js +62 -61
  5. package/dist/shared/assistant/conversation.d.ts +20 -6
  6. package/dist/shared/assistant/conversation.d.ts.map +1 -1
  7. package/dist/shared/assistant/history/historyMapping.d.ts.map +1 -1
  8. package/dist/shared/assistant/history/historyMapping.js +43 -24
  9. package/dist/shared/assistant/i18nManifest.d.ts +9 -0
  10. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  11. package/dist/shared/assistant/i18nManifest.js +9 -0
  12. package/dist/shared/assistant/index.d.ts +3 -0
  13. package/dist/shared/assistant/index.d.ts.map +1 -1
  14. package/dist/shared/assistant/localUiCommandCopy.d.ts +28 -0
  15. package/dist/shared/assistant/localUiCommandCopy.d.ts.map +1 -1
  16. package/dist/shared/assistant/localUiCommandCopy.js +54 -1
  17. package/dist/shared/assistant/localUiCommands.d.ts +33 -3
  18. package/dist/shared/assistant/localUiCommands.d.ts.map +1 -1
  19. package/dist/shared/assistant/localUiCommands.js +110 -59
  20. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  21. package/dist/shared/assistant/ui/AssistantChatArea.js +788 -656
  22. package/dist/shared/assistant/ui/AssistantMarkdownRenderer.d.ts +18 -1
  23. package/dist/shared/assistant/ui/AssistantMarkdownRenderer.d.ts.map +1 -1
  24. package/dist/shared/assistant/ui/assistantOverlayState.d.ts +2 -1
  25. package/dist/shared/assistant/ui/assistantOverlayState.d.ts.map +1 -1
  26. package/dist/shared/assistant/ui/assistantOverlayState.js +1 -7
  27. package/dist/shared/assistant/uiActions/backStack.d.ts +35 -0
  28. package/dist/shared/assistant/uiActions/backStack.d.ts.map +1 -0
  29. package/dist/shared/assistant/uiActions/backStack.js +28 -0
  30. package/dist/shared/assistant/uiActions/navigateAction.d.ts +41 -0
  31. package/dist/shared/assistant/uiActions/navigateAction.d.ts.map +1 -0
  32. package/dist/shared/assistant/uiActions/navigateAction.js +40 -0
  33. package/dist/shared/assistant/uiActions/navigationOutcome.d.ts +52 -0
  34. package/dist/shared/assistant/uiActions/navigationOutcome.d.ts.map +1 -0
  35. package/dist/shared/assistant/uiActions/navigationOutcome.js +61 -0
  36. package/dist/shared/navigation/navTargetPath.d.ts +23 -0
  37. package/dist/shared/navigation/navTargetPath.d.ts.map +1 -0
  38. package/dist/shared/navigation/navTargetPath.js +6 -0
  39. package/dist/shared-assistant.js +19 -16
  40. package/package.json +1 -1
@@ -8,10 +8,10 @@ import { useAssistantNavigate as a } from "./AssistantMarkdownRenderer.js";
8
8
  import { isAssistantModeId as o } from "../modeIds.js";
9
9
  import { AUTO_READ_MODE as s, autoSuggestions as c, classifyAssistantIntent as l, escalationToUndo as u, isAutoRoutingOffered as d, resolveAutoRoute as f } from "../autoRouting.js";
10
10
  import { getHistoryStamp as p, setHistoryBusyProbe as ee } from "../history/stampRegistry.js";
11
- import { beginApprovalInFlight as m, endApprovalInFlight as h, getApprovalInFlight as g, markLiveTurn as te, newestModelReplyId as ne, resolveApprovablePendingWrite as _, resolveRetryableMessageId as v, subscribeApprovalInFlight as y } from "../liveTurns.js";
12
- import { isWriteModeAcknowledged as re, writeModeSendRefusalReason as ie } from "../writeModeConsent.js";
13
- import { resolveActiveModeSandbox as b, useAssistantStore as x } from "../store.js";
14
- import { abortAssistantTurn as ae, approvePendingWrite as oe, createAssistantSandbox as S, createAssistantSession as C, extendAssistantSandboxTTL as se, findExistingSandboxWithStatus as ce, getAssistantArtifacts as le, getAssistantMessages as ue, getAssistantSession as de, modeRequiresConfirmWrites as fe, promptGatewayRequestBytes as pe, releaseSupersededAssistantSandboxes as w, sendAssistantPromptAsync as me, waitForAssistantServiceReady as T, waitForSandboxRunning as he, writeApprovalModeOf as ge } from "../api.js";
11
+ import { beginApprovalInFlight as m, endApprovalInFlight as h, getApprovalInFlight as te, markLiveTurn as ne, newestModelReplyId as re, resolveApprovablePendingWrite as g, resolveRetryableMessageId as _, subscribeApprovalInFlight as v } from "../liveTurns.js";
12
+ import { isWriteModeAcknowledged as ie, writeModeSendRefusalReason as ae } from "../writeModeConsent.js";
13
+ import { resolveActiveModeSandbox as y, useAssistantStore as b } from "../store.js";
14
+ import { abortAssistantTurn as oe, approvePendingWrite as se, createAssistantSandbox as x, createAssistantSession as S, extendAssistantSandboxTTL as ce, findExistingSandboxWithStatus as le, getAssistantArtifacts as ue, getAssistantMessages as de, getAssistantSession as C, modeRequiresConfirmWrites as fe, promptGatewayRequestBytes as pe, releaseSupersededAssistantSandboxes as w, sendAssistantPromptAsync as me, waitForAssistantServiceReady as T, waitForSandboxRunning as he, writeApprovalModeOf as ge } from "../api.js";
15
15
  import { sanitize as _e } from "../progress.js";
16
16
  import { AssistantSendRefusal as ve, classifyTurnFailure as ye, turnConfirmsNoAction as be, turnOutcomeCopy as xe } from "../turnOutcome.js";
17
17
  import { assistantUsageLedger as Se, hasPendingUsageReports as Ce, reportUsageWithRetry as we, retryPendingUsageReports as Te, usageSendRefusal as Ee } from "../usageReporting.js";
@@ -68,147 +68,150 @@ import { useConversationTurns as _n } from "../useConversationTurns.js";
68
68
  import { sendAssistantTurnTimings as vn, startTurnTimingReporting as yn } from "../turnTimingReporter.js";
69
69
  import { QuarantineSet as bn, WarmCancelled as xn, claimPreopenedSession as Sn, consumeWarm as Cn, preopenKey as wn, preopenWanted as Tn, prewarmTarget as En, settleWarmBeforeSend as Dn, startPreopen as On, startWarm as kn, warmState as An } from "../prewarm.js";
70
70
  import { isAlreadyThere as jn, matchLocalUiCommand as Mn, navDestinations as Nn, planThemeChange as Pn } from "../localUiCommands.js";
71
- import { chooseDestinationCopy as Fn, navigationCommandCopy as In, themeCommandCopy as Ln } from "../localUiCommandCopy.js";
72
- import { dispatchAssistantQuotaExhausted as Rn, notifyAiCreditsUpdated as zn } from "../aiCredits.js";
73
- import { useAssistantAttachments as Bn } from "../useAssistantAttachments.js";
74
- import { AssistantComposer as Vn } from "./composer/AssistantComposer.js";
75
- import { isProdRuntime as Hn } from "../env.js";
76
- import { AssistantApiCallsConsentDialog as Un } from "./AssistantApiCallsConsentDialog.js";
77
- import { useVisibleNavItems as Wn } from "../../../chrome/mobileTabBar/useVisibleNavItems.js";
78
- import { useCallback as j, useEffect as M, useMemo as Gn, useRef as N, useState as Kn, useSyncExternalStore as qn } from "react";
79
- import { jsx as P, jsxs as Jn } from "react/jsx-runtime";
71
+ import { backDoneCopy as Fn, chooseDestinationCopy as In, navigationCommandCopy as Ln, navigationOutcomeCopy as Rn, themeCommandCopy as zn } from "../localUiCommandCopy.js";
72
+ import { runNavigation as Bn } from "../uiActions/navigationOutcome.js";
73
+ import { assistantBackStack as Vn, isBackRunnable as Hn } from "../uiActions/backStack.js";
74
+ import { buildNavigateAction as Un, destinationForPath as Wn, labelForPath as Gn, newestAssistantOnSurface as Kn } from "../uiActions/navigateAction.js";
75
+ import { dispatchAssistantQuotaExhausted as qn, notifyAiCreditsUpdated as Jn } from "../aiCredits.js";
76
+ import { useAssistantAttachments as Yn } from "../useAssistantAttachments.js";
77
+ import { AssistantComposer as Xn } from "./composer/AssistantComposer.js";
78
+ import { isProdRuntime as Zn } from "../env.js";
79
+ import { AssistantApiCallsConsentDialog as Qn } from "./AssistantApiCallsConsentDialog.js";
80
+ import { useVisibleNavItems as $n } from "../../../chrome/mobileTabBar/useVisibleNavItems.js";
81
+ import { useCallback as j, useEffect as M, useMemo as er, useRef as N, useState as tr, useSyncExternalStore as nr } from "react";
82
+ import { jsx as P, jsxs as rr } from "react/jsx-runtime";
80
83
  //#region src/shared/assistant/ui/AssistantChatArea.tsx
81
- var Yn = 600, Xn = 2e4, Zn = 1e4, Qn = 6e3;
84
+ var ir = 600, ar = 2e4, or = 1e4, sr = 6e3;
82
85
  function F() {
83
86
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
84
87
  }
85
- var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
86
- let I = i(), { product: L, modes: R, gatherPageContext: tr, buildPrompt: nr, reportTurnTimings: rr, reportTokenUsage: ir, localUiCommands: ar } = r(), z = ge(r().writeApproval), or = j((e, t) => {
87
- let n = x.getState(), r = t ?? n.sandboxesByMode[e]?.sandboxId ?? null;
88
+ var cr = ({ visible: cr = !0, writeAccess: lr = "unknown" }) => {
89
+ let I = i(), { product: L, modes: R, gatherPageContext: ur, buildPrompt: dr, reportTurnTimings: fr, reportTokenUsage: pr, localUiCommands: mr } = r(), z = ge(r().writeApproval), hr = j((e, t) => {
90
+ let n = b.getState(), r = t ?? n.sandboxesByMode[e]?.sandboxId ?? null;
88
91
  return et({
89
92
  mode: e,
90
93
  productWriteApproval: z,
91
94
  capabilities: r ? n.sandboxWriteCapabilities[r] : null
92
95
  });
93
- }, [z]), { getAccessToken: B, getWorkspaceToken: sr, userId: V } = n(), { locale: H } = t(), cr = x((e) => e.assistantLanguage), lr = x((e) => e.replyLanguage), ur = Gn(() => Le(cr, lr, H), [
94
- cr,
95
- lr,
96
+ }, [z]), { getAccessToken: B, getWorkspaceToken: gr, userId: V } = n(), { locale: H } = t(), _r = b((e) => e.assistantLanguage), vr = b((e) => e.replyLanguage), yr = er(() => Le(_r, vr, H), [
97
+ _r,
98
+ vr,
96
99
  H
97
- ]), dr = ur.reply.english, fr = ur.replyIsExplicit, pr = ur.reply.code, { conversations: mr, activeConversationId: U, mode: W, processingByConversationId: hr, setMode: gr, setConversationMode: _r, setActiveConversation: vr, createConversation: G, addMessage: K, updateMessage: yr, patchMessage: br, mergeMessageMetadata: xr, setConversationProcessing: Sr, clearConversationProcessing: Cr, setBackendSessionId: wr, clearBackendSessionId: Tr, setSandbox: Er, clearSandbox: Dr, acknowledgedWriteModes: Or, acknowledgeWriteMode: kr, autoRouting: Ar, setAutoRouting: jr, routeConversation: Mr } = x(), Nr = mr.find((e) => e.id === U), Pr = _n(Nr), Fr = Pr.all, q = U ? hr[U] : void 0, Ir = ut(q?.status), Lr = Ir ? q?.messageId ?? null : null, Rr = q?.status === "error" ? q.messageId : null, zr = x((e) => e.sandboxWriteCapabilities), { panel: J, entries: Br, retiredSandboxes: Vr } = Gt({
100
+ ]), br = yr.reply.english, xr = yr.replyIsExplicit, Sr = yr.reply.code, { conversations: Cr, activeConversationId: U, mode: W, processingByConversationId: wr, setMode: Tr, setConversationMode: Er, setActiveConversation: Dr, createConversation: G, addMessage: K, updateMessage: Or, patchMessage: kr, mergeMessageMetadata: Ar, setConversationProcessing: jr, clearConversationProcessing: Mr, setBackendSessionId: Nr, clearBackendSessionId: Pr, setSandbox: Fr, clearSandbox: Ir, acknowledgedWriteModes: Lr, acknowledgeWriteMode: Rr, autoRouting: zr, setAutoRouting: Br, routeConversation: Vr } = b(), Hr = Cr.find((e) => e.id === U), Ur = _n(Hr), Wr = Ur.all, q = U ? wr[U] : void 0, Gr = ut(q?.status), Kr = Gr ? q?.messageId ?? null : null, qr = q?.status === "error" ? q.messageId : null, Jr = b((e) => e.sandboxWriteCapabilities), { panel: J, entries: Yr, retiredSandboxes: Xr } = Gt({
98
101
  tr: I,
99
102
  productWriteApproval: z
100
- }), Hr = zt({
103
+ }), Zr = zt({
101
104
  approve: (e, t) => J.approve(e, t),
102
105
  decline: (e, t, n) => J.decline(e, t, n),
103
106
  presented: (e, t) => J.presented(e, t)
104
- }), Ur = Hr.dismiss, Wr = N(null);
107
+ }), Qr = Zr.dismiss, $r = N(null);
105
108
  M(() => {
106
- Ur();
107
- let e = Wr.current;
108
- Wr.current = U, e && e !== U && J.withdraw(e, "conversation_closed"), U && J.openConversation(U);
109
+ Qr();
110
+ let e = $r.current;
111
+ $r.current = U, e && e !== U && J.withdraw(e, "conversation_closed"), U && J.openConversation(U);
109
112
  }, [
110
113
  U,
111
114
  J,
112
- Ur
115
+ Qr
113
116
  ]);
114
- let Gr = nn(Nr), Kr = pn(Nr)?.archivedAt != null, qr = an((e) => U !== null && U in e.loadingIds), Jr = an((e) => U !== null && U in e.loadErrorIds), Yr = an((e) => e.remoteDelete), [Xr, Zr] = Kn(() => an.getState().remoteDelete?.at ?? null), Qr = Yr?.wasActive === !0 && Yr.at !== Xr ? Yr.at : null;
117
+ let ei = nn(Hr), ti = pn(Hr)?.archivedAt != null, ni = an((e) => U !== null && U in e.loadingIds), ri = an((e) => U !== null && U in e.loadErrorIds), ii = an((e) => e.remoteDelete), [ai, oi] = tr(() => an.getState().remoteDelete?.at ?? null), si = ii?.wasActive === !0 && ii.at !== ai ? ii.at : null;
115
118
  M(() => {
116
- if (Qr === null) return;
117
- let e = window.setTimeout(() => Zr(Qr), Zn);
119
+ if (si === null) return;
120
+ let e = window.setTimeout(() => oi(si), or);
118
121
  return () => window.clearTimeout(e);
119
- }, [Qr]);
120
- let { canUseApiCalls: $r, loading: ei } = gn(A(), V), ti = N(st({
121
- loading: ei,
122
- canUseAdminModes: $r
123
- })).current, ni = N(R);
122
+ }, [si]);
123
+ let { canUseApiCalls: ci, loading: li } = gn(A(), V), ui = N(st({
124
+ loading: li,
125
+ canUseAdminModes: ci
126
+ })).current, di = N(R);
124
127
  M(() => {
125
- ni.current = R;
128
+ di.current = R;
126
129
  }, [R]);
127
- let ri = () => {
128
- let e = x.getState().activeConversationId;
129
- e && on.openConversation(e, { modes: ni.current });
130
- }, ii = () => {
131
- let e = x.getState().activeConversationId;
130
+ let fi = () => {
131
+ let e = b.getState().activeConversationId;
132
+ e && on.openConversation(e, { modes: di.current });
133
+ }, pi = () => {
134
+ let e = b.getState().activeConversationId;
132
135
  e && on.loadEarlier(e);
133
- }, ai = N(B);
136
+ }, mi = N(B);
134
137
  M(() => {
135
- ai.current = B;
138
+ mi.current = B;
136
139
  }, [B]);
137
- let oi = !!L && rr !== !1;
140
+ let hi = !!L && fr !== !1;
138
141
  M(() => {
139
- if (oi) return yn({ send: (e) => vn(e, {
142
+ if (hi) return yn({ send: (e) => vn(e, {
140
143
  workspaceId: A(),
141
144
  authContext: {
142
- accessToken: ai.current(),
145
+ accessToken: mi.current(),
143
146
  organizationId: At()
144
147
  }
145
148
  }) });
146
- }, [oi]), M(() => {
147
- ti.update({
148
- loading: ei,
149
- canUseAdminModes: $r
149
+ }, [hi]), M(() => {
150
+ ui.update({
151
+ loading: li,
152
+ canUseAdminModes: ci
150
153
  });
151
154
  }, [
152
- ti,
153
- ei,
154
- $r
155
+ ui,
156
+ li,
157
+ ci
155
158
  ]), M(() => () => {
156
- ti.abandon();
157
- }, [ti]);
158
- let si = Gn(() => R.filter((e) => !e.requiresAdmin || $r), [R, $r]), ci = d(si), li = Ar && ci, ui = N(ci);
159
+ ui.abandon();
160
+ }, [ui]);
161
+ let gi = er(() => R.filter((e) => !e.requiresAdmin || ci), [R, ci]), _i = d(gi), vi = zr && _i, yi = N(_i);
159
162
  M(() => {
160
- ui.current = ci;
161
- }, [ci]);
162
- let di = N(null), fi = N(!1), pi = Xe(R), [mi, hi] = Kn(null), [gi, _i] = Kn(null), vi = gi !== null && gi === U, yi = j((e) => {
163
- _i(e ? x.getState().activeConversationId : null);
163
+ yi.current = _i;
164
+ }, [_i]);
165
+ let bi = N(null), xi = N(!1), Si = Xe(R), [Ci, wi] = tr(null), [Ti, Ei] = tr(null), Di = Ti !== null && Ti === U, Oi = j((e) => {
166
+ Ei(e ? b.getState().activeConversationId : null);
164
167
  }, []);
165
168
  M(() => {
166
- _i((e) => e !== null && e !== U ? null : e);
169
+ Ei((e) => e !== null && e !== U ? null : e);
167
170
  }, [U]);
168
- let bi = N(void 0), [xi, Si] = Kn(!1), Ci = j((e) => {
169
- bi.current = e, Si(ze(e));
170
- }, []), wi = j(() => {
171
- let e = x.getState(), t = e.activeConversationId, n = t ? e.conversations.find((e) => e.id === t) : void 0;
171
+ let ki = N(void 0), [Ai, ji] = tr(!1), Mi = j((e) => {
172
+ ki.current = e, ji(ze(e));
173
+ }, []), Ni = j(() => {
174
+ let e = b.getState(), t = e.activeConversationId, n = t ? e.conversations.find((e) => e.id === t) : void 0;
172
175
  return !t || !n ? null : {
173
176
  id: t,
174
177
  reusableDraft: rn(n, p()),
175
178
  liveProposals: J.liveFor(t).count,
176
179
  turnInFlight: ut(e.processingByConversationId[t]?.status)
177
180
  };
178
- }, [J]), Ti = N({}), Y = N(Nt()), X = N(new bn()), Ei = N(/* @__PURE__ */ new Set()), Di = Gn(() => R.find((e) => e.id === W), [R, W]), Oi = x((e) => {
181
+ }, [J]), Pi = N({}), Y = N(Nt()), X = N(new bn()), Fi = N(/* @__PURE__ */ new Set()), Ii = er(() => R.find((e) => e.id === W), [R, W]), Li = b((e) => {
179
182
  let t = e.sandboxesByMode[W]?.sandboxId;
180
183
  return t ? e.sandboxWriteCapabilities[t] : void 0;
181
- }), ki = Di !== void 0 && et({
184
+ }), Ri = Ii !== void 0 && et({
182
185
  mode: W,
183
186
  productWriteApproval: z,
184
- capabilities: Oi
185
- }), Ai = W === "assistant" || Di !== void 0 && !Di.writeCapable && !fe(W) || ki;
187
+ capabilities: Li
188
+ }), zi = W === "assistant" || Ii !== void 0 && !Ii.writeCapable && !fe(W) || Ri;
186
189
  M(() => {
187
- if (W !== "assistant" && Di?.writeCapable && !re(Or, W)) {
188
- gr("assistant");
190
+ if (W !== "assistant" && Ii?.writeCapable && !ie(Lr, W)) {
191
+ Tr("assistant");
189
192
  return;
190
193
  }
191
- ei || (!Di || Di.requiresAdmin && !$r) && W !== "assistant" && gr("assistant");
194
+ li || (!Ii || Ii.requiresAdmin && !ci) && W !== "assistant" && Tr("assistant");
192
195
  }, [
193
196
  W,
194
- Di,
195
- $r,
196
- ei,
197
- gr,
198
- Or
197
+ Ii,
198
+ ci,
199
+ li,
200
+ Tr,
201
+ Lr
199
202
  ]);
200
- let ji = j((e, t, n, r) => {
201
- Sr(e, n, t, null, r);
202
- }, [Sr]), Mi = j(async (e, t, n, r, i, a = null) => {
203
+ let Bi = j((e, t, n, r) => {
204
+ jr(e, n, t, null, r);
205
+ }, [jr]), Vi = j(async (e, t, n, r, i, a = null) => {
203
206
  let s = (e, t) => {
204
- r && ji(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
207
+ r && Bi(r.conversationId, r.assistantMessageId, e, t), a && (a.step = t, a.onStep?.(t));
205
208
  }, c = (e) => {
206
209
  r && k(r.assistantMessageId, e);
207
210
  }, l = () => {
208
211
  c("bootAdopted"), a?.beginBoot();
209
212
  }, u = () => a !== null && (a.signal.aborted || A() !== t), d = () => {
210
213
  if (u()) throw new xn("cancelled");
211
- }, f = x.getState().sandboxesByMode[e]?.sandboxId ?? null, p = !1, ee = !1, m = !1, h = !1, g = !1, te = async (r) => {
214
+ }, f = b.getState().sandboxesByMode[e]?.sandboxId ?? null, p = !1, ee = !1, m = !1, h = !1, te = !1, ne = async (r) => {
212
215
  if (i && !X.current.has(r) && Y.current.isFresh(r)) return p = !0, !0;
213
216
  m = !0;
214
217
  let o = !1;
@@ -218,77 +221,77 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
218
221
  });
219
222
  } catch {
220
223
  if (u()) throw new xn("cancelled");
221
- return Y.current.invalidate(r), X.current.add(r), a?.dead.push(r), g = !0, !1;
224
+ return Y.current.invalidate(r), X.current.add(r), a?.dead.push(r), te = !0, !1;
222
225
  }
223
226
  return d(), Y.current.markVerified(r), o && (h = !0), !0;
224
227
  };
225
- if (f && (Er(e, f, "provisioning"), s("provisioning", "reusingEnvironment"), await te(f) || (Er(e, null, "provisioning"), f = null)), !f) {
228
+ if (f && (Fr(e, f, "provisioning"), s("provisioning", "reusingEnvironment"), await ne(f) || (Fr(e, null, "provisioning"), f = null)), !f) {
226
229
  s("provisioning", "lookingForEnvironment");
227
- let r = await ce(t, L, e, Hn(), n, X.current, z);
230
+ let r = await le(t, L, e, Zn(), n, X.current, z);
228
231
  d();
229
232
  let i = r?.id ?? null;
230
233
  if (i) {
231
- Er(e, i, "provisioning"), s("provisioning", "reusingEnvironment");
234
+ Fr(e, i, "provisioning"), s("provisioning", "reusingEnvironment");
232
235
  let t = r?.status === "PROVISIONING" || r?.status === "PENDING";
233
- t && l(), await te(i) ? (f = i, t && (h = !0)) : Er(e, null, "provisioning");
236
+ t && l(), await ne(i) ? (f = i, t && (h = !0)) : Fr(e, null, "provisioning");
234
237
  }
235
238
  }
236
239
  if (!f) {
237
240
  if (a && !a.mayCreate) throw new xn("no-create");
238
241
  if (c("provisionStarted"), e === "api-calls" && !B()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
239
- s("provisioning", "startingEnvironment"), Er(e, null, "provisioning");
240
- let r = a ? [] : await w(t, L, e, Hn(), n, X.current, z);
242
+ s("provisioning", "startingEnvironment"), Fr(e, null, "provisioning");
243
+ let r = a ? [] : await w(t, L, e, Zn(), n, X.current, z);
241
244
  if (r.length > 0) {
242
245
  let e = new Set(r);
243
246
  for (let e of r) Y.current.invalidate(e), X.current.add(e);
244
- let t = x.getState().sandboxesByMode;
245
- for (let [n, r] of Object.entries(t)) o(n) && r?.sandboxId && e.has(r.sandboxId) && Dr(n);
247
+ let t = b.getState().sandboxesByMode;
248
+ for (let [n, r] of Object.entries(t)) o(n) && r?.sandboxId && e.has(r.sandboxId) && Ir(n);
246
249
  }
247
250
  c("createRequested");
248
251
  let i = a?.beginCreate();
249
252
  try {
250
- f = await S(L, e, t, Hn(), Yn, n, { writeApproval: z });
253
+ f = await x(L, e, t, Zn(), ir, n, { writeApproval: z });
251
254
  } finally {
252
255
  i?.();
253
256
  }
254
- ee = !0, d(), Er(e, f, "provisioning"), await he(f, t, n, 3e5), d(), c("sandboxRunning"), await T(f, t, e, n, 9e4), d(), c("serviceReady"), Y.current.markVerified(f);
257
+ ee = !0, d(), Fr(e, f, "provisioning"), await he(f, t, n, 3e5), d(), c("sandboxRunning"), await T(f, t, e, n, 9e4), d(), c("serviceReady"), Y.current.markVerified(f);
255
258
  }
256
- return Er(e, f, "running"), {
259
+ return Fr(e, f, "running"), {
257
260
  sandboxId: f,
258
261
  sandboxIsNew: ee,
259
262
  sandboxProbed: m,
260
263
  sandboxAdopted: h,
261
- deadSandboxProbe: g,
264
+ deadSandboxProbe: te,
262
265
  trustedFromCache: p
263
266
  };
264
267
  }, [
265
- Dr,
268
+ Ir,
266
269
  B,
267
270
  L,
268
271
  z,
269
- Er,
270
- ji
271
- ]), Ni = j(async function e(t, n, r, i, a, o = {}) {
272
- let s = await Dn(i, r, (e) => ji(t, n, "provisioning", e), () => k(n, "prewarmJoined"));
272
+ Fr,
273
+ Bi
274
+ ]), Hi = j(async function e(t, n, r, i, a, o = {}) {
275
+ let s = await Dn(i, r, (e) => Bi(t, n, "provisioning", e), () => k(n, "prewarmJoined"));
273
276
  for (let e of s.dead) Y.current.invalidate(e), X.current.add(e);
274
277
  s.verified && !X.current.has(s.verified) && Y.current.markVerified(s.verified), s.joined && O(n, { prewarm: s.joined });
275
- let { sandboxId: c, sandboxIsNew: l, sandboxProbed: u, sandboxAdopted: d, deadSandboxProbe: f, trustedFromCache: p } = await Mi(r, i, a, {
278
+ let { sandboxId: c, sandboxIsNew: l, sandboxProbed: u, sandboxAdopted: d, deadSandboxProbe: f, trustedFromCache: p } = await Vi(r, i, a, {
276
279
  conversationId: t,
277
280
  assistantMessageId: n
278
281
  }, o.trustCache !== !1), ee = Cn(i, r, c);
279
282
  !s.waited && ee && O(n, { prewarm: "hit" });
280
- let m = x.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, h = !1, g = null;
283
+ let m = b.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null, h = !1, te = null;
281
284
  if (m) {
282
- let e = vt(c, m, (e, t) => ue(e, i, t, r, a, { limit: 50 }));
285
+ let e = vt(c, m, (e, t) => de(e, i, t, r, a, { limit: 50 }));
283
286
  try {
284
- let t = await de(c, i, m, r, a);
287
+ let t = await C(c, i, m, r, a);
285
288
  if (t.mode !== r) throw Error(`Session mode mismatch: expected ${r}, received ${t.mode}`);
286
- g = e;
289
+ te = e;
287
290
  } catch {
288
- Tr(t), m = null;
291
+ Pr(t), m = null;
289
292
  }
290
293
  }
291
- let te = !1;
294
+ let ne = !1;
292
295
  if (!m) {
293
296
  let e = Sn(wn({
294
297
  workspaceId: i,
@@ -297,24 +300,24 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
297
300
  userId: V
298
301
  }), Date.now());
299
302
  if (e) {
300
- "pending" in e && ji(t, n, "connecting", "preparingSession");
303
+ "pending" in e && Bi(t, n, "connecting", "preparingSession");
301
304
  let o = "sessionId" in e ? e.sessionId : await e.pending;
302
305
  if (o && !X.current.has(c)) try {
303
- (await de(c, i, o, r, a)).mode === r && (m = o, te = !0, wr(t, m), h = !0);
306
+ (await C(c, i, o, r, a)).mode === r && (m = o, ne = !0, Nr(t, m), h = !0);
304
307
  } catch {}
305
308
  }
306
309
  }
307
310
  if (!m) {
308
- ji(t, n, "connecting", "preparingSession");
311
+ Bi(t, n, "connecting", "preparingSession");
309
312
  let s;
310
313
  try {
311
- s = await C(c, i, r, a);
314
+ s = await S(c, i, r, a);
312
315
  } catch (s) {
313
316
  if (p) {
314
317
  Y.current.invalidate(c);
315
318
  let l = Ft(s, o.isAbandoned?.() ?? !1), p = l === "check-network";
316
- if (l === "check-network" && (l = await Pt(() => ce(i, L, r, Hn(), a, X.current, z))), l !== "rethrow" && o.isAbandoned?.() && (l = "rethrow"), l !== "rethrow") {
317
- p || O(n, { cacheProofFailed: !0 }), l === "replace" && (X.current.add(c), Tr(t), Dr(r), J.retireSandbox(c));
319
+ if (l === "check-network" && (l = await Pt(() => le(i, L, r, Zn(), a, X.current, z))), l !== "rethrow" && o.isAbandoned?.() && (l = "rethrow"), l !== "rethrow") {
320
+ p || O(n, { cacheProofFailed: !0 }), l === "replace" && (X.current.add(c), Pr(t), Ir(r), J.retireSandbox(c));
318
321
  let s = await e(t, n, r, i, a, {
319
322
  ...o,
320
323
  trustCache: !1
@@ -329,43 +332,43 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
329
332
  }
330
333
  throw s;
331
334
  }
332
- m = s.sessionId, wr(t, m), h = !0;
335
+ m = s.sessionId, Nr(t, m), h = !0;
333
336
  }
334
337
  return {
335
338
  sandboxId: c,
336
339
  sessionId: m,
337
340
  sessionIsNew: h,
338
- readAhead: g,
341
+ readAhead: te,
339
342
  sandboxIsNew: l,
340
343
  sandboxProbed: u,
341
344
  sandboxAdopted: d,
342
345
  deadSandboxProbe: f,
343
- sessionPreopened: te
346
+ sessionPreopened: ne
344
347
  };
345
348
  }, [
346
- Mi,
347
- Tr,
348
- Dr,
349
+ Vi,
350
+ Pr,
351
+ Ir,
349
352
  L,
350
353
  z,
351
- wr,
352
- ji,
354
+ Nr,
355
+ Bi,
353
356
  V,
354
357
  J
355
- ]), Pi = j((e, t = !1) => {
358
+ ]), Ui = j((e, t = !1) => {
356
359
  let n = A();
357
360
  if (!n) return;
358
- let r = x.getState(), i = Date.now(), a = En({
361
+ let r = b.getState(), i = Date.now(), a = En({
359
362
  autoRouting: r.autoRouting,
360
- autoOffered: ui.current,
363
+ autoOffered: yi.current,
361
364
  active: !t && r.activeConversationId ? r.conversations.find((e) => e.id === r.activeConversationId) : void 0,
362
365
  selectedMode: r.mode,
363
366
  autoReadMode: s,
364
- modes: ni.current,
367
+ modes: di.current,
365
368
  acknowledgedWriteModes: r.acknowledgedWriteModes,
366
- adminAccess: ti.read(),
369
+ adminAccess: ui.read(),
367
370
  dictated: e,
368
- voiceProposalBound: (e) => or(e),
371
+ voiceProposalBound: (e) => hr(e),
369
372
  turnInFlight: Object.values(r.processingByConversationId).some((e) => ut(e?.status)),
370
373
  ...An(n),
371
374
  now: i
@@ -373,11 +376,11 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
373
376
  if (!a) return;
374
377
  let o = kn(n, a, i), c = {
375
378
  accessToken: B(),
376
- workspaceToken: sr(),
379
+ workspaceToken: gr(),
377
380
  userId: V,
378
381
  organizationId: At()
379
382
  };
380
- Mi(a.mode, n, c, null, !0, o).then((e) => {
383
+ Vi(a.mode, n, c, null, !0, o).then((e) => {
381
384
  if (o.finish({
382
385
  ok: !0,
383
386
  sandboxId: e.sandboxId,
@@ -385,7 +388,7 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
385
388
  booted: e.sandboxIsNew || e.sandboxAdopted,
386
389
  dead: o.dead
387
390
  }), o.signal.aborted || A() !== n || X.current.has(e.sandboxId)) return;
388
- let r = x.getState(), i = !t && r.activeConversationId ? r.conversations.find((e) => e.id === r.activeConversationId) : void 0, s = p();
391
+ let r = b.getState(), i = !t && r.activeConversationId ? r.conversations.find((e) => e.id === r.activeConversationId) : void 0, s = p();
389
392
  Tn({
390
393
  active: i ? {
391
394
  mode: i.mode,
@@ -399,11 +402,11 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
399
402
  mode: a.mode,
400
403
  sandboxId: e.sandboxId,
401
404
  userId: V
402
- }), () => C(e.sandboxId, n, a.mode, c).then((e) => e.sessionId), Date.now());
405
+ }), () => S(e.sandboxId, n, a.mode, c).then((e) => e.sessionId), Date.now());
403
406
  }, (e) => {
404
407
  if (!(e instanceof xn) && !o.signal.aborted && A() === n) {
405
- let e = x.getState().sandboxesByMode[a.mode]?.sandboxId ?? null;
406
- e && (Y.current.invalidate(e), X.current.add(e), o.dead.push(e), Dr(a.mode));
408
+ let e = b.getState().sandboxesByMode[a.mode]?.sandboxId ?? null;
409
+ e && (Y.current.invalidate(e), X.current.add(e), o.dead.push(e), Ir(a.mode));
407
410
  }
408
411
  o.finish({
409
412
  ok: !1,
@@ -413,44 +416,44 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
413
416
  });
414
417
  });
415
418
  }, [
416
- Mi,
417
- ti,
418
- Dr,
419
+ Vi,
420
+ ui,
421
+ Ir,
419
422
  B,
420
- sr,
423
+ gr,
421
424
  V,
422
- or
423
- ]), Fi = j(() => Pi(!1), [Pi]), Ii = qn(y, g, g)?.reference ?? null, [Li, Ri] = Kn(0), zi = N(/* @__PURE__ */ new Set()), Bi = N(null), Vi = j(() => {
424
- let e = x.getState(), t = e.activeConversationId;
425
+ hr
426
+ ]), Wi = j(() => Ui(!1), [Ui]), Gi = nr(v, te, te)?.reference ?? null, [Ki, qi] = tr(0), Ji = N(/* @__PURE__ */ new Set()), Yi = N(null), Xi = j(() => {
427
+ let e = b.getState(), t = e.activeConversationId;
425
428
  if (!t) return;
426
429
  let n = e.processingByConversationId[t], r = ut(n?.status) ? n?.messageId ?? null : null;
427
430
  if (!ft({
428
431
  interruptedTurnId: r,
429
432
  activeTurnId: r,
430
- alreadyRequested: r ? zi.current.has(r) : !1
433
+ alreadyRequested: r ? Ji.current.has(r) : !1
431
434
  }).send || !r) return;
432
- zi.current.add(r);
433
- let i = b(e), a = A(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
434
- !i || !a || !o || ae(i.sandboxId, a, o, i.mode, {
435
+ Ji.current.add(r);
436
+ let i = y(e), a = A(), o = e.conversations.find((e) => e.id === t)?.backendSessionId;
437
+ !i || !a || !o || oe(i.sandboxId, a, o, i.mode, {
435
438
  accessToken: B(),
436
- workspaceToken: sr(),
439
+ workspaceToken: gr(),
437
440
  userId: V,
438
441
  organizationId: At()
439
442
  });
440
443
  }, [
441
444
  V,
442
445
  B,
443
- sr
444
- ]), Hi = j(async (e) => {
445
- let t = x.getState(), n = b(t), r = A(), i = t.activeConversationId;
446
+ gr
447
+ ]), Zi = j(async (e) => {
448
+ let t = b.getState(), n = y(t), r = A(), i = t.activeConversationId;
446
449
  if (!n || !r || !i || Ht(t.sandboxWriteCapabilities[n.sandboxId])) return;
447
- let a = t.conversations.find((e) => e.id === i), o = a ? _(E(a.messages), {
450
+ let a = t.conversations.find((e) => e.id === i), o = a ? g(E(a.messages), {
448
451
  sessionId: a.backendSessionId,
449
452
  sandboxId: n.sandboxId,
450
453
  nowMs: Date.now()
451
454
  }) : null;
452
455
  if (o?.reference !== e) {
453
- Ri((e) => e + 1);
456
+ qi((e) => e + 1);
454
457
  return;
455
458
  }
456
459
  let s = {
@@ -459,9 +462,9 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
459
462
  };
460
463
  if (!m(s)) return;
461
464
  try {
462
- await oe(n.sandboxId, r, e, n.mode, {
465
+ await se(n.sandboxId, r, e, n.mode, {
463
466
  accessToken: B(),
464
- workspaceToken: sr(),
467
+ workspaceToken: gr(),
465
468
  userId: V,
466
469
  organizationId: At()
467
470
  });
@@ -474,37 +477,69 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
474
477
  });
475
478
  return;
476
479
  }
477
- h(s), xr(i, o.messageId, { pendingWriteApprovedAt: (/* @__PURE__ */ new Date()).toISOString() });
478
- let c = x.getState(), l = c.conversations.find((e) => e.id === i);
479
- c.activeConversationId !== i || !l || c.mode !== n.mode || l.backendSessionId !== a?.backendSessionId || b(c)?.sandboxId !== n.sandboxId || ut(c.processingByConversationId[i]?.status) || ne(E(l.messages)) !== o.messageId || oa.current(I("pendingWrite.approvedPrompt", "I approved that change — go ahead."), [], {
480
+ h(s), Ar(i, o.messageId, { pendingWriteApprovedAt: (/* @__PURE__ */ new Date()).toISOString() });
481
+ let c = b.getState(), l = c.conversations.find((e) => e.id === i);
482
+ c.activeConversationId !== i || !l || c.mode !== n.mode || l.backendSessionId !== a?.backendSessionId || y(c)?.sandboxId !== n.sandboxId || ut(c.processingByConversationId[i]?.status) || re(E(l.messages)) !== o.messageId || Ca.current(I("pendingWrite.approvedPrompt", "I approved that change — go ahead."), [], {
480
483
  approvalFollowUp: { approvedReplyId: o.messageId },
481
484
  targetConversationId: i
482
485
  });
483
486
  }, [
484
487
  V,
485
488
  K,
486
- xr,
489
+ Ar,
487
490
  I
488
- ]), Ui = e(), { speakFinishedReply: Wi } = Ot(), Gi = a(), { items: Ki } = Wn(), qi = N({
489
- theme: Ui,
490
- navigate: Gi,
491
- navItems: Ki,
492
- options: ar ?? {}
491
+ ]), Qi = e(), { speakFinishedReply: $i } = Ot(), ea = a(), { items: ta } = $n(), na = N({
492
+ theme: Qi,
493
+ navigate: ea,
494
+ navItems: ta,
495
+ options: mr ?? {}
493
496
  });
494
497
  M(() => {
495
- qi.current = {
496
- theme: Ui,
497
- navigate: Gi,
498
- navItems: Ki,
499
- options: ar ?? {}
498
+ na.current = {
499
+ theme: Qi,
500
+ navigate: ea,
501
+ navItems: ta,
502
+ options: mr ?? {}
500
503
  };
501
504
  }, [
502
- Ui,
503
- Gi,
504
- Ki,
505
- ar
505
+ Qi,
506
+ ea,
507
+ ta,
508
+ mr
506
509
  ]);
507
- let Ji = j((e, t, n, r, i) => {
510
+ let ra = N(!0);
511
+ M(() => (ra.current = !0, () => {
512
+ ra.current = !1;
513
+ }), []);
514
+ let ia = N(null), [aa, oa] = tr(!1), sa = j((e) => {
515
+ let t = b.getState(), n = t.conversations.find((e) => e.id === t.activeConversationId);
516
+ return n ? Hn(Vn, window.location.pathname, Kn(n.messages, e)) : !1;
517
+ }, []), ca = j((e, t) => {
518
+ let { navItems: n, options: r } = na.current;
519
+ return Mn(e, Nn(n), {
520
+ ...r,
521
+ locale: t === void 0 ? H : yr.input.code
522
+ }, { backRunnable: sa(t) });
523
+ }, [
524
+ sa,
525
+ yr,
526
+ H
527
+ ]), la = j((e, t) => {
528
+ let n = ca(e, t);
529
+ if (!n) return !1;
530
+ let { theme: r, navigate: i } = na.current;
531
+ switch (n.kind) {
532
+ case "theme": return r !== null;
533
+ case "navigate":
534
+ case "choose-destination":
535
+ case "back": return i !== null;
536
+ case "conversation-delete": return !1;
537
+ }
538
+ }, [ca]), ua = N(la);
539
+ M(() => {
540
+ ua.current = la;
541
+ }, [la]);
542
+ let da = j((e, t, n, r, i) => {
508
543
  let a = I(n.key, n.fallback, r), o = n.fallback.replace(/\{\{\s*count\s*\}\}/g, String(r.count)), s = {
509
544
  kind: "write-reply",
510
545
  line: n.key
@@ -530,46 +565,118 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
530
565
  localAction: s,
531
566
  ...D(i)
532
567
  }
533
- }), on.recordCommittedEntries(e, [l, u], "LOCAL_COMMAND", A()), Wi(e, u);
568
+ }), on.recordCommittedEntries(e, [l, u], "LOCAL_COMMAND", A()), $i(e, u);
534
569
  }, [
535
570
  K,
536
571
  H,
537
- Wi,
572
+ $i,
538
573
  I
539
- ]), Yi = un(), Xi = Yi?.request ?? null, Zi = N(() => void 0), [Qi, $i] = Kn(null);
574
+ ]), fa = un(), pa = fa?.request ?? null, ma = N(() => void 0), [ha, ga] = tr(null);
540
575
  M(() => {
541
- if (Qi === null) return;
542
- let e = window.setTimeout(() => $i(null), Qn);
576
+ if (ha === null) return;
577
+ let e = window.setTimeout(() => ga(null), sr);
543
578
  return () => window.clearTimeout(e);
544
- }, [Qi]);
545
- let ea = j(() => {
546
- let e = x.getState();
547
- return G(void 0, e.autoRouting && ui.current ? s : e.mode, e.autoRouting ? { routedBy: "auto" } : void 0);
548
- }, [G]), ta = j((e) => {
549
- if (!Xi) return !1;
550
- let t = e !== void 0, n = x.getState(), r = dn({
579
+ }, [ha]);
580
+ let _a = j(() => {
581
+ let e = b.getState();
582
+ return G(void 0, e.autoRouting && yi.current ? s : e.mode, e.autoRouting ? { routedBy: "auto" } : void 0);
583
+ }, [G]), va = j((e) => {
584
+ if (!pa) return !1;
585
+ let t = e !== void 0, n = b.getState(), r = dn({
551
586
  spoken: t,
552
- bound: bi.current,
587
+ bound: ki.current,
553
588
  activeConversationId: n.activeConversationId,
554
589
  conversations: n.conversations,
555
590
  historyOn: ln()
556
591
  });
557
- if (r && Xi(r), t) {
592
+ if (r && pa(r), t) {
558
593
  let e = r ? "Opened the delete confirmation. Choose Delete or Cancel on screen." : "There is no conversation to delete.", t = r ? I("deleteConversation.opened", "Opened the delete confirmation. Choose Delete or Cancel on screen.") : I("deleteConversation.nothing", "There is no conversation to delete.");
559
- Zi.current({
594
+ ma.current({
560
595
  id: `conversation-delete:${F()}`,
561
596
  text: t,
562
597
  lang: t === e ? "en" : H
563
598
  });
564
- } else r || $i(Date.now());
599
+ } else r || ga(Date.now());
565
600
  return !0;
566
601
  }, [
567
- Xi,
602
+ pa,
568
603
  H,
569
604
  I
570
- ]), na = j((e, t, n, r = !1) => {
571
- if (e.kind === "conversation-delete") return ta(n);
572
- let { theme: i, navigate: a } = qi.current, o, s;
605
+ ]), ya = j((e, t, n, r = !1) => {
606
+ if (e.kind === "conversation-delete") return va(n);
607
+ let { theme: i, navigate: a } = na.current, o = () => {
608
+ let e = (r ? null : b.getState().activeConversationId) ?? _a();
609
+ return r && Mi(e), e;
610
+ }, s = (e, r) => {
611
+ let i = F();
612
+ return K(e, {
613
+ id: i,
614
+ role: "user",
615
+ content: t,
616
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
617
+ metadata: {
618
+ localAction: r,
619
+ ...D(n)
620
+ }
621
+ }), i;
622
+ }, c = (e, t, r, i, a, o) => {
623
+ let s = F();
624
+ return K(e, {
625
+ id: s,
626
+ role: "assistant",
627
+ content: r.text,
628
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
629
+ metadata: {
630
+ lang: r.translated ? H : "en",
631
+ localAction: i,
632
+ ...D(n)
633
+ }
634
+ }), on.recordCommittedEntries(e, [t, s], "LOCAL_COMMAND", a), o && $i(e, s), s;
635
+ }, l = (e, t) => {
636
+ let n = o();
637
+ return c(n, s(n, t), e, t, A(), !0), !0;
638
+ }, u = (e) => {
639
+ let t = o(), n = A(), r = window.location.pathname, i = s(t, Un({
640
+ destinationId: e.destinationId,
641
+ path: e.registryPath,
642
+ alreadyHere: !1,
643
+ via: e.via
644
+ })), l = F();
645
+ ia.current = l, oa(!0);
646
+ let u = (a) => {
647
+ try {
648
+ if (!b.getState().conversations.some((e) => e.id === t)) return;
649
+ let o = Nn(na.current.navItems), s = a.status === "arrived" || a.status === "redirected" ? a.landedPath : null, l = Un({
650
+ destinationId: e.destinationId,
651
+ path: e.registryPath,
652
+ alreadyHere: !1,
653
+ via: e.via,
654
+ outcome: a
655
+ });
656
+ Ar(t, i, { localAction: l });
657
+ let u = c(t, i, e.via === "back" && a.status === "arrived" ? Fn(I, e.pageLabel()) : Rn(I, a, {
658
+ page: e.pageLabel(),
659
+ landed: s === null ? null : Gn(o, s),
660
+ path: e.target
661
+ }), l, n, ra.current);
662
+ a.status === "arrived" && e.onArrived?.({
663
+ replyId: u,
664
+ fromPath: r,
665
+ landedPath: a.landedPath
666
+ });
667
+ } finally {
668
+ ia.current === l && (ia.current = null, ra.current && oa(!1));
669
+ }
670
+ };
671
+ return Bn(a, e.target, {
672
+ readPath: () => window.location.pathname + window.location.search,
673
+ now: () => Date.now(),
674
+ schedule: (e, t) => {
675
+ window.setTimeout(e, t);
676
+ },
677
+ isShellLess: () => !ra.current
678
+ }).then(u, () => u({ status: "unconfirmed" })), !0;
679
+ };
573
680
  if (e.kind === "theme") {
574
681
  if (!i) return !1;
575
682
  let t = Pn(e.request, {
@@ -579,78 +686,83 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
579
686
  if (!t.alreadyApplied) try {
580
687
  i.setMode(t.mode);
581
688
  } catch {}
582
- o = Ln(I, t, e.request.kind === "family"), s = {
689
+ return l(zn(I, t, e.request.kind === "family"), {
583
690
  kind: "theme",
584
691
  mode: t.mode,
585
692
  alreadyApplied: t.alreadyApplied
586
- };
587
- } else {
588
- if (!a) return !1;
589
- if (e.kind === "navigate") {
590
- let { destination: t } = e, n = jn(t, window.location.pathname + window.location.search, Nn(qi.current.navItems));
591
- n || a(t.path), o = In(I, t.label, n), s = {
592
- kind: "navigate",
593
- destinationId: t.id,
594
- path: t.path,
595
- alreadyHere: n
596
- };
597
- } else o = Fn(I, e.candidates[0]?.label ?? e.query, e.candidates), s = {
598
- kind: "choose-destination",
599
- candidateIds: e.candidates.map((e) => e.id)
600
- };
693
+ });
601
694
  }
602
- let c = (r ? null : x.getState().activeConversationId) ?? ea();
603
- r && Ci(c);
604
- let l = (/* @__PURE__ */ new Date()).toISOString(), u = F();
605
- K(c, {
606
- id: u,
607
- role: "user",
608
- content: t,
609
- timestamp: l,
610
- metadata: {
611
- localAction: s,
612
- ...D(n)
613
- }
695
+ if (!a) return !1;
696
+ if (e.kind === "choose-destination") return l(In(I, e.candidates[0]?.label ?? e.query, e.candidates), {
697
+ kind: "choose-destination",
698
+ candidateIds: e.candidates.map((e) => e.id)
699
+ });
700
+ if (e.kind === "back") {
701
+ let e = Vn.top();
702
+ if (!e) return !1;
703
+ let t = Wn(Nn(na.current.navItems), e.fromPath);
704
+ return u({
705
+ target: e.fromPath,
706
+ destinationId: t?.id ?? "",
707
+ registryPath: t?.path ?? e.fromPath,
708
+ via: "back",
709
+ pageLabel: () => t?.label ?? null,
710
+ onArrived: () => {
711
+ Vn.top() === e && Vn.pop();
712
+ }
713
+ });
714
+ }
715
+ let { destination: d } = e;
716
+ return jn(d, window.location.pathname + window.location.search, Nn(na.current.navItems)) ? l(Ln(I, d.label, !0), Un({
717
+ destinationId: d.id,
718
+ path: d.path,
719
+ alreadyHere: !0,
720
+ via: "named"
721
+ })) : u({
722
+ target: d.path,
723
+ destinationId: d.id,
724
+ registryPath: d.path,
725
+ via: "named",
726
+ pageLabel: () => d.label,
727
+ onArrived: ({ replyId: e, fromPath: t, landedPath: n }) => Vn.push({
728
+ fromPath: t,
729
+ toPath: n,
730
+ replyMessageId: e,
731
+ at: Date.now()
732
+ })
614
733
  });
615
- let d = F();
616
- return K(c, {
617
- id: d,
618
- role: "assistant",
619
- content: o.text,
620
- timestamp: l,
621
- metadata: {
622
- lang: o.translated ? H : "en",
623
- localAction: s,
624
- ...D(n)
625
- }
626
- }), on.recordCommittedEntries(c, [u, d], "LOCAL_COMMAND", A()), Wi(c, d), !0;
627
734
  }, [
628
735
  K,
629
- Ci,
630
- ea,
736
+ Mi,
737
+ _a,
631
738
  H,
632
- ta,
633
- Wi,
739
+ Ar,
740
+ va,
741
+ $i,
634
742
  I
635
- ]), ra = j(async (e) => {
636
- fi.current = !0;
743
+ ]), ba = j(async (e) => {
744
+ xi.current = !0;
637
745
  try {
638
746
  await J.declineForReply(e.conversationId, e.reason, e.origin);
639
747
  } finally {
640
- fi.current = !1;
748
+ xi.current = !1;
641
749
  }
642
750
  if (e.commandText !== null) {
643
- let t = Mn(e.commandText, Nn(qi.current.navItems), qi.current.options);
644
- if (t && na(t, e.content, e.options.voiceSessionId)) return;
751
+ let t = ca(e.commandText, e.options.voiceSessionId);
752
+ if (t && ya(t, e.content, e.options.voiceSessionId)) return;
645
753
  }
646
- await oa.current(e.content, e.attachments, e.options);
647
- }, [na, J]), Z = j(async (e, t = [], n = {}) => {
648
- let r = n.voiceSessionId !== void 0, i = x.getState(), a = !1, o = bi.current;
754
+ await Ca.current(e.content, e.attachments, e.options);
755
+ }, [
756
+ ca,
757
+ ya,
758
+ J
759
+ ]), Z = j(async (e, t = [], n = {}) => {
760
+ let r = n.voiceSessionId !== void 0, i = b.getState(), a = !1, o = ki.current;
649
761
  if (r && ze(o)) {
650
- let e = We(o, i.activeConversationId, wi());
762
+ let e = We(o, i.activeConversationId, Ni());
651
763
  if (e.kind === "gone") return;
652
764
  let t = n.voiceEntry ?? e;
653
- t.kind === "adopt" && Ci(t.conversationId), a = t.kind === "own", n = {
765
+ t.kind === "adopt" && Mi(t.conversationId), a = t.kind === "own", n = {
654
766
  ...n,
655
767
  voiceEntry: t
656
768
  };
@@ -659,7 +771,7 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
659
771
  if (c) {
660
772
  if (ut(i.processingByConversationId[c]?.status)) {
661
773
  let r = i.processingByConversationId[c]?.messageId ?? null;
662
- r && zi.current.has(r) && (Bi.current = {
774
+ r && Ji.current.has(r) && (Yi.current = {
663
775
  conversationId: c,
664
776
  content: e,
665
777
  attachments: t,
@@ -667,9 +779,9 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
667
779
  });
668
780
  return;
669
781
  }
670
- if (Ei.current.has(c)) return;
782
+ if (Fi.current.has(c)) return;
671
783
  }
672
- if (di.current || g() !== null || fi.current) return;
784
+ if (bi.current || te() !== null || xi.current || ia.current !== null) return;
673
785
  let d = n.targetConversationId, ee = p(), m = (e) => nn(e) || tn(e, ee);
674
786
  if (d !== void 0) {
675
787
  let e = i.conversations.find((e) => e.id === d);
@@ -678,18 +790,18 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
678
790
  if (n.fromPerson && n.writeReplyBound === void 0) {
679
791
  let r = d ?? s ?? null, i = n.voiceSessionId === void 0 ? "typed" : "spoken", a = Ut({
680
792
  text: e,
681
- locale: i === "spoken" ? ur.input.code : H,
793
+ locale: i === "spoken" ? yr.input.code : H,
682
794
  origin: i,
683
795
  hasAttachments: t.length > 0,
684
796
  live: J.liveFor(r),
685
- matchesLocalCommand: (e) => Mn(e, Nn(qi.current.navItems), qi.current.options) !== null
797
+ matchesLocalCommand: (e) => ca(e, n.voiceSessionId) !== null
686
798
  });
687
799
  if (a.kind === "local_reply") {
688
- r && Ji(r, e, a.line, a.values, n.voiceSessionId);
800
+ r && da(r, e, a.line, a.values, n.voiceSessionId);
689
801
  return;
690
802
  }
691
803
  let o = a.kind === "local" ? a.fallback : a.bound, c = a.declineAll;
692
- if (c !== null && r) return ra({
804
+ if (c !== null && r) return ba({
693
805
  conversationId: r,
694
806
  reason: c,
695
807
  origin: i,
@@ -708,47 +820,47 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
708
820
  }
709
821
  let h = n.writeReplyBound?.promptText ?? e;
710
822
  if (n.fromPerson && t.length === 0 && n.writeReplyBound?.localCommands !== !1) {
711
- let t = Mn(e, Nn(qi.current.navItems), qi.current.options);
712
- if (t && na(t, e, n.voiceSessionId, a)) return;
823
+ let t = ca(e, n.voiceSessionId);
824
+ if (t && ya(t, e, n.voiceSessionId, a)) return;
713
825
  }
714
- let ne = s ? i.conversations.find((e) => e.id === s) : void 0, _ = m(ne) ? void 0 : ne, v = i.autoRouting && ui.current && d === void 0 ? f({
826
+ let re = s ? i.conversations.find((e) => e.id === s) : void 0, g = m(re) ? void 0 : re, _ = i.autoRouting && yi.current && d === void 0 ? f({
715
827
  intent: n.autoIntent ?? l(e),
716
828
  dictated: r,
717
- voiceProposalBound: r && or("api-calls") && re(i.acknowledgedWriteModes, "api-calls"),
718
- conversation: _ ? {
719
- mode: _.mode,
720
- routedBy: _.routedBy,
721
- hasHistory: en(_)
829
+ voiceProposalBound: r && hr("api-calls") && ie(i.acknowledgedWriteModes, "api-calls"),
830
+ conversation: g ? {
831
+ mode: g.mode,
832
+ routedBy: g.routedBy,
833
+ hasHistory: en(g)
722
834
  } : null
723
835
  }) : null;
724
- if (v && ni.current.find((e) => e.id === v.mode)?.writeCapable && !re(i.acknowledgedWriteModes, v.mode)) {
725
- di.current = {
836
+ if (_ && di.current.find((e) => e.id === _.mode)?.writeCapable && !ie(i.acknowledgedWriteModes, _.mode)) {
837
+ bi.current = {
726
838
  content: e,
727
839
  attachments: t,
728
840
  options: n
729
- }, hi(v.mode);
841
+ }, wi(_.mode);
730
842
  return;
731
843
  }
732
- let y = v ? v.mode : i.mode, b, oe, S = d ?? (a ? null : U), C = S ? x.getState().conversations.find((e) => e.id === S) : void 0, ce = v?.action === "escalate" && _ ? {
733
- mode: _.mode,
734
- backendSessionId: _.backendSessionId ?? null
844
+ let v = _ ? _.mode : i.mode, y, se, x = d ?? (a ? null : U), S = x ? b.getState().conversations.find((e) => e.id === x) : void 0, le = _?.action === "escalate" && g ? {
845
+ mode: g.mode,
846
+ backendSessionId: g.backendSessionId ?? null
735
847
  } : null;
736
- if (v) v.action === "new" || !_ ? S = G(void 0, y, { routedBy: "auto" }) : (S = _.id, Mr(S, y));
848
+ if (_) _.action === "new" || !g ? x = G(void 0, v, { routedBy: "auto" }) : (x = g.id, Vr(x, v));
737
849
  else {
738
850
  let e = i.autoRouting ? { routedBy: "auto" } : void 0;
739
- !S || m(C) || C && C.mode !== y && en(C) ? S = G(void 0, y, e) : C && C.mode !== y && (e ? Mr(S, y) : _r(S, y));
851
+ !x || m(S) || S && S.mode !== v && en(S) ? x = G(void 0, v, e) : S && S.mode !== v && (e ? Vr(x, v) : Er(x, v));
740
852
  }
741
- if (!S) return;
742
- r && bi.current !== void 0 && S !== i.activeConversationId && Ci(S), n.approvalFollowUp || (Ti.current[S] = t);
743
- let de = () => x.getState().conversations.some((e) => e.id === S), w = A(), T = {
853
+ if (!x) return;
854
+ r && ki.current !== void 0 && x !== i.activeConversationId && Mi(x), n.approvalFollowUp || (Pi.current[x] = t);
855
+ let C = () => b.getState().conversations.some((e) => e.id === x), w = A(), T = {
744
856
  accessToken: B(),
745
- workspaceToken: sr(),
857
+ workspaceToken: gr(),
746
858
  userId: V,
747
859
  organizationId: At()
748
860
  }, he = (e, t) => {
749
- de() || !w || ae(e, w, t, y, {
861
+ C() || !w || oe(e, w, t, v, {
750
862
  accessToken: B(),
751
- workspaceToken: sr(),
863
+ workspaceToken: gr(),
752
864
  userId: V,
753
865
  organizationId: At()
754
866
  });
@@ -766,35 +878,35 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
766
878
  ...D(n.voiceSessionId)
767
879
  }
768
880
  };
769
- K(S, ge);
881
+ K(x, ge);
770
882
  let E = F();
771
- K(S, {
883
+ K(x, {
772
884
  id: E,
773
885
  role: "assistant",
774
886
  content: "",
775
887
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
776
888
  metadata: {
777
- lang: pr,
889
+ lang: Sr,
778
890
  ...D(n.voiceSessionId)
779
891
  }
780
892
  }), wt(E, {
781
893
  channel: r ? "voice" : "chat",
782
- mode: y,
894
+ mode: v,
783
895
  product: L,
784
- language: pr,
896
+ language: Sr,
785
897
  device: Tt(),
786
- routedByAuto: !!v
787
- }, n.voiceTiming), k(E, "accepted"), Sr(S, "provisioning", E, null), te(E);
898
+ routedByAuto: !!_
899
+ }, n.voiceTiming), k(E, "accepted"), jr(x, "provisioning", E, null), ne(E);
788
900
  let Oe = () => dt({
789
901
  turnId: E,
790
- abortRequested: zi.current.has(E),
791
- activeTurnId: x.getState().processingByConversationId[S]?.messageId ?? null,
792
- conversationExists: de()
793
- }), ke = (e, t, r, i, a = !1, o = pr) => {
794
- br(S, E, { content: _e(e) }), xr(S, E, {
902
+ abortRequested: Ji.current.has(E),
903
+ activeTurnId: b.getState().processingByConversationId[x]?.messageId ?? null,
904
+ conversationExists: C()
905
+ }), ke = (e, t, r, i, a = !1, o = Sr) => {
906
+ kr(x, E, { content: _e(e) }), Ar(x, E, {
795
907
  lang: o,
796
908
  ...t?.length ? { artifacts: t } : {},
797
- ...t?.length || r || i ? { mode: y } : {},
909
+ ...t?.length || r || i ? { mode: v } : {},
798
910
  ...r ? { sessionId: r } : {},
799
911
  ...i ? { sandboxId: i } : {},
800
912
  ...a ? { incomplete: !0 } : {},
@@ -806,11 +918,11 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
806
918
  k(E, "attemptStarted");
807
919
  let a = null, o = null, s = !1;
808
920
  try {
809
- let { sandboxId: i, sessionId: c, sessionIsNew: l, readAhead: u, sandboxIsNew: d, sandboxProbed: f, sandboxAdopted: p, deadSandboxProbe: ee, sessionPreopened: m } = await Ni(S, E, y, w, T, { isAbandoned: () => dt({
921
+ let { sandboxId: i, sessionId: c, sessionIsNew: l, readAhead: u, sandboxIsNew: d, sandboxProbed: f, sandboxAdopted: p, deadSandboxProbe: ee, sessionPreopened: m } = await Hi(x, E, v, w, T, { isAbandoned: () => dt({
810
922
  turnId: E,
811
- abortRequested: zi.current.has(E),
812
- activeTurnId: x.getState().processingByConversationId[S]?.messageId ?? null,
813
- conversationExists: de()
923
+ abortRequested: Ji.current.has(E),
924
+ activeTurnId: b.getState().processingByConversationId[x]?.messageId ?? null,
925
+ conversationExists: C()
814
926
  }).abandon });
815
927
  if (a = i, k(E, "runtimeReady"), O(E, {
816
928
  runtime: d ? "cold" : p ? "adopted" : f ? "probed" : m ? "preopened" : l ? "new-session" : "warm",
@@ -818,246 +930,247 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
818
930
  }), o = c, je.session = {
819
931
  sandboxId: i,
820
932
  sessionId: c
821
- }, ie(y, b, x.getState().acknowledgedWriteModes, {
933
+ }, ae(v, y, b.getState().acknowledgedWriteModes, {
822
934
  dictated: r,
823
- confirmsWrites: fe(y),
824
- proposalBound: or(y, i)
935
+ confirmsWrites: fe(v),
936
+ proposalBound: hr(v, i)
825
937
  }) === "voice-in-write-mode") throw new ve("voice-in-write-mode", "Voice in a write mode");
826
- let g = fn({
827
- conversation: x.getState().conversations.find((e) => e.id === S),
938
+ let te = fn({
939
+ conversation: b.getState().conversations.find((e) => e.id === x),
828
940
  content: e,
829
941
  sessionIsNew: l,
830
- sendingMode: y,
831
- sendingModeConfig: b,
832
- modes: ni.current,
942
+ sendingMode: v,
943
+ sendingModeConfig: y,
944
+ modes: di.current,
833
945
  answerText: (e) => bt(e).text
834
- }), te = await _t(() => ue(i, w, c, y, T, { limit: 50 }), l, gt(u, i, c));
835
- ji(S, E, "streaming", "thinking");
836
- let ne = tr?.(), _ = Wt(x.getState().sandboxWriteCapabilities[i]), v = {
837
- conversationId: S,
838
- writeReply: _ === "proposal-v1" ? n.writeReplyBound?.writeReply ?? null : null
839
- }, { prompt: re, parts: ae } = lt({
840
- content: g ? `${g}${h}` : h,
946
+ }), ne = await _t(() => de(i, w, c, v, T, { limit: 50 }), l, gt(u, i, c));
947
+ Bi(x, E, "streaming", "thinking");
948
+ let re = ur?.(), g = Wt(b.getState().sandboxWriteCapabilities[i]), _ = {
949
+ conversationId: x,
950
+ writeReply: g === "proposal-v1" ? n.writeReplyBound?.writeReply ?? null : null
951
+ }, { prompt: ie, parts: oe } = lt({
952
+ content: te ? `${te}${h}` : h,
841
953
  attachments: t,
842
- limits: Ze(b),
843
- wrapPrompt: (e) => nr?.(y, e, dr, fr, r, { writeApproval: _ }) ?? e,
954
+ limits: Ze(y),
955
+ wrapPrompt: (e) => dr?.(v, e, br, xr, r, { writeApproval: g }) ?? e,
844
956
  requestBytes: (e, t) => pe({
845
957
  sandboxId: i,
846
958
  workspaceId: w,
847
959
  sessionId: c,
848
- mode: y,
960
+ mode: v,
849
961
  prompt: e,
850
962
  parts: t,
851
- pageContext: ne,
963
+ pageContext: re,
852
964
  authContext: T,
853
- ...v
965
+ ..._
854
966
  })
855
- }), C = Je(ae), ce = C > 0;
856
- s = qe(t) > C;
967
+ }), S = Je(oe), le = S > 0;
968
+ s = qe(t) > S;
857
969
  let ye = Oe();
858
970
  if (ye.abandon) {
859
- ye.clearProcessing && Cr(S);
971
+ ye.clearProcessing && Mr(x);
860
972
  return;
861
973
  }
862
974
  try {
863
- await me(i, w, c, re, y, ne, T, ae?.length ? {
864
- parts: ae,
865
- ...v
866
- } : v);
975
+ await me(i, w, c, ie, v, re, T, oe?.length ? {
976
+ parts: oe,
977
+ ..._
978
+ } : _);
867
979
  } catch (e) {
868
- if (!ae || !jt(e)) throw e;
869
- await me(i, w, c, re, y, ne, T, v), s ||= ce;
980
+ if (!oe || !jt(e)) throw e;
981
+ await me(i, w, c, ie, v, re, T, _), s ||= le;
870
982
  }
871
- let be = (e) => br(S, E, { content: e }), xe = (e) => s ? `${e}\n\n${I("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._")}` : e;
983
+ let be = (e) => kr(x, E, { content: e }), xe = (e) => s ? `${e}\n\n${I("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._")}` : e;
872
984
  k(E, "promptSent");
873
- let Ce = null, Te = !1, Ee = mt, D = ht([], te), Ne = Date.now() + oe.streamBudgetMs, Fe = Date.now(), Ie = Date.now();
985
+ let Ce = null, Te = !1, Ee = mt, D = ht([], ne), Ne = Date.now() + se.streamBudgetMs, Fe = Date.now(), Ie = Date.now();
874
986
  for (; Date.now() < Ne;) {
875
987
  he(i, c);
876
988
  let e = Oe();
877
989
  if (e.abandon) {
878
- e.clearProcessing && Cr(S);
990
+ e.clearProcessing && Mr(x);
879
991
  return;
880
992
  }
881
- if (D = ht(await ue(i, w, c, y, T, {
993
+ if (D = ht(await de(i, w, c, v, T, {
882
994
  limit: 50,
883
- sinceMs: te,
995
+ sinceMs: ne,
884
996
  surfaceTurnTerminal: !0
885
- }), te, { accumulateNarration: oe.accumulatesNarration }), br(S, E, { content: _e(D.content) }), D.hasRenderableOutput ? Te || (Te = !0, Ce !== null && k(E, "lastQuietPoll", Ce), k(E, "firstOutput")) : Ce = Dt(), oe.accumulatesNarration) D.hasText && k(E, "firstText");
997
+ }), ne, { accumulateNarration: se.accumulatesNarration }), kr(x, E, { content: _e(D.content) }), D.hasRenderableOutput ? Te || (Te = !0, Ce !== null && k(E, "lastQuietPoll", Ce), k(E, "firstOutput")) : Ce = Dt(), se.accumulatesNarration) D.hasText && k(E, "firstText");
886
998
  else {
887
999
  let e = yt(Ee, D, Dt());
888
1000
  Ee = e.tracker, e.confirmedAt !== null && k(E, "firstText", e.confirmedAt);
889
1001
  }
890
- if (D.pendingWrite && !Ht(x.getState().sandboxWriteCapabilities[i]) && xr(S, E, { pendingWrite: D.pendingWrite }), D.done) {
1002
+ if (D.pendingWrite && !Ht(b.getState().sandboxWriteCapabilities[i]) && Ar(x, E, { pendingWrite: D.pendingWrite }), D.done) {
891
1003
  k(E, "answerDone"), Y.current.markVerified(i);
892
1004
  break;
893
1005
  }
894
- Date.now() - Fe > 3e4 && (await se(i, w, 600, T).catch(() => void 0), Fe = Date.now()), await new Promise((e) => setTimeout(e, Pe(Date.now() - Ie)));
1006
+ Date.now() - Fe > 3e4 && (await ce(i, w, 600, T).catch(() => void 0), Fe = Date.now()), await new Promise((e) => setTimeout(e, Pe(Date.now() - Ie)));
895
1007
  }
896
1008
  if (D.done && n.voiceSessionId !== void 0 && !Oe().abandon) {
897
1009
  let e = _e(xe(D.content));
898
1010
  e.trim() && (s && be(e), k(E, "speechQueued"), Me = !0, Ae.publish(E, {
899
- conversationId: S,
1011
+ conversationId: x,
900
1012
  channel: "voice",
901
1013
  voiceSessionId: n.voiceSessionId,
902
1014
  text: e,
903
- lang: pr,
1015
+ lang: Sr,
904
1016
  final: !0
905
1017
  }));
906
1018
  }
907
- let Le = oe.producesArtifacts ? await le(i, w, c, y, T).then((e) => e).catch(() => []) : void 0;
1019
+ let Le = se.producesArtifacts ? await ue(i, w, c, v, T).then((e) => e).catch(() => []) : void 0;
908
1020
  D.usedTools !== void 0 && O(E, { usedTools: D.usedTools }), D.done || (O(E, { outcome: "timedOut" }), D = {
909
1021
  ...D,
910
- content: De(D.content, y, I, b)
1022
+ content: De(D.content, v, I, y)
911
1023
  }), s && (D = {
912
1024
  ...D,
913
1025
  content: xe(D.content)
914
1026
  });
915
1027
  let Re = !D.done;
916
- ke(D.content, Le, c, i, Re), D.tokens && (br(S, E, { tokens: D.tokens }), (ir ? await we({
1028
+ ke(D.content, Le, c, i, Re), D.tokens && (kr(x, E, { tokens: D.tokens }), (pr ? await we({
917
1029
  workspaceId: w,
918
1030
  sessionId: c,
919
1031
  messageId: D.messageId,
920
1032
  model: D.model,
921
1033
  tokens: D.tokens
922
- }, ir, { ledger: Se("panel", L) }) : { ok: !0 }).ok && zn(L)), D.done || he(i, c);
1034
+ }, pr, { ledger: Se("panel", L) }) : { ok: !0 }).ok && Jn(L)), D.done || he(i, c);
923
1035
  let ze = Oe();
924
1036
  if (ze.abandon) {
925
- ze.clearProcessing && Cr(S);
1037
+ ze.clearProcessing && Mr(x);
926
1038
  return;
927
1039
  }
928
- k(E, "complete"), O(E, { outcome: "answered" }), Sr(S, "complete", E, null), on.recordCommittedEntries(S, [ge.id, E], "TURN", w), Me = !1;
1040
+ k(E, "complete"), O(E, { outcome: "answered" }), jr(x, "complete", E, null), on.recordCommittedEntries(x, [ge.id, E], "TURN", w), Me = !1;
929
1041
  } catch (e) {
930
- Y.current.invalidate(a ?? x.getState().sandboxesByMode[y]?.sandboxId ?? null);
1042
+ Y.current.invalidate(a ?? b.getState().sandboxesByMode[v]?.sandboxId ?? null);
931
1043
  let t = dt({
932
1044
  turnId: E,
933
- abortRequested: zi.current.has(E),
934
- activeTurnId: x.getState().processingByConversationId[S]?.messageId ?? null,
935
- conversationExists: de()
1045
+ abortRequested: Ji.current.has(E),
1046
+ activeTurnId: b.getState().processingByConversationId[x]?.messageId ?? null,
1047
+ conversationExists: C()
936
1048
  });
937
1049
  if (a && o && he(a, o), t.abandon) {
938
- t.clearProcessing && Cr(S);
1050
+ t.clearProcessing && Mr(x);
939
1051
  return;
940
1052
  }
941
1053
  if (i === 1 && Mt(e)) {
942
- let e = a ?? x.getState().sandboxesByMode[y]?.sandboxId ?? null;
943
- return e && (X.current.add(e), Y.current.invalidate(e)), Tr(S), Dr(y), yr(S, E, ""), xr(S, E, { pendingWrite: void 0 }), e && J.retireSandbox(e), Ne(), Et(E), Fe(2);
1054
+ let e = a ?? b.getState().sandboxesByMode[v]?.sandboxId ?? null;
1055
+ return e && (X.current.add(e), Y.current.invalidate(e)), Pr(x), Ir(v), Or(x, E, ""), Ar(x, E, { pendingWrite: void 0 }), e && J.retireSandbox(e), Ne(), Et(E), Fe(2);
944
1056
  }
945
1057
  throw e;
946
1058
  }
947
- }, Ie = S;
948
- Ei.current.add(Ie);
1059
+ }, Ie = x;
1060
+ Fi.current.add(Ie);
949
1061
  try {
950
1062
  if (!w) throw Object.assign(/* @__PURE__ */ Error("Assistant backend is unavailable without an active workspace context."), { extensions: {
951
1063
  code: "UNAUTHENTICATED",
952
1064
  authFailure: "WORKSPACE_CONTEXT_MISSING"
953
1065
  } });
954
- let e = await ct(y, () => ni.current.find((e) => e.id === y), ti);
955
- b = e.config, oe = e.capabilities;
956
- let t = b, n = Oe();
1066
+ let e = await ct(v, () => di.current.find((e) => e.id === v), ui);
1067
+ y = e.config, se = e.capabilities;
1068
+ let t = y, n = Oe();
957
1069
  if (n.abandon) {
958
- n.clearProcessing && Cr(S);
1070
+ n.clearProcessing && Mr(x);
959
1071
  return;
960
1072
  }
961
- let i = ie(y, t, x.getState().acknowledgedWriteModes, {
1073
+ let i = ae(v, t, b.getState().acknowledgedWriteModes, {
962
1074
  dictated: r,
963
- confirmsWrites: fe(y),
964
- proposalBound: or(y)
1075
+ confirmsWrites: fe(v),
1076
+ proposalBound: hr(v)
965
1077
  });
966
1078
  if (i) throw new ve(i, i === "confirm-write-mode" ? "Write mode not confirmed" : "Voice in a write mode");
967
1079
  let a = Se("panel", L);
968
- if (ir && Ce(a, w)) {
969
- let e = await Te(a, w, ir);
1080
+ if (pr && Ce(a, w)) {
1081
+ let e = await Te(a, w, pr);
970
1082
  if (!e.ok) throw Ee(e.kind);
971
1083
  let t = Oe();
972
1084
  if (t.abandon) {
973
- t.clearProcessing && Cr(S);
1085
+ t.clearProcessing && Mr(x);
974
1086
  return;
975
1087
  }
976
1088
  }
977
1089
  k(E, "cleared"), await Fe();
978
1090
  } catch (e) {
979
- if (Y.current.invalidate(x.getState().sandboxesByMode[y]?.sandboxId ?? null), !de()) {
980
- Cr(S);
1091
+ if (Y.current.invalidate(b.getState().sandboxesByMode[v]?.sandboxId ?? null), !C()) {
1092
+ Mr(x);
981
1093
  return;
982
1094
  }
983
1095
  let t = je.session?.sandboxId ?? null, r = ye(e, { confirmsNoAction: be({
984
- mode: y,
985
- capabilities: t ? x.getState().sandboxWriteCapabilities[t] : null
1096
+ mode: v,
1097
+ capabilities: t ? b.getState().sandboxWriteCapabilities[t] : null
986
1098
  }) });
987
- O(E, { outcome: r.kind === "temporary" ? "failed" : "refused" }), r.offersUpgrade && Rn(L, "sandbox");
1099
+ O(E, { outcome: r.kind === "temporary" ? "failed" : "refused" }), r.offersUpgrade && qn(L, "sandbox");
988
1100
  let i = xe(r, I, { locale: H });
989
- Sr(S, "error", E, i.headline), br(S, E, { content: i.text }), xr(S, E, {
1101
+ jr(x, "error", E, i.headline), kr(x, E, { content: i.text }), Ar(x, E, {
990
1102
  lang: i.translated ? H : "en",
991
1103
  ...D(n.voiceSessionId)
992
1104
  });
993
1105
  } finally {
994
- Ei.current.delete(Ie), O(E, { outcome: "stopped" }), k(E, "complete"), Ne();
995
- let e = x.getState(), t = u(ce, y, e.conversations.find((e) => e.id === Ie), (t) => !!e.sandboxesByMode[t]?.sandboxId);
996
- t && (Mr(Ie, t.mode), t.backendSessionId && wr(Ie, t.backendSessionId)), je.session && de() && J.afterTurn({
1106
+ Fi.current.delete(Ie), O(E, { outcome: "stopped" }), k(E, "complete"), Ne();
1107
+ let e = b.getState(), t = u(le, v, e.conversations.find((e) => e.id === Ie), (t) => !!e.sandboxesByMode[t]?.sandboxId);
1108
+ t && (Vr(Ie, t.mode), t.backendSessionId && Nr(Ie, t.backendSessionId)), je.session && C() && J.afterTurn({
997
1109
  ...je.session,
998
1110
  conversationId: Ie
999
1111
  }, E);
1000
- let n = Bi.current;
1001
- Bi.current = null, n && n.conversationId === Ie && de() && oa.current(n.content, n.attachments, n.options);
1112
+ let n = Yi.current;
1113
+ Yi.current = null, n && n.conversationId === Ie && C() && Ca.current(n.content, n.attachments, n.options);
1002
1114
  }
1003
1115
  }, [
1004
1116
  U,
1005
1117
  K,
1006
- nr,
1007
- Tr,
1008
- Dr,
1009
- mr,
1118
+ dr,
1119
+ Pr,
1120
+ Ir,
1121
+ Cr,
1010
1122
  G,
1011
- Ni,
1123
+ Hi,
1012
1124
  J,
1013
- Ji,
1014
- ra,
1125
+ da,
1126
+ ba,
1015
1127
  H,
1128
+ yr,
1129
+ hr,
1016
1130
  ur,
1017
- or,
1018
- tr,
1019
1131
  B,
1020
- sr,
1021
- br,
1132
+ gr,
1133
+ kr,
1022
1134
  L,
1023
- ti,
1024
- ir,
1025
- fr,
1026
- H,
1135
+ ui,
1027
1136
  pr,
1028
- dr,
1029
- Mr,
1030
- na,
1031
- Ci,
1032
- wi,
1033
- wr,
1034
- _r,
1137
+ xr,
1138
+ H,
1035
1139
  Sr,
1036
- Cr,
1140
+ br,
1141
+ Vr,
1142
+ ya,
1143
+ ca,
1144
+ Mi,
1145
+ Ni,
1146
+ Nr,
1147
+ Er,
1148
+ jr,
1149
+ Mr,
1037
1150
  I,
1038
- ji,
1039
- yr,
1151
+ Bi,
1152
+ Or,
1040
1153
  V
1041
- ]), ia = j((e, t) => {
1154
+ ]), xa = j((e, t) => {
1042
1155
  Z(e, [], t ? { autoIntent: t } : {});
1043
- }, [Z]), aa = j(() => {
1044
- let e = [...Pr.chat].reverse().find((e) => e.role === "user" && !e.metadata?.localAction);
1156
+ }, [Z]), Sa = j(() => {
1157
+ let e = [...Ur.chat].reverse().find((e) => e.role === "user" && !e.metadata?.localAction);
1045
1158
  if (!e || e.metadata?.approvalFollowUp) return;
1046
- let t = U ? Ti.current[U] ?? [] : [];
1159
+ let t = U ? Pi.current[U] ?? [] : [];
1047
1160
  Z(e.content, t);
1048
1161
  }, [
1049
- Fr,
1162
+ Wr,
1050
1163
  Z,
1051
1164
  U
1052
- ]), oa = N(Z);
1165
+ ]), Ca = N(Z);
1053
1166
  M(() => {
1054
- oa.current = Z;
1167
+ Ca.current = Z;
1055
1168
  }, [Z]);
1056
- let sa = Gn(() => {
1057
- if (Ir) return null;
1058
- for (let e = Fr.length - 1; e >= 0; --e) {
1059
- let t = Fr[e];
1060
- if (t?.role !== "assistant" || !Oe(t) || zi.current.has(t.id)) continue;
1169
+ let wa = er(() => {
1170
+ if (Gr) return null;
1171
+ for (let e = Wr.length - 1; e >= 0; --e) {
1172
+ let t = Wr[e];
1173
+ if (t?.role !== "assistant" || !Oe(t) || Ji.current.has(t.id)) continue;
1061
1174
  let n = pt(t, q, I);
1062
1175
  if (n.kind !== "output") return null;
1063
1176
  let r = bt(n.text).text.trim();
@@ -1068,48 +1181,48 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
1068
1181
  }
1069
1182
  return null;
1070
1183
  }, [
1071
- Fr,
1072
- Ir,
1184
+ Wr,
1185
+ Gr,
1073
1186
  q,
1074
1187
  I
1075
- ]), ca = Gn(() => sa ? Fe(sa.text) : null, [sa]), la = Pr.chat, ua = x((e) => b(e)?.sandboxId ?? null), da = _(la, {
1076
- sessionId: Nr?.backendSessionId,
1077
- sandboxId: ua,
1188
+ ]), Ta = er(() => wa ? Fe(wa.text) : null, [wa]), Ea = Ur.chat, Da = b((e) => y(e)?.sandboxId ?? null), Oa = g(Ea, {
1189
+ sessionId: Hr?.backendSessionId,
1190
+ sandboxId: Da,
1078
1191
  nowMs: Date.now()
1079
- }), fa = v(la), pa = (e) => {
1192
+ }), ka = _(Ea), Aa = (e) => {
1080
1193
  if (Vt(e.metadata).length > 0) return !0;
1081
1194
  let t = e.metadata?.sandboxId;
1082
- return Ht(t ? zr[t] : null);
1083
- }, ma = (e) => {
1195
+ return Ht(t ? Jr[t] : null);
1196
+ }, ja = (e) => {
1084
1197
  let t = Vt(e.metadata);
1085
1198
  return t.length === 0 || !U ? null : /* @__PURE__ */ P(Bt, {
1086
1199
  refs: t,
1087
1200
  conversationId: U,
1088
1201
  panel: J,
1089
- entries: Br,
1090
- capabilitiesOf: (e) => zr[e],
1091
- turnInFlight: Ir,
1202
+ entries: Yr,
1203
+ capabilitiesOf: (e) => Jr[e],
1204
+ turnInFlight: Gr,
1092
1205
  tr: I,
1093
- onReview: Hr.review,
1094
- retiredSandboxes: Vr
1206
+ onReview: Zr.review,
1207
+ retiredSandboxes: Xr
1095
1208
  });
1096
- }, ha = Hr.dialog.view ? Br[Hr.dialog.view.proposalId] : void 0, ga = da?.expiresAtMs ?? null;
1209
+ }, Ma = Zr.dialog.view ? Yr[Zr.dialog.view.proposalId] : void 0, Na = Oa?.expiresAtMs ?? null;
1097
1210
  M(() => {
1098
- if (ga === null) return;
1099
- let e = window.setTimeout(() => Ri((e) => e + 1), Math.max(0, ga - Date.now()));
1211
+ if (Na === null) return;
1212
+ let e = window.setTimeout(() => qi((e) => e + 1), Math.max(0, Na - Date.now()));
1100
1213
  return () => window.clearTimeout(e);
1101
- }, [ga, Li]);
1102
- let Q = Gn(() => Pr.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
1214
+ }, [Na, Ki]);
1215
+ let Q = er(() => Ur.voice.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
1103
1216
  id: e.id,
1104
1217
  role: e.role,
1105
1218
  text: Ct(e, q, I),
1106
1219
  sessionId: ke(e),
1107
1220
  timestamp: e.timestamp
1108
1221
  })).filter((e) => e.text.length > 0), [
1109
- Pr.voice,
1222
+ Ur.voice,
1110
1223
  q,
1111
1224
  I
1112
- ]), _a = j(() => {
1225
+ ]), Pa = j(() => {
1113
1226
  if (Q.length === 0) return;
1114
1227
  let e = /* @__PURE__ */ new Date();
1115
1228
  $t(Me(Q, {
@@ -1124,14 +1237,14 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
1124
1237
  L,
1125
1238
  Q,
1126
1239
  I
1127
- ]), va = Bn({ perFileChars: pi }), ya = N(va);
1128
- ya.current = va;
1129
- let ba = N(/* @__PURE__ */ new Set()), xa = N(() => !1), $ = kt({
1240
+ ]), Fa = Yn({ perFileChars: Si }), Ia = N(Fa);
1241
+ Ia.current = Fa;
1242
+ let La = N(/* @__PURE__ */ new Set()), Ra = N(() => !1), $ = kt({
1130
1243
  onSubmit: j((e, t, n) => {
1131
- let r = bi.current, i = Ke(r), a = () => {
1132
- let a = ya.current, o = x.getState();
1244
+ let r = ki.current, i = Ke(r), a = () => {
1245
+ let a = Ia.current, o = b.getState();
1133
1246
  if (!Be({
1134
- sessionLive: xa.current(t),
1247
+ sessionLive: Ra.current(t),
1135
1248
  boundAtSubmit: r,
1136
1249
  activeConversationId: o.activeConversationId,
1137
1250
  boundConversationExists: o.conversations.some((e) => e.id === i)
@@ -1143,98 +1256,117 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
1143
1256
  ...n,
1144
1257
  handedOver: Dt()
1145
1258
  };
1146
- oa.current(e, s, {
1259
+ Ca.current(e, s, {
1147
1260
  fromPerson: !0,
1148
1261
  voiceSessionId: t,
1149
1262
  voiceTiming: c
1150
1263
  }), a.clear();
1151
1264
  };
1152
- if (!ya.current.isBusy) {
1265
+ if ((() => {
1266
+ let e = b.getState();
1267
+ return Be({
1268
+ sessionLive: Ra.current(t),
1269
+ boundAtSubmit: r,
1270
+ activeConversationId: e.activeConversationId,
1271
+ boundConversationExists: e.conversations.some((e) => e.id === i)
1272
+ });
1273
+ })() && ua.current(e, t)) {
1274
+ Ca.current(e, [], {
1275
+ fromPerson: !0,
1276
+ voiceSessionId: t,
1277
+ voiceTiming: {
1278
+ ...n,
1279
+ handedOver: Dt()
1280
+ }
1281
+ });
1282
+ return;
1283
+ }
1284
+ if (!Ia.current.isBusy) {
1153
1285
  a();
1154
1286
  return;
1155
1287
  }
1156
- let o = Date.now(), s = ba.current, c = window.setInterval(() => {
1157
- ya.current.isBusy && Date.now() - o < Xn || (window.clearInterval(c), s.delete(c), a());
1288
+ let o = Date.now(), s = La.current, c = window.setInterval(() => {
1289
+ Ia.current.isBusy && Date.now() - o < ar || (window.clearInterval(c), s.delete(c), a());
1158
1290
  }, 200);
1159
1291
  s.add(c);
1160
1292
  }, []),
1161
- latestReply: sa,
1162
- language: Ie(cr, H).tag
1293
+ latestReply: wa,
1294
+ language: Ie(_r, H).tag
1163
1295
  });
1164
- xa.current = $.isCurrentSession;
1165
- let Sa = xi ? Q.filter((e) => e.sessionId !== void 0 && $.isCurrentSession(e.sessionId)) : Q, Ca = $.answerLocally;
1296
+ Ra.current = $.isCurrentSession;
1297
+ let za = Ai ? Q.filter((e) => e.sessionId !== void 0 && $.isCurrentSession(e.sessionId)) : Q, Ba = $.answerLocally;
1166
1298
  M(() => {
1167
- Zi.current = Ca;
1168
- }, [Ca]);
1169
- let wa = $.active, Ta = Gn(() => it(Object.values(Br), U, Vr), [
1170
- Br,
1299
+ ma.current = Ba;
1300
+ }, [Ba]);
1301
+ let Va = $.active, Ha = er(() => it(Object.values(Yr), U, Xr), [
1302
+ Yr,
1171
1303
  U,
1172
- Vr
1173
- ]), [Ea, Da] = Kn(null);
1304
+ Xr
1305
+ ]), [Ua, Wa] = tr(null);
1174
1306
  M(() => {
1175
- wa || Da(null);
1176
- }, [wa]);
1177
- let Oa = Hr.review, ka = j(() => {
1178
- let e = Ta[Ta.length - 1];
1307
+ Va || Wa(null);
1308
+ }, [Va]);
1309
+ let Ga = Zr.review, Ka = j(() => {
1310
+ let e = Ha[Ha.length - 1];
1179
1311
  if (!e) return;
1180
1312
  let { view: t } = e;
1181
- if (Lt(t) && It(t, zr[e.session.sandboxId]).offerConfirm) {
1182
- Oa(t);
1313
+ if (Lt(t) && It(t, Jr[e.session.sandboxId]).offerConfirm) {
1314
+ Ga(t);
1183
1315
  return;
1184
1316
  }
1185
- Da(t.proposalId);
1317
+ Wa(t.proposalId);
1186
1318
  }, [
1187
- Ta,
1188
- zr,
1189
- Oa
1190
- ]), Aa = wa ? tt(Ta) : null, ja = Ea ? Br[Ea] : void 0, Ma = wa && ja && ja.session.conversationId === U ? {
1319
+ Ha,
1320
+ Jr,
1321
+ Ga
1322
+ ]), qa = Va ? tt(Ha) : null, Ja = Ua ? Yr[Ua] : void 0, Ya = Va && Ja && Ja.session.conversationId === U ? {
1191
1323
  content: /* @__PURE__ */ P(Bt, {
1192
1324
  refs: [{
1193
- proposalId: ja.view.proposalId,
1194
- sandboxId: ja.session.sandboxId,
1195
- sessionId: ja.session.sessionId
1325
+ proposalId: Ja.view.proposalId,
1326
+ sandboxId: Ja.session.sandboxId,
1327
+ sessionId: Ja.session.sessionId
1196
1328
  }],
1197
- conversationId: ja.session.conversationId,
1329
+ conversationId: Ja.session.conversationId,
1198
1330
  panel: J,
1199
- entries: Br,
1200
- capabilitiesOf: (e) => zr[e],
1201
- turnInFlight: Ir,
1331
+ entries: Yr,
1332
+ capabilitiesOf: (e) => Jr[e],
1333
+ turnInFlight: Gr,
1202
1334
  tr: I,
1203
- onReview: Oa,
1204
- retiredSandboxes: Vr
1335
+ onReview: Ga,
1336
+ retiredSandboxes: Xr
1205
1337
  }),
1206
1338
  closeLabel: at(I, $e.trayClose),
1207
- onClose: () => Da(null)
1208
- } : null, Na = Hr.asking, Pa = Yi?.asking === !0, Fa = $.holdListening;
1339
+ onClose: () => Wa(null)
1340
+ } : null, Xa = Zr.asking, Za = fa?.asking === !0, Qa = $.holdListening;
1209
1341
  M(() => {
1210
- Fa(wa && (Na || Pa));
1342
+ Qa(Va && (Xa || Za));
1211
1343
  }, [
1212
- wa,
1213
- Na,
1214
- Pa,
1215
- Fa
1344
+ Va,
1345
+ Xa,
1346
+ Za,
1347
+ Qa
1216
1348
  ]);
1217
- let Ia = N(null), La = $.announce;
1349
+ let $a = N(null), eo = $.announce;
1218
1350
  M(() => {
1219
- if (!wa) {
1220
- Ia.current = null;
1351
+ if (!Va) {
1352
+ $a.current = null;
1221
1353
  return;
1222
1354
  }
1223
- let e = Ia.current;
1355
+ let e = $a.current;
1224
1356
  if (e === null) {
1225
- Ia.current = new Set(Object.keys(Br));
1357
+ $a.current = new Set(Object.keys(Yr));
1226
1358
  return;
1227
1359
  }
1228
- for (let { view: t, session: n } of rt(Ta, e)) {
1360
+ for (let { view: t, session: n } of rt(Ha, e)) {
1229
1361
  e.add(t.proposalId);
1230
- let r = zr[n.sandboxId];
1362
+ let r = Jr[n.sandboxId];
1231
1363
  if (!et({
1232
1364
  mode: "api-calls",
1233
1365
  productWriteApproval: z,
1234
1366
  capabilities: r
1235
1367
  })) continue;
1236
1368
  let i = ot(t, It(t, r).offerConfirm, I), a = t.proposalId;
1237
- La({
1369
+ eo({
1238
1370
  id: `write-readback:${a}`,
1239
1371
  text: i.text,
1240
1372
  lang: i.translated ? H : "en",
@@ -1242,36 +1374,36 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
1242
1374
  });
1243
1375
  }
1244
1376
  }, [
1245
- wa,
1246
- Ta,
1247
- Br,
1248
- zr,
1377
+ Va,
1378
+ Ha,
1379
+ Yr,
1380
+ Jr,
1249
1381
  z,
1250
1382
  I,
1251
1383
  H,
1252
- La,
1384
+ eo,
1253
1385
  J
1254
1386
  ]);
1255
- let Ra = N(!1);
1387
+ let to = N(!1);
1256
1388
  M(() => {
1257
- Ra.current = $.active;
1389
+ to.current = $.active;
1258
1390
  }, [$.active]), M(() => ee((e) => {
1259
- if (!Ra.current) return !1;
1260
- let t = bi.current;
1261
- return typeof t == "string" ? t === e : x.getState().activeConversationId === e;
1391
+ if (!to.current) return !1;
1392
+ let t = ki.current;
1393
+ return typeof t == "string" ? t === e : b.getState().activeConversationId === e;
1262
1394
  }), []);
1263
- let za = $.start, Ba = j(() => {
1264
- let e = x.getState().activeConversationId, t = Ue(wi());
1265
- Ci(Ge(t, e)), Pi(!0, t.kind === "own"), za();
1395
+ let no = $.start, ro = j(() => {
1396
+ let e = b.getState().activeConversationId, t = Ue(Ni());
1397
+ Mi(Ge(t, e)), Ui(!0, t.kind === "own"), no();
1266
1398
  }, [
1267
- Ci,
1268
- Pi,
1269
- wi,
1270
- za
1271
- ]), Va = Gn(() => St(Nr?.messages ?? []), [Nr?.messages]), Ha = xt(Pr.voice, q, I), Ua = xt(Va, q, I) > 0, Wa = j(() => {
1272
- let e = x.getState().activeConversationId;
1399
+ Mi,
1400
+ Ui,
1401
+ Ni,
1402
+ no
1403
+ ]), io = er(() => St(Hr?.messages ?? []), [Hr?.messages]), ao = xt(Ur.voice, q, I), oo = xt(io, q, I) > 0, so = j(() => {
1404
+ let e = b.getState().activeConversationId;
1273
1405
  if (!e || Q.length === 0) return;
1274
- let t = new Set(Va.map((e) => e.id)), n = F();
1406
+ let t = new Set(io.map((e) => e.id)), n = F();
1275
1407
  K(e, {
1276
1408
  id: n,
1277
1409
  role: "system",
@@ -1281,247 +1413,247 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
1281
1413
  more: (e) => I("voiceSession.continuedMore", "…and {{count}} more", { count: e })
1282
1414
  }),
1283
1415
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1284
- metadata: { continuedVoiceTurns: Ha }
1285
- }), on.recordCommittedEntries(e, [n], "NOTE", A()), yi(!1), $.end();
1416
+ metadata: { continuedVoiceTurns: ao }
1417
+ }), on.recordCommittedEntries(e, [n], "NOTE", A()), Oi(!1), $.end();
1286
1418
  }, [
1287
1419
  Q,
1288
- Ha,
1289
- Va,
1420
+ ao,
1421
+ io,
1290
1422
  K,
1291
1423
  I,
1292
1424
  $,
1293
- yi
1294
- ]), Ga = N({
1425
+ Oi
1426
+ ]), co = N({
1295
1427
  conversationId: null,
1296
1428
  count: 0
1297
1429
  });
1298
1430
  M(() => {
1299
- $.active && (Ga.current = {
1431
+ $.active && (co.current = {
1300
1432
  conversationId: U,
1301
- count: Ha
1433
+ count: ao
1302
1434
  });
1303
1435
  }, [$.active]);
1304
- let Ka = j(() => {
1305
- let e = Ga.current, t = Ha > (e.conversationId === U ? e.count : 0);
1306
- $.end(), t && yi(!0);
1436
+ let lo = j(() => {
1437
+ let e = co.current, t = ao > (e.conversationId === U ? e.count : 0);
1438
+ $.end(), t && Oi(!0);
1307
1439
  }, [
1308
1440
  U,
1309
- Ha,
1441
+ ao,
1310
1442
  $,
1311
- yi
1443
+ Oi
1312
1444
  ]);
1313
1445
  M(() => {
1314
- (!$n || !Ai) && $.active && $.end();
1446
+ (!cr || !zi) && $.active && $.end();
1315
1447
  }, [
1316
- $n,
1317
- Ai,
1448
+ cr,
1449
+ zi,
1318
1450
  $
1319
1451
  ]), M(() => {
1320
- let e = bi.current, t = Ke(e), n = x.getState(), r = He({
1452
+ let e = ki.current, t = Ke(e), n = b.getState(), r = He({
1321
1453
  sessionLive: $.active,
1322
1454
  bound: e,
1323
1455
  activeConversationId: n.activeConversationId,
1324
1456
  boundConversationExists: n.conversations.some((e) => e.id === t)
1325
1457
  });
1326
- Ci(r.bound), r.end && $.end();
1458
+ Mi(r.bound), r.end && $.end();
1327
1459
  }, [
1328
1460
  $,
1329
1461
  U,
1330
- mr,
1331
- Ci
1462
+ Cr,
1463
+ Mi
1332
1464
  ]);
1333
- let qa = N(Re);
1465
+ let uo = N(Re);
1334
1466
  M(() => {
1335
- let e = Ve(qa.current, {
1467
+ let e = Ve(uo.current, {
1336
1468
  activeConversationId: U,
1337
- chatTurnCount: la.length,
1469
+ chatTurnCount: Ea.length,
1338
1470
  voiceTurnCount: Q.length,
1339
1471
  sessionLive: $.active,
1340
- sessionBoundTo: bi.current,
1341
- turnInFlight: Ir
1472
+ sessionBoundTo: ki.current,
1473
+ turnInFlight: Gr
1342
1474
  });
1343
- qa.current = e.state, e.open && yi(!0);
1475
+ uo.current = e.state, e.open && Oi(!0);
1344
1476
  }, [
1345
1477
  U,
1346
- la.length,
1478
+ Ea.length,
1347
1479
  Q.length,
1348
1480
  $.active,
1349
- Ir,
1350
- yi
1481
+ Gr,
1482
+ Oi
1351
1483
  ]), M(() => {
1352
1484
  if (!$.active) {
1353
- ya.current.clear(), Bi.current = null;
1354
- for (let e of ba.current) window.clearInterval(e);
1355
- ba.current.clear();
1485
+ Ia.current.clear(), Yi.current = null;
1486
+ for (let e of La.current) window.clearInterval(e);
1487
+ La.current.clear();
1356
1488
  }
1357
1489
  }, [$.active]), M(() => {
1358
- let e = ba.current;
1490
+ let e = La.current;
1359
1491
  return () => {
1360
1492
  for (let t of e) window.clearInterval(t);
1361
1493
  e.clear();
1362
1494
  };
1363
1495
  }, []), M(() => {
1364
- let e = x.getState().consumePendingPrompt();
1365
- return e && oa.current(e), x.subscribe((e, t) => {
1496
+ let e = b.getState().consumePendingPrompt();
1497
+ return e && Ca.current(e), b.subscribe((e, t) => {
1366
1498
  if (e.pendingPrompt && e.pendingPrompt !== t.pendingPrompt) {
1367
- let e = x.getState().consumePendingPrompt();
1368
- e && oa.current(e);
1499
+ let e = b.getState().consumePendingPrompt();
1500
+ e && Ca.current(e);
1369
1501
  }
1370
1502
  });
1371
1503
  }, []);
1372
- let Ja = j((e) => {
1373
- let t = U ? x.getState().conversations.find((e) => e.id === U) : void 0;
1504
+ let fo = j((e) => {
1505
+ let t = U ? b.getState().conversations.find((e) => e.id === U) : void 0;
1374
1506
  if (t && t.mode !== e && J.withdraw(t.id, "mode_switched"), t && en(t)) {
1375
1507
  if (t.mode !== e) {
1376
- let t = p(), n = x.getState().conversations.find((n) => n.mode === e && rn(n, t) && !x.getState().processingByConversationId[n.id]);
1377
- n ? vr(n.id) : G(void 0, e);
1508
+ let t = p(), n = b.getState().conversations.find((n) => n.mode === e && rn(n, t) && !b.getState().processingByConversationId[n.id]);
1509
+ n ? Dr(n.id) : G(void 0, e);
1378
1510
  }
1379
- } else U && _r(U, e);
1380
- let n = x.getState().activeConversationId;
1381
- n ? _r(n, e) : jr(!1), gr(e);
1511
+ } else U && Er(U, e);
1512
+ let n = b.getState().activeConversationId;
1513
+ n ? Er(n, e) : Br(!1), Tr(e);
1382
1514
  }, [
1383
1515
  U,
1384
1516
  G,
1385
- vr,
1386
- jr,
1387
- _r,
1388
- gr,
1517
+ Dr,
1518
+ Br,
1519
+ Er,
1520
+ Tr,
1389
1521
  J
1390
- ]), Ya = j(() => {
1391
- let e = x.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
1522
+ ]), po = j(() => {
1523
+ let e = b.getState(), t = e.activeConversationId ? e.conversations.find((t) => t.id === e.activeConversationId) : void 0;
1392
1524
  if (!t) {
1393
- jr(!0), gr(s);
1525
+ Br(!0), Tr(s);
1394
1526
  return;
1395
1527
  }
1396
1528
  if (t.routedBy === "auto") {
1397
- jr(!0);
1529
+ Br(!0);
1398
1530
  return;
1399
1531
  }
1400
1532
  if (!en(t)) {
1401
- Mr(t.id, s);
1533
+ Vr(t.id, s);
1402
1534
  return;
1403
1535
  }
1404
1536
  J.withdraw(t.id, "mode_switched");
1405
1537
  let n = p(), r = e.conversations.find((t) => t.routedBy === "auto" && rn(t, n) && !e.processingByConversationId[t.id]);
1406
- r ? (vr(r.id), Mr(r.id, s)) : G(void 0, s, { routedBy: "auto" });
1538
+ r ? (Dr(r.id), Vr(r.id, s)) : G(void 0, s, { routedBy: "auto" });
1407
1539
  }, [
1408
1540
  G,
1409
- Mr,
1410
- vr,
1411
- jr,
1412
- gr,
1541
+ Vr,
1542
+ Dr,
1543
+ Br,
1544
+ Tr,
1413
1545
  J
1414
- ]), Xa = j((e) => {
1415
- if (R.find((t) => t.id === e)?.writeCapable && !re(x.getState().acknowledgedWriteModes, e)) {
1416
- hi(e);
1546
+ ]), mo = j((e) => {
1547
+ if (R.find((t) => t.id === e)?.writeCapable && !ie(b.getState().acknowledgedWriteModes, e)) {
1548
+ wi(e);
1417
1549
  return;
1418
1550
  }
1419
- Ja(e);
1420
- }, [Ja, R]), Za = j(() => {
1421
- let e = mi;
1422
- if (hi(null), !e) return;
1423
- let t = di.current;
1424
- if (di.current = null, t) {
1425
- kr(e), Z(t.content, t.attachments, t.options);
1551
+ fo(e);
1552
+ }, [fo, R]), ho = j(() => {
1553
+ let e = Ci;
1554
+ if (wi(null), !e) return;
1555
+ let t = bi.current;
1556
+ if (bi.current = null, t) {
1557
+ Rr(e), Z(t.content, t.attachments, t.options);
1426
1558
  return;
1427
1559
  }
1428
- kr(e), Ja(e);
1560
+ Rr(e), fo(e);
1429
1561
  }, [
1430
- mi,
1431
- kr,
1432
- Ja,
1562
+ Ci,
1563
+ Rr,
1564
+ fo,
1433
1565
  Z
1434
- ]), Qa = mi === null ? void 0 : R.find((e) => e.id === mi) ?? { id: mi }, $a = j(() => {
1435
- hi(null);
1436
- let e = di.current;
1437
- di.current = null, e && Z(e.content, e.attachments, {
1566
+ ]), go = Ci === null ? void 0 : R.find((e) => e.id === Ci) ?? { id: Ci }, _o = j(() => {
1567
+ wi(null);
1568
+ let e = bi.current;
1569
+ bi.current = null, e && Z(e.content, e.attachments, {
1438
1570
  ...e.options,
1439
1571
  autoIntent: "read"
1440
1572
  });
1441
1573
  }, [Z]);
1442
- return /* @__PURE__ */ Jn("div", {
1574
+ return /* @__PURE__ */ rr("div", {
1443
1575
  className: "relative flex flex-1 flex-col overflow-hidden",
1444
1576
  children: [
1445
- /* @__PURE__ */ Jn("div", {
1577
+ /* @__PURE__ */ rr("div", {
1446
1578
  className: "contents",
1447
1579
  inert: $.active || void 0,
1448
1580
  children: [
1449
- Qr === null ? null : /* @__PURE__ */ P(Jt, { onDismiss: () => Zr(Qr) }),
1581
+ si === null ? null : /* @__PURE__ */ P(Jt, { onDismiss: () => oi(si) }),
1450
1582
  Q.length > 0 && !$.active ? /* @__PURE__ */ P(Kt, {
1451
1583
  count: Q.length,
1452
- onOpenTranscript: () => yi(!0)
1584
+ onOpenTranscript: () => Oi(!0)
1453
1585
  }) : null,
1454
- la.length === 0 && (qr || Jr) ? /* @__PURE__ */ P(Yt, {
1455
- state: qr ? "loading" : "failed",
1456
- onRetry: ri
1457
- }) : la.length === 0 && Nr?.sync?.hasOlder ? /* @__PURE__ */ P("div", {
1586
+ Ea.length === 0 && (ni || ri) ? /* @__PURE__ */ P(Yt, {
1587
+ state: ni ? "loading" : "failed",
1588
+ onRetry: fi
1589
+ }) : Ea.length === 0 && Hr?.sync?.hasOlder ? /* @__PURE__ */ P("div", {
1458
1590
  className: "flex min-h-0 flex-1 flex-col",
1459
1591
  children: /* @__PURE__ */ P(Zt, {
1460
- onShowEarlier: ii,
1461
- disabled: qr
1592
+ onShowEarlier: pi,
1593
+ disabled: ni
1462
1594
  })
1463
- }) : la.length === 0 ? /* @__PURE__ */ P(sn, {
1595
+ }) : Ea.length === 0 ? /* @__PURE__ */ P(sn, {
1464
1596
  mode: W,
1465
- onSuggestionClick: ia,
1466
- explainsAuto: li,
1467
- suggestions: li && W === "assistant" ? c(R.find((e) => e.id === "assistant")?.suggestions ?? [], R.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
1468
- }) : /* @__PURE__ */ Jn("div", {
1597
+ onSuggestionClick: xa,
1598
+ explainsAuto: vi,
1599
+ suggestions: vi && W === "assistant" ? c(R.find((e) => e.id === "assistant")?.suggestions ?? [], R.find((e) => e.id === "api-calls")?.suggestions ?? []) : void 0
1600
+ }) : /* @__PURE__ */ rr("div", {
1469
1601
  className: "flex min-h-0 flex-1 flex-col",
1470
- children: [Nr?.sync?.hasOlder ? /* @__PURE__ */ P(Zt, {
1471
- onShowEarlier: ii,
1472
- disabled: qr
1602
+ children: [Hr?.sync?.hasOlder ? /* @__PURE__ */ P(Zt, {
1603
+ onShowEarlier: pi,
1604
+ disabled: ni
1473
1605
  }) : null, /* @__PURE__ */ P(mn, {
1474
- onApprovePendingWrite: Hi,
1475
- approvingWriteRef: Ii,
1476
- approvableMessageId: da?.messageId ?? null,
1477
- retryableMessageId: fa,
1478
- messages: la,
1606
+ onApprovePendingWrite: Zi,
1607
+ approvingWriteRef: Gi,
1608
+ approvableMessageId: Oa?.messageId ?? null,
1609
+ retryableMessageId: ka,
1610
+ messages: Ea,
1479
1611
  processing: q ?? null,
1480
- streamingMessageId: Lr,
1481
- failedMessageId: Rr,
1482
- onRetry: Ii === null ? aa : void 0,
1483
- renderWriteProposals: ma,
1484
- hidesLegacyWriteCard: pa
1612
+ streamingMessageId: Kr,
1613
+ failedMessageId: qr,
1614
+ onRetry: Gi === null ? Sa : void 0,
1615
+ renderWriteProposals: ja,
1616
+ hidesLegacyWriteCard: Aa
1485
1617
  })]
1486
1618
  }),
1487
- Gr ? /* @__PURE__ */ P(Xt, { onStartNew: () => G() }) : null,
1488
- Kr && U ? /* @__PURE__ */ P(qt, { onUnarchive: () => on.updateConversation(U, { archived: !1 }) }) : null,
1489
- Qi === null ? null : /* @__PURE__ */ P(cn, {
1619
+ ei ? /* @__PURE__ */ P(Xt, { onStartNew: () => G() }) : null,
1620
+ ti && U ? /* @__PURE__ */ P(qt, { onUnarchive: () => on.updateConversation(U, { archived: !1 }) }) : null,
1621
+ ha === null ? null : /* @__PURE__ */ P(cn, {
1490
1622
  tr: I,
1491
- onDismiss: () => $i(null)
1623
+ onDismiss: () => ga(null)
1492
1624
  }),
1493
- la.length > 0 && (qr || Jr) ? /* @__PURE__ */ P(Yt, {
1494
- state: qr ? "loading" : "failed",
1495
- onRetry: ri,
1625
+ Ea.length > 0 && (ni || ri) ? /* @__PURE__ */ P(Yt, {
1626
+ state: ni ? "loading" : "failed",
1627
+ onRetry: fi,
1496
1628
  compact: !0
1497
1629
  }) : null,
1498
- /* @__PURE__ */ P(Vn, {
1499
- onStartVoiceSession: $.available && Ai ? Ba : void 0,
1630
+ /* @__PURE__ */ P(Xn, {
1631
+ onStartVoiceSession: $.available && zi ? ro : void 0,
1500
1632
  onSend: (e, t) => void Z(e, t, { fromPerson: !0 }),
1501
- onDraftStart: Fi,
1502
- disabled: Ir || Ii !== null || qr,
1503
- readOnly: Gr,
1633
+ onDraftStart: Wi,
1634
+ disabled: Gr || Gi !== null || ni || aa,
1635
+ readOnly: ei,
1504
1636
  placeholder: W === "api-calls" ? I("chatArea.placeholderActions", "What would you like me to do?") : I("chatArea.placeholderGeneral", "Ask me anything…"),
1505
1637
  mode: W,
1506
- writeAccessDenied: er === "denied" && !!Di?.writeCapable,
1507
- availableModes: si,
1508
- attachmentCharsPerFile: pi,
1509
- onModeChange: Xa,
1510
- auto: ci ? {
1511
- active: li,
1512
- onSelect: Ya
1638
+ writeAccessDenied: lr === "denied" && !!Ii?.writeCapable,
1639
+ availableModes: gi,
1640
+ attachmentCharsPerFile: Si,
1641
+ onModeChange: mo,
1642
+ auto: _i ? {
1643
+ active: vi,
1644
+ onSelect: po
1513
1645
  } : void 0
1514
1646
  })
1515
1647
  ]
1516
1648
  }),
1517
- vi && !$.active ? /* @__PURE__ */ P(Qt, {
1649
+ Di && !$.active ? /* @__PURE__ */ P(Qt, {
1518
1650
  turns: Q,
1519
- onClose: () => yi(!1),
1520
- onSave: _a,
1521
- onContinueInChat: Ua ? Wa : void 0,
1651
+ onClose: () => Oi(!1),
1652
+ onSave: Pa,
1653
+ onContinueInChat: oo ? so : void 0,
1522
1654
  closeOnEscape: !0,
1523
- onShowEarlier: Nr?.sync?.hasOlder ? ii : void 0,
1524
- showEarlierDisabled: qr
1655
+ onShowEarlier: Hr?.sync?.hasOlder ? pi : void 0,
1656
+ showEarlierDisabled: ni
1525
1657
  }) : null,
1526
1658
  $.active && /* @__PURE__ */ P(hn, {
1527
1659
  session: $.session,
@@ -1529,46 +1661,46 @@ var $n = ({ visible: $n = !0, writeAccess: er = "unknown" }) => {
1529
1661
  capturing: $.capturing,
1530
1662
  interrupting: $.interrupting,
1531
1663
  awaitingEndpoint: $.awaitingEndpoint,
1532
- turns: Sa,
1664
+ turns: za,
1533
1665
  spokenChunks: $.spokenChunks,
1534
- attachments: va.attachments,
1535
- onAttachFiles: va.addFiles,
1536
- onRemoveAttachment: va.remove,
1537
- onRetryAttachment: va.retry,
1538
- canAttachMore: va.canAddMore,
1539
- preparingAttachments: va.preparingCount,
1540
- onSaveTranscript: _a,
1541
- onContinueInChat: Wa,
1666
+ attachments: Fa.attachments,
1667
+ onAttachFiles: Fa.addFiles,
1668
+ onRemoveAttachment: Fa.remove,
1669
+ onRetryAttachment: Fa.retry,
1670
+ canAttachMore: Fa.canAddMore,
1671
+ preparingAttachments: Fa.preparingCount,
1672
+ onSaveTranscript: Pa,
1673
+ onContinueInChat: so,
1542
1674
  onInterrupt: () => {
1543
- $.interrupt(), Vi();
1675
+ $.interrupt(), Xi();
1544
1676
  },
1545
- spoken: ca,
1677
+ spoken: Ta,
1546
1678
  onToggleMute: $.toggleMute,
1547
- onEnd: Ka,
1548
- proposalChip: Aa ? {
1549
- label: nt(Aa, I),
1550
- onOpen: ka
1679
+ onEnd: lo,
1680
+ proposalChip: qa ? {
1681
+ label: nt(qa, I),
1682
+ onOpen: Ka
1551
1683
  } : null,
1552
- proposalTray: Ma
1684
+ proposalTray: Ya
1553
1685
  }),
1554
- /* @__PURE__ */ P(Un, {
1555
- open: mi !== null,
1556
- mode: Qa,
1557
- currentMode: Di ?? { id: W },
1558
- onConfirm: Za,
1559
- onCancel: $a
1686
+ /* @__PURE__ */ P(Qn, {
1687
+ open: Ci !== null,
1688
+ mode: go,
1689
+ currentMode: Ii ?? { id: W },
1690
+ onConfirm: ho,
1691
+ onCancel: _o
1560
1692
  }),
1561
1693
  /* @__PURE__ */ P(Rt, {
1562
- ...Hr.dialog,
1563
- view: ha?.view ?? Hr.dialog.view,
1564
- serverNow: ha?.serverNow ?? NaN,
1565
- arrivedAt: ha?.arrivedAt ?? NaN,
1566
- capabilities: ha ? zr[ha.session.sandboxId] : null,
1567
- turnInFlight: Ir,
1694
+ ...Zr.dialog,
1695
+ view: Ma?.view ?? Zr.dialog.view,
1696
+ serverNow: Ma?.serverNow ?? NaN,
1697
+ arrivedAt: Ma?.arrivedAt ?? NaN,
1698
+ capabilities: Ma ? Jr[Ma.session.sandboxId] : null,
1699
+ turnInFlight: Gr,
1568
1700
  tr: I
1569
1701
  })
1570
1702
  ]
1571
1703
  });
1572
1704
  };
1573
1705
  //#endregion
1574
- export { $n as AssistantChatArea };
1706
+ export { cr as AssistantChatArea };