@streamoid/agent 0.6.54 → 0.6.55

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 (3) hide show
  1. package/dist/index.js +12 -2
  2. package/dist/pane.js +255 -251
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -138042,6 +138042,16 @@ function deriveSurfaceState(e, t, n) {
138042
138042
  function surfaceFingerprint(e) {
138043
138043
  return `${e.mode}:${e.panelCount}:${e.activePanel?.id ?? ""}`;
138044
138044
  }
138045
+ let storesWorkspaceId = null;
138046
+ function syncStoresToWorkspace(e) {
138047
+ if (e) {
138048
+ if (storesWorkspaceId !== null && storesWorkspaceId !== e) {
138049
+ const t = useChatStore.getState();
138050
+ t.reset(), t.setConversationsLoading(!0), useSupportStore.getState().leave();
138051
+ }
138052
+ storesWorkspaceId = e;
138053
+ }
138054
+ }
138045
138055
  function getCentralUrl() {
138046
138056
  return useAuthStore.getState().centralDashboardUrl;
138047
138057
  }
@@ -138279,7 +138289,7 @@ function AgentChatShell({ adapters: e }) {
138279
138289
  getWorkspaceId: () => t.current.workspace.current.id,
138280
138290
  onSessionExpired: () => t.current.auth.onSessionExpired?.(),
138281
138291
  onBackendRecovered: () => t.current.onBackendRecovered?.()
138282
- });
138292
+ }), syncStoresToWorkspace(s.current.id);
138283
138293
  const Ke = useAuthStore.getState();
