@rajnandan1/atticus 1.1.2 → 1.1.3
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 +124 -22
- package/dist/index.cjs +1304 -1432
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.global.js +1305 -1433
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1304 -1432
- package/dist/index.js.map +1 -1
- package/package.json +17 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Raj Nandan
|
|
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
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
# Atticus
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Features
|
|
3
|
+

|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
- 🖱️ UI-aware interactions - let users control your app with voice
|
|
9
|
-
- ⚡ Auto-executes UI actions (click, type, scroll, etc.)
|
|
10
|
-
- 🌍 Multi-language support (40+ languages)
|
|
11
|
-
- 📦 Framework-agnostic - works with React, Vue, Svelte, vanilla JS, etc.
|
|
12
|
-
- 🔧 Simple event-based API
|
|
13
|
-
- 🎯 DOM compression for efficient context via d2snap
|
|
5
|
+
A framework-agnostic voice agent library for voice-controlled UI interactions, powered by OpenAI's Realtime API.
|
|
14
6
|
|
|
15
7
|
## Installation
|
|
16
8
|
|
|
9
|
+
### npm/yarn
|
|
10
|
+
|
|
17
11
|
```bash
|
|
18
12
|
npm install @rajnandan1/atticus
|
|
19
13
|
```
|
|
20
14
|
|
|
15
|
+
### CDN (Vanilla HTML/JS)
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<!-- Use the IIFE build via unpkg or jsdelivr -->
|
|
19
|
+
<script src="https://unpkg.com/@rajnandan1/atticus@latest/dist/index.global.js"></script>
|
|
20
|
+
|
|
21
|
+
<!-- Or specific version -->
|
|
22
|
+
<script src="https://unpkg.com/@rajnandan1/atticus@v1.1.3/dist/index.global.js"></script>
|
|
23
|
+
|
|
24
|
+
<!-- jsdelivr alternative -->
|
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/@rajnandan1/atticus@latest/dist/index.global.js"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The script tag exposes `Atticus` globally - see [Vanilla HTML Usage](#vanilla-htmljs-usage) below.
|
|
29
|
+
|
|
21
30
|
## Quick Start
|
|
22
31
|
|
|
23
32
|
```typescript
|
|
@@ -34,6 +43,10 @@ const agent = new Atticus({
|
|
|
34
43
|
name: "Assistant",
|
|
35
44
|
instructions: "You are a helpful assistant.",
|
|
36
45
|
},
|
|
46
|
+
ui: {
|
|
47
|
+
enabled: true,
|
|
48
|
+
rootElement: formContainer,
|
|
49
|
+
},
|
|
37
50
|
});
|
|
38
51
|
|
|
39
52
|
// Listen to events
|
|
@@ -48,6 +61,73 @@ await agent.connect();
|
|
|
48
61
|
agent.disconnect();
|
|
49
62
|
```
|
|
50
63
|
|
|
64
|
+
## Vanilla HTML/JS Usage
|
|
65
|
+
|
|
66
|
+
Atticus works perfectly with vanilla HTML/JS using a script tag:
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<!DOCTYPE html>
|
|
70
|
+
<html>
|
|
71
|
+
<head>
|
|
72
|
+
<title>Atticus Voice Demo</title>
|
|
73
|
+
</head>
|
|
74
|
+
<body>
|
|
75
|
+
<button id="connectBtn">Connect</button>
|
|
76
|
+
<div id="status">Idle</div>
|
|
77
|
+
|
|
78
|
+
<!-- Include Atticus -->
|
|
79
|
+
<script src="https://unpkg.com/@rajnandan1/atticus@latest/dist/index.global.js"></script>
|
|
80
|
+
|
|
81
|
+
<script>
|
|
82
|
+
// Atticus is now available globally
|
|
83
|
+
let agent = null;
|
|
84
|
+
|
|
85
|
+
document
|
|
86
|
+
.getElementById("connectBtn")
|
|
87
|
+
.addEventListener("click", async () => {
|
|
88
|
+
if (agent && agent.isConnected) {
|
|
89
|
+
agent.disconnect();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Get client secret from your backend
|
|
94
|
+
const response = await fetch("/api/session", {
|
|
95
|
+
method: "POST",
|
|
96
|
+
});
|
|
97
|
+
const { clientSecret } = await response.json();
|
|
98
|
+
|
|
99
|
+
agent = new Atticus.Atticus({
|
|
100
|
+
clientSecret,
|
|
101
|
+
agent: {
|
|
102
|
+
name: "Assistant",
|
|
103
|
+
instructions: "You are a helpful voice assistant.",
|
|
104
|
+
},
|
|
105
|
+
voice: "shimmer",
|
|
106
|
+
language: "en",
|
|
107
|
+
ui: {
|
|
108
|
+
enabled: true,
|
|
109
|
+
rootElement: document.body,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
agent.on("connected", () => {
|
|
114
|
+
document.getElementById("status").textContent =
|
|
115
|
+
"Connected!";
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
agent.on("message", (msg) => {
|
|
119
|
+
console.log("Message:", msg);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
await agent.connect();
|
|
123
|
+
});
|
|
124
|
+
</script>
|
|
125
|
+
</body>
|
|
126
|
+
</html>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
See [index.html](index.html) for a complete example.
|
|
130
|
+
|
|
51
131
|
## UI-Aware Mode
|
|
52
132
|
|
|
53
133
|
Enable UI awareness to let users control your interface with voice. Actions are **automatically executed** by default:
|
|
@@ -249,18 +329,42 @@ When UI mode is enabled, the agent can perform these actions:
|
|
|
249
329
|
|
|
250
330
|
## Getting a Client Secret
|
|
251
331
|
|
|
252
|
-
The client secret (ephemeral key) must be obtained from
|
|
332
|
+
The client secret (ephemeral key) must be obtained from OpenAI's API. You can get it directly via curl or from your backend.
|
|
253
333
|
|
|
254
|
-
###
|
|
334
|
+
### Option 1: Direct curl (for testing)
|
|
255
335
|
|
|
256
|
-
```
|
|
257
|
-
|
|
336
|
+
```bash
|
|
337
|
+
curl -X POST "https://api.openai.com/v1/realtime/sessions" \
|
|
338
|
+
-H "Authorization: Bearer $OPENAI_API_KEY" \
|
|
339
|
+
-H "Content-Type: application/json" \
|
|
340
|
+
-d '{
|
|
341
|
+
"model": "gpt-4o-realtime-preview-2024-12-17",
|
|
342
|
+
"voice": "shimmer"
|
|
343
|
+
}'
|
|
344
|
+
```
|
|
258
345
|
|
|
259
|
-
|
|
346
|
+
Response:
|
|
260
347
|
|
|
348
|
+
```json
|
|
349
|
+
{
|
|
350
|
+
"id": "sess_xxx",
|
|
351
|
+
"object": "realtime.session",
|
|
352
|
+
"model": "gpt-4o-realtime-preview-2024-12-17",
|
|
353
|
+
"client_secret": {
|
|
354
|
+
"value": "ek_xxx...",
|
|
355
|
+
"expires_at": 1234567890
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Copy the `client_secret.value` and use it with Atticus.
|
|
361
|
+
|
|
362
|
+
### Option 2: Backend (Node.js/Express) - Recommended for Production
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
261
365
|
app.post("/api/session", async (req, res) => {
|
|
262
366
|
const response = await fetch(
|
|
263
|
-
"https://api.openai.com/v1/realtime/
|
|
367
|
+
"https://api.openai.com/v1/realtime/sessions",
|
|
264
368
|
{
|
|
265
369
|
method: "POST",
|
|
266
370
|
headers: {
|
|
@@ -268,10 +372,8 @@ app.post("/api/session", async (req, res) => {
|
|
|
268
372
|
"Content-Type": "application/json",
|
|
269
373
|
},
|
|
270
374
|
body: JSON.stringify({
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
model: "gpt-4o-realtime-preview",
|
|
274
|
-
},
|
|
375
|
+
model: "gpt-4o-realtime-preview-2024-12-17",
|
|
376
|
+
voice: "shimmer",
|
|
275
377
|
}),
|
|
276
378
|
}
|
|
277
379
|
);
|
|
@@ -298,7 +400,7 @@ const agent = new Atticus({ clientSecret, ... });
|
|
|
298
400
|
|
|
299
401
|
```bash
|
|
300
402
|
# Clone the repo
|
|
301
|
-
git clone https://github.com/
|
|
403
|
+
git clone https://github.com/rajnandan1/atticus.git
|
|
302
404
|
cd atticus
|
|
303
405
|
|
|
304
406
|
# Install dependencies
|
|
@@ -312,4 +414,4 @@ npm run dev
|
|
|
312
414
|
|
|
313
415
|
## License
|
|
314
416
|
|
|
315
|
-
MIT
|
|
417
|
+
[MIT](LICENSE)
|