@40rty/ams-ui 0.3.1 → 0.4.2
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 +5 -5
- package/dist/{chunk-MHUEIBJ3.js → chunk-GQURT3IR.js} +3 -47
- package/dist/{chunk-BFZ3YCUY.js → chunk-H6MSAD5M.js} +1 -40
- package/dist/{chunk-ORIOBWTD.js → chunk-PHXP2SKS.js} +5 -1
- package/dist/{chunk-OKP7MC72.js → chunk-RKPDCXL4.js} +241 -195
- package/dist/{chunk-TEPH476O.js → chunk-RMJDSHLA.js} +6 -36
- package/dist/hooks.js +4 -4
- package/dist/index.js +172 -338
- package/dist/presence.js +3 -4
- package/dist/shell.js +419 -570
- package/dist/thread-panel.js +3 -3
- package/dist/types/agent/presence/AgentAsk.d.ts +13 -0
- package/dist/types/agent/presence/index.d.ts +3 -1
- package/dist/types/agent/presence/read-data.d.ts +5 -0
- package/dist/types/components/ecommerce/cart/CartFoot.d.ts +1 -2
- package/dist/types/components/ecommerce/cart/CartLineRow.d.ts +1 -1
- package/dist/types/hooks/index.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/labels.d.ts +6 -0
- package/dist/types/shell/Composer.d.ts +1 -1
- package/dist/types/shell/ShellScaffold.d.ts +2 -1
- package/dist/types/shell/TurnAsk.d.ts +14 -0
- package/dist/types/shell/composer/AttachmentStrip.d.ts +1 -1
- package/dist/types/shell/dock-context.d.ts +1 -1
- package/dist/types/shell/index.d.ts +2 -2
- package/dist/types/shell/mobile/IslandComposeGroup.d.ts +1 -1
- package/dist/types/shell/mobile/IslandInputBar.d.ts +1 -1
- package/dist/types/shell/mobile/MorphIsland.d.ts +1 -1
- package/dist/types/shell/mobile/RestIsland.d.ts +1 -1
- package/dist/types/shell/slots.d.ts +1 -5
- package/package.json +3 -4
- package/dist/types/agent/presence/use-forget-fact.d.ts +0 -56
- package/dist/types/components/ecommerce/cart/use-cart-view.d.ts +0 -50
- package/dist/types/hooks/use-projection.d.ts +0 -24
- package/dist/types/shell/composer/heic-convert.d.ts +0 -6
- package/dist/types/shell/composer/useComposerAttachments.d.ts +0 -37
- package/dist/types/shell/composer/usePromptComposer.d.ts +0 -51
- package/dist/types/shell/use-dock-state.d.ts +0 -54
- package/dist/types/utils/use-is-seed-home.d.ts +0 -13
- package/dist/types/utils/use-safe-cart.d.ts +0 -17
- package/dist/types/utils/use-safe-facts.d.ts +0 -9
- package/dist/types/utils/use-safe-fourty-session.d.ts +0 -15
package/dist/agent.js
CHANGED
|
@@ -64,17 +64,17 @@ import {
|
|
|
64
64
|
sourceCardBox,
|
|
65
65
|
sourceCardClass,
|
|
66
66
|
sourceCardState,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
useForgetFact,
|
|
68
|
+
useMeasuredHeight,
|
|
69
|
+
useVisibleFactList
|
|
70
|
+
} from "./chunk-RKPDCXL4.js";
|
|
69
71
|
import {
|
|
70
72
|
PRESENCE_DURABLE_SLOTS,
|
|
71
73
|
PRESENCE_FACT_LIMIT,
|
|
72
74
|
readFacts,
|
|
73
75
|
readLabel,
|
|
74
|
-
useForgetFact,
|
|
75
|
-
useVisibleFactList,
|
|
76
76
|
useVisibleFacts
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-RMJDSHLA.js";
|
|
78
78
|
import "./chunk-432XYPDT.js";
|
|
79
79
|
export {
|
|
80
80
|
AgentPresenceWidget,
|
|
@@ -1,48 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
// src/hooks/use-projection.ts
|
|
4
|
-
import { useCallback, useEffect, useState } from "react";
|
|
5
|
-
function readResult(raw) {
|
|
6
|
-
if (raw === null || typeof raw !== "object") return void 0;
|
|
7
|
-
const obj = raw;
|
|
8
|
-
if (typeof obj.hiddenCount !== "number") return void 0;
|
|
9
|
-
const trimmedAxes = Array.isArray(obj.trimmedAxes) ? obj.trimmedAxes.filter((a) => typeof a === "string") : [];
|
|
10
|
-
return { full: obj.full, hiddenCount: obj.hiddenCount, trimmedAxes };
|
|
11
|
-
}
|
|
12
|
-
function entityIdOf(value) {
|
|
13
|
-
if (value === null || typeof value !== "object") return "";
|
|
14
|
-
const id = value.id;
|
|
15
|
-
return typeof id === "string" ? id : "";
|
|
16
|
-
}
|
|
17
|
-
var NO_AXES = [];
|
|
18
|
-
function useProjection(projectionProp, entity) {
|
|
19
|
-
const [expanded, setExpanded] = useState(false);
|
|
20
|
-
const toggle = useCallback(() => setExpanded((e) => !e), []);
|
|
21
|
-
const entityId = entityIdOf(entity);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
setExpanded(false);
|
|
24
|
-
}, [entityId]);
|
|
25
|
-
const result = readResult(projectionProp);
|
|
26
|
-
if (result === void 0) {
|
|
27
|
-
return {
|
|
28
|
-
active: false,
|
|
29
|
-
expanded: false,
|
|
30
|
-
hiddenCount: 0,
|
|
31
|
-
trimmedAxes: NO_AXES,
|
|
32
|
-
fullEntity: void 0,
|
|
33
|
-
toggle
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
active: true,
|
|
38
|
-
expanded,
|
|
39
|
-
hiddenCount: result.hiddenCount,
|
|
40
|
-
trimmedAxes: result.trimmedAxes,
|
|
41
|
-
fullEntity: result.full,
|
|
42
|
-
toggle
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
3
|
// src/hooks/use-focus-trap.ts
|
|
47
4
|
import React from "react";
|
|
48
5
|
var FOCUSABLE_SELECTOR = [
|
|
@@ -94,11 +51,11 @@ function useFocusTrap(ref, active) {
|
|
|
94
51
|
}
|
|
95
52
|
|
|
96
53
|
// src/hooks/use-container-width.ts
|
|
97
|
-
import { useEffect
|
|
54
|
+
import { useEffect, useRef, useState } from "react";
|
|
98
55
|
function useContainerWidth() {
|
|
99
56
|
const ref = useRef(null);
|
|
100
|
-
const [width, setWidth] =
|
|
101
|
-
|
|
57
|
+
const [width, setWidth] = useState(0);
|
|
58
|
+
useEffect(() => {
|
|
102
59
|
const el = ref.current;
|
|
103
60
|
if (!el) return;
|
|
104
61
|
const observer = new ResizeObserver(([entry]) => {
|
|
@@ -111,7 +68,6 @@ function useContainerWidth() {
|
|
|
111
68
|
}
|
|
112
69
|
|
|
113
70
|
export {
|
|
114
|
-
useProjection,
|
|
115
71
|
useFocusTrap,
|
|
116
72
|
useContainerWidth
|
|
117
73
|
};
|
|
@@ -116,48 +116,9 @@ function useSideDockSpacing(open, width, animate = true) {
|
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
// src/shell/use-dock-state.ts
|
|
120
|
-
import React2 from "react";
|
|
121
|
-
import { useAgentDriven, useDockPersistence, useHasLeftSeedHome, useHydrated, useOverridableToggle, useSessionId, useSessionMessages } from "@40rty/ams-sdk";
|
|
122
|
-
function useDockState(reopenOnMessage, autoOpen) {
|
|
123
|
-
const { initialOpen, onOpenChange } = useDockPersistence();
|
|
124
|
-
const messages = useSessionMessages();
|
|
125
|
-
const sessionId = useSessionId();
|
|
126
|
-
const hasLeftHome = useHasLeftSeedHome();
|
|
127
|
-
const agentDriven = useAgentDriven();
|
|
128
|
-
const settled = sessionId !== null;
|
|
129
|
-
const settledRef = React2.useRef(false);
|
|
130
|
-
const engagedWhenSettledRef = React2.useRef(false);
|
|
131
|
-
const hasEngagedRef = React2.useRef(initialOpen === true);
|
|
132
|
-
const historyIsAccountedFor = initialOpen !== null;
|
|
133
|
-
const engagementIsNew = historyIsAccountedFor ? settledRef.current && !engagedWhenSettledRef.current : true;
|
|
134
|
-
if (hasLeftHome && engagementIsNew && !agentDriven) hasEngagedRef.current = true;
|
|
135
|
-
const hydrated = useHydrated();
|
|
136
|
-
const openDefault = agentDriven || !autoOpen ? false : hydrated ? hasEngagedRef.current : initialOpen === true;
|
|
137
|
-
const toggle = useOverridableToggle(openDefault);
|
|
138
|
-
const userTurns = messages.reduce((n, m) => m.role === "user" ? n + 1 : n, 0);
|
|
139
|
-
const prevUserTurns = React2.useRef(userTurns);
|
|
140
|
-
React2.useEffect(() => {
|
|
141
|
-
if (!settledRef.current) {
|
|
142
|
-
if (!settled) return;
|
|
143
|
-
settledRef.current = true;
|
|
144
|
-
engagedWhenSettledRef.current = hasLeftHome;
|
|
145
|
-
prevUserTurns.current = userTurns;
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (reopenOnMessage && autoOpen && !agentDriven && userTurns > prevUserTurns.current) toggle.set(true);
|
|
149
|
-
prevUserTurns.current = userTurns;
|
|
150
|
-
}, [userTurns, settled, hasLeftHome, reopenOnMessage, autoOpen, agentDriven, toggle.set]);
|
|
151
|
-
React2.useEffect(() => {
|
|
152
|
-
onOpenChange(toggle.value);
|
|
153
|
-
}, [toggle.value, onOpenChange]);
|
|
154
|
-
return { open: toggle.value, toggle: toggle.toggle };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
119
|
export {
|
|
158
120
|
SIDE_DOCK_REVEAL_MS,
|
|
159
121
|
SIDE_DOCK_EASE,
|
|
160
122
|
SideDock,
|
|
161
|
-
useSideDockSpacing
|
|
162
|
-
useDockState
|
|
123
|
+
useSideDockSpacing
|
|
163
124
|
};
|
|
@@ -102,11 +102,15 @@ function useTextareaAutosize(ref, value, { maxLines = 4, lineHeightPx = 22, extr
|
|
|
102
102
|
}, [ref, value, maxLines, lineHeightPx, ...extraDeps]);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
// src/hooks/index.ts
|
|
106
|
+
import { useProjection } from "@40rty/ams-sdk";
|
|
107
|
+
|
|
105
108
|
export {
|
|
106
109
|
activateOnSpaceEnter,
|
|
107
110
|
submitOnEnter,
|
|
108
111
|
useDismissOnOutside,
|
|
109
112
|
useFocusOnChange,
|
|
110
113
|
useScrollThreshold,
|
|
111
|
-
useTextareaAutosize
|
|
114
|
+
useTextareaAutosize,
|
|
115
|
+
useProjection
|
|
112
116
|
};
|