138284
138294
  return Ke.setMode("iframe"), Ke.setAuth({
138285
138295
  workspaceId: s.current.id,
@@ -138300,7 +138310,7 @@ function AgentChatShell({ adapters: e }) {
138300
138310
  workspaceName: s.current.name ?? null
138301
138311
  }), useThemeStore.getState().setTheme(o.mode), !0;
138302
138312
  }), useEffect(() => {
138303
- useAuthStore.getState().switchWorkspace(s.current.id);
138313
+ syncStoresToWorkspace(s.current.id), useAuthStore.getState().switchWorkspace(s.current.id);
138304
138314
  }, [s.current.id]), useEffect(() => {
138305
138315
  useThemeStore.getState().setTheme(o.mode);
138306
138316
  }, [o.mode]), useEffect(() => {
package/dist/pane.js CHANGED
@@ -1,16 +1,16 @@
1
- import { useState as F, useEffect as _, useCallback as f, useMemo as J, Component as de, useRef as B, useLayoutEffect as fe, Suspense as pe, lazy as he } from "react";
2
- import { useStreamoidSearchShortcut as me, useStreamoidPanelWidth as ge, SC_ASSISTANT_PANEL_BOUNDS as Se, SC_ASSISTANT_PANEL_WIDTH as ye, ScPanelResizeHandle as Ie } from "@streamoid/ui";
3
- import { jsxs as re, jsx as m, Fragment as we } from "react/jsx-runtime";
4
- import { d as Ee } from "./agentScope-BlOT7qMu.js";
5
- function M() {
1
+ import { useState as _, useEffect as O, useCallback as p, useMemo as Q, Component as pe, useRef as G, useLayoutEffect as he, Suspense as me, lazy as ge } from "react";
2
+ import { useStreamoidSearchShortcut as Se, useStreamoidPanelWidth as ye, SC_ASSISTANT_PANEL_BOUNDS as Ee, SC_ASSISTANT_PANEL_WIDTH as we, ScPanelResizeHandle as Ie } from "@streamoid/ui";
3
+ import { jsxs as oe, jsx as g, Fragment as ve } from "react/jsx-runtime";
4
+ import { d as be } from "./agentScope-BlOT7qMu.js";
5
+ function j() {
6
6
  return import("./index.js");
7
7
  }
8
- function Z() {
9
- M().catch(() => {
8
+ function te() {
9
+ j().catch(() => {
10
10
  });
11
11
  }
12
- const ve = "streamoid.askPane.session", O = { open: !1, chatId: null };
13
- function oe(e, t) {
12
+ const Ae = "streamoid.askPane.session", D = { open: !1, chatId: null };
13
+ function ae(e, t) {
14
14
  return `${e}:${t}`;
15
15
  }
16
16
  function ie() {
@@ -20,40 +20,40 @@ function ie() {
20
20
  return null;
21
21
  }
22
22
  }
23
- function be(e, t) {
24
- if (!t) return O;
25
- const i = ie();
26
- if (!i) return O;
23
+ function Ce(e, t) {
24
+ if (!t) return D;
25
+ const a = ie();
26
+ if (!a) return D;
27
27
  try {
28
- const n = i.getItem(oe(e, t));
29
- if (!n) return O;
28
+ const n = a.getItem(ae(e, t));
29
+ if (!n) return D;
30
30
  const o = JSON.parse(n);
31
- if (!o || typeof o != "object") return O;
32
- const { surface: l, chatId: u } = o;
33
- return l !== "pane" && l !== "rail" ? O : { open: !0, chatId: typeof u == "string" && u ? u : null };
31
+ if (!o || typeof o != "object") return D;
32
+ const { surface: c, chatId: l } = o;
33
+ return c !== "pane" && c !== "rail" ? D : { open: !0, chatId: typeof l == "string" && l ? l : null };
34
34
  } catch {
35
- return O;
35
+ return D;
36
36
  }
37
37
  }
38
- function Ae(e, t, i) {
38
+ function Pe(e, t, a) {
39
39
  if (!t) return;
40
40
  const n = ie();
41
41
  if (!n) return;
42
- const o = oe(e, t);
42
+ const o = ae(e, t);
43
43
  try {
44
- if (i.surface === "closed") {
44
+ if (a.surface === "closed") {
45
45
  n.removeItem(o);
46
46
  return;
47
47
  }
48
- n.setItem(o, JSON.stringify({ surface: "pane", chatId: i.chatId }));
48
+ n.setItem(o, JSON.stringify({ surface: "rail", chatId: a.chatId }));
49
49
  } catch {
50
50
  }
51
51
  }
52
- const ae = { surface: "closed", declinedPanelId: null }, Q = { surface: "pane", declinedPanelId: null };
53
- function ce(e, t) {
54
- return e.surface === "closed" ? t.mode === "inline" && e.declinedPanelId !== null ? ae : e : t.mode === "inline" ? e.surface === "pane" && e.declinedPanelId === null ? e : Q : t.activePanel && t.activePanel.id === e.declinedPanelId || e.surface === "fullscreen" ? e : { surface: "fullscreen", declinedPanelId: e.declinedPanelId };
52
+ const ce = { surface: "closed", declinedPanelId: null }, Z = { surface: "pane", declinedPanelId: null };
53
+ function se(e, t) {
54
+ return e.surface === "closed" ? t.mode === "inline" && e.declinedPanelId !== null ? ce : e : t.mode === "inline" ? e.surface === "pane" && e.declinedPanelId === null ? e : Z : t.activePanel && t.activePanel.id === e.declinedPanelId || e.surface === "fullscreen" ? e : { surface: "fullscreen", declinedPanelId: e.declinedPanelId };
55
55
  }
56
- function Ce(e, t) {
56
+ function xe(e, t) {
57
57
  return e.surface === "closed" ? e : {
58
58
  surface: "pane",
59
59
  declinedPanelId: t?.activePanel?.id ?? null
@@ -61,193 +61,195 @@ function Ce(e, t) {
61
61
  }
62
62
  function le(e, t = null) {
63
63
  if (e.surface !== "closed") return e;
64
- const i = { surface: "pane", declinedPanelId: e.declinedPanelId };
65
- return t ? ce(i, t) : i;
64
+ const a = { surface: "pane", declinedPanelId: e.declinedPanelId };
65
+ return t ? se(a, t) : a;
66
66
  }
67
- function se(e) {
67
+ function ue(e) {
68
68
  return e.surface === "closed" ? e : { surface: "closed", declinedPanelId: e.declinedPanelId };
69
69
  }
70
- function Pe(e, t = null) {
71
- return e.surface === "closed" ? le(e, t) : se(e);
70
+ function ke(e, t = null) {
71
+ return e.surface === "closed" ? le(e, t) : ue(e);
72
72
  }
73
- const $ = "streamoid.askPane.width";
74
- function xe(e, t = ke()) {
73
+ const Y = "streamoid.askPane.width";
74
+ function Re(e, t = De()) {
75
75
  if (!t || !e) return !1;
76
- const i = typeof e == "string" ? [e] : e;
76
+ const a = typeof e == "string" ? [e] : e;
77
77
  try {
78
- if (t.getItem($) !== null) return !1;
79
- for (const n of i) {
80
- if (!n || n === $) continue;
78
+ if (t.getItem(Y) !== null) return !1;
79
+ for (const n of a) {
80
+ if (!n || n === Y) continue;
81
81
  const o = t.getItem(n);
82
82
  if (o === null) continue;
83
- const l = Number.parseInt(o, 10);
84
- if (Number.isFinite(l))
85
- return t.setItem($, String(l)), !0;
83
+ const c = Number.parseInt(o, 10);
84
+ if (Number.isFinite(c))
85
+ return t.setItem(Y, String(c)), !0;
86
86
  }
87
87
  } catch {
88
88
  }
89
89
  return !1;
90
90
  }
91
- function ke() {
91
+ function De() {
92
92
  try {
93
93
  return typeof window > "u" ? null : window.localStorage;
94
94
  } catch {
95
95
  return null;
96
96
  }
97
97
  }
98
- function G(e, t, i = 0) {
99
- const n = be(e, t);
98
+ function J(e, t, a = 0) {
99
+ const n = Ce(e, t);
100
100
  return {
101
101
  workspaceId: t,
102
- memory: n.open ? Q : ae,
102
+ memory: n.open ? Z : ce,
103
103
  chatId: n.chatId,
104
104
  selectionSnapshot: null,
105
- epoch: i,
105
+ epoch: a,
106
106
  lastReport: null
107
107
  };
108
108
  }
109
- function Ue({
109
+ function $e({
110
110
  workspaceId: e,
111
- persistKey: t = ve,
112
- legacyWidthKey: i,
111
+ persistKey: t = Ae,
112
+ legacyWidthKey: a,
113
113
  bindShortcut: n = !0
114
114
  }) {
115
- const o = e ?? "", [l, u] = F(() => G(t, o));
116
- let d = l;
117
- if (l.workspaceId !== o) {
118
- if (l.workspaceId === "") {
119
- const r = G(t, o, l.epoch);
120
- d = l.memory.surface !== "closed" ? { ...l, workspaceId: o, chatId: l.chatId ?? r.chatId } : { ...r, selectionSnapshot: l.selectionSnapshot };
115
+ const o = e ?? "", [c, l] = _(() => J(t, o));
116
+ let d = c;
117
+ if (c.workspaceId !== o) {
118
+ if (c.workspaceId === "") {
119
+ const r = J(t, o, c.epoch);
120
+ d = c.memory.surface !== "closed" ? { ...c, workspaceId: o, chatId: c.chatId ?? r.chatId } : { ...r, selectionSnapshot: c.selectionSnapshot };
121
121
  } else
122
- d = G(t, o, l.epoch + 1);
123
- u(d);
122
+ d = J(t, o, c.epoch + 1);
123
+ l(d);
124
124
  }
125
- _(() => {
126
- Ae(t, d.workspaceId, {
125
+ O(() => {
126
+ Pe(t, d.workspaceId, {
127
127
  surface: d.memory.surface,
128
128
  chatId: d.chatId
129
129
  });
130
130
  }, [t, d.workspaceId, d.memory.surface, d.chatId]);
131
- const p = f(
132
- (r) => u((c) => {
133
- const a = r(c.memory);
134
- return a === c.memory ? c : { ...c, memory: a };
131
+ const h = p(
132
+ (r) => l((i) => {
133
+ const f = r(i.memory);
134
+ return f === i.memory ? i : { ...i, memory: f };
135
135
  }),
136
136
  []
137
- ), A = f(
138
- (r) => u((c) => c.chatId === r ? c : { ...c, chatId: r }),
137
+ ), A = p(
138
+ (r) => l((i) => i.chatId === r ? i : { ...i, chatId: r }),
139
139
  []
140
- ), g = f(
141
- (r) => u((c) => {
142
- const a = r(c);
143
- return a === c.memory ? c : { ...c, memory: a };
140
+ ), S = p(
141
+ (r) => l((i) => {
142
+ const f = r(i);
143
+ return f === i.memory ? i : { ...i, memory: f };
144
144
  }),
145
145
  []
146
- ), C = f(
147
- () => g((r) => le(r.memory, r.lastReport)),
148
- [g]
149
- ), P = f(() => p(se), [p]), L = f(
150
- () => g((r) => Pe(r.memory, r.lastReport)),
151
- [g]
152
- ), x = f(
153
- () => u((r) => ({
146
+ ), C = p(
147
+ () => S((r) => le(r.memory, r.lastReport)),
148
+ [S]
149
+ ), P = p(() => h(ue), [h]), L = p(
150
+ () => S((r) => ke(r.memory, r.lastReport)),
151
+ [S]
152
+ ), x = p(
153
+ () => l((r) => ({
154
154
  ...r,
155
155
  chatId: null,
156
156
  lastReport: null,
157
- memory: r.memory.surface === "closed" ? Q : r.memory
157
+ memory: r.memory.surface === "closed" ? Z : r.memory
158
158
  })),
159
159
  []
160
- ), T = f(
161
- (r) => u((c) => {
162
- const a = ce(c.memory, r);
163
- return { ...c, lastReport: r, memory: a };
160
+ ), T = p(
161
+ (r) => l((i) => {
162
+ const f = se(i.memory, r);
163
+ return { ...i, lastReport: r, memory: f };
164
164
  }),
165
165
  []
166
- ), h = f(
167
- () => g((r) => Ce(r.memory, r.lastReport)),
168
- [g]
169
- ), b = f(() => {
170
- C(), M().then((r) => r.focusAgentComposer()).catch(() => {
166
+ ), m = p(
167
+ () => S((r) => xe(r.memory, r.lastReport)),
168
+ [S]
169
+ ), b = p(() => {
170
+ C(), j().then((r) => r.focusAgentComposer()).catch(() => {
171
171
  });
172
- }, [C]), S = f(
172
+ }, [C]), y = p(
173
173
  (r) => {
174
- const c = typeof r == "string" ? r.trim() : "";
175
- return c ? (x(), M().then((a) => a.enqueueChatPrompt({ prompt: c, forceNewConversation: !0 })).catch(() => {
174
+ const i = typeof r == "string" ? r.trim() : "";
175
+ return i ? (x(), j().then((f) => {
176
+ f.focusAgentComposer(), f.enqueueChatPrompt({ prompt: i, forceNewConversation: !0 });
177
+ }).catch(() => {
176
178
  }), !0) : !1;
177
179
  },
178
180
  [x]
179
- ), N = f(
181
+ ), N = p(
180
182
  (r) => {
181
- x(), M().then((c) => {
182
- c.showAgentSupport(r ?? null);
183
+ x(), j().then((i) => {
184
+ i.showAgentSupport(r ?? null);
183
185
  }).catch(() => {
184
186
  });
185
187
  },
186
188
  [x]
187
189
  );
188
- me({
190
+ Se({
189
191
  onTrigger: () => {
190
- Z(), b();
192
+ te(), b();
191
193
  },
192
194
  enabled: n
193
- }), F(() => xe(i));
194
- const k = Se, { width: j, setWidth: z, commitWidth: q } = ge({
195
- storageKey: $,
196
- defaultWidth: ye,
195
+ }), _(() => Re(a));
196
+ const k = Ee, { width: z, setWidth: W, commitWidth: q } = ye({
197
+ storageKey: Y,
198
+ defaultWidth: we,
197
199
  min: k.min,
198
200
  max: k.max
199
- }), y = f(
200
- (r) => u(
201
- (c) => c.selectionSnapshot === (r ?? null) ? c : { ...c, selectionSnapshot: r ?? null }
201
+ }), U = p(
202
+ (r) => l(
203
+ (i) => i.selectionSnapshot === (r ?? null) ? i : { ...i, selectionSnapshot: r ?? null }
202
204
  ),
203
205
  []
204
- ), U = d.selectionSnapshot, R = d.epoch, I = d.memory.surface;
205
- return J(
206
+ ), X = d.selectionSnapshot, E = d.epoch, H = d.memory.surface;
207
+ return Q(
206
208
  () => ({
207
- open: I !== "closed",
208
- surface: I,
209
+ open: H !== "closed",
210
+ surface: H,
209
211
  chatId: d.chatId,
210
212
  reveal: C,
211
213
  close: P,
212
214
  toggle: L,
213
215
  askCxo: b,
214
- askAbout: S,
216
+ askAbout: y,
215
217
  requestSupport: N,
216
- prefetch: Z,
217
- width: j,
218
- setWidth: z,
218
+ prefetch: te,
219
+ width: z,
220
+ setWidth: W,
219
221
  commitWidth: q,
220
222
  bounds: k,
221
- selectionSnapshot: U,
222
- workspaceEpoch: R,
223
+ selectionSnapshot: X,
224
+ workspaceEpoch: E,
223
225
  setChatId: A,
224
226
  reportSurface: T,
225
- collapse: h,
226
- reportSelectionSnapshot: y
227
+ collapse: m,
228
+ reportSelectionSnapshot: U
227
229
  }),
228
230
  [
229
- I,
231
+ H,
230
232
  d.chatId,
231
233
  C,
232
234
  P,
233
235
  L,
234
236
  b,
235
- S,
237
+ y,
236
238
  N,
237
- j,
238
239
  z,
240
+ W,
239
241
  q,
240
242
  k,
241
- U,
242
- R,
243
+ X,
244
+ E,
243
245
  A,
244
246
  T,
245
- h,
246
- y
247
+ m,
248
+ U
247
249
  ]
248
250
  );
249
251
  }
250
- class Re extends de {
252
+ class Oe extends pe {
251
253
  state = { error: null };
252
254
  static getDerivedStateFromError(t) {
253
255
  return { error: t ?? new Error("Ask CXO failed to load") };
@@ -259,7 +261,7 @@ class Re extends de {
259
261
  this.setState({ error: null }), this.props.onRetry();
260
262
  };
261
263
  render() {
262
- return this.state.error === null ? this.props.children : /* @__PURE__ */ re(
264
+ return this.state.error === null ? this.props.children : /* @__PURE__ */ oe(
263
265
  "div",
264
266
  {
265
267
  role: "alert",
@@ -277,8 +279,8 @@ class Re extends de {
277
279
  color: "var(--alias-text---icons-secondary, currentColor)"
278
280
  },
279
281
  children: [
280
- /* @__PURE__ */ m("span", { children: "Ask CXO couldn’t load." }),
281
- /* @__PURE__ */ m(
282
+ /* @__PURE__ */ g("span", { children: "Ask CXO couldn’t load." }),
283
+ /* @__PURE__ */ g(
282
284
  "button",
283
285
  {
284
286
  type: "button",
@@ -301,8 +303,8 @@ class Re extends de {
301
303
  );
302
304
  }
303
305
  }
304
- function De() {
305
- return /* @__PURE__ */ m(
306
+ function _e() {
307
+ return /* @__PURE__ */ g(
306
308
  "div",
307
309
  {
308
310
  role: "status",
@@ -321,193 +323,195 @@ function De() {
321
323
  }
322
324
  );
323
325
  }
324
- const Oe = '[role="dialog"], [role="alertdialog"], [aria-modal="true"], dialog[open]';
325
- function Y(e, t) {
326
- const n = (K(e) ? e : null)?.closest(Oe) ?? null;
326
+ const Le = '[role="dialog"], [role="alertdialog"], [aria-modal="true"], dialog[open]';
327
+ function B(e, t) {
328
+ const n = (V(e) ? e : null)?.closest(Le) ?? null;
327
329
  return n !== null && n !== t;
328
330
  }
329
- function _e(e, t) {
330
- const i = e.querySelectorAll('[aria-modal="true"], dialog[open]');
331
- for (const n of Array.from(i))
332
- if (!(n === t || Le(n, e)))
331
+ function Te(e, t) {
332
+ const a = e.querySelectorAll('[aria-modal="true"], dialog[open]');
333
+ for (const n of Array.from(a))
334
+ if (!(n === t || Ne(n, e)))
333
335
  return !0;
334
336
  return !1;
335
337
  }
336
- function Le(e, t) {
338
+ function Ne(e, t) {
337
339
  if (e.closest("[hidden]")) return !0;
338
- const i = t.defaultView?.getComputedStyle?.(e);
339
- return !!i && (i.display === "none" || i.visibility === "hidden");
340
+ const a = t.defaultView?.getComputedStyle?.(e);
341
+ return !!a && (a.display === "none" || a.visibility === "hidden");
340
342
  }
341
- function Te({
343
+ function We({
342
344
  event: e,
343
345
  pane: t,
344
- active: i,
346
+ active: a,
345
347
  doc: n,
346
348
  surface: o,
347
- isSheet: l
349
+ isSheet: c
348
350
  }) {
349
- return e.key !== "Escape" || e.defaultPrevented || !t || o === "closed" || Y(e.target, t) || Y(i, t) || _e(n, t) || !l && !(K(i) && t.contains(i) || K(e.target) && t.contains(e.target)) ? null : o === "fullscreen" ? "collapse" : "close";
351
+ return e.key !== "Escape" || e.defaultPrevented || !t || o === "closed" || B(e.target, t) || B(a, t) || Te(n, t) || !c && !(V(a) && t.contains(a) || V(e.target) && t.contains(e.target)) ? null : o === "fullscreen" ? "collapse" : "close";
350
352
  }
351
- function K(e) {
353
+ function V(e) {
352
354
  return typeof e == "object" && e !== null && e.nodeType === 1 && typeof e.closest == "function";
353
355
  }
354
- const ue = "__streamoidAskPane";
355
- let Ne = 0;
356
- function ee(e) {
356
+ const de = "__streamoidAskPane";
357
+ let He = 0;
358
+ function ne(e) {
357
359
  if (!e || typeof e != "object") return null;
358
- const t = e[ue];
360
+ const t = e[de];
359
361
  return typeof t == "string" ? t : null;
360
362
  }
361
- function We(e, t = (n) => setTimeout(n, 0), i = (n) => clearTimeout(n)) {
363
+ function Me(e, t = (n) => setTimeout(n, 0), a = (n) => clearTimeout(n)) {
362
364
  let n = null, o = null;
363
- const l = () => n !== null && ee(e.state) === n;
365
+ const c = () => n !== null && ne(e.state) === n;
364
366
  return {
365
367
  enter() {
366
- if (o !== null && (i(o), o = null), l()) return;
367
- const u = ee(e.state);
368
- if (u) {
369
- n = u;
368
+ if (o !== null && (a(o), o = null), c()) return;
369
+ const l = ne(e.state);
370
+ if (l) {
371
+ n = l;
370
372
  return;
371
373
  }
372
- n = `pane-${Date.now().toString(36)}-${Ne += 1}`;
374
+ n = `pane-${Date.now().toString(36)}-${He += 1}`;
373
375
  const d = e.state && typeof e.state == "object" ? e.state : {};
374
- e.pushState({ ...d, [ue]: n }, "");
376
+ e.pushState({ ...d, [de]: n }, "");
375
377
  },
376
378
  leave() {
377
379
  n === null || o !== null || (o = t(() => {
378
380
  o = null;
379
- const u = l();
380
- n = null, u && e.back();
381
+ const l = c();
382
+ n = null, l && e.back();
381
383
  }));
382
384
  },
383
385
  handlePop() {
384
- return n === null || l() ? !1 : (n = null, o !== null && (i(o), o = null), !0);
386
+ return n === null || c() ? !1 : (n = null, o !== null && (a(o), o = null), !0);
385
387
  },
386
- isCurrent: l
388
+ isCurrent: c
387
389
  };
388
390
  }
389
- const te = "(min-width: 768px)", He = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
390
- function Me() {
391
- const e = () => typeof window < "u" && typeof window.matchMedia == "function" && !window.matchMedia(te).matches, [t, i] = F(e);
392
- return _(() => {
391
+ const re = "(min-width: 768px)", Fe = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
392
+ function je() {
393
+ const e = () => typeof window < "u" && typeof window.matchMedia == "function" && !window.matchMedia(re).matches, [t, a] = _(e);
394
+ return O(() => {
393
395
  if (typeof window > "u" || typeof window.matchMedia != "function") return;
394
- const n = window.matchMedia(te), o = () => i(!n.matches);
396
+ const n = window.matchMedia(re), o = () => a(!n.matches);
395
397
  return o(), n.addEventListener?.("change", o), () => n.removeEventListener?.("change", o);
396
398
  }, []), t;
397
399
  }
398
- function ne() {
399
- return he(() => M().then((e) => ({ default: e.AgentPanel })));
400
+ function K() {
401
+ return ge(() => j().then((e) => ({ default: e.AgentPanel })));
400
402
  }
401
- function Xe({
403
+ function Ye({
402
404
  controller: e,
403
405
  adapters: t,
404
- hostContext: i,
406
+ hostContext: a,
405
407
  scope: n,
406
408
  support: o,
407
- canvas: l,
408
- className: u,
409
+ canvas: c,
410
+ className: l,
409
411
  ariaLabel: d = "Ask CXO assistant"
410
412
  }) {
411
- const { open: p, surface: A, chatId: g, setChatId: C, close: P, collapse: L, reportSurface: x, reportSelectionSnapshot: T } = e, h = Me(), b = B(null), S = p && h, [N, k] = F(p);
412
- p && !N && k(!0);
413
- const [j, z] = F(ne), q = f(() => z(() => ne()), []), y = B({ surface: A, close: P, collapse: L, isSheet: h });
414
- fe(() => {
415
- y.current = { surface: A, close: P, collapse: L, isSheet: h };
413
+ const { open: h, surface: A, chatId: S, setChatId: C, close: P, collapse: L, reportSurface: x, reportSelectionSnapshot: T } = e, m = je(), b = G(null), y = h && m, [N, k] = _(h);
414
+ h && !N && k(!0);
415
+ const [z, W] = _(K), q = p(() => W(() => K()), []), [U, X] = _(e.workspaceEpoch);
416
+ U !== e.workspaceEpoch && (X(e.workspaceEpoch), W(() => K()));
417
+ const E = G({ surface: A, close: P, collapse: L, isSheet: m });
418
+ he(() => {
419
+ E.current = { surface: A, close: P, collapse: L, isSheet: m };
416
420
  });
417
- const U = J(
421
+ const H = Q(
418
422
  () => ({
419
423
  ...t,
420
- navigation: { chatId: g, onChatIdChange: C },
424
+ navigation: { chatId: S, onChatIdChange: C },
421
425
  onClose: P,
422
426
  onSurfaceChange: x,
423
427
  onSelectionSnapshot: T,
424
- hostContext: i ?? null,
428
+ hostContext: a ?? null,
425
429
  scope: n ?? null,
426
430
  support: o ?? null,
427
- ...l ? { canvas: l } : {}
431
+ ...c ? { canvas: c } : {}
428
432
  }),
429
433
  [
430
434
  t,
431
- g,
435
+ S,
432
436
  C,
433
437
  P,
434
438
  x,
435
439
  T,
436
- i,
440
+ a,
437
441
  n,
438
442
  o,
439
- l
443
+ c
440
444
  ]
441
445
  );
442
- _(() => {
443
- if (!p) return;
444
- const a = (w) => {
445
- const E = Te({
446
+ O(() => {
447
+ if (!h) return;
448
+ const u = (w) => {
449
+ const I = We({
446
450
  event: w,
447
451
  pane: b.current,
448
452
  active: document.activeElement,
449
453
  doc: document,
450
- surface: y.current.surface,
451
- isSheet: y.current.isSheet
454
+ surface: E.current.surface,
455
+ isSheet: E.current.isSheet
452
456
  });
453
- E && (w.preventDefault(), E === "collapse" ? y.current.collapse() : y.current.close());
457
+ I && (w.preventDefault(), I === "collapse" ? E.current.collapse() : E.current.close());
454
458
  };
455
- return document.addEventListener("keydown", a), () => document.removeEventListener("keydown", a);
456
- }, [p]);
457
- const R = B(null);
458
- _(() => {
459
- const a = b.current;
460
- if (p) {
461
- const D = document.activeElement;
462
- D && D !== document.body && !a?.contains(D) && (R.current = D);
459
+ return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
460
+ }, [h]);
461
+ const r = G(null);
462
+ O(() => {
463
+ const u = b.current;
464
+ if (h) {
465
+ const R = document.activeElement;
466
+ R && R !== document.body && !u?.contains(R) && (r.current = R);
463
467
  return;
464
468
  }
465
- const w = R.current;
466
- R.current = null;
467
- const E = document.activeElement, W = !E || E === document.body || (a?.contains(E) ?? !1);
468
- w && W && w.isConnected && w.focus?.();
469
- }, [p]), _(() => {
470
- if (!S) return;
471
- const a = b.current;
472
- if (!a) return;
469
+ const w = r.current;
470
+ r.current = null;
471
+ const I = document.activeElement, M = !I || I === document.body || (u?.contains(I) ?? !1);
472
+ w && M && w.isConnected && w.focus?.();
473
+ }, [h]), O(() => {
474
+ if (!y) return;
475
+ const u = b.current;
476
+ if (!u) return;
473
477
  const w = () => {
474
- const s = Array.from(a.querySelectorAll(He)), v = s.filter((H) => H.getClientRects().length > 0);
478
+ const s = Array.from(u.querySelectorAll(Fe)), v = s.filter((F) => F.getClientRects().length > 0);
475
479
  return v.length > 0 ? v : s;
476
480
  };
477
- a.contains(document.activeElement) || (w()[0] ?? a).focus?.();
478
- const E = (s) => {
479
- if (s.key !== "Tab" || Y(s.target, a) || Y(document.activeElement, a)) return;
481
+ u.contains(document.activeElement) || (w()[0] ?? u).focus?.();
482
+ const I = (s) => {
483
+ if (s.key !== "Tab" || B(s.target, u) || B(document.activeElement, u)) return;
480
484
  const v = w();
481
485
  if (v.length === 0) {
482
- s.preventDefault(), a.focus?.();
486
+ s.preventDefault(), u.focus?.();
483
487
  return;
484
488
  }
485
- const H = v[0], V = v[v.length - 1], X = document.activeElement;
486
- !s.shiftKey && X === V ? (s.preventDefault(), H.focus()) : s.shiftKey && X === H ? (s.preventDefault(), V.focus()) : X && !a.contains(X) && (s.preventDefault(), H.focus());
487
- }, W = Array.from(a.parentElement?.children ?? []).filter(
488
- (s) => s !== a && s instanceof HTMLElement
489
- ), D = W.map((s) => s.hasAttribute("inert"));
490
- return W.forEach((s) => s.setAttribute("inert", "")), document.addEventListener("keydown", E), () => {
491
- document.removeEventListener("keydown", E), W.forEach((s, v) => {
492
- D[v] || s.removeAttribute("inert");
489
+ const F = v[0], ee = v[v.length - 1], $ = document.activeElement;
490
+ !s.shiftKey && $ === ee ? (s.preventDefault(), F.focus()) : s.shiftKey && $ === F ? (s.preventDefault(), ee.focus()) : $ && !u.contains($) && (s.preventDefault(), F.focus());
491
+ }, M = Array.from(u.parentElement?.children ?? []).filter(
492
+ (s) => s !== u && s instanceof HTMLElement
493
+ ), R = M.map((s) => s.hasAttribute("inert"));
494
+ return M.forEach((s) => s.setAttribute("inert", "")), document.addEventListener("keydown", I), () => {
495
+ document.removeEventListener("keydown", I), M.forEach((s, v) => {
496
+ R[v] || s.removeAttribute("inert");
493
497
  });
494
498
  };
495
- }, [S]);
496
- const I = J(
497
- () => typeof window > "u" ? null : We(window.history),
499
+ }, [y]);
500
+ const i = Q(
501
+ () => typeof window > "u" ? null : Me(window.history),
498
502
  []
499
503
  );
500
- _(() => {
501
- if (!S || !I) return;
502
- I.enter();
503
- const a = () => {
504
- I.handlePop() && y.current.close();
504
+ O(() => {
505
+ if (!y || !i) return;
506
+ i.enter();
507
+ const u = () => {
508
+ i.handlePop() && E.current.close();
505
509
  };
506
- return window.addEventListener("popstate", a), () => {
507
- window.removeEventListener("popstate", a), I.leave();
510
+ return window.addEventListener("popstate", u), () => {
511
+ window.removeEventListener("popstate", u), i.leave();
508
512
  };
509
- }, [S, I]);
510
- const r = A === "fullscreen", c = p ? h ? { display: "flex", position: "fixed", inset: 0, zIndex: 50, width: "100%", height: "100%" } : r ? { display: "flex", position: "relative", flex: "1 1 0%", minWidth: 0, height: "100%", minHeight: 0 } : {
513
+ }, [y, i]);
514
+ const f = A === "fullscreen", fe = h ? m ? { display: "flex", position: "fixed", inset: 0, zIndex: 50, width: "100%", height: "100%" } : f ? { display: "flex", position: "relative", flex: "1 1 0%", minWidth: 0, height: "100%", minHeight: 0 } : {
511
515
  display: "flex",
512
516
  position: "relative",
513
517
  flex: "0 0 auto",
@@ -515,28 +519,28 @@ function Xe({
515
519
  height: "100%",
516
520
  minHeight: 0
517
521
  } : { display: "none" };
518
- return /* @__PURE__ */ m(
522
+ return /* @__PURE__ */ g(
519
523
  "aside",
520
524
  {
521
525
  ref: b,
522
526
  "aria-label": d,
523
- "aria-hidden": !p,
524
- ...S ? { role: "dialog", "aria-modal": !0 } : {},
525
- tabIndex: S ? -1 : void 0,
527
+ "aria-hidden": !h,
528
+ ...y ? { role: "dialog", "aria-modal": !0 } : {},
529
+ tabIndex: y ? -1 : void 0,
526
530
  "data-streamoid-agent": "pane",
527
531
  "data-surface": A,
528
- "data-layout": h ? "sheet" : "docked",
532
+ "data-layout": m ? "sheet" : "docked",
529
533
  "data-testid": "agent-side-pane",
530
- className: u,
534
+ className: l,
531
535
  style: {
532
536
  flexDirection: "column",
533
537
  boxSizing: "border-box",
534
538
  background: "var(--alias-surface-base)",
535
- borderRight: h || r ? void 0 : "1px solid var(--alias-border-subtle)",
536
- ...c
539
+ borderRight: m || f ? void 0 : "1px solid var(--alias-border-subtle)",
540
+ ...fe
537
541
  },
538
- children: N ? /* @__PURE__ */ re(we, { children: [
539
- !h && !r ? /* @__PURE__ */ m(
542
+ children: N ? /* @__PURE__ */ oe(ve, { children: [
543
+ !m && !f ? /* @__PURE__ */ g(
540
544
  Ie,
541
545
  {
542
546
  width: e.width,
@@ -548,7 +552,7 @@ function Xe({
548
552
  ariaLabel: "Resize Ask CXO"
549
553
  }
550
554
  ) : null,
551
- /* @__PURE__ */ m(
555
+ /* @__PURE__ */ g(
552
556
  "div",
553
557
  {
554
558
  style: {
@@ -559,23 +563,23 @@ function Xe({
559
563
  minWidth: 0,
560
564
  overflow: "hidden"
561
565
  },
562
- children: /* @__PURE__ */ m(Re, { onRetry: q, children: /* @__PURE__ */ m(pe, { fallback: /* @__PURE__ */ m(De, {}), children: /* @__PURE__ */ m(j, { adapters: U }, e.workspaceEpoch) }) })
566
+ children: /* @__PURE__ */ g(Oe, { onRetry: q, children: /* @__PURE__ */ g(me, { fallback: /* @__PURE__ */ g(_e, {}), children: /* @__PURE__ */ g(z, { adapters: H }, e.workspaceEpoch) }) }, e.workspaceEpoch)
563
567
  }
564
568
  )
565
569
  ] }) : null
566
570
  }
567
571
  );
568
572
  }
569
- function $e(e, t) {
570
- return Ee(e, t).length;
573
+ function Be(e, t) {
574
+ return be(e, t).length;
571
575
  }
572
576
  export {
573
- te as AGENT_PANE_DOCKED_MEDIA_QUERY,
574
- $ as AGENT_PANE_WIDTH_KEY,
575
- Xe as AgentSidePane,
576
- ve as DEFAULT_PANE_PERSIST_KEY,
577
- Ee as deriveScopeSuggestions,
578
- $e as paneSuggestionCount,
579
- Z as prefetchAgent,
580
- Ue as useAgentPaneController
577
+ re as AGENT_PANE_DOCKED_MEDIA_QUERY,
578
+ Y as AGENT_PANE_WIDTH_KEY,
579
+ Ye as AgentSidePane,
580
+ Ae as DEFAULT_PANE_PERSIST_KEY,
581
+ be as deriveScopeSuggestions,
582
+ Be as paneSuggestionCount,
583
+ te as prefetchAgent,
584
+ $e as useAgentPaneController
581
585
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamoid/agent",
3
- "version": "0.6.54",
3
+ "version": "0.6.55",
4
4
  "description": "Native (no-iframe) embeddable Streamoid agent chat panel. Host renders <AgentPanel adapters={\u2026}/>. Prebuilt bundle \u2014 source + build live in the stream-agent repo.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",