@cheerlyai/agentlib-react 0.1.0
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/LICENSE +21 -0
- package/README.md +76 -0
- package/dist/index.cjs +759 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +723 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cheerly AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @cheerlyai/agentlib-react
|
|
2
|
+
|
|
3
|
+
Embeddable React chat component for agentlib agents. Talks directly to the
|
|
4
|
+
platform's public embed API with a **publishable key** — no proxy or backend
|
|
5
|
+
route needed in your app.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @cheerlyai/agentlib-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { AgentChat } from "@cheerlyai/agentlib-react";
|
|
13
|
+
|
|
14
|
+
<AgentChat
|
|
15
|
+
baseUrl="https://api.your-platform.com"
|
|
16
|
+
agentId="AGENT_ID"
|
|
17
|
+
publishableKey="alk_pub_…"
|
|
18
|
+
/>;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Get the agent id, publishable key, and ready-made snippets from the agent's
|
|
22
|
+
**Embed** tab in the console (where you also lock the key to your domains).
|
|
23
|
+
|
|
24
|
+
## Identified users (optional)
|
|
25
|
+
|
|
26
|
+
Anonymous visitors get a per-browser identity automatically. To keep a
|
|
27
|
+
signed-in user's threads across devices — and unforgeable by other visitors —
|
|
28
|
+
sign their id on your backend with the key's signing secret:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createHmac } from "node:crypto";
|
|
32
|
+
const signature = createHmac("sha256", SIGNING_SECRET).update(user.id).digest("hex");
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
<AgentChat … user={{ id: user.id, signature }} />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Telling the agent about them
|
|
40
|
+
|
|
41
|
+
A verified user can also carry facts for the agent to rely on — name, plan,
|
|
42
|
+
locale. Encode and sign them together, on the server:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const data = Buffer.from(JSON.stringify({ name: user.name, plan: user.plan }))
|
|
46
|
+
.toString("base64");
|
|
47
|
+
const signature = createHmac("sha256", SIGNING_SECRET)
|
|
48
|
+
.update(`${user.id}.${data}`)
|
|
49
|
+
.digest("hex");
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
<AgentChat … user={{ id: user.id, signature, data }} />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The facts become part of the run's instructions, not the conversation, so they
|
|
57
|
+
refresh every turn and never enter the stored thread. Pass `data` through
|
|
58
|
+
untouched: the signature covers those exact bytes, so re-encoding the object in
|
|
59
|
+
the browser breaks it. Anonymous visitors cannot send attributes (400) — an
|
|
60
|
+
unsigned fact is worth no more than one typed into the chat box.
|
|
61
|
+
|
|
62
|
+
## Props
|
|
63
|
+
|
|
64
|
+
| Prop | Notes |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `baseUrl` | agentlib API origin |
|
|
67
|
+
| `agentId` | the agent id (console View tab) |
|
|
68
|
+
| `publishableKey` | `alk_pub_…`, safe in page source |
|
|
69
|
+
| `user?` | `{ id, signature, data? }` verified identity, optionally with signed facts |
|
|
70
|
+
| `title?` | header title (defaults to the agent's name) |
|
|
71
|
+
| `placeholder?`, `welcomeTitle?`, `welcomeSubtitle?` | copy overrides |
|
|
72
|
+
| `accentColor?` | user bubble / send button color |
|
|
73
|
+
| `persistConversation?` | resume after reload (default `true`) |
|
|
74
|
+
|
|
75
|
+
Styles are self-contained (injected on mount, `alw-` prefixed, Shadow-DOM
|
|
76
|
+
compatible) — no CSS import required.
|