@40rty/ams-ui 0.3.0 → 0.3.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/agent.js +8 -6
- package/dist/chunk-BFZ3YCUY.js +163 -0
- package/dist/{chunk-54QPRWEG.js → chunk-OKP7MC72.js} +89 -281
- package/dist/chunk-QXCHHCPU.js +58 -0
- package/dist/chunk-TEPH476O.js +218 -0
- package/dist/css/shell/spacefront-island.css +30 -13
- package/dist/css/shell/spacefront-presence.css +222 -0
- package/dist/css/shell/spacefront-thread-panel.css +255 -0
- package/dist/index.js +6 -4
- package/dist/island.js +13 -3
- package/dist/presence.js +134 -0
- package/dist/shell.js +305 -451
- package/dist/thread-panel.js +238 -0
- package/dist/types/presence/index.d.ts +1 -0
- package/dist/types/shell/PresenceActivity.d.ts +22 -0
- package/dist/types/shell/SideDock.d.ts +3 -2
- package/dist/types/shell/SpacefrontIsland.d.ts +5 -1
- package/dist/types/shell/SpacefrontPresence.d.ts +25 -0
- package/dist/types/shell/SpacefrontThreadPanel.d.ts +45 -0
- package/dist/types/shell/ThreadPanelConversation.d.ts +14 -0
- package/dist/types/shell/host-shell-store.d.ts +35 -0
- package/dist/types/thread-panel/index.d.ts +1 -0
- package/package.json +12 -2
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
<SpacefrontThreadPanel /> — the chat side panel for a host-owned page.
|
|
3
|
+
Published as `@40rty/ams-ui/thread-panel.css`. Same contract as
|
|
4
|
+
`island.css`: plain CSS, UNLAYERED, every element reset by
|
|
5
|
+
`.fourty-tp :is(…)` (0,1,1) and every rule `.fourty-tp .fourty-tp__x`
|
|
6
|
+
(0,2,0), so a host's `form button { width: 100% }` cannot reach it.
|
|
7
|
+
|
|
8
|
+
Themed through the SHARED shell tokens (see `island.css`):
|
|
9
|
+
--fourty-surface (#fff) --fourty-fg (#111) --fourty-accent (fg)
|
|
10
|
+
--fourty-accent-fg (surface) --fourty-radius (16px)
|
|
11
|
+
--fourty-font-family (inherit)
|
|
12
|
+
…and the panel's own placement properties:
|
|
13
|
+
--fourty-panel-offset-top (0) clears a host header
|
|
14
|
+
--fourty-panel-offset-bottom (0) clears a host bottom bar
|
|
15
|
+
--fourty-panel-inset-right (0) docks it beside a host's own right column
|
|
16
|
+
--fourty-panel-z-index (45) above the island (40)
|
|
17
|
+
--fourty-panel-edge (1px hairline of fg on the left edge)
|
|
18
|
+
--fourty-panel-error (#b42318)
|
|
19
|
+
The panel sets `--fourty-thread-panel-inset` on <html> (its width while
|
|
20
|
+
docked open on desktop, else 0px) for the host's canvas to pad by.
|
|
21
|
+
============================================================================ */
|
|
22
|
+
|
|
23
|
+
.fourty-tp {
|
|
24
|
+
--_surface: var(--fourty-surface, #fff);
|
|
25
|
+
--_fg: var(--fourty-fg, #111);
|
|
26
|
+
--_accent: var(--fourty-accent, var(--_fg));
|
|
27
|
+
--_accent-fg: var(--fourty-accent-fg, var(--_surface));
|
|
28
|
+
--_radius: var(--fourty-radius, 16px);
|
|
29
|
+
--_ease: cubic-bezier(0.22, 1, 0.36, 1);
|
|
30
|
+
position: fixed;
|
|
31
|
+
top: var(--fourty-panel-offset-top, 0);
|
|
32
|
+
bottom: var(--fourty-panel-offset-bottom, 0);
|
|
33
|
+
right: var(--fourty-panel-inset-right, 0);
|
|
34
|
+
z-index: var(--fourty-panel-z-index, 45);
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
font-family: var(--fourty-font-family, inherit);
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
line-height: 1.45;
|
|
40
|
+
color: var(--_fg);
|
|
41
|
+
text-align: left;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* The reset — the host's element globals stop here. */
|
|
45
|
+
.fourty-tp :is(div, p, form, button, input, svg, section, header, h2) {
|
|
46
|
+
all: unset;
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
}
|
|
49
|
+
.fourty-tp :focus-visible {
|
|
50
|
+
outline: 2px solid var(--_accent);
|
|
51
|
+
outline-offset: 2px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* The tab — the collapsed panel, on the right edge. */
|
|
55
|
+
.fourty-tp .fourty-tp__tab {
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 50%;
|
|
58
|
+
right: 0;
|
|
59
|
+
transform: translateY(-50%);
|
|
60
|
+
writing-mode: vertical-rl;
|
|
61
|
+
padding: 18px 10px;
|
|
62
|
+
border-radius: var(--_radius) 0 0 var(--_radius);
|
|
63
|
+
background: var(--_fg);
|
|
64
|
+
color: var(--_surface);
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
letter-spacing: 0.04em;
|
|
67
|
+
box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--_fg) 30%, transparent);
|
|
68
|
+
pointer-events: auto;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
animation: fourty-tp-in 220ms var(--_ease);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.fourty-tp .fourty-tp__panel {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
height: 100%;
|
|
77
|
+
background: var(--_surface);
|
|
78
|
+
box-shadow: var(--fourty-panel-edge, -1px 0 0 color-mix(in srgb, var(--_fg) 14%, transparent));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.fourty-tp .fourty-tp__head {
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: space-between;
|
|
85
|
+
gap: 8px;
|
|
86
|
+
padding: 14px 12px 8px 16px;
|
|
87
|
+
}
|
|
88
|
+
.fourty-tp .fourty-tp__title {
|
|
89
|
+
display: block;
|
|
90
|
+
font-size: 15px;
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
}
|
|
93
|
+
.fourty-tp .fourty-tp__close {
|
|
94
|
+
display: grid;
|
|
95
|
+
place-items: center;
|
|
96
|
+
width: 32px;
|
|
97
|
+
height: 32px;
|
|
98
|
+
border-radius: 999px;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
transition: background-color 150ms ease;
|
|
101
|
+
}
|
|
102
|
+
.fourty-tp .fourty-tp__close svg {
|
|
103
|
+
display: block;
|
|
104
|
+
width: 16px;
|
|
105
|
+
height: 16px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Where <SpacefrontPresence /> attaches while the panel is open. */
|
|
109
|
+
.fourty-tp .fourty-tp__presence {
|
|
110
|
+
display: block;
|
|
111
|
+
padding: 0 12px 8px;
|
|
112
|
+
}
|
|
113
|
+
.fourty-tp .fourty-tp__presence:empty {
|
|
114
|
+
display: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.fourty-tp .fourty-tp__thread {
|
|
118
|
+
display: flex;
|
|
119
|
+
flex: 1 1 auto;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
gap: 18px;
|
|
122
|
+
min-height: 0;
|
|
123
|
+
overflow-y: auto;
|
|
124
|
+
overscroll-behavior: contain;
|
|
125
|
+
padding: 8px 16px 16px;
|
|
126
|
+
}
|
|
127
|
+
.fourty-tp .fourty-tp__turn {
|
|
128
|
+
display: grid;
|
|
129
|
+
gap: 8px;
|
|
130
|
+
}
|
|
131
|
+
.fourty-tp .fourty-tp__asked {
|
|
132
|
+
display: block;
|
|
133
|
+
justify-self: end;
|
|
134
|
+
max-width: 85%;
|
|
135
|
+
padding: 8px 12px;
|
|
136
|
+
border-radius: calc(var(--_radius) * 0.75);
|
|
137
|
+
background: color-mix(in srgb, var(--_fg) 7%, var(--_surface));
|
|
138
|
+
}
|
|
139
|
+
.fourty-tp .fourty-tp__answer {
|
|
140
|
+
display: block;
|
|
141
|
+
line-height: 1.55;
|
|
142
|
+
}
|
|
143
|
+
.fourty-tp .fourty-tp__muted {
|
|
144
|
+
display: block;
|
|
145
|
+
color: color-mix(in srgb, var(--_fg) 60%, transparent);
|
|
146
|
+
}
|
|
147
|
+
.fourty-tp .fourty-tp__error {
|
|
148
|
+
display: block;
|
|
149
|
+
color: var(--fourty-panel-error, #b42318);
|
|
150
|
+
}
|
|
151
|
+
.fourty-tp .fourty-tp__working {
|
|
152
|
+
display: block;
|
|
153
|
+
color: transparent;
|
|
154
|
+
background: linear-gradient(100deg,
|
|
155
|
+
color-mix(in srgb, var(--_fg) 45%, transparent) 40%,
|
|
156
|
+
var(--_fg) 50%,
|
|
157
|
+
color-mix(in srgb, var(--_fg) 45%, transparent) 60%) 0 0 / 250% 100%;
|
|
158
|
+
-webkit-background-clip: text;
|
|
159
|
+
background-clip: text;
|
|
160
|
+
animation: fourty-tp-shimmer 1.6s linear infinite;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.fourty-tp .fourty-tp__chips {
|
|
164
|
+
display: flex;
|
|
165
|
+
flex-wrap: wrap;
|
|
166
|
+
gap: 8px;
|
|
167
|
+
padding: 0 16px 10px;
|
|
168
|
+
}
|
|
169
|
+
.fourty-tp .fourty-tp__chip {
|
|
170
|
+
padding: 4px 14px;
|
|
171
|
+
border: 1px solid color-mix(in srgb, var(--_fg) 24%, transparent);
|
|
172
|
+
border-radius: 999px;
|
|
173
|
+
background: var(--_surface);
|
|
174
|
+
cursor: pointer;
|
|
175
|
+
transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.fourty-tp .fourty-tp__face {
|
|
179
|
+
display: flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
gap: 8px;
|
|
182
|
+
margin: 0 12px 12px;
|
|
183
|
+
padding: 6px 6px 6px 12px;
|
|
184
|
+
border-radius: var(--_radius);
|
|
185
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--_fg) 18%, transparent);
|
|
186
|
+
}
|
|
187
|
+
.fourty-tp .fourty-tp__field {
|
|
188
|
+
flex: 1 1 auto;
|
|
189
|
+
min-width: 0;
|
|
190
|
+
margin: 0;
|
|
191
|
+
border: 0;
|
|
192
|
+
background: transparent;
|
|
193
|
+
padding: 8px 0;
|
|
194
|
+
font-size: 16px; /* under 16px iOS zooms the page on focus */
|
|
195
|
+
cursor: text;
|
|
196
|
+
}
|
|
197
|
+
.fourty-tp .fourty-tp__field::placeholder {
|
|
198
|
+
color: color-mix(in srgb, var(--_fg) 52%, transparent);
|
|
199
|
+
opacity: 1;
|
|
200
|
+
}
|
|
201
|
+
.fourty-tp .fourty-tp__stamp {
|
|
202
|
+
display: grid;
|
|
203
|
+
place-items: center;
|
|
204
|
+
flex: 0 0 34px;
|
|
205
|
+
width: 34px;
|
|
206
|
+
height: 34px;
|
|
207
|
+
border-radius: 999px;
|
|
208
|
+
background: var(--_fg);
|
|
209
|
+
color: var(--_surface);
|
|
210
|
+
cursor: pointer;
|
|
211
|
+
transition: background-color 150ms ease, color 150ms ease, opacity 150ms ease;
|
|
212
|
+
}
|
|
213
|
+
.fourty-tp .fourty-tp__stamp svg {
|
|
214
|
+
display: block;
|
|
215
|
+
width: 16px;
|
|
216
|
+
height: 16px;
|
|
217
|
+
}
|
|
218
|
+
.fourty-tp .fourty-tp__stamp:disabled {
|
|
219
|
+
opacity: 0.4;
|
|
220
|
+
cursor: default;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@media (hover: hover) {
|
|
224
|
+
.fourty-tp .fourty-tp__chip:hover,
|
|
225
|
+
.fourty-tp .fourty-tp__stamp:not(:disabled):hover {
|
|
226
|
+
background: var(--_accent);
|
|
227
|
+
color: var(--_accent-fg);
|
|
228
|
+
border-color: var(--_accent);
|
|
229
|
+
}
|
|
230
|
+
.fourty-tp .fourty-tp__close:hover {
|
|
231
|
+
background: color-mix(in srgb, var(--_fg) 8%, transparent);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@keyframes fourty-tp-in {
|
|
236
|
+
from { opacity: 0; }
|
|
237
|
+
}
|
|
238
|
+
@keyframes fourty-tp-shimmer {
|
|
239
|
+
to { background-position: -150% 0; }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@media (prefers-reduced-motion: reduce) {
|
|
243
|
+
.fourty-tp .fourty-tp__tab,
|
|
244
|
+
.fourty-tp .fourty-tp__working {
|
|
245
|
+
animation: none;
|
|
246
|
+
}
|
|
247
|
+
.fourty-tp .fourty-tp__working {
|
|
248
|
+
color: color-mix(in srgb, var(--_fg) 55%, transparent);
|
|
249
|
+
}
|
|
250
|
+
.fourty-tp .fourty-tp__close,
|
|
251
|
+
.fourty-tp .fourty-tp__chip,
|
|
252
|
+
.fourty-tp .fourty-tp__stamp {
|
|
253
|
+
transition: none;
|
|
254
|
+
}
|
|
255
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -38,13 +38,15 @@ import {
|
|
|
38
38
|
Thought,
|
|
39
39
|
colorSwatch,
|
|
40
40
|
presenceClass,
|
|
41
|
-
readFacts,
|
|
42
|
-
readLabel,
|
|
43
41
|
registerDefaultPresenceForms,
|
|
44
42
|
useLabels,
|
|
45
|
-
useMeasuredHeight
|
|
43
|
+
useMeasuredHeight
|
|
44
|
+
} from "./chunk-OKP7MC72.js";
|
|
45
|
+
import {
|
|
46
|
+
readFacts,
|
|
47
|
+
readLabel,
|
|
46
48
|
useVisibleFacts
|
|
47
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-TEPH476O.js";
|
|
48
50
|
import {
|
|
49
51
|
AnimatePresence,
|
|
50
52
|
Reveal,
|
package/dist/island.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import {
|
|
3
|
+
stopHostKeys,
|
|
4
|
+
useHostShell,
|
|
5
|
+
useIslandSlot,
|
|
6
|
+
useRegisterIsland
|
|
7
|
+
} from "./chunk-QXCHHCPU.js";
|
|
2
8
|
|
|
3
9
|
// src/shell/SpacefrontIsland.tsx
|
|
4
10
|
import * as React from "react";
|
|
@@ -24,6 +30,10 @@ function SpacefrontIsland({
|
|
|
24
30
|
const [threadOpen, setThreadOpen] = React.useState(false);
|
|
25
31
|
const [folded, setFolded] = React.useState(false);
|
|
26
32
|
const rootRef = React.useRef(null);
|
|
33
|
+
const [presenceSlot, setPresenceSlot] = React.useState(null);
|
|
34
|
+
useRegisterIsland();
|
|
35
|
+
useIslandSlot(presenceSlot);
|
|
36
|
+
const { panelSlot } = useHostShell();
|
|
27
37
|
React.useEffect(() => {
|
|
28
38
|
let last = window.scrollY;
|
|
29
39
|
const onScroll = () => {
|
|
@@ -44,9 +54,7 @@ function SpacefrontIsland({
|
|
|
44
54
|
setThreadOpen(false);
|
|
45
55
|
};
|
|
46
56
|
const isolate = (event) => {
|
|
47
|
-
if (
|
|
48
|
-
event.stopPropagation();
|
|
49
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
57
|
+
if (stopKeyPropagation) stopHostKeys(event);
|
|
50
58
|
};
|
|
51
59
|
const status = (() => {
|
|
52
60
|
if (session.error !== null) return /* @__PURE__ */ jsx("p", { className: "fourty-si__error", role: "alert", children: session.error });
|
|
@@ -62,6 +70,7 @@ function SpacefrontIsland({
|
|
|
62
70
|
if (latest === void 0) return isEmpty ? /* @__PURE__ */ jsx("p", { className: "fourty-si__muted", children: emptyText }) : null;
|
|
63
71
|
return /* @__PURE__ */ jsx("button", { type: "button", className: "fourty-si__latest", "aria-expanded": false, onClick: () => setThreadOpen(true), children: renderInline(latest.prose, latest.key) });
|
|
64
72
|
})();
|
|
73
|
+
if (panelSlot !== null) return null;
|
|
65
74
|
return /* @__PURE__ */ jsx(
|
|
66
75
|
"div",
|
|
67
76
|
{
|
|
@@ -76,6 +85,7 @@ function SpacefrontIsland({
|
|
|
76
85
|
},
|
|
77
86
|
onKeyUp: isolate,
|
|
78
87
|
children: folded ? /* @__PURE__ */ jsx("button", { type: "button", className: "fourty-si__pill", "aria-label": `${pillLabel} \u2014 open the assistant`, onClick: () => setFolded(false), children: pillLabel }) : /* @__PURE__ */ jsxs("div", { className: "fourty-si__stack", children: [
|
|
88
|
+
/* @__PURE__ */ jsx("div", { ref: setPresenceSlot, className: "fourty-si__presence" }),
|
|
79
89
|
chips.length > 0 && /* @__PURE__ */ jsx("div", { className: "fourty-si__chips", role: "group", "aria-label": "Suggestions", children: chips.map((chip) => /* @__PURE__ */ jsx("button", { type: "button", className: "fourty-si__chip", onClick: () => selectChip(chip), children: chip.label }, chip.id)) }),
|
|
80
90
|
/* @__PURE__ */ jsxs("div", { className: "fourty-si__slab", children: [
|
|
81
91
|
/* @__PURE__ */ jsx(
|
package/dist/presence.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
factIdentity,
|
|
4
|
+
useBandFacts,
|
|
5
|
+
useForgetFact
|
|
6
|
+
} from "./chunk-TEPH476O.js";
|
|
7
|
+
import {
|
|
8
|
+
useHostShell
|
|
9
|
+
} from "./chunk-QXCHHCPU.js";
|
|
10
|
+
|
|
11
|
+
// src/shell/SpacefrontPresence.tsx
|
|
12
|
+
import { createPortal } from "react-dom";
|
|
13
|
+
import { AGENT_ASK_SIGNAL, useAgentPresence, useConsumeStandingSignal, useFourtySession, usePresenceNotch } from "@40rty/ams-sdk";
|
|
14
|
+
|
|
15
|
+
// src/shell/PresenceActivity.tsx
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
var MAX_THUMBS = 5;
|
|
18
|
+
function presenceThumbs(sources, scanning) {
|
|
19
|
+
const thumbs = [];
|
|
20
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21
|
+
let count = 0;
|
|
22
|
+
for (const source of sources) {
|
|
23
|
+
count += source.total === void 0 ? source.refs.length : source.total;
|
|
24
|
+
for (const ref of source.refs) {
|
|
25
|
+
if (ref.imageUrl === void 0 || seen.has(ref.id)) continue;
|
|
26
|
+
seen.add(ref.id);
|
|
27
|
+
thumbs.push({ id: ref.id, url: ref.imageUrl });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (thumbs.length === 0 && scanning !== null) return { thumbs: scanning.thumbnails.slice(0, MAX_THUMBS), count: scanning.count };
|
|
31
|
+
return { thumbs: thumbs.slice(0, MAX_THUMBS), count };
|
|
32
|
+
}
|
|
33
|
+
function PresenceActivity({ working, thumbs, voice, queryHint, thinkingText }) {
|
|
34
|
+
const scanning = working && thumbs.thumbs.length > 0;
|
|
35
|
+
let line = voice;
|
|
36
|
+
if (scanning) line = queryHint === void 0 ? `Looking through ${thumbs.count} results` : `Looking for \u201C${queryHint}\u201D`;
|
|
37
|
+
else if (working && voice === "") line = thinkingText;
|
|
38
|
+
return /* @__PURE__ */ jsxs("div", { className: "fourty-sp__activity", role: "status", children: [
|
|
39
|
+
scanning && /* @__PURE__ */ jsx("span", { className: "fourty-sp__thumbs", "aria-hidden": "true", children: thumbs.thumbs.map((thumb) => /* @__PURE__ */ jsx("img", { className: "fourty-sp__thumb", src: thumb.url, alt: "", loading: "lazy", decoding: "async" }, thumb.id)) }),
|
|
40
|
+
/* @__PURE__ */ jsx("span", { className: working && !scanning && voice === "" ? "fourty-sp__line fourty-sp__line--thinking" : "fourty-sp__line", children: line })
|
|
41
|
+
] });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/shell/SpacefrontPresence.tsx
|
|
45
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
46
|
+
var NO_WIDGETS = [];
|
|
47
|
+
function SpacefrontPresence({
|
|
48
|
+
thinkingText = "Thinking\u2026",
|
|
49
|
+
factsLabel = "What I understood",
|
|
50
|
+
confirmLabel = "Yes",
|
|
51
|
+
placement = "auto"
|
|
52
|
+
}) {
|
|
53
|
+
const session = useFourtySession();
|
|
54
|
+
const { view } = useBandFacts();
|
|
55
|
+
const { scanning } = useAgentPresence();
|
|
56
|
+
const { expanded, rootHandlers, rootRef } = usePresenceNotch(NO_WIDGETS);
|
|
57
|
+
const standing = useConsumeStandingSignal(AGENT_ASK_SIGNAL);
|
|
58
|
+
const { forget } = useForgetFact();
|
|
59
|
+
const shell = useHostShell();
|
|
60
|
+
const working = session.isRunning || session.isSubmitting;
|
|
61
|
+
const thumbs = presenceThumbs(view.sources, scanning);
|
|
62
|
+
const showActivity = expanded && (working || view.voice !== "");
|
|
63
|
+
const ask = standingAsk(standing, view.ask);
|
|
64
|
+
const empty = !showActivity && view.facts.length === 0 && ask === null;
|
|
65
|
+
let target = "inline";
|
|
66
|
+
if (placement === "auto") {
|
|
67
|
+
if (shell.panelSlot !== null) target = shell.panelSlot;
|
|
68
|
+
else if (shell.islands > 0) target = shell.islandSlot;
|
|
69
|
+
}
|
|
70
|
+
if (empty || target === null) return null;
|
|
71
|
+
const band = /* @__PURE__ */ jsxs2(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
ref: rootRef,
|
|
75
|
+
className: "fourty-sp",
|
|
76
|
+
role: "region",
|
|
77
|
+
"aria-label": "Assistant activity",
|
|
78
|
+
"data-expanded": expanded,
|
|
79
|
+
"data-working": working,
|
|
80
|
+
...rootHandlers,
|
|
81
|
+
children: [
|
|
82
|
+
showActivity && /* @__PURE__ */ jsx2(PresenceActivity, { working, thumbs, voice: view.voice, queryHint: scanning === null ? void 0 : scanning.queryHint, thinkingText }),
|
|
83
|
+
view.facts.length > 0 && /* @__PURE__ */ jsxs2("div", { className: "fourty-sp__facts", role: "group", "aria-label": factsLabel, children: [
|
|
84
|
+
/* @__PURE__ */ jsx2("p", { className: "fourty-sp__eyebrow", "aria-hidden": "true", children: factsLabel }),
|
|
85
|
+
/* @__PURE__ */ jsxs2("ul", { className: "fourty-sp__fact-list", children: [
|
|
86
|
+
view.facts.map((fact) => /* @__PURE__ */ jsxs2("li", { className: "fourty-sp__fact", children: [
|
|
87
|
+
/* @__PURE__ */ jsx2("span", { className: "fourty-sp__fact-label", children: fact.label }),
|
|
88
|
+
/* @__PURE__ */ jsx2("span", { className: "fourty-sp__fact-value", children: fact.value }),
|
|
89
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "fourty-sp__forget", "aria-label": `Forget ${fact.label}: ${fact.value}`, onClick: () => forget(fact), children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("path", { d: "M3 3l6 6M9 3 3 9", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) })
|
|
90
|
+
] }, factIdentity(fact))),
|
|
91
|
+
view.hiddenFacts > 0 && /* @__PURE__ */ jsxs2("li", { className: "fourty-sp__more", children: [
|
|
92
|
+
"+",
|
|
93
|
+
view.hiddenFacts
|
|
94
|
+
] })
|
|
95
|
+
] })
|
|
96
|
+
] }),
|
|
97
|
+
ask !== null && /* @__PURE__ */ jsxs2("div", { className: "fourty-sp__ask", role: "group", "aria-label": "A question from the assistant", children: [
|
|
98
|
+
/* @__PURE__ */ jsx2("p", { className: "fourty-sp__question", "aria-live": "polite", children: ask.question }),
|
|
99
|
+
/* @__PURE__ */ jsxs2("div", { className: "fourty-sp__replies", children: [
|
|
100
|
+
ask.replies.map((reply) => /* @__PURE__ */ jsx2(
|
|
101
|
+
"button",
|
|
102
|
+
{
|
|
103
|
+
type: "button",
|
|
104
|
+
className: "fourty-sp__reply",
|
|
105
|
+
onClick: () => {
|
|
106
|
+
session.dispatchSuggestionAction({ id: `ask-${ask.id}-${reply}`, label: reply, type: "message", payload: { text: reply } });
|
|
107
|
+
if (ask.confirm !== void 0) ask.confirm();
|
|
108
|
+
},
|
|
109
|
+
children: reply
|
|
110
|
+
},
|
|
111
|
+
reply
|
|
112
|
+
)),
|
|
113
|
+
ask.replies.length === 0 && ask.confirm !== void 0 && /* @__PURE__ */ jsx2("button", { type: "button", className: "fourty-sp__reply", onClick: ask.confirm, children: confirmLabel }),
|
|
114
|
+
ask.dismiss !== void 0 && /* @__PURE__ */ jsx2("button", { type: "button", className: "fourty-sp__dismiss", "aria-label": "Dismiss the question", onClick: ask.dismiss, children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("path", { d: "M3 3l6 6M9 3 3 9", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) })
|
|
115
|
+
] })
|
|
116
|
+
] })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
return target === "inline" ? band : createPortal(band, target);
|
|
121
|
+
}
|
|
122
|
+
function standingAsk(standing, streamAsk) {
|
|
123
|
+
if (standing !== null) {
|
|
124
|
+
const p = standing.payload;
|
|
125
|
+
const replies = Array.isArray(p.suggestions) ? p.suggestions.filter((x) => typeof x === "string" && x.length > 0) : [];
|
|
126
|
+
const question = typeof p.ask === "string" && p.ask.length > 0 ? p.ask : "Want me to do that?";
|
|
127
|
+
return { id: standing.id, question, replies, confirm: standing.confirm, dismiss: standing.dismiss };
|
|
128
|
+
}
|
|
129
|
+
if (streamAsk === void 0) return null;
|
|
130
|
+
return { id: streamAsk.id, question: streamAsk.question, replies: streamAsk.suggestions === void 0 ? [] : streamAsk.suggestions };
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
SpacefrontPresence
|
|
134
|
+
};
|