@40rty/ams-cli 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/bin/commands/connect.mjs +67 -13
- package/bin/commands/deploy.mjs +15 -9
- package/bin/commands/doctor.mjs +112 -29
- package/bin/commands/hosting.mjs +14 -0
- package/bin/commands/init.mjs +12 -8
- package/bin/commands/publish.mjs +12 -3
- package/bin/forty.mjs +3 -1
- package/bin/lib/__tests__/app-kind.test.mjs +48 -0
- package/bin/lib/__tests__/ask.test.mjs +52 -0
- package/bin/lib/ask.mjs +111 -0
- package/bin/lib/base-path-build.mjs +149 -0
- package/bin/lib/build.mjs +20 -8
- package/bin/lib/context.mjs +42 -3
- package/bin/lib/deploy-target.mjs +5 -3
- package/bin/lib/hosted-build.mjs +13 -7
- package/dist/wire.js +104 -0
- package/package.json +1 -1
- package/templates/package/package.json +2 -1
- package/templates/package/src/shell.tsx +8 -131
- package/templates/package/src/styles.css +7 -0
|
@@ -1,54 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
renderInline,
|
|
5
|
-
useCart,
|
|
6
|
-
useComposerChipSelect,
|
|
7
|
-
useComposerDraft,
|
|
8
|
-
useFourtySession,
|
|
9
|
-
useGoHome,
|
|
10
|
-
useThreadRows,
|
|
11
|
-
} from '@40rty/ams-sdk';
|
|
1
|
+
import {SpacefrontCanvas, useCart, useGoHome} from '@40rty/ams-sdk';
|
|
2
|
+
import {SpacefrontIsland} from '@40rty/ams-ui/island';
|
|
3
|
+
import '@40rty/ams-ui/island.css';
|
|
12
4
|
|
|
13
5
|
/**
|
|
14
6
|
* The page: a header, the canvas the agent composes onto, and the AMS island —
|
|
15
|
-
* the floating composer every 40rty spacefront is recognised by.
|
|
16
|
-
* fixed (grip, latest answer, field, round send
|
|
17
|
-
* when folded); its look
|
|
7
|
+
* the floating composer every 40rty spacefront is recognised by. The island is
|
|
8
|
+
* `@40rty/ams-ui`'s: its shape is fixed (grip, latest answer, field, round send
|
|
9
|
+
* stamp, suggestion chips, a pill when folded); its look is the brand tokens,
|
|
10
|
+
* mapped onto its `--fourty-island-*` properties in `styles.css`.
|
|
18
11
|
*/
|
|
19
12
|
export function Shell() {
|
|
20
|
-
const session = useFourtySession();
|
|
21
|
-
const [draft, setDraft] = useComposerDraft();
|
|
22
|
-
const {rows, isEmpty} = useThreadRows();
|
|
23
|
-
const selectChip = useComposerChipSelect();
|
|
24
13
|
const goHome = useGoHome();
|
|
25
14
|
const {cart} = useCart();
|
|
26
|
-
const chips = session.suggestions ? session.suggestions.actions : [];
|
|
27
|
-
const latest = rows.length > 0 ? rows[rows.length - 1] : undefined;
|
|
28
|
-
|
|
29
|
-
const [threadOpen, setThreadOpen] = useState(false);
|
|
30
|
-
const [folded, setFolded] = useState(false);
|
|
31
|
-
|
|
32
|
-
// Folds to the pill while the visitor scrolls down the canvas, back on scroll up.
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
let last = window.scrollY;
|
|
35
|
-
const onScroll = () => {
|
|
36
|
-
const y = window.scrollY;
|
|
37
|
-
if (Math.abs(y - last) > 24) {
|
|
38
|
-
setFolded(y > last && y > 120);
|
|
39
|
-
last = y;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
window.addEventListener('scroll', onScroll, {passive: true});
|
|
43
|
-
return () => window.removeEventListener('scroll', onScroll);
|
|
44
|
-
}, []);
|
|
45
|
-
|
|
46
|
-
const send = (text: string) => {
|
|
47
|
-
if (text.trim() === '') return;
|
|
48
|
-
session.sendMessage(text);
|
|
49
|
-
setDraft('');
|
|
50
|
-
setFolded(false);
|
|
51
|
-
};
|
|
52
15
|
|
|
53
16
|
return (
|
|
54
17
|
<div className="min-h-screen bg-paper text-ink antialiased">
|
|
@@ -65,93 +28,7 @@ export function Shell() {
|
|
|
65
28
|
<SpacefrontCanvas />
|
|
66
29
|
</main>
|
|
67
30
|
|
|
68
|
-
<
|
|
69
|
-
{folded ? (
|
|
70
|
-
<button
|
|
71
|
-
type="button"
|
|
72
|
-
className="pointer-events-auto h-10 w-28 rounded-[20px] bg-ink text-paper text-sm font-semibold shadow-lg"
|
|
73
|
-
onClick={() => setFolded(false)}
|
|
74
|
-
>
|
|
75
|
-
Ask
|
|
76
|
-
</button>
|
|
77
|
-
) : (
|
|
78
|
-
<div className="pointer-events-auto grid w-full max-w-[640px] gap-2">
|
|
79
|
-
{chips.length > 0 && (
|
|
80
|
-
<div className="flex flex-wrap justify-center gap-2">
|
|
81
|
-
{chips.map((chip) => (
|
|
82
|
-
<button
|
|
83
|
-
key={chip.id}
|
|
84
|
-
type="button"
|
|
85
|
-
className="rounded-full border border-ink/20 bg-paper px-3 py-1 text-sm hover:border-accent"
|
|
86
|
-
onClick={() => selectChip(chip)}
|
|
87
|
-
>
|
|
88
|
-
{chip.label}
|
|
89
|
-
</button>
|
|
90
|
-
))}
|
|
91
|
-
</div>
|
|
92
|
-
)}
|
|
93
|
-
|
|
94
|
-
<div className="overflow-hidden rounded-2xl bg-paper text-ink shadow-[0_0_0_1px_rgb(var(--color-ink)/.14),0_6px_16px_-4px_rgb(var(--color-ink)/.26),0_20px_44px_-12px_rgb(var(--color-ink)/.36)]">
|
|
95
|
-
<button
|
|
96
|
-
type="button"
|
|
97
|
-
aria-label="Fold the assistant"
|
|
98
|
-
className="flex w-full justify-center py-2"
|
|
99
|
-
onClick={() => setFolded(true)}
|
|
100
|
-
>
|
|
101
|
-
<span className="h-1 w-8 rounded-full bg-ink/40" />
|
|
102
|
-
</button>
|
|
103
|
-
|
|
104
|
-
<div className={`px-4 text-sm ${threadOpen ? 'grid max-h-64 gap-3 overflow-y-auto pb-2' : ''}`} aria-live="polite">
|
|
105
|
-
{session.error ? (
|
|
106
|
-
<p className="text-accent">{session.error}</p>
|
|
107
|
-
) : session.isRunning ? (
|
|
108
|
-
<p className="animate-pulse text-ink/50">Pulling that together…</p>
|
|
109
|
-
) : threadOpen ? (
|
|
110
|
-
rows.map((row) => (
|
|
111
|
-
<div key={row.key} className="grid gap-1">
|
|
112
|
-
<p className="text-ink/60">{row.visitorText}</p>
|
|
113
|
-
<p>{renderInline(row.prose, row.key)}</p>
|
|
114
|
-
</div>
|
|
115
|
-
))
|
|
116
|
-
) : isEmpty ? (
|
|
117
|
-
<p className="text-ink/60">Tell us what you’re looking for.</p>
|
|
118
|
-
) : (
|
|
119
|
-
latest && (
|
|
120
|
-
<button type="button" className="line-clamp-2 text-left text-ink/70" onClick={() => setThreadOpen(true)}>
|
|
121
|
-
{renderInline(latest.prose, latest.key)}
|
|
122
|
-
</button>
|
|
123
|
-
)
|
|
124
|
-
)}
|
|
125
|
-
</div>
|
|
126
|
-
|
|
127
|
-
<form
|
|
128
|
-
className="flex items-center gap-2 px-3 pb-3 pt-2"
|
|
129
|
-
onSubmit={(event) => {
|
|
130
|
-
event.preventDefault();
|
|
131
|
-
send(draft);
|
|
132
|
-
}}
|
|
133
|
-
>
|
|
134
|
-
<input
|
|
135
|
-
className="min-w-0 flex-1 bg-transparent px-3 py-2 outline-none"
|
|
136
|
-
aria-label="Ask"
|
|
137
|
-
placeholder="Ask anything…"
|
|
138
|
-
value={draft}
|
|
139
|
-
onChange={(event) => setDraft(event.target.value)}
|
|
140
|
-
onFocus={() => setThreadOpen(false)}
|
|
141
|
-
/>
|
|
142
|
-
<button
|
|
143
|
-
type="submit"
|
|
144
|
-
aria-label="Send"
|
|
145
|
-
className="grid h-[34px] w-[34px] shrink-0 place-items-center rounded-full bg-ink text-paper disabled:opacity-40"
|
|
146
|
-
disabled={session.isRunning || draft.trim() === ''}
|
|
147
|
-
>
|
|
148
|
-
↑
|
|
149
|
-
</button>
|
|
150
|
-
</form>
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
)}
|
|
154
|
-
</div>
|
|
31
|
+
<SpacefrontIsland />
|
|
155
32
|
</div>
|
|
156
33
|
);
|
|
157
34
|
}
|
|
@@ -7,4 +7,11 @@
|
|
|
7
7
|
--color-ink: 20 20 20;
|
|
8
8
|
--color-paper: 250 250 249;
|
|
9
9
|
--color-accent: 191 72 0;
|
|
10
|
+
|
|
11
|
+
/* The AMS island (`@40rty/ams-ui/island`), in the same tokens. */
|
|
12
|
+
--fourty-island-surface: rgb(var(--color-paper));
|
|
13
|
+
--fourty-island-fg: rgb(var(--color-ink));
|
|
14
|
+
--fourty-island-accent: rgb(var(--color-accent));
|
|
15
|
+
--fourty-island-accent-fg: rgb(var(--color-paper));
|
|
16
|
+
--fourty-island-error: rgb(var(--color-accent));
|
|
10
17
|
}
|