@streamoid/agent 0.8.1-preview.6812717d6a04 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pane.js CHANGED
@@ -1,4 +1,4 @@
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";
1
+ import { useState as _, useEffect as O, useCallback as h, useMemo as Q, Component as pe, useRef as G, useLayoutEffect as he, Suspense as me, lazy as ge } from "react";
2
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
3
  import { jsxs as oe, jsx as g, Fragment as ve } from "react/jsx-runtime";
4
4
  import { d as be } from "./agentScope-BlOT7qMu.js";
@@ -10,10 +10,10 @@ function te() {
10
10
  });
11
11
  }
12
12
  const Ae = "streamoid.askPane.session", D = { open: !1, chatId: null };
13
- function ae(e, t) {
13
+ function ie(e, t) {
14
14
  return `${e}:${t}`;
15
15
  }
16
- function ie() {
16
+ function ae() {
17
17
  try {
18
18
  return typeof window > "u" ? null : window.localStorage;
19
19
  } catch {
@@ -22,10 +22,10 @@ function ie() {
22
22
  }
23
23
  function Ce(e, t) {
24
24
  if (!t) return D;
25
- const a = ie();
26
- if (!a) return D;
25
+ const i = ae();
26
+ if (!i) return D;
27
27
  try {
28
- const n = a.getItem(ae(e, t));
28
+ const n = i.getItem(ie(e, t));
29
29
  if (!n) return D;
30
30
  const o = JSON.parse(n);
31
31
  if (!o || typeof o != "object") return D;
@@ -35,17 +35,17 @@ function Ce(e, t) {
35
35
  return D;
36
36
  }
37
37
  }
38
- function Pe(e, t, a) {
38
+ function Pe(e, t, i) {
39
39
  if (!t) return;
40
- const n = ie();
40
+ const n = ae();
41
41
  if (!n) return;
42
- const o = ae(e, t);
42
+ const o = ie(e, t);
43
43
  try {
44
- if (a.surface === "closed") {
44
+ if (i.surface === "closed") {
45
45
  n.removeItem(o);
46
46
  return;
47
47
  }
48
- n.setItem(o, JSON.stringify({ surface: "rail", chatId: a.chatId }));
48
+ n.setItem(o, JSON.stringify({ surface: "rail", chatId: i.chatId }));
49
49
  } catch {
50
50
  }
51
51
  }
@@ -61,8 +61,8 @@ function xe(e, t) {
61
61
  }
62
62
  function le(e, t = null) {
63
63
  if (e.surface !== "closed") return e;
64
- const a = { surface: "pane", declinedPanelId: e.declinedPanelId };
65
- return t ? se(a, t) : a;
64
+ const i = { surface: "pane", declinedPanelId: e.declinedPanelId };
65
+ return t ? se(i, t) : i;
66
66
  }
67
67
  function ue(e) {
68
68
  return e.surface === "closed" ? e : { surface: "closed", declinedPanelId: e.declinedPanelId };
@@ -73,10 +73,10 @@ function ke(e, t = null) {
73
73
  const Y = "streamoid.askPane.width";
74
74
  function Re(e, t = De()) {
75
75
  if (!t || !e) return !1;
76
- const a = typeof e == "string" ? [e] : e;
76
+ const i = typeof e == "string" ? [e] : e;
77
77
  try {
78
78
  if (t.getItem(Y) !== null) return !1;
79
- for (const n of a) {
79
+ for (const n of i) {
80
80
  if (!n || n === Y) continue;
81
81
  const o = t.getItem(n);
82
82
  if (o === null) continue;
@@ -95,21 +95,21 @@ function De() {
95
95
  return null;
96
96
  }
97
97
  }
98
- function J(e, t, a = 0) {
98
+ function J(e, t, i = 0) {
99
99
  const n = Ce(e, t);
100
100
  return {
101
101
  workspaceId: t,
102
102
  memory: n.open ? Z : ce,
103
103
  chatId: n.chatId,
104
104
  selectionSnapshot: null,
105
- epoch: a,
105
+ epoch: i,
106
106
  lastReport: null
107
107
  };
108
108
  }
109
109
  function $e({
110
110
  workspaceId: e,
111
111
  persistKey: t = Ae,
112
- legacyWidthKey: a,
112
+ legacyWidthKey: i,
113
113
  bindShortcut: n = !0
114
114
  }) {
115
115
  const o = e ?? "", [c, l] = _(() => J(t, o));
@@ -128,28 +128,28 @@ function $e({
128
128
  chatId: d.chatId
129
129
  });
130
130
  }, [t, d.workspaceId, d.memory.surface, d.chatId]);
131
- const h = p(
132
- (r) => l((i) => {
133
- const f = r(i.memory);
134
- return f === i.memory ? i : { ...i, memory: f };
131
+ const f = h(
132
+ (r) => l((a) => {
133
+ const p = r(a.memory);
134
+ return p === a.memory ? a : { ...a, memory: p };
135
135
  }),
136
136
  []
137
- ), A = p(
138
- (r) => l((i) => i.chatId === r ? i : { ...i, chatId: r }),
137
+ ), A = h(
138
+ (r) => l((a) => a.chatId === r ? a : { ...a, chatId: r }),
139
139
  []
140
- ), S = p(
141
- (r) => l((i) => {
142
- const f = r(i);
143
- return f === i.memory ? i : { ...i, memory: f };
140
+ ), S = h(
141
+ (r) => l((a) => {
142
+ const p = r(a);
143
+ return p === a.memory ? a : { ...a, memory: p };
144
144
  }),
145
145
  []
146
- ), C = p(
146
+ ), C = h(
147
147
  () => S((r) => le(r.memory, r.lastReport)),
148
148
  [S]
149
- ), P = p(() => h(ue), [h]), L = p(
149
+ ), P = h(() => f(ue), [f]), L = h(
150
150
  () => S((r) => ke(r.memory, r.lastReport)),
151
151
  [S]
152
- ), x = p(
152
+ ), x = h(
153
153
  () => l((r) => ({
154
154
  ...r,
155
155
  chatId: null,
@@ -157,31 +157,31 @@ function $e({
157
157
  memory: r.memory.surface === "closed" ? Z : r.memory
158
158
  })),
159
159
  []
160
- ), T = p(
161
- (r) => l((i) => {
162
- const f = se(i.memory, r);
163
- return { ...i, lastReport: r, memory: f };
160
+ ), T = h(
161
+ (r) => l((a) => {
162
+ const p = se(a.memory, r);
163
+ return { ...a, lastReport: r, memory: p };
164
164
  }),
165
165
  []
166
- ), m = p(
166
+ ), m = h(
167
167
  () => S((r) => xe(r.memory, r.lastReport)),
168
168
  [S]
169
- ), b = p(() => {
169
+ ), b = h(() => {
170
170
  C(), j().then((r) => r.focusAgentComposer()).catch(() => {
171
171
  });
172
- }, [C]), y = p(
172
+ }, [C]), y = h(
173
173
  (r) => {
174
- const i = typeof r == "string" ? r.trim() : "";
175
- return i ? (x(), j().then((f) => {
176
- f.focusAgentComposer(), f.enqueueChatPrompt({ prompt: i, forceNewConversation: !0 });
174
+ const a = typeof r == "string" ? r.trim() : "";
175
+ return a ? (x(), j().then((p) => {
176
+ p.focusAgentComposer(), p.enqueueChatPrompt({ prompt: a, forceNewConversation: !0 });
177
177
  }).catch(() => {
178
178
  }), !0) : !1;
179
179
  },
180
180
  [x]
181
- ), N = p(
181
+ ), N = h(
182
182
  (r) => {
183
- x(), j().then((i) => {
184
- i.showAgentSupport(r ?? null);
183
+ x(), j().then((a) => {
184
+ a.showAgentSupport(r ?? null);
185
185
  }).catch(() => {
186
186
  });
187
187
  },
@@ -192,15 +192,15 @@ function $e({
192
192
  te(), b();
193
193
  },
194
194
  enabled: n
195
- }), _(() => Re(a));
195
+ }), _(() => Re(i));
196
196
  const k = Ee, { width: z, setWidth: W, commitWidth: q } = ye({
197
197
  storageKey: Y,
198
198
  defaultWidth: we,
199
199
  min: k.min,
200
200
  max: k.max
201
- }), U = p(
201
+ }), U = h(
202
202
  (r) => l(
203
- (i) => i.selectionSnapshot === (r ?? null) ? i : { ...i, selectionSnapshot: r ?? null }
203
+ (a) => a.selectionSnapshot === (r ?? null) ? a : { ...a, selectionSnapshot: r ?? null }
204
204
  ),
205
205
  []
206
206
  ), X = d.selectionSnapshot, E = d.epoch, H = d.memory.surface;
@@ -329,26 +329,26 @@ function B(e, t) {
329
329
  return n !== null && n !== t;
330
330
  }
331
331
  function Te(e, t) {
332
- const a = e.querySelectorAll('[aria-modal="true"], dialog[open]');
333
- for (const n of Array.from(a))
332
+ const i = e.querySelectorAll('[aria-modal="true"], dialog[open]');
333
+ for (const n of Array.from(i))
334
334
  if (!(n === t || Ne(n, e)))
335
335
  return !0;
336
336
  return !1;
337
337
  }
338
338
  function Ne(e, t) {
339
339
  if (e.closest("[hidden]")) return !0;
340
- const a = t.defaultView?.getComputedStyle?.(e);
341
- return !!a && (a.display === "none" || a.visibility === "hidden");
340
+ const i = t.defaultView?.getComputedStyle?.(e);
341
+ return !!i && (i.display === "none" || i.visibility === "hidden");
342
342
  }
343
343
  function We({
344
344
  event: e,
345
345
  pane: t,
346
- active: a,
346
+ active: i,
347
347
  doc: n,
348
348
  surface: o,
349
349
  isSheet: c
350
350
  }) {
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";
351
+ return e.key !== "Escape" || e.defaultPrevented || !t || o === "closed" || B(e.target, t) || B(i, t) || Te(n, t) || !c && !(V(i) && t.contains(i) || V(e.target) && t.contains(e.target)) ? null : o === "fullscreen" ? "collapse" : "close";
352
352
  }
353
353
  function V(e) {
354
354
  return typeof e == "object" && e !== null && e.nodeType === 1 && typeof e.closest == "function";
@@ -360,12 +360,12 @@ function ne(e) {
360
360
  const t = e[de];
361
361
  return typeof t == "string" ? t : null;
362
362
  }
363
- function Me(e, t = (n) => setTimeout(n, 0), a = (n) => clearTimeout(n)) {
363
+ function Me(e, t = (n) => setTimeout(n, 0), i = (n) => clearTimeout(n)) {
364
364
  let n = null, o = null;
365
365
  const c = () => n !== null && ne(e.state) === n;
366
366
  return {
367
367
  enter() {
368
- if (o !== null && (a(o), o = null), c()) return;
368
+ if (o !== null && (i(o), o = null), c()) return;
369
369
  const l = ne(e.state);
370
370
  if (l) {
371
371
  n = l;
@@ -383,17 +383,17 @@ function Me(e, t = (n) => setTimeout(n, 0), a = (n) => clearTimeout(n)) {
383
383
  }));
384
384
  },
385
385
  handlePop() {
386
- return n === null || c() ? !1 : (n = null, o !== null && (a(o), o = null), !0);
386
+ return n === null || c() ? !1 : (n = null, o !== null && (i(o), o = null), !0);
387
387
  },
388
388
  isCurrent: c
389
389
  };
390
390
  }
391
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
392
  function je() {
393
- const e = () => typeof window < "u" && typeof window.matchMedia == "function" && !window.matchMedia(re).matches, [t, a] = _(e);
393
+ const e = () => typeof window < "u" && typeof window.matchMedia == "function" && !window.matchMedia(re).matches, [t, i] = _(e);
394
394
  return O(() => {
395
395
  if (typeof window > "u" || typeof window.matchMedia != "function") return;
396
- const n = window.matchMedia(re), o = () => a(!n.matches);
396
+ const n = window.matchMedia(re), o = () => i(!n.matches);
397
397
  return o(), n.addEventListener?.("change", o), () => n.removeEventListener?.("change", o);
398
398
  }, []), t;
399
399
  }
@@ -403,16 +403,16 @@ function K() {
403
403
  function Ye({
404
404
  controller: e,
405
405
  adapters: t,
406
- hostContext: a,
406
+ hostContext: i,
407
407
  scope: n,
408
408
  support: o,
409
409
  canvas: c,
410
410
  className: l,
411
411
  ariaLabel: d = "Ask CXO assistant"
412
412
  }) {
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);
413
+ const { open: f, surface: A, chatId: S, setChatId: C, close: P, collapse: L, reportSurface: x, reportSelectionSnapshot: T } = e, m = je(), b = G(null), y = f && m, [N, k] = _(f);
414
+ f && !N && k(!0);
415
+ const [z, W] = _(K), q = h(() => W(() => K()), []), [U, X] = _(e.workspaceEpoch);
416
416
  U !== e.workspaceEpoch && (X(e.workspaceEpoch), W(() => K()));
417
417
  const E = G({ surface: A, close: P, collapse: L, isSheet: m });
418
418
  he(() => {
@@ -421,30 +421,32 @@ function Ye({
421
421
  const H = Q(
422
422
  () => ({
423
423
  ...t,
424
+ ...t.integration ? { integration: { ...t.integration, active: f } } : {},
424
425
  navigation: { chatId: S, onChatIdChange: C },
425
426
  onClose: P,
426
427
  onSurfaceChange: x,
427
428
  onSelectionSnapshot: T,
428
- hostContext: a ?? null,
429
+ hostContext: i ?? null,
429
430
  scope: n ?? null,
430
431
  support: o ?? null,
431
432
  ...c ? { canvas: c } : {}
432
433
  }),
433
434
  [
434
435
  t,
436
+ f,
435
437
  S,
436
438
  C,
437
439
  P,
438
440
  x,
439
441
  T,
440
- a,
442
+ i,
441
443
  n,
442
444
  o,
443
445
  c
444
446
  ]
445
447
  );
446
448
  O(() => {
447
- if (!h) return;
449
+ if (!f) return;
448
450
  const u = (w) => {
449
451
  const I = We({
450
452
  event: w,
@@ -457,11 +459,11 @@ function Ye({
457
459
  I && (w.preventDefault(), I === "collapse" ? E.current.collapse() : E.current.close());
458
460
  };
459
461
  return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
460
- }, [h]);
462
+ }, [f]);
461
463
  const r = G(null);
462
464
  O(() => {
463
465
  const u = b.current;
464
- if (h) {
466
+ if (f) {
465
467
  const R = document.activeElement;
466
468
  R && R !== document.body && !u?.contains(R) && (r.current = R);
467
469
  return;
@@ -470,7 +472,7 @@ function Ye({
470
472
  r.current = null;
471
473
  const I = document.activeElement, M = !I || I === document.body || (u?.contains(I) ?? !1);
472
474
  w && M && w.isConnected && w.focus?.();
473
- }, [h]), O(() => {
475
+ }, [f]), O(() => {
474
476
  if (!y) return;
475
477
  const u = b.current;
476
478
  if (!u) return;
@@ -497,21 +499,21 @@ function Ye({
497
499
  });
498
500
  };
499
501
  }, [y]);
500
- const i = Q(
502
+ const a = Q(
501
503
  () => typeof window > "u" ? null : Me(window.history),
502
504
  []
503
505
  );
504
506
  O(() => {
505
- if (!y || !i) return;
506
- i.enter();
507
+ if (!y || !a) return;
508
+ a.enter();
507
509
  const u = () => {
508
- i.handlePop() && E.current.close();
510
+ a.handlePop() && E.current.close();
509
511
  };
510
512
  return window.addEventListener("popstate", u), () => {
511
- window.removeEventListener("popstate", u), i.leave();
513
+ window.removeEventListener("popstate", u), a.leave();
512
514
  };
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 } : {
515
+ }, [y, a]);
516
+ const p = A === "fullscreen", fe = f ? m ? { display: "flex", position: "fixed", inset: 0, zIndex: 50, width: "100%", height: "100%" } : p ? { display: "flex", position: "relative", flex: "1 1 0%", minWidth: 0, height: "100%", minHeight: 0 } : {
515
517
  display: "flex",
516
518
  position: "relative",
517
519
  flex: "0 0 auto",
@@ -524,7 +526,7 @@ function Ye({
524
526
  {
525
527
  ref: b,
526
528
  "aria-label": d,
527
- "aria-hidden": !h,
529
+ "aria-hidden": !f,
528
530
  ...y ? { role: "dialog", "aria-modal": !0 } : {},
529
531
  tabIndex: y ? -1 : void 0,
530
532
  "data-streamoid-agent": "pane",
@@ -536,11 +538,11 @@ function Ye({
536
538
  flexDirection: "column",
537
539
  boxSizing: "border-box",
538
540
  background: "var(--alias-surface-base)",
539
- borderRight: m || f ? void 0 : "1px solid var(--alias-border-subtle)",
541
+ borderRight: m || p ? void 0 : "1px solid var(--alias-border-subtle)",
540
542
  ...fe
541
543
  },
542
544
  children: N ? /* @__PURE__ */ oe(ve, { children: [
543
- !m && !f ? /* @__PURE__ */ g(
545
+ !m && !p ? /* @__PURE__ */ g(
544
546
  Ie,
545
547
  {
546
548
  width: e.width,