@burdenoff/fe-libs 2026.1113.1 → 2026.1113.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/shared/assistant/askAbout/AskAboutLayer.js +47 -47
  2. package/dist/shared/assistant/askAbout/askAboutStore.d.ts +7 -0
  3. package/dist/shared/assistant/askAbout/focus.js +1 -1
  4. package/dist/shared/assistant/askAbout/placement.d.ts +9 -0
  5. package/dist/shared/assistant/askAbout/placement.js +5 -1
  6. package/dist/shared/assistant/askAbout/useAskable.js +6 -5
  7. package/dist/shared/assistant/i18nManifest.d.ts +40 -0
  8. package/dist/shared/assistant/i18nManifest.js +40 -0
  9. package/dist/shared/proactive/ProactiveProvider.d.ts +67 -0
  10. package/dist/shared/proactive/ProactiveProvider.js +128 -0
  11. package/dist/shared/proactive/actions.d.ts +101 -0
  12. package/dist/shared/proactive/actions.js +71 -0
  13. package/dist/shared/proactive/activity.d.ts +27 -0
  14. package/dist/shared/proactive/activity.js +37 -0
  15. package/dist/shared/proactive/adapters.d.ts +54 -0
  16. package/dist/shared/proactive/adapters.js +62 -0
  17. package/dist/shared/proactive/anchors.d.ts +47 -0
  18. package/dist/shared/proactive/anchors.js +53 -0
  19. package/dist/shared/proactive/budget.d.ts +17 -0
  20. package/dist/shared/proactive/budget.js +30 -0
  21. package/dist/shared/proactive/capabilities.d.ts +26 -0
  22. package/dist/shared/proactive/capabilities.js +63 -0
  23. package/dist/shared/proactive/coalesce.d.ts +11 -0
  24. package/dist/shared/proactive/coalesce.js +15 -0
  25. package/dist/shared/proactive/context.d.ts +42 -0
  26. package/dist/shared/proactive/context.js +31 -0
  27. package/dist/shared/proactive/flags.d.ts +5 -0
  28. package/dist/shared/proactive/flags.js +11 -0
  29. package/dist/shared/proactive/index.d.ts +40 -0
  30. package/dist/shared/proactive/metadata.d.ts +48 -0
  31. package/dist/shared/proactive/metadata.js +126 -0
  32. package/dist/shared/proactive/operations.d.ts +96 -0
  33. package/dist/shared/proactive/operations.js +117 -0
  34. package/dist/shared/proactive/severityCopy.d.ts +4 -0
  35. package/dist/shared/proactive/severityCopy.js +10 -0
  36. package/dist/shared/proactive/snooze.d.ts +4 -0
  37. package/dist/shared/proactive/snooze.js +9 -0
  38. package/dist/shared/proactive/transport.d.ts +32 -0
  39. package/dist/shared/proactive/transport.js +124 -0
  40. package/dist/shared/proactive/types.d.ts +83 -0
  41. package/dist/shared/proactive/ui/ProactiveInbox.d.ts +20 -0
  42. package/dist/shared/proactive/ui/ProactiveInbox.js +78 -0
  43. package/dist/shared/proactive/ui/ProactiveSettingsPanel.d.ts +8 -0
  44. package/dist/shared/proactive/ui/ProactiveSettingsPanel.js +210 -0
  45. package/dist/shared/proactive/ui/SuggestionAnchorsLayer.d.ts +9 -0
  46. package/dist/shared/proactive/ui/SuggestionAnchorsLayer.js +140 -0
  47. package/dist/shared/proactive/ui/SuggestionBadge.d.ts +11 -0
  48. package/dist/shared/proactive/ui/SuggestionBadge.js +53 -0
  49. package/dist/shared/proactive/ui/SuggestionCard.d.ts +23 -0
  50. package/dist/shared/proactive/ui/SuggestionCard.js +119 -0
  51. package/dist/shared/proactive/ui/anchorLayerDom.d.ts +28 -0
  52. package/dist/shared/proactive/ui/anchorLayerDom.js +23 -0
  53. package/dist/shared/proactive/useProactiveSession.d.ts +56 -0
  54. package/dist/shared/proactive/useProactiveSession.js +150 -0
  55. package/dist/shared/proactive/useSuggestionControls.d.ts +25 -0
  56. package/dist/shared/proactive/useSuggestionControls.js +118 -0
  57. package/dist/shared-assistant.js +301 -301
  58. package/dist/shared-proactive.d.ts +2 -0
  59. package/dist/shared-proactive.js +21 -0
  60. package/package.json +5 -1
