@40rty/ams-ui 0.2.2 → 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 +286 -0
- 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 +137 -0
- package/dist/presence.js +134 -0
- package/dist/shell.js +305 -451
- package/dist/thread-panel.js +238 -0
- package/dist/types/island/index.d.ts +1 -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 +36 -0
- 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 +17 -2
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
|
+
};
|