@streamoid/agent 0.6.52 → 0.6.54
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 +131 -4
- package/dist/agentScope-BlOT7qMu.js +114 -0
- package/dist/index.d.ts +195 -13
- package/dist/index.js +17773 -17733
- package/dist/pane.d.ts +73 -0
- package/dist/pane.js +581 -0
- package/dist/style.css +1 -1
- 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,581 @@
|
|
|
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() {
|
|
6
|
+
return import("./index.js");
|
|
7
|
+
}
|
|
8
|
+
function Z() {
|
|
9
|
+
M().catch(() => {
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const ve = "streamoid.askPane.session", O = { open: !1, chatId: null };
|
|
13
|
+
function oe(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 be(e, t) {
|
|
24
|
+
if (!t) return O;
|
|
25
|
+
const i = ie();
|
|
26
|
+
if (!i) return O;
|
|
27
|
+
try {
|
|
28
|
+
const n = i.getItem(oe(e, t));
|
|
29
|
+
if (!n) return O;
|
|
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 };
|
|
34
|
+
} catch {
|
|
35
|
+
return O;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function Ae(e, t, i) {
|
|
39
|
+
if (!t) return;
|
|
40
|
+
const n = ie();
|
|
41
|
+
if (!n) return;
|
|
42
|
+
const o = oe(e, t);
|
|
43
|
+
try {
|
|
44
|
+
if (i.surface === "closed") {
|
|
45
|
+
n.removeItem(o);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
n.setItem(o, JSON.stringify({ surface: "pane", chatId: i.chatId }));
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
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 };
|
|
55
|
+
}
|
|
56
|
+
function Ce(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 i = { surface: "pane", declinedPanelId: e.declinedPanelId };
|
|
65
|
+
return t ? ce(i, t) : i;
|
|
66
|
+
}
|
|
67
|
+
function se(e) {
|
|
68
|
+
return e.surface === "closed" ? e : { surface: "closed", declinedPanelId: e.declinedPanelId };
|
|
69
|
+
}
|
|
70
|
+
function Pe(e, t = null) {
|
|
71
|
+
return e.surface === "closed" ? le(e, t) : se(e);
|
|
72
|
+
}
|
|
73
|
+
const $ = "streamoid.askPane.width";
|
|
74
|
+
function xe(e, t = ke()) {
|
|
75
|
+
if (!t || !e) return !1;
|
|
76
|
+
const i = typeof e == "string" ? [e] : e;
|
|
77
|
+
try {
|
|
78
|
+
if (t.getItem($) !== null) return !1;
|
|
79
|
+
for (const n of i) {
|
|
80
|
+
if (!n || n === $) continue;
|
|
81
|
+
const o = t.getItem(n);
|
|
82
|
+
if (o === null) continue;
|
|
83
|
+
const l = Number.parseInt(o, 10);
|
|
84
|
+
if (Number.isFinite(l))
|
|
85
|
+
return t.setItem($, String(l)), !0;
|
|
86
|
+
}
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
return !1;
|
|
90
|
+
}
|
|
91
|
+
function ke() {
|
|
92
|
+
try {
|
|
93
|
+
return typeof window > "u" ? null : window.localStorage;
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function G(e, t, i = 0) {
|
|
99
|
+
const n = be(e, t);
|
|
100
|
+
return {
|
|
101
|
+
workspaceId: t,
|
|
102
|
+
memory: n.open ? Q : ae,
|
|
103
|
+
chatId: n.chatId,
|
|
104
|
+
selectionSnapshot: null,
|
|
105
|
+
epoch: i,
|
|
106
|
+
lastReport: null
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function Ue({
|
|
110
|
+
workspaceId: e,
|
|
111
|
+
persistKey: t = ve,
|
|
112
|
+
legacyWidthKey: i,
|
|
113
|
+
bindShortcut: n = !0
|
|
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 };
|
|
121
|
+
} else
|
|
122
|
+
d = G(t, o, l.epoch + 1);
|
|
123
|
+
u(d);
|
|
124
|
+
}
|
|
125
|
+
_(() => {
|
|
126
|
+
Ae(t, d.workspaceId, {
|
|
127
|
+
surface: d.memory.surface,
|
|
128
|
+
chatId: d.chatId
|
|
129
|
+
});
|
|
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 };
|
|
135
|
+
}),
|
|
136
|
+
[]
|
|
137
|
+
), A = f(
|
|
138
|
+
(r) => u((c) => c.chatId === r ? c : { ...c, chatId: r }),
|
|
139
|
+
[]
|
|
140
|
+
), g = f(
|
|
141
|
+
(r) => u((c) => {
|
|
142
|
+
const a = r(c);
|
|
143
|
+
return a === c.memory ? c : { ...c, memory: a };
|
|
144
|
+
}),
|
|
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) => ({
|
|
154
|
+
...r,
|
|
155
|
+
chatId: null,
|
|
156
|
+
lastReport: null,
|
|
157
|
+
memory: r.memory.surface === "closed" ? Q : r.memory
|
|
158
|
+
})),
|
|
159
|
+
[]
|
|
160
|
+
), T = f(
|
|
161
|
+
(r) => u((c) => {
|
|
162
|
+
const a = ce(c.memory, r);
|
|
163
|
+
return { ...c, lastReport: r, memory: a };
|
|
164
|
+
}),
|
|
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(() => {
|
|
171
|
+
});
|
|
172
|
+
}, [C]), S = f(
|
|
173
|
+
(r) => {
|
|
174
|
+
const c = typeof r == "string" ? r.trim() : "";
|
|
175
|
+
return c ? (x(), M().then((a) => a.enqueueChatPrompt({ prompt: c, forceNewConversation: !0 })).catch(() => {
|
|
176
|
+
}), !0) : !1;
|
|
177
|
+
},
|
|
178
|
+
[x]
|
|
179
|
+
), N = f(
|
|
180
|
+
(r) => {
|
|
181
|
+
x(), M().then((c) => {
|
|
182
|
+
c.showAgentSupport(r ?? null);
|
|
183
|
+
}).catch(() => {
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
[x]
|
|
187
|
+
);
|
|
188
|
+
me({
|
|
189
|
+
onTrigger: () => {
|
|
190
|
+
Z(), b();
|
|
191
|
+
},
|
|
192
|
+
enabled: n
|
|
193
|
+
}), F(() => xe(i));
|
|
194
|
+
const k = Se, { width: j, setWidth: z, commitWidth: q } = ge({
|
|
195
|
+
storageKey: $,
|
|
196
|
+
defaultWidth: ye,
|
|
197
|
+
min: k.min,
|
|
198
|
+
max: k.max
|
|
199
|
+
}), y = f(
|
|
200
|
+
(r) => u(
|
|
201
|
+
(c) => c.selectionSnapshot === (r ?? null) ? c : { ...c, selectionSnapshot: r ?? null }
|
|
202
|
+
),
|
|
203
|
+
[]
|
|
204
|
+
), U = d.selectionSnapshot, R = d.epoch, I = d.memory.surface;
|
|
205
|
+
return J(
|
|
206
|
+
() => ({
|
|
207
|
+
open: I !== "closed",
|
|
208
|
+
surface: I,
|
|
209
|
+
chatId: d.chatId,
|
|
210
|
+
reveal: C,
|
|
211
|
+
close: P,
|
|
212
|
+
toggle: L,
|
|
213
|
+
askCxo: b,
|
|
214
|
+
askAbout: S,
|
|
215
|
+
requestSupport: N,
|
|
216
|
+
prefetch: Z,
|
|
217
|
+
width: j,
|
|
218
|
+
setWidth: z,
|
|
219
|
+
commitWidth: q,
|
|
220
|
+
bounds: k,
|
|
221
|
+
selectionSnapshot: U,
|
|
222
|
+
workspaceEpoch: R,
|
|
223
|
+
setChatId: A,
|
|
224
|
+
reportSurface: T,
|
|
225
|
+
collapse: h,
|
|
226
|
+
reportSelectionSnapshot: y
|
|
227
|
+
}),
|
|
228
|
+
[
|
|
229
|
+
I,
|
|
230
|
+
d.chatId,
|
|
231
|
+
C,
|
|
232
|
+
P,
|
|
233
|
+
L,
|
|
234
|
+
b,
|
|
235
|
+
S,
|
|
236
|
+
N,
|
|
237
|
+
j,
|
|
238
|
+
z,
|
|
239
|
+
q,
|
|
240
|
+
k,
|
|
241
|
+
U,
|
|
242
|
+
R,
|
|
243
|
+
A,
|
|
244
|
+
T,
|
|
245
|
+
h,
|
|
246
|
+
y
|
|
247
|
+
]
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
class Re extends de {
|
|
251
|
+
state = { error: null };
|
|
252
|
+
static getDerivedStateFromError(t) {
|
|
253
|
+
return { error: t ?? new Error("Ask CXO failed to load") };
|
|
254
|
+
}
|
|
255
|
+
componentDidCatch(t) {
|
|
256
|
+
typeof console < "u" && console.error("[streamoid-agent] Ask CXO pane failed:", t);
|
|
257
|
+
}
|
|
258
|
+
retry = () => {
|
|
259
|
+
this.setState({ error: null }), this.props.onRetry();
|
|
260
|
+
};
|
|
261
|
+
render() {
|
|
262
|
+
return this.state.error === null ? this.props.children : /* @__PURE__ */ re(
|
|
263
|
+
"div",
|
|
264
|
+
{
|
|
265
|
+
role: "alert",
|
|
266
|
+
"data-testid": "agent-pane-error",
|
|
267
|
+
style: {
|
|
268
|
+
display: "flex",
|
|
269
|
+
flex: 1,
|
|
270
|
+
flexDirection: "column",
|
|
271
|
+
alignItems: "center",
|
|
272
|
+
justifyContent: "center",
|
|
273
|
+
gap: 12,
|
|
274
|
+
padding: 24,
|
|
275
|
+
textAlign: "center",
|
|
276
|
+
fontSize: 14,
|
|
277
|
+
color: "var(--alias-text---icons-secondary, currentColor)"
|
|
278
|
+
},
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ m("span", { children: "Ask CXO couldn’t load." }),
|
|
281
|
+
/* @__PURE__ */ m(
|
|
282
|
+
"button",
|
|
283
|
+
{
|
|
284
|
+
type: "button",
|
|
285
|
+
onClick: this.retry,
|
|
286
|
+
"data-testid": "agent-pane-retry",
|
|
287
|
+
style: {
|
|
288
|
+
font: "inherit",
|
|
289
|
+
padding: "6px 14px",
|
|
290
|
+
borderRadius: 8,
|
|
291
|
+
border: "1px solid var(--alias-border-subtle, currentColor)",
|
|
292
|
+
background: "transparent",
|
|
293
|
+
color: "var(--alias-text---icons-primary, currentColor)",
|
|
294
|
+
cursor: "pointer"
|
|
295
|
+
},
|
|
296
|
+
children: "Retry"
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function De() {
|
|
305
|
+
return /* @__PURE__ */ m(
|
|
306
|
+
"div",
|
|
307
|
+
{
|
|
308
|
+
role: "status",
|
|
309
|
+
"aria-live": "polite",
|
|
310
|
+
"data-testid": "agent-pane-loading",
|
|
311
|
+
style: {
|
|
312
|
+
display: "flex",
|
|
313
|
+
flex: 1,
|
|
314
|
+
alignItems: "center",
|
|
315
|
+
justifyContent: "center",
|
|
316
|
+
padding: 24,
|
|
317
|
+
fontSize: 13,
|
|
318
|
+
color: "var(--alias-text---icons-secondary, currentColor)"
|
|
319
|
+
},
|
|
320
|
+
children: "Loading Ask CXO…"
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
}
|
|
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;
|
|
327
|
+
return n !== null && n !== t;
|
|
328
|
+
}
|
|
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)))
|
|
333
|
+
return !0;
|
|
334
|
+
return !1;
|
|
335
|
+
}
|
|
336
|
+
function Le(e, t) {
|
|
337
|
+
if (e.closest("[hidden]")) return !0;
|
|
338
|
+
const i = t.defaultView?.getComputedStyle?.(e);
|
|
339
|
+
return !!i && (i.display === "none" || i.visibility === "hidden");
|
|
340
|
+
}
|
|
341
|
+
function Te({
|
|
342
|
+
event: e,
|
|
343
|
+
pane: t,
|
|
344
|
+
active: i,
|
|
345
|
+
doc: n,
|
|
346
|
+
surface: o,
|
|
347
|
+
isSheet: l
|
|
348
|
+
}) {
|
|
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";
|
|
350
|
+
}
|
|
351
|
+
function K(e) {
|
|
352
|
+
return typeof e == "object" && e !== null && e.nodeType === 1 && typeof e.closest == "function";
|
|
353
|
+
}
|
|
354
|
+
const ue = "__streamoidAskPane";
|
|
355
|
+
let Ne = 0;
|
|
356
|
+
function ee(e) {
|
|
357
|
+
if (!e || typeof e != "object") return null;
|
|
358
|
+
const t = e[ue];
|
|
359
|
+
return typeof t == "string" ? t : null;
|
|
360
|
+
}
|
|
361
|
+
function We(e, t = (n) => setTimeout(n, 0), i = (n) => clearTimeout(n)) {
|
|
362
|
+
let n = null, o = null;
|
|
363
|
+
const l = () => n !== null && ee(e.state) === n;
|
|
364
|
+
return {
|
|
365
|
+
enter() {
|
|
366
|
+
if (o !== null && (i(o), o = null), l()) return;
|
|
367
|
+
const u = ee(e.state);
|
|
368
|
+
if (u) {
|
|
369
|
+
n = u;
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
n = `pane-${Date.now().toString(36)}-${Ne += 1}`;
|
|
373
|
+
const d = e.state && typeof e.state == "object" ? e.state : {};
|
|
374
|
+
e.pushState({ ...d, [ue]: n }, "");
|
|
375
|
+
},
|
|
376
|
+
leave() {
|
|
377
|
+
n === null || o !== null || (o = t(() => {
|
|
378
|
+
o = null;
|
|
379
|
+
const u = l();
|
|
380
|
+
n = null, u && e.back();
|
|
381
|
+
}));
|
|
382
|
+
},
|
|
383
|
+
handlePop() {
|
|
384
|
+
return n === null || l() ? !1 : (n = null, o !== null && (i(o), o = null), !0);
|
|
385
|
+
},
|
|
386
|
+
isCurrent: l
|
|
387
|
+
};
|
|
388
|
+
}
|
|
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 _(() => {
|
|
393
|
+
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
394
|
+
const n = window.matchMedia(te), o = () => i(!n.matches);
|
|
395
|
+
return o(), n.addEventListener?.("change", o), () => n.removeEventListener?.("change", o);
|
|
396
|
+
}, []), t;
|
|
397
|
+
}
|
|
398
|
+
function ne() {
|
|
399
|
+
return he(() => M().then((e) => ({ default: e.AgentPanel })));
|
|
400
|
+
}
|
|
401
|
+
function Xe({
|
|
402
|
+
controller: e,
|
|
403
|
+
adapters: t,
|
|
404
|
+
hostContext: i,
|
|
405
|
+
scope: n,
|
|
406
|
+
support: o,
|
|
407
|
+
canvas: l,
|
|
408
|
+
className: u,
|
|
409
|
+
ariaLabel: d = "Ask CXO assistant"
|
|
410
|
+
}) {
|
|
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 };
|
|
416
|
+
});
|
|
417
|
+
const U = J(
|
|
418
|
+
() => ({
|
|
419
|
+
...t,
|
|
420
|
+
navigation: { chatId: g, onChatIdChange: C },
|
|
421
|
+
onClose: P,
|
|
422
|
+
onSurfaceChange: x,
|
|
423
|
+
onSelectionSnapshot: T,
|
|
424
|
+
hostContext: i ?? null,
|
|
425
|
+
scope: n ?? null,
|
|
426
|
+
support: o ?? null,
|
|
427
|
+
...l ? { canvas: l } : {}
|
|
428
|
+
}),
|
|
429
|
+
[
|
|
430
|
+
t,
|
|
431
|
+
g,
|
|
432
|
+
C,
|
|
433
|
+
P,
|
|
434
|
+
x,
|
|
435
|
+
T,
|
|
436
|
+
i,
|
|
437
|
+
n,
|
|
438
|
+
o,
|
|
439
|
+
l
|
|
440
|
+
]
|
|
441
|
+
);
|
|
442
|
+
_(() => {
|
|
443
|
+
if (!p) return;
|
|
444
|
+
const a = (w) => {
|
|
445
|
+
const E = Te({
|
|
446
|
+
event: w,
|
|
447
|
+
pane: b.current,
|
|
448
|
+
active: document.activeElement,
|
|
449
|
+
doc: document,
|
|
450
|
+
surface: y.current.surface,
|
|
451
|
+
isSheet: y.current.isSheet
|
|
452
|
+
});
|
|
453
|
+
E && (w.preventDefault(), E === "collapse" ? y.current.collapse() : y.current.close());
|
|
454
|
+
};
|
|
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);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
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;
|
|
473
|
+
const w = () => {
|
|
474
|
+
const s = Array.from(a.querySelectorAll(He)), v = s.filter((H) => H.getClientRects().length > 0);
|
|
475
|
+
return v.length > 0 ? v : s;
|
|
476
|
+
};
|
|
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;
|
|
480
|
+
const v = w();
|
|
481
|
+
if (v.length === 0) {
|
|
482
|
+
s.preventDefault(), a.focus?.();
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
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");
|
|
493
|
+
});
|
|
494
|
+
};
|
|
495
|
+
}, [S]);
|
|
496
|
+
const I = J(
|
|
497
|
+
() => typeof window > "u" ? null : We(window.history),
|
|
498
|
+
[]
|
|
499
|
+
);
|
|
500
|
+
_(() => {
|
|
501
|
+
if (!S || !I) return;
|
|
502
|
+
I.enter();
|
|
503
|
+
const a = () => {
|
|
504
|
+
I.handlePop() && y.current.close();
|
|
505
|
+
};
|
|
506
|
+
return window.addEventListener("popstate", a), () => {
|
|
507
|
+
window.removeEventListener("popstate", a), I.leave();
|
|
508
|
+
};
|
|
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 } : {
|
|
511
|
+
display: "flex",
|
|
512
|
+
position: "relative",
|
|
513
|
+
flex: "0 0 auto",
|
|
514
|
+
width: `${e.width}px`,
|
|
515
|
+
height: "100%",
|
|
516
|
+
minHeight: 0
|
|
517
|
+
} : { display: "none" };
|
|
518
|
+
return /* @__PURE__ */ m(
|
|
519
|
+
"aside",
|
|
520
|
+
{
|
|
521
|
+
ref: b,
|
|
522
|
+
"aria-label": d,
|
|
523
|
+
"aria-hidden": !p,
|
|
524
|
+
...S ? { role: "dialog", "aria-modal": !0 } : {},
|
|
525
|
+
tabIndex: S ? -1 : void 0,
|
|
526
|
+
"data-streamoid-agent": "pane",
|
|
527
|
+
"data-surface": A,
|
|
528
|
+
"data-layout": h ? "sheet" : "docked",
|
|
529
|
+
"data-testid": "agent-side-pane",
|
|
530
|
+
className: u,
|
|
531
|
+
style: {
|
|
532
|
+
flexDirection: "column",
|
|
533
|
+
boxSizing: "border-box",
|
|
534
|
+
background: "var(--alias-surface-base)",
|
|
535
|
+
borderRight: h || r ? void 0 : "1px solid var(--alias-border-subtle)",
|
|
536
|
+
...c
|
|
537
|
+
},
|
|
538
|
+
children: N ? /* @__PURE__ */ re(we, { children: [
|
|
539
|
+
!h && !r ? /* @__PURE__ */ m(
|
|
540
|
+
Ie,
|
|
541
|
+
{
|
|
542
|
+
width: e.width,
|
|
543
|
+
onWidthChange: e.setWidth,
|
|
544
|
+
onWidthCommit: e.commitWidth,
|
|
545
|
+
min: e.bounds.min,
|
|
546
|
+
max: e.bounds.max,
|
|
547
|
+
edge: "right",
|
|
548
|
+
ariaLabel: "Resize Ask CXO"
|
|
549
|
+
}
|
|
550
|
+
) : null,
|
|
551
|
+
/* @__PURE__ */ m(
|
|
552
|
+
"div",
|
|
553
|
+
{
|
|
554
|
+
style: {
|
|
555
|
+
display: "flex",
|
|
556
|
+
flexDirection: "column",
|
|
557
|
+
flex: 1,
|
|
558
|
+
minHeight: 0,
|
|
559
|
+
minWidth: 0,
|
|
560
|
+
overflow: "hidden"
|
|
561
|
+
},
|
|
562
|
+
children: /* @__PURE__ */ m(Re, { onRetry: q, children: /* @__PURE__ */ m(pe, { fallback: /* @__PURE__ */ m(De, {}), children: /* @__PURE__ */ m(j, { adapters: U }, e.workspaceEpoch) }) })
|
|
563
|
+
}
|
|
564
|
+
)
|
|
565
|
+
] }) : null
|
|
566
|
+
}
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
function $e(e, t) {
|
|
570
|
+
return Ee(e, t).length;
|
|
571
|
+
}
|
|
572
|
+
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
|
|
581
|
+
};
|