@@ -0,0 +1,28 @@
1
+ /**
2
+ * DOM helpers of the inline comment layer (BOFF-13165), kept apart from the
3
+ * component so the component file exports components only.
4
+ */
5
+ /** The marker on every element the proactive UI renders. */
6
+ export declare const PROACTIVE_UI_ATTRIBUTE = "data-proactive-ui";
7
+ export declare const OWN_SELECTOR = "[data-proactive-ui]";
8
+ /** Is `node` part of the proactive UI itself? */
9
+ export declare function isOwnProactiveNode(node: Node | null): boolean;
10
+ /** Does this batch of mutations touch anything but the proactive UI? */
11
+ export declare function mutationsConcernAnchors(records: readonly MutationRecord[]): boolean;
12
+ export interface PinPosition {
13
+ top: number;
14
+ left: number;
15
+ visible: boolean;
16
+ }
17
+ /** Where the badge goes for an anchor rectangle, or hidden when it is out of view. */
18
+ export declare function pinPositionFor(rect: {
19
+ top: number;
20
+ left: number;
21
+ right: number;
22
+ bottom: number;
23
+ width: number;
24
+ height: number;
25
+ }, viewport: {
26
+ width: number;
27
+ height: number;
28
+ }, rtl: boolean): PinPosition;
@@ -0,0 +1,23 @@
1
+ // src/shared/proactive/ui/anchorLayerDom.ts
2
+ var e = "data-proactive-ui", t = `[${e}]`, n = 10;
3
+ function r(e) {
4
+ if (!e || e.nodeType !== 1) return !1;
5
+ let t = e;
6
+ return t.closest("[data-proactive-ui]") !== null || t.querySelector("[data-proactive-ui]") !== null;
7
+ }
8
+ function i(e) {
9
+ return e.some((e) => {
10
+ if (e.type === "attributes") return !r(e.target);
11
+ let t = [...Array.from(e.addedNodes), ...Array.from(e.removedNodes)];
12
+ return t.length !== 0 && t.some((e) => e.nodeType === 1 && !r(e));
13
+ });
14
+ }
15
+ function a(e, t, r) {
16
+ let i = (e.width > 0 || e.height > 0) && e.bottom > 0 && e.right > 0 && e.top < t.height && e.left < t.width;
17
+ return {
18
+ top: Math.round(e.top - n),
19
+ left: Math.round(r ? e.left - n : e.right - n * 1.4),
20
+ visible: i
21
+ };
22
+ }
23
+ export { t as OWN_SELECTOR, e as PROACTIVE_UI_ATTRIBUTE, r as isOwnProactiveNode, i as mutationsConcernAnchors, a as pinPositionFor };
@@ -0,0 +1,56 @@
1
+ import { ProactiveTransport } from './transport';
2
+ import { ProactiveActivityEntity, ProactiveSettings, ProactiveStatus, ProactiveSuggestion } from './types';
3
+ /** How often the open entity and the active workspace are re-read. */
4
+ export declare const PAGE_POLL_MS = 1000;
5
+ export interface SessionState {
6
+ /** The product and workspace this state was loaded for; '' before anything loaded. */
7
+ key: string;
8
+ status: Exclude<ProactiveStatus, 'disabled'>;
9
+ settings: ProactiveSettings | null;
10
+ suggestions: readonly ProactiveSuggestion[];
11
+ /** The list has been read at least once for this session. */
12
+ listLoaded: boolean;
13
+ }
14
+ export declare const NO_SUGGESTIONS: readonly ProactiveSuggestion[];
15
+ /**
16
+ * The active workspace, followed while `active` (popstate plus a 1 s poll, the
17
+ * same router-agnostic pattern as `useAssistantPageLabel`).
18
+ */
19
+ export declare function useStoredWorkspaceId(active: boolean): string | null;
20
+ export interface ProactiveSessionOptions {
21
+ /** Flags on, a transport, and authentication ready. */
22
+ active: boolean;
23
+ product: string;
24
+ transport: ProactiveTransport | null;
25
+ }
26
+ export interface ProactiveSession {
27
+ /** Product and workspace, or null while inactive. */
28
+ sessionKey: string | null;
29
+ status: ProactiveStatus;
30
+ settings: ProactiveSettings | null;
31
+ /** Unordered, as loaded. */
32
+ suggestions: readonly ProactiveSuggestion[];
33
+ listLoaded: boolean;
34
+ /** Change the session's state (ignored once the session changed). */
35
+ update(patch: (base: SessionState) => Partial<SessionState>): void;
36
+ /** The backend does not know the proactive fields: off for this page. */
37
+ markUnsupported(): void;
38
+ reloadSettings(): void;
39
+ reloadList(): void;
40
+ }
41
+ export declare function useProactiveSession({ active, product, transport, }: ProactiveSessionOptions): ProactiveSession;
42
+ export interface ActivityReportingOptions {
43
+ /** The session is ready (opted in). Restarted per session key. */
44
+ enabled: boolean;
45
+ sessionKey: string | null;
46
+ product: string;
47
+ transport: ProactiveTransport | null;
48
+ /** The entity open now; read on every poll. */
49
+ readEntity: () => ProactiveActivityEntity | null;
50
+ }
51
+ /**
52
+ * Reports the session start and entity changes (`activity.ts`). Restarted per
53
+ * session (product and workspace), so each opted-in workspace gets its own
54
+ * session-start report and nothing is sent for one that is not.
55
+ */
56
+ export declare function useActivityReporting({ enabled, sessionKey, product, transport, readEntity, }: ActivityReportingOptions): void;
@@ -0,0 +1,150 @@
1
+ import { getStoredWorkspaceId as e } from "../graphql/fetch.js";
2
+ import { createActivityReporter as t } from "./activity.js";
3
+ import { isMissingAnyProactiveField as n, isMissingProactiveField as r, isProactiveUnsupported as i, markProactiveUnsupported as a, subscribeProactiveCapabilities as o } from "./capabilities.js";
4
+ import { createCoalescer as s } from "./coalesce.js";
5
+ import { parseProactiveSuggestions as c } from "./metadata.js";
6
+ import { useCallback as l, useEffect as u, useRef as d, useState as f, useSyncExternalStore as p } from "react";
7
+ // src/shared/proactive/useProactiveSession.ts
8
+ var m = 1e3, h = 300, g = 3e5, _ = [], v = {
9
+ key: "",
10
+ status: "loading",
11
+ settings: null,
12
+ suggestions: _,
13
+ listLoaded: !1
14
+ };
15
+ function y(t) {
16
+ let [n, r] = f(() => e());
17
+ return u(() => {
18
+ if (!t) return;
19
+ let n = () => r(e());
20
+ window.addEventListener("popstate", n);
21
+ let i = window.setInterval(n, m);
22
+ return () => {
23
+ window.removeEventListener("popstate", n), window.clearInterval(i);
24
+ };
25
+ }, [t]), n;
26
+ }
27
+ function b({ active: e, product: t, transport: r }) {
28
+ let d = y(e), m = e ? `${t}\u0000${d ?? ""}` : null, [b, x] = f(v), [S, C] = f(0), [w, T] = f(0), E = p(o, () => i(t), () => !1), D = m !== null && b.key === m ? b : null, O = m === null ? "disabled" : E ? "unsupported" : D?.status ?? "loading", k = l((e, t) => {
29
+ x((n) => {
30
+ let r = n.key === e ? n : {
31
+ ...v,
32
+ key: e
33
+ };
34
+ return {
35
+ ...r,
36
+ ...t(r)
37
+ };
38
+ });
39
+ }, []), A = l((e) => {
40
+ a(t), k(e, () => ({
41
+ status: "unsupported",
42
+ suggestions: _
43
+ }));
44
+ }, [t, k]);
45
+ u(() => {
46
+ if (m === null || !r || E) return;
47
+ let e = !1;
48
+ return r.getSettings(t).then((t) => {
49
+ e || k(m, () => ({
50
+ settings: t,
51
+ status: t.enabled ? "ready" : "opted-out",
52
+ ...t.enabled ? {} : { suggestions: _ }
53
+ }));
54
+ }).catch((t) => {
55
+ e || (n(t) ? A(m) : k(m, (e) => ({ status: e.status === "ready" ? "ready" : "error" })));
56
+ }), () => {
57
+ e = !0;
58
+ };
59
+ }, [
60
+ m,
61
+ t,
62
+ r,
63
+ E,
64
+ S,
65
+ k,
66
+ A
67
+ ]);
68
+ let j = O === "ready";
69
+ u(() => {
70
+ if (!j || m === null || !r) return;
71
+ let e = !1;
72
+ return r.listSuggestionRows(t).then((n) => {
73
+ e || k(m, () => ({
74
+ suggestions: c(n, t),
75
+ listLoaded: !0
76
+ }));
77
+ }).catch((t) => {
78
+ e || n(t) && A(m);
79
+ }), () => {
80
+ e = !0;
81
+ };
82
+ }, [
83
+ j,
84
+ m,
85
+ t,
86
+ r,
87
+ w,
88
+ k,
89
+ A
90
+ ]), u(() => {
91
+ if (!j || m === null || !r) return;
92
+ let e = m, i = s(() => T((e) => e + 1), h), a = r.watchSuggestions(t, i.schedule, (t) => {
93
+ n(t) && A(e);
94
+ }), o = window.setInterval(i.schedule, g), c = () => {
95
+ document.visibilityState === "visible" && i.schedule();
96
+ };
97
+ return document.addEventListener("visibilitychange", c), () => {
98
+ a(), window.clearInterval(o), document.removeEventListener("visibilitychange", c), i.cancel();
99
+ };
100
+ }, [
101
+ j,
102
+ m,
103
+ r,
104
+ t,
105
+ A
106
+ ]);
107
+ let M = l((e) => {
108
+ m !== null && k(m, e);
109
+ }, [m, k]), N = l(() => {
110
+ m !== null && A(m);
111
+ }, [m, A]), P = l(() => C((e) => e + 1), []), F = l(() => T((e) => e + 1), []);
112
+ return {
113
+ sessionKey: m,
114
+ status: O,
115
+ settings: D?.settings ?? null,
116
+ suggestions: D?.suggestions ?? _,
117
+ listLoaded: D?.listLoaded ?? !1,
118
+ update: M,
119
+ markUnsupported: N,
120
+ reloadSettings: P,
121
+ reloadList: F
122
+ };
123
+ }
124
+ function x({ enabled: e, sessionKey: n, product: i, transport: a, readEntity: o }) {
125
+ let s = d(o);
126
+ u(() => {
127
+ s.current = o;
128
+ }), u(() => {
129
+ if (!e || n === null || !a) return;
130
+ let o = t({
131
+ report: (e) => a.reportActivity(i, e),
132
+ onError: (e) => {
133
+ r(e, "reportProactiveActivity") && o.stop();
134
+ }
135
+ });
136
+ o.start(s.current());
137
+ let c = () => o.update(s.current());
138
+ window.addEventListener("popstate", c);
139
+ let l = window.setInterval(c, m);
140
+ return () => {
141
+ o.stop(), window.removeEventListener("popstate", c), window.clearInterval(l);
142
+ };
143
+ }, [
144
+ e,
145
+ n,
146
+ a,
147
+ i
148
+ ]);
149
+ }
150
+ export { _ as NO_SUGGESTIONS, m as PAGE_POLL_MS, x as useActivityReporting, b as useProactiveSession, y as useStoredWorkspaceId };
@@ -0,0 +1,25 @@
1
+ import { AssistantTr } from '../assistant/i18n';
2
+ import { BuiltInActionOptions, ProactiveActionHandler } from './actions';
3
+ import { SuggestionControls } from './adapters';
4
+ import { ProactiveSaveOutcome } from './context';
5
+ import { ProactiveTransport } from './transport';
6
+ import { ProactiveSettingsInput } from './types';
7
+ import { ProactiveSession } from './useProactiveSession';
8
+ export interface SuggestionControlsOptions {
9
+ product: string;
10
+ transport: ProactiveTransport | null;
11
+ session: ProactiveSession;
12
+ tr: AssistantTr;
13
+ actions: Readonly<Record<string, ProactiveActionHandler>> | undefined;
14
+ navigate: ((path: string) => void) | undefined;
15
+ isAllowedRoute: ((path: string) => boolean) | undefined;
16
+ reviewProposal: BuiltInActionOptions['reviewProposal'] | undefined;
17
+ openAssistant: ((prompt: string) => void) | undefined;
18
+ }
19
+ export declare function useSuggestionControls({ product, transport, session, tr, actions, navigate, isAllowedRoute, reviewProposal, openAssistant, }: SuggestionControlsOptions): SuggestionControls;
20
+ /**
21
+ * Stores the opt-in (contract C5 `setMyProactiveSettings`). When the
22
+ * orchestrator cannot store a frequency yet, the opt-in alone is saved and the
23
+ * outcome says so.
24
+ */
25
+ export declare function useSaveSettings(product: string, transport: ProactiveTransport | null, session: ProactiveSession): (input: ProactiveSettingsInput) => Promise<ProactiveSaveOutcome>;
@@ -0,0 +1,118 @@
1
+ import { useAssistantStore as e } from "../assistant/store.js";
2
+ import { useAssistantOverlayOrNull as t } from "../assistant/ui/AssistantOverlay.js";
3
+ import { isSafeInAppPath as n, navigateInApp as r } from "../navigation/inAppPath.js";
4
+ import { createBuiltInActions as i, mergeActionRegistries as a, offeredActions as o, runProactiveAction as s } from "./actions.js";
5
+ import { isMissingProactiveField as c, isPreferencesUnavailableError as l } from "./capabilities.js";
6
+ import { snoozeUntil as u } from "./snooze.js";
7
+ import { NO_SUGGESTIONS as d } from "./useProactiveSession.js";
8
+ import { useCallback as f, useMemo as p, useState as m } from "react";
9
+ // src/shared/proactive/useSuggestionControls.ts
10
+ function h(n) {
11
+ let r = t(), i = f((t) => n ? (n(t), !0) : r ? (r.openFull(), e.getState().submitPrompt(t), !0) : !1, [n, r]);
12
+ return n !== void 0 || r !== null ? i : null;
13
+ }
14
+ function g({ product: e, transport: t, session: l, tr: d, actions: g, navigate: _, isAllowedRoute: v, reviewProposal: y, openAssistant: b }) {
15
+ let [x, S] = m(!0), C = h(b), { update: w } = l, T = f((e) => !n(e) || v && !v(e) ? !1 : _ ? (_(e), !0) : r(e), [_, v]), E = p(() => {
16
+ let e = i({
17
+ ...v ? { isAllowedRoute: v } : {},
18
+ ...y ? { reviewProposal: y } : {},
19
+ canOpenAssistant: C !== null,
20
+ defaultAssistantPrompt: (e) => d("proactive.assistantPrompt", "Help me with this AI suggestion about {{entityType}} {{entityId}}: \"{{title}}\". {{why}}", {
21
+ entityType: e.anchor.entityType,
22
+ entityId: e.anchor.entityId,
23
+ title: e.title,
24
+ why: e.why
25
+ })
26
+ });
27
+ return a(e, g);
28
+ }, [
29
+ g,
30
+ v,
31
+ y,
32
+ C,
33
+ d
34
+ ]), D = f((e) => w((t) => ({ suggestions: e(t.suggestions) })), [w]);
35
+ return p(() => {
36
+ let n = (e) => D((t) => t.filter((t) => t.notificationId !== e.notificationId)), r = (e) => D((t) => t.some((t) => t.notificationId === e.notificationId) ? t : [...t, e]);
37
+ return {
38
+ tr: d,
39
+ canSnooze: x,
40
+ offeredActions: (e) => o(e, E),
41
+ runAction: (t, n) => s(E, {
42
+ product: e,
43
+ suggestion: t,
44
+ action: n,
45
+ navigate: T,
46
+ openInAssistant: (e) => C?.(e) ?? !1
47
+ }),
48
+ dismiss: async (e) => {
49
+ if (!t) return !1;
50
+ n(e);
51
+ try {
52
+ return await t.dismiss(e.notificationId), !0;
53
+ } catch {
54
+ return r(e), !1;
55
+ }
56
+ },
57
+ snooze: async (e, i) => {
58
+ if (!t || !x) return !1;
59
+ n(e);
60
+ try {
61
+ return await t.snooze(e.notificationId, u(i)), !0;
62
+ } catch (t) {
63
+ return c(t, "snoozeNotification") && S(!1), r(e), !1;
64
+ }
65
+ },
66
+ markSeen: (e) => {
67
+ t && !e.isRead && (D((t) => t.map((t) => t.notificationId === e.notificationId ? {
68
+ ...t,
69
+ isRead: !0
70
+ } : t)), t.markRead(e.notificationId).catch(() => {}));
71
+ }
72
+ };
73
+ }, [
74
+ d,
75
+ x,
76
+ E,
77
+ e,
78
+ T,
79
+ C,
80
+ t,
81
+ D
82
+ ]);
83
+ }
84
+ function _(e, t, n) {
85
+ let { sessionKey: r, status: i, update: a, markUnsupported: o, reloadList: s } = n;
86
+ return f(async (n) => {
87
+ if (!t || r === null || i === "unsupported") return { status: "unavailable" };
88
+ let u = (e, t) => (a(() => ({
89
+ settings: e,
90
+ status: e.enabled ? "ready" : "opted-out",
91
+ ...e.enabled ? {} : { suggestions: d }
92
+ })), e.enabled && s(), {
93
+ status: "saved",
94
+ settings: e,
95
+ frequencyUnavailable: t
96
+ });
97
+ try {
98
+ return u(await t.setSettings(e, n), !1);
99
+ } catch (r) {
100
+ if (c(r, "setMyProactiveSettings")) return o(), { status: "unavailable" };
101
+ if (n.frequency !== void 0 && l(r)) try {
102
+ return u(await t.setSettings(e, { enabled: n.enabled }), !0);
103
+ } catch {
104
+ return { status: "failed" };
105
+ }
106
+ return { status: "failed" };
107
+ }
108
+ }, [
109
+ e,
110
+ t,
111
+ r,
112
+ i,
113
+ a,
114
+ o,
115
+ s
116
+ ]);
117
+ }
118
+ export { _ as useSaveSettings, g as useSuggestionControls };