@streamoid/agent 0.6.53 → 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.
- package/README.md +124 -0
- package/dist/agentScope-BlOT7qMu.js +114 -0
- package/dist/index.d.ts +133 -0
- package/dist/index.js +2449 -2536
- package/dist/pane.d.ts +73 -0
- package/dist/pane.js +585 -0
- package/package.json +5 -1
package/dist/pane.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
AgentPaneController,
|
|
4
|
+
AgentPaneControllerOptions,
|
|
5
|
+
AgentScopeSection,
|
|
6
|
+
AgentScopeSelection,
|
|
7
|
+
AgentScopeSuggestion,
|
|
8
|
+
AgentSidePaneProps,
|
|
9
|
+
} from './index';
|
|
10
|
+
|
|
11
|
+
/* `@streamoid/agent/pane` — the shared Ask CXO side pane.
|
|
12
|
+
*
|
|
13
|
+
* Hand-maintained like `index.d.ts` (and copied beside it by `build:lib`). The
|
|
14
|
+
* types are declared in `index.d.ts`; this file declares the VALUES the
|
|
15
|
+
* `./pane` subpath exports, and re-exports the types for convenience. Keep it
|
|
16
|
+
* in step with `src/embed/pane/index.ts` — the publish workflow fails on a
|
|
17
|
+
* value export missing here. */
|
|
18
|
+
|
|
19
|
+
export type {
|
|
20
|
+
AgentPaneController,
|
|
21
|
+
AgentPaneControllerOptions,
|
|
22
|
+
AgentPaneSupportOptions,
|
|
23
|
+
AgentPaneSurface,
|
|
24
|
+
AgentSidePaneAdapters,
|
|
25
|
+
AgentSidePaneProps,
|
|
26
|
+
} from './index';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The Ask CXO pane's state, owned by the host shell. Persists the open state
|
|
30
|
+
* and the conversation per workspace, binds ⌘K (unless `bindShortcut: false`),
|
|
31
|
+
* and reaches the chat only through a lazy `import()`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useAgentPaneController(
|
|
34
|
+
options: AgentPaneControllerOptions,
|
|
35
|
+
): AgentPaneController;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The pane itself: docked beside the page (resizable) from 768px, a
|
|
39
|
+
* full-screen dialog sheet below it (focus trap, siblings inert, Escape and
|
|
40
|
+
* the Back button close it), fullscreen when an artefact asks. Stays mounted
|
|
41
|
+
* after the first open; wraps the lazy `AgentPanel` in an error boundary with
|
|
42
|
+
* a Retry.
|
|
43
|
+
*/
|
|
44
|
+
export declare function AgentSidePane(props: AgentSidePaneProps): ReactElement;
|
|
45
|
+
|
|
46
|
+
/** `(min-width: 768px)` — docked at and above, the sheet below. */
|
|
47
|
+
export declare const AGENT_PANE_DOCKED_MEDIA_QUERY: string;
|
|
48
|
+
/** `streamoid.askPane.width` */
|
|
49
|
+
export declare const AGENT_PANE_WIDTH_KEY: string;
|
|
50
|
+
/** `streamoid.askPane.session` */
|
|
51
|
+
export declare const DEFAULT_PANE_PERSIST_KEY: string;
|
|
52
|
+
/** Warm the agent chunk without a controller. */
|
|
53
|
+
export declare function prefetchAgent(): void;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The pane's own suggestion rule: one card per section of the outcome table,
|
|
57
|
+
* about the selection where an outcome runs on its kind, else about the
|
|
58
|
+
* section's first runnable sample. The same function the pane renders from,
|
|
59
|
+
* so a host that plans its table around the row (Artifax splits a tool page's
|
|
60
|
+
* table to fill three cards) needs no hand copy. Pass
|
|
61
|
+
* `controller.selectionSnapshot`, not the live selection.
|
|
62
|
+
*/
|
|
63
|
+
export declare function deriveScopeSuggestions(
|
|
64
|
+
sections: readonly AgentScopeSection[] | null | undefined,
|
|
65
|
+
selection: AgentScopeSelection | null | undefined,
|
|
66
|
+
): AgentScopeSuggestion[];
|
|
67
|
+
|
|
68
|
+
/** `deriveScopeSuggestions(sections, selection).length` — how many cards the
|
|
69
|
+
* pane draws before the first turn. */
|
|
70
|
+
export declare function paneSuggestionCount(
|
|
71
|
+
sections: readonly AgentScopeSection[] | null | undefined,
|
|
72
|
+
selection: AgentScopeSelection | null | undefined,
|
|
73
|
+
): number;
|
package/dist/pane.js
ADDED
|
@@ -0,0 +1,585 @@
|
|
|
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
|
+
return import("./index.js");
|
|
7
|
+
}
|
|
8
|
+
function te() {
|
|
9
|
+
j().catch(() => {
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const Ae = "streamoid.askPane.session", D = { open: !1, chatId: null };
|
|
13
|
+
function ae(e, t) {
|
|
14
|
+
return `${e}:${t}`;
|
|
15
|
+
}
|
|
16
|
+
function ie() {
|
|
17
|
+
try {
|
|
18
|
+
return typeof window > "u" ? null : window.localStorage;
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function Ce(e, t) {
|
|
24
|
+
if (!t) return D;
|
|
25
|
+
const a = ie();
|
|
26
|
+
if (!a) return D;
|
|
27
|
+
try {
|
|
28
|
+
const n = a.getItem(ae(e, t));
|
|
29
|
+
if (!n) return D;
|
|
30
|
+
const o = JSON.parse(n);
|
|
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
|
+
} catch {
|
|
35
|
+
return D;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function Pe(e, t, a) {
|
|
39
|
+
if (!t) return;
|
|
40
|
+
const n = ie();
|
|
41
|
+
if (!n) return;
|
|
42
|
+
const o = ae(e, t);
|
|
43
|
+
try {
|
|
44
|
+
if (a.surface === "closed") {
|
|
45
|
+
n.removeItem(o);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
n.setItem(o, JSON.stringify({ surface: "rail", chatId: a.chatId }));
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
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
|
+
}
|
|
56
|
+
function xe(e, t) {
|
|
57
|
+
return e.surface === "closed" ? e : {
|
|
58
|
+
surface: "pane",
|
|
59
|
+
declinedPanelId: t?.activePanel?.id ?? null
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function le(e, t = null) {
|
|
63
|
+
if (e.surface !== "closed") return e;
|
|
64
|
+
const a = { surface: "pane", declinedPanelId: e.declinedPanelId };
|
|
65
|
+
return t ? se(a, t) : a;
|
|
66
|
+
}
|
|
67
|
+
function ue(e) {
|
|
68
|
+
return e.surface === "closed" ? e : { surface: "closed", declinedPanelId: e.declinedPanelId };
|
|
69
|
+
}
|
|
70
|
+
function ke(e, t = null) {
|
|
71
|
+
return e.surface === "closed" ? le(e, t) : ue(e);
|
|
72
|
+
}
|
|
73
|
+
const Y = "streamoid.askPane.width";
|
|
74
|
+
function Re(e, t = De()) {
|
|
75
|
+
if (!t || !e) return !1;
|
|
76
|
+
const a = typeof e == "string" ? [e] : e;
|
|
77
|
+
try {
|
|
78
|
+
if (t.getItem(Y) !== null) return !1;
|
|
79
|
+
for (const n of a) {
|
|
80
|
+
if (!n || n === Y) continue;
|
|
81
|
+
const o = t.getItem(n);
|
|
82
|
+
if (o === null) continue;
|
|
83
|
+
const c = Number.parseInt(o, 10);
|
|
84
|
+
if (Number.isFinite(c))
|
|
85
|
+
return t.setItem(Y, String(c)), !0;
|
|
86
|
+
}
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
return !1;
|
|
90
|
+
}
|
|
91
|
+
function De() {
|
|
92
|
+
try {
|
|
93
|
+
return typeof window > "u" ? null : window.localStorage;
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function J(e, t, a = 0) {
|
|
99
|
+
const n = Ce(e, t);
|
|
100
|
+
return {
|
|
101
|
+
workspaceId: t,
|
|
102
|
+
memory: n.open ? Z : ce,
|
|
103
|
+
chatId: n.chatId,
|
|
104
|
+
selectionSnapshot: null,
|
|
105
|
+
epoch: a,
|
|
106
|
+
lastReport: null
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function $e({
|
|
110
|
+
workspaceId: e,
|
|
111
|
+
persistKey: t = Ae,
|
|
112
|
+
legacyWidthKey: a,
|
|
113
|
+
bindShortcut: n = !0
|
|
114
|
+
}) {
|
|
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
|
+
} else
|
|
122
|
+
d = J(t, o, c.epoch + 1);
|
|
123
|
+
l(d);
|
|
124
|
+
}
|
|
125
|
+
O(() => {
|
|
126
|
+
Pe(t, d.workspaceId, {
|
|
127
|
+
surface: d.memory.surface,
|
|
128
|
+
chatId: d.chatId
|
|
129
|
+
});
|
|
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 };
|
|
135
|
+
}),
|
|
136
|
+
[]
|
|
137
|
+
), A = p(
|
|
138
|
+
(r) => l((i) => i.chatId === r ? i : { ...i, chatId: r }),
|
|
139
|
+
[]
|
|
140
|
+
), S = p(
|
|
141
|
+
(r) => l((i) => {
|
|
142
|
+
const f = r(i);
|
|
143
|
+
return f === i.memory ? i : { ...i, memory: f };
|
|
144
|
+
}),
|
|
145
|
+
[]
|
|
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
|
+
...r,
|
|
155
|
+
chatId: null,
|
|
156
|
+
lastReport: null,
|
|
157
|
+
memory: r.memory.surface === "closed" ? Z : r.memory
|
|
158
|
+
})),
|
|
159
|
+
[]
|
|
160
|
+
), T = p(
|
|
161
|
+
(r) => l((i) => {
|
|
162
|
+
const f = se(i.memory, r);
|
|
163
|
+
return { ...i, lastReport: r, memory: f };
|
|
164
|
+
}),
|
|
165
|
+
[]
|
|
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
|
+
});
|
|
172
|
+
}, [C]), y = p(
|
|
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 });
|
|
177
|
+
}).catch(() => {
|
|
178
|
+
}), !0) : !1;
|
|
179
|
+
},
|
|
180
|
+
[x]
|
|
181
|
+
), N = p(
|
|
182
|
+
(r) => {
|
|
183
|
+
x(), j().then((i) => {
|
|
184
|
+
i.showAgentSupport(r ?? null);
|
|
185
|
+
}).catch(() => {
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
[x]
|
|
189
|
+
);
|
|
190
|
+
Se({
|
|
191
|
+
onTrigger: () => {
|
|
192
|
+
te(), b();
|
|
193
|
+
},
|
|
194
|
+
enabled: n
|
|
195
|
+
}), _(() => Re(a));
|
|
196
|
+
const k = Ee, { width: z, setWidth: W, commitWidth: q } = ye({
|
|
197
|
+
storageKey: Y,
|
|
198
|
+
defaultWidth: we,
|
|
199
|
+
min: k.min,
|
|
200
|
+
max: k.max
|
|
201
|
+
}), U = p(
|
|
202
|
+
(r) => l(
|
|
203
|
+
(i) => i.selectionSnapshot === (r ?? null) ? i : { ...i, selectionSnapshot: r ?? null }
|
|
204
|
+
),
|
|
205
|
+
[]
|
|
206
|
+
), X = d.selectionSnapshot, E = d.epoch, H = d.memory.surface;
|
|
207
|
+
return Q(
|
|
208
|
+
() => ({
|
|
209
|
+
open: H !== "closed",
|
|
210
|
+
surface: H,
|
|
211
|
+
chatId: d.chatId,
|
|
212
|
+
reveal: C,
|
|
213
|
+
close: P,
|
|
214
|
+
toggle: L,
|
|
215
|
+
askCxo: b,
|
|
216
|
+
askAbout: y,
|
|
217
|
+
requestSupport: N,
|
|
218
|
+
prefetch: te,
|
|
219
|
+
width: z,
|
|
220
|
+
setWidth: W,
|
|
221
|
+
commitWidth: q,
|
|
222
|
+
bounds: k,
|
|
223
|
+
selectionSnapshot: X,
|
|
224
|
+
workspaceEpoch: E,
|
|
225
|
+
setChatId: A,
|
|
226
|
+
reportSurface: T,
|
|
227
|
+
collapse: m,
|
|
228
|
+
reportSelectionSnapshot: U
|
|
229
|
+
}),
|
|
230
|
+
[
|
|
231
|
+
H,
|
|
232
|
+
d.chatId,
|
|
233
|
+
C,
|
|
234
|
+
P,
|
|
235
|
+
L,
|
|
236
|
+
b,
|
|
237
|
+
y,
|
|
238
|
+
N,
|
|
239
|
+
z,
|
|
240
|
+
W,
|
|
241
|
+
q,
|
|
242
|
+
k,
|
|
243
|
+
X,
|
|
244
|
+
E,
|
|
245
|
+
A,
|
|
246
|
+
T,
|
|
247
|
+
m,
|
|
248
|
+
U
|
|
249
|
+
]
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
class Oe extends pe {
|
|
253
|
+
state = { error: null };
|
|
254
|
+
static getDerivedStateFromError(t) {
|
|
255
|
+
return { error: t ?? new Error("Ask CXO failed to load") };
|
|
256
|
+
}
|
|
257
|
+
componentDidCatch(t) {
|
|
258
|
+
typeof console < "u" && console.error("[streamoid-agent] Ask CXO pane failed:", t);
|
|
259
|
+
}
|
|
260
|
+
retry = () => {
|
|
261
|
+
this.setState({ error: null }), this.props.onRetry();
|
|
262
|
+
};
|
|
263
|
+
render() {
|
|
264
|
+
return this.state.error === null ? this.props.children : /* @__PURE__ */ oe(
|
|
265
|
+
"div",
|
|
266
|
+
{
|
|
267
|
+
role: "alert",
|
|
268
|
+
"data-testid": "agent-pane-error",
|
|
269
|
+
style: {
|
|
270
|
+
display: "flex",
|
|
271
|
+
flex: 1,
|
|
272
|
+
flexDirection: "column",
|
|
273
|
+
alignItems: "center",
|
|
274
|
+
justifyContent: "center",
|
|
275
|
+
gap: 12,
|
|
276
|
+
padding: 24,
|
|
277
|
+
textAlign: "center",
|
|
278
|
+
fontSize: 14,
|
|
279
|
+
color: "var(--alias-text---icons-secondary, currentColor)"
|
|
280
|
+
},
|
|
281
|
+
children: [
|
|
282
|
+
/* @__PURE__ */ g("span", { children: "Ask CXO couldn’t load." }),
|
|
283
|
+
/* @__PURE__ */ g(
|
|
284
|
+
"button",
|
|
285
|
+
{
|
|
286
|
+
type: "button",
|
|
287
|
+
onClick: this.retry,
|
|
288
|
+
"data-testid": "agent-pane-retry",
|
|
289
|
+
style: {
|
|
290
|
+
font: "inherit",
|
|
291
|
+
padding: "6px 14px",
|
|
292
|
+
borderRadius: 8,
|
|
293
|
+
border: "1px solid var(--alias-border-subtle, currentColor)",
|
|
294
|
+
background: "transparent",
|
|
295
|
+
color: "var(--alias-text---icons-primary, currentColor)",
|
|
296
|
+
cursor: "pointer"
|
|
297
|
+
},
|
|
298
|
+
children: "Retry"
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function _e() {
|
|
307
|
+
return /* @__PURE__ */ g(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
role: "status",
|
|
311
|
+
"aria-live": "polite",
|
|
312
|
+
"data-testid": "agent-pane-loading",
|
|
313
|
+
style: {
|
|
314
|
+
display: "flex",
|
|
315
|
+
flex: 1,
|
|
316
|
+
alignItems: "center",
|
|
317
|
+
justifyContent: "center",
|
|
318
|
+
padding: 24,
|
|
319
|
+
fontSize: 13,
|
|
320
|
+
color: "var(--alias-text---icons-secondary, currentColor)"
|
|
321
|
+
},
|
|
322
|
+
children: "Loading Ask CXO…"
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
}
|
|
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;
|
|
329
|
+
return n !== null && n !== t;
|
|
330
|
+
}
|
|
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)))
|
|
335
|
+
return !0;
|
|
336
|
+
return !1;
|
|
337
|
+
}
|
|
338
|
+
function Ne(e, t) {
|
|
339
|
+
if (e.closest("[hidden]")) return !0;
|
|
340
|
+
const a = t.defaultView?.getComputedStyle?.(e);
|
|
341
|
+
return !!a && (a.display === "none" || a.visibility === "hidden");
|
|
342
|
+
}
|
|
343
|
+
function We({
|
|
344
|
+
event: e,
|
|
345
|
+
pane: t,
|
|
346
|
+
active: a,
|
|
347
|
+
doc: n,
|
|
348
|
+
surface: o,
|
|
349
|
+
isSheet: c
|
|
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";
|
|
352
|
+
}
|
|
353
|
+
function V(e) {
|
|
354
|
+
return typeof e == "object" && e !== null && e.nodeType === 1 && typeof e.closest == "function";
|
|
355
|
+
}
|
|
356
|
+
const de = "__streamoidAskPane";
|
|
357
|
+
let He = 0;
|
|
358
|
+
function ne(e) {
|
|
359
|
+
if (!e || typeof e != "object") return null;
|
|
360
|
+
const t = e[de];
|
|
361
|
+
return typeof t == "string" ? t : null;
|
|
362
|
+
}
|
|
363
|
+
function Me(e, t = (n) => setTimeout(n, 0), a = (n) => clearTimeout(n)) {
|
|
364
|
+
let n = null, o = null;
|
|
365
|
+
const c = () => n !== null && ne(e.state) === n;
|
|
366
|
+
return {
|
|
367
|
+
enter() {
|
|
368
|
+
if (o !== null && (a(o), o = null), c()) return;
|
|
369
|
+
const l = ne(e.state);
|
|
370
|
+
if (l) {
|
|
371
|
+
n = l;
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
n = `pane-${Date.now().toString(36)}-${He += 1}`;
|
|
375
|
+
const d = e.state && typeof e.state == "object" ? e.state : {};
|
|
376
|
+
e.pushState({ ...d, [de]: n }, "");
|
|
377
|
+
},
|
|
378
|
+
leave() {
|
|
379
|
+
n === null || o !== null || (o = t(() => {
|
|
380
|
+
o = null;
|
|
381
|
+
const l = c();
|
|
382
|
+
n = null, l && e.back();
|
|
383
|
+
}));
|
|
384
|
+
},
|
|
385
|
+
handlePop() {
|
|
386
|
+
return n === null || c() ? !1 : (n = null, o !== null && (a(o), o = null), !0);
|
|
387
|
+
},
|
|
388
|
+
isCurrent: c
|
|
389
|
+
};
|
|
390
|
+
}
|
|
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(() => {
|
|
395
|
+
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
396
|
+
const n = window.matchMedia(re), o = () => a(!n.matches);
|
|
397
|
+
return o(), n.addEventListener?.("change", o), () => n.removeEventListener?.("change", o);
|
|
398
|
+
}, []), t;
|
|
399
|
+
}
|
|
400
|
+
function K() {
|
|
401
|
+
return ge(() => j().then((e) => ({ default: e.AgentPanel })));
|
|
402
|
+
}
|
|
403
|
+
function Ye({
|
|
404
|
+
controller: e,
|
|
405
|
+
adapters: t,
|
|
406
|
+
hostContext: a,
|
|
407
|
+
scope: n,
|
|
408
|
+
support: o,
|
|
409
|
+
canvas: c,
|
|
410
|
+
className: l,
|
|
411
|
+
ariaLabel: d = "Ask CXO assistant"
|
|
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);
|
|
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 };
|
|
420
|
+
});
|
|
421
|
+
const H = Q(
|
|
422
|
+
() => ({
|
|
423
|
+
...t,
|
|
424
|
+
navigation: { chatId: S, onChatIdChange: C },
|
|
425
|
+
onClose: P,
|
|
426
|
+
onSurfaceChange: x,
|
|
427
|
+
onSelectionSnapshot: T,
|
|
428
|
+
hostContext: a ?? null,
|
|
429
|
+
scope: n ?? null,
|
|
430
|
+
support: o ?? null,
|
|
431
|
+
...c ? { canvas: c } : {}
|
|
432
|
+
}),
|
|
433
|
+
[
|
|
434
|
+
t,
|
|
435
|
+
S,
|
|
436
|
+
C,
|
|
437
|
+
P,
|
|
438
|
+
x,
|
|
439
|
+
T,
|
|
440
|
+
a,
|
|
441
|
+
n,
|
|
442
|
+
o,
|
|
443
|
+
c
|
|
444
|
+
]
|
|
445
|
+
);
|
|
446
|
+
O(() => {
|
|
447
|
+
if (!h) return;
|
|
448
|
+
const u = (w) => {
|
|
449
|
+
const I = We({
|
|
450
|
+
event: w,
|
|
451
|
+
pane: b.current,
|
|
452
|
+
active: document.activeElement,
|
|
453
|
+
doc: document,
|
|
454
|
+
surface: E.current.surface,
|
|
455
|
+
isSheet: E.current.isSheet
|
|
456
|
+
});
|
|
457
|
+
I && (w.preventDefault(), I === "collapse" ? E.current.collapse() : E.current.close());
|
|
458
|
+
};
|
|
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);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
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;
|
|
477
|
+
const w = () => {
|
|
478
|
+
const s = Array.from(u.querySelectorAll(Fe)), v = s.filter((F) => F.getClientRects().length > 0);
|
|
479
|
+
return v.length > 0 ? v : s;
|
|
480
|
+
};
|
|
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;
|
|
484
|
+
const v = w();
|
|
485
|
+
if (v.length === 0) {
|
|
486
|
+
s.preventDefault(), u.focus?.();
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
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");
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
}, [y]);
|
|
500
|
+
const i = Q(
|
|
501
|
+
() => typeof window > "u" ? null : Me(window.history),
|
|
502
|
+
[]
|
|
503
|
+
);
|
|
504
|
+
O(() => {
|
|
505
|
+
if (!y || !i) return;
|
|
506
|
+
i.enter();
|
|
507
|
+
const u = () => {
|
|
508
|
+
i.handlePop() && E.current.close();
|
|
509
|
+
};
|
|
510
|
+
return window.addEventListener("popstate", u), () => {
|
|
511
|
+
window.removeEventListener("popstate", u), i.leave();
|
|
512
|
+
};
|
|
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
|
+
display: "flex",
|
|
516
|
+
position: "relative",
|
|
517
|
+
flex: "0 0 auto",
|
|
518
|
+
width: `${e.width}px`,
|
|
519
|
+
height: "100%",
|
|
520
|
+
minHeight: 0
|
|
521
|
+
} : { display: "none" };
|
|
522
|
+
return /* @__PURE__ */ g(
|
|
523
|
+
"aside",
|
|
524
|
+
{
|
|
525
|
+
ref: b,
|
|
526
|
+
"aria-label": d,
|
|
527
|
+
"aria-hidden": !h,
|
|
528
|
+
...y ? { role: "dialog", "aria-modal": !0 } : {},
|
|
529
|
+
tabIndex: y ? -1 : void 0,
|
|
530
|
+
"data-streamoid-agent": "pane",
|
|
531
|
+
"data-surface": A,
|
|
532
|
+
"data-layout": m ? "sheet" : "docked",
|
|
533
|
+
"data-testid": "agent-side-pane",
|
|
534
|
+
className: l,
|
|
535
|
+
style: {
|
|
536
|
+
flexDirection: "column",
|
|
537
|
+
boxSizing: "border-box",
|
|
538
|
+
background: "var(--alias-surface-base)",
|
|
539
|
+
borderRight: m || f ? void 0 : "1px solid var(--alias-border-subtle)",
|
|
540
|
+
...fe
|
|
541
|
+
},
|
|
542
|
+
children: N ? /* @__PURE__ */ oe(ve, { children: [
|
|
543
|
+
!m && !f ? /* @__PURE__ */ g(
|
|
544
|
+
Ie,
|
|
545
|
+
{
|
|
546
|
+
width: e.width,
|
|
547
|
+
onWidthChange: e.setWidth,
|
|
548
|
+
onWidthCommit: e.commitWidth,
|
|
549
|
+
min: e.bounds.min,
|
|
550
|
+
max: e.bounds.max,
|
|
551
|
+
edge: "right",
|
|
552
|
+
ariaLabel: "Resize Ask CXO"
|
|
553
|
+
}
|
|
554
|
+
) : null,
|
|
555
|
+
/* @__PURE__ */ g(
|
|
556
|
+
"div",
|
|
557
|
+
{
|
|
558
|
+
style: {
|
|
559
|
+
display: "flex",
|
|
560
|
+
flexDirection: "column",
|
|
561
|
+
flex: 1,
|
|
562
|
+
minHeight: 0,
|
|
563
|
+
minWidth: 0,
|
|
564
|
+
overflow: "hidden"
|
|
565
|
+
},
|
|
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)
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
] }) : null
|
|
570
|
+
}
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
function Be(e, t) {
|
|
574
|
+
return be(e, t).length;
|
|
575
|
+
}
|
|
576
|
+
export {
|
|
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
|
|
585
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamoid/agent",
|
|
3
|
-
"version": "0.6.
|
|
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",
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./pane": {
|
|
15
|
+
"types": "./dist/pane.d.ts",
|
|
16
|
+
"import": "./dist/pane.js"
|
|
17
|
+
},
|
|
14
18
|
"./style.css": "./dist/style.css"
|
|
15
19
|
},
|
|
16
20
|
"files": [
|