@40rty/ams-cli 0.2.1 → 0.2.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/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "peerDependencies": {
16
16
  "zod": "^3.25.0"
17
17
  },
18
- "version": "0.2.1",
18
+ "version": "0.2.2",
19
19
  "homepage": "https://docs.40rty.ai",
20
20
  "license": "UNLICENSED",
21
21
  "engines": {
@@ -1,3 +1,4 @@
1
+ import {useEffect, useState} from 'react';
1
2
  import {
2
3
  SpacefrontCanvas,
3
4
  renderInline,
@@ -9,7 +10,12 @@ import {
9
10
  useThreadRows,
10
11
  } from '@40rty/ams-sdk';
11
12
 
12
- /** The page: a header, the canvas the agent composes onto, and the conversation. */
13
+ /**
14
+ * The page: a header, the canvas the agent composes onto, and the AMS island —
15
+ * the floating composer every 40rty spacefront is recognised by. Its shape is
16
+ * fixed (grip, latest answer, field, round send stamp, suggestion chips, a pill
17
+ * when folded); its look comes from the brand tokens in `styles.css`.
18
+ */
13
19
  export function Shell() {
14
20
  const session = useFourtySession();
15
21
  const [draft, setDraft] = useComposerDraft();
@@ -18,9 +24,34 @@ export function Shell() {
18
24
  const goHome = useGoHome();
19
25
  const {cart} = useCart();
20
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
+ };
21
52
 
22
53
  return (
23
- <div className="flex min-h-screen flex-col bg-paper text-ink antialiased">
54
+ <div className="min-h-screen bg-paper text-ink antialiased">
24
55
  <header className="sticky top-0 z-40 flex h-16 items-center justify-between border-b border-ink/10 bg-paper/90 px-6 backdrop-blur md:px-10">
25
56
  <button type="button" className="font-semibold" onClick={goHome}>
26
57
  __LABEL__
@@ -30,51 +61,96 @@ export function Shell() {
30
61
  </a>
31
62
  </header>
32
63
 
33
- <div className="grid flex-grow lg:grid-cols-[1fr_24rem]">
34
- <main className="min-w-0">
35
- <SpacefrontCanvas />
36
- </main>
64
+ <main className="min-w-0 pb-56">
65
+ <SpacefrontCanvas />
66
+ </main>
37
67
 
38
- <aside className="flex flex-col gap-6 border-l border-ink/10 p-6 lg:sticky lg:top-16 lg:h-[calc(100vh-4rem)]">
39
- <div className="grid grow content-start gap-4 overflow-y-auto">
40
- {isEmpty && <p className="text-ink/60">Tell us what you’re looking for.</p>}
41
- {rows.map((row) => (
42
- <div key={row.key} className="grid gap-1">
43
- <p className="text-sm text-ink/60">{row.visitorText}</p>
44
- <p>{renderInline(row.prose, row.key)}</p>
68
+ <div className="pointer-events-none fixed inset-x-0 bottom-4 z-40 flex justify-center px-4">
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
+ ))}
45
91
  </div>
46
- ))}
47
- {session.error && <p className="text-accent">{session.error}</p>}
48
- </div>
92
+ )}
49
93
 
50
- <div className="flex flex-wrap gap-2">
51
- {chips.map((chip) => (
52
- <button key={chip.id} type="button" className="rounded-full border border-ink/20 px-3 py-1 text-sm" onClick={() => selectChip(chip)}>
53
- {chip.label}
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" />
54
102
  </button>
55
- ))}
56
- </div>
57
103
 
58
- <form
59
- className="flex gap-3"
60
- onSubmit={(event) => {
61
- event.preventDefault();
62
- if (draft.trim() === '') return;
63
- session.sendMessage(draft);
64
- setDraft('');
65
- }}
66
- >
67
- <input
68
- className="w-full border-b border-ink/20 bg-transparent py-2 outline-none focus:border-ink"
69
- placeholder="Ask anything…"
70
- value={draft}
71
- onChange={(event) => setDraft(event.target.value)}
72
- />
73
- <button type="submit" className="rounded bg-ink px-4 text-paper disabled:opacity-50" disabled={session.isRunning}>
74
- Ask
75
- </button>
76
- </form>
77
- </aside>
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
+ )}
78
154
  </div>
79
155
  </div>
80
156
  );