@keyframelabs/sdk 0.1.3 → 0.1.6
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/README.md +104 -78
- package/dist/PersonaSession.d.ts +10 -1
- package/dist/PersonaSession.d.ts.map +1 -1
- package/dist/PersonaSession.js +26 -8
- package/dist/PersonaSession.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,44 +1,51 @@
|
|
|
1
1
|
# @keyframelabs/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The universal, low-level SDK for Keyframe Labs.
|
|
4
|
+
|
|
5
|
+
**Which package should I use?**
|
|
6
|
+
- **@keyframelabs/sdk** (high control)
|
|
7
|
+
- You implement the UI, state management, and agent/llm binding yourself
|
|
8
|
+
- **@keyframelabs/elements** (custom UI)
|
|
9
|
+
- You implement the UI; we handle the state and agent/llm binding (framework-agnostic)
|
|
10
|
+
- **@keyframelabs/react**: (drop-in)
|
|
11
|
+
- We handle the UI, state, and agent/llm binding
|
|
4
12
|
|
|
5
13
|
## Installation
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
|
-
|
|
16
|
+
pnpm add @keyframelabs/sdk
|
|
9
17
|
```
|
|
10
18
|
|
|
11
|
-
## Quick
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
### 1. Server-side: create a session
|
|
12
22
|
|
|
13
|
-
|
|
23
|
+
From your backend, use your secret Keyframe API key to create a session.
|
|
14
24
|
|
|
15
25
|
```typescript
|
|
16
|
-
|
|
26
|
+
// POST https://api.keyframelabs.com/v1/session
|
|
27
|
+
const response = await fetch('https://api.keyframelabs.com/v1/session', {
|
|
17
28
|
method: 'POST',
|
|
18
29
|
headers: {
|
|
19
30
|
'Content-Type': 'application/json',
|
|
20
|
-
Authorization: `Bearer ${KFL_API_KEY}`,
|
|
31
|
+
'Authorization': `Bearer ${process.env.KFL_API_KEY}`,
|
|
21
32
|
},
|
|
22
33
|
body: JSON.stringify({
|
|
23
|
-
persona_id: "
|
|
24
|
-
model_id: "persona-1-live"
|
|
34
|
+
persona_id: "6efx..." // or persona_slug
|
|
25
35
|
}),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
30
|
-
}
|
|
36
|
+
});
|
|
31
37
|
|
|
32
|
-
//
|
|
33
|
-
const
|
|
38
|
+
// Returns { serverUrl, participantToken }
|
|
39
|
+
const session = await response.json();
|
|
34
40
|
```
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
### 2. Client-side: connect the client
|
|
43
|
+
|
|
44
|
+
Pass the session details to the client SDK.
|
|
37
45
|
|
|
38
46
|
```typescript
|
|
39
47
|
import { createClient } from '@keyframelabs/sdk';
|
|
40
48
|
|
|
41
|
-
// Create a Persona client
|
|
42
49
|
const persona = createClient({
|
|
43
50
|
serverUrl: "wss://...",
|
|
44
51
|
participantToken: "A6gB...",
|
|
@@ -52,97 +59,116 @@ const persona = createClient({
|
|
|
52
59
|
},
|
|
53
60
|
});
|
|
54
61
|
|
|
55
|
-
// Connect to the
|
|
56
|
-
await
|
|
62
|
+
// Connect to the session
|
|
63
|
+
await client.connect();
|
|
57
64
|
|
|
58
|
-
// Send audio from your
|
|
59
|
-
|
|
65
|
+
// Send audio (e.g. from your LLM/Agent)
|
|
66
|
+
client.sendAudio(pcmAudioBytes);
|
|
60
67
|
|
|
61
68
|
// Signal an interruption (clears pending frames)
|
|
62
69
|
persona.interrupt();
|
|
63
70
|
|
|
64
|
-
//
|
|
65
|
-
await
|
|
71
|
+
// Cleanup
|
|
72
|
+
await client.close();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Architecture
|
|
76
|
+
|
|
77
|
+
The SDK handles the real-time transport loop between your agent or real-time LLM and the Keyframe Platform, as well as synced audio/video rendering.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
+-----------------------+ +-----------------------+
|
|
81
|
+
| Browser | | Keyframe Platform |
|
|
82
|
+
| | | |
|
|
83
|
+
| +-----------------+ | | +-----------------+ |
|
|
84
|
+
| | Microphone | | | | AvatarSession | |
|
|
85
|
+
| +-----------------+ | | +-----------------+ |
|
|
86
|
+
| | | | ^ |
|
|
87
|
+
| v | | | |
|
|
88
|
+
| +-----------------+ | DataStream | | |
|
|
89
|
+
| | Agent / LLM | | (PCM 16kHz) | | |
|
|
90
|
+
| +-----------------+ | ----------------------> | | |
|
|
91
|
+
| | | | | |
|
|
92
|
+
| v | | v |
|
|
93
|
+
| +-----------------+ | | +-----------------+ |
|
|
94
|
+
| | PersonaSession | | | | Inference | |
|
|
95
|
+
| +-----------------+ | | +-----------------+ |
|
|
96
|
+
| ^ | | | |
|
|
97
|
+
| | | WebRTC | | |
|
|
98
|
+
| | | (Audio + Video) | v |
|
|
99
|
+
| +-----------------+ | <---------------------- | +-----------------+ |
|
|
100
|
+
| | Video Element | | | | Video | |
|
|
101
|
+
| +-----------------+ | | +-----------------+ |
|
|
102
|
+
| | | |
|
|
103
|
+
+-----------------------+ +-----------------------+
|
|
66
104
|
```
|
|
67
105
|
|
|
106
|
+
## Integrating a specific agent or real-time LLM
|
|
107
|
+
|
|
108
|
+
The SDK is intentionally minimal—it only handles the avatar connection. You bring your own agent or real-time LLM (e.g, Cartesia, ElevenLabs, Gemini, OpenAI).
|
|
109
|
+
|
|
68
110
|
## API
|
|
69
111
|
|
|
70
112
|
### `createClient(options)`
|
|
71
113
|
|
|
72
|
-
|
|
114
|
+
Initializes the WebSocket connection and media managers.
|
|
73
115
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
116
|
+
| Option | Type | Default | Description |
|
|
117
|
+
| ------------------ | ----------------- | -------- | --------------------------------------------------------- |
|
|
118
|
+
| `serverUrl` | `string` | Required | The WSS URL returned by the `/session` API endpoint. |
|
|
119
|
+
| `participantToken` | `string` | Required | The access token returned by the `/session` API endpoint. |
|
|
120
|
+
| `onVideoTrack` | `(track) => void` | Required | Fired when the WebRTC video track is ready. |
|
|
121
|
+
| `onAudioTrack` | `(track) => void` | Required | Fired when the WebRTC audio track is ready. |
|
|
122
|
+
| `onStateChange` | `(state) => void` | — | Fired when session state changes. |
|
|
123
|
+
| `onError` | `(err) => void` | — | Fired on errors. |
|
|
82
124
|
|
|
83
125
|
### `PersonaSession`
|
|
84
126
|
|
|
85
127
|
The client instance returned by `createClient()`.
|
|
86
128
|
|
|
87
|
-
|
|
88
|
-
- `connect()` - Connect to the avatar session
|
|
89
|
-
- `sendAudio(pcmData)` - Send 24kHz 16-bit PCM audio
|
|
90
|
-
- `interrupt()` - Signal an interruption (clears pending frames)
|
|
91
|
-
- `close()` - Close the session
|
|
92
|
-
|
|
93
|
-
**Properties:**
|
|
94
|
-
- `state` - Current session state ('disconnected', 'connecting', 'connected', 'error')
|
|
129
|
+
#### Methods
|
|
95
130
|
|
|
96
|
-
|
|
131
|
+
| Method | Signature | Description |
|
|
132
|
+
| ------------ | ---------------------------------------------- | ------------------------------------------------ |
|
|
133
|
+
| `connect` | `() => Promise<void>` | Connect to the session. |
|
|
134
|
+
| `sendAudio` | `(pcmData: ArrayBuffer \| Int16Array) => void` | Send 24 kHz 16-bit PCM audio. |
|
|
135
|
+
| `interrupt` | `() => void` | Signal an interruption and clear pending frames. |
|
|
136
|
+
| `setEmotion` | `(emotion: Emotion) => Promise<void>` | Set the avatar's emotional expression. |
|
|
137
|
+
| `close` | `() => void` | Close the session and release resources. |
|
|
97
138
|
|
|
98
|
-
|
|
139
|
+
#### Properties
|
|
99
140
|
|
|
100
|
-
|
|
141
|
+
| Property | Type | Description |
|
|
142
|
+
| -------- | ---------------------------------------------------------- | ---------------------- |
|
|
143
|
+
| `state` | `'disconnected' \| 'connecting' \| 'connected' \| 'error'` | Current session state. |
|
|
101
144
|
|
|
102
|
-
|
|
103
|
-
import { createClient } from '@keyframelabs/sdk';
|
|
104
|
-
// Your agent implementation (copy from experiments/src/agents/)
|
|
105
|
-
import { GeminiLiveAgent } from './agents/gemini-live';
|
|
145
|
+
### Types
|
|
106
146
|
|
|
107
|
-
|
|
108
|
-
personaId: 'luna',
|
|
109
|
-
onVideoTrack: (track) => {
|
|
110
|
-
videoElement.srcObject = new MediaStream([track]);
|
|
111
|
-
},
|
|
112
|
-
});
|
|
147
|
+
#### `Emotion`
|
|
113
148
|
|
|
114
|
-
|
|
149
|
+
Emotion states for avatar expression:
|
|
115
150
|
|
|
116
|
-
|
|
117
|
-
|
|
151
|
+
```typescript
|
|
152
|
+
type Emotion = 'neutral' | 'angry' | 'sad' | 'happy';
|
|
153
|
+
```
|
|
118
154
|
|
|
119
|
-
|
|
120
|
-
agent.on('interrupted', () => persona.interrupt());
|
|
155
|
+
## Emotion Controls
|
|
121
156
|
|
|
122
|
-
|
|
123
|
-
await persona.connect();
|
|
124
|
-
await agent.connect({ apiKey: 'your-gemini-key' });
|
|
157
|
+
You can dynamically change the avatar's emotional expression using the `setEmotion` method:
|
|
125
158
|
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
|
|
159
|
+
```typescript
|
|
160
|
+
// Set the avatar to show happiness
|
|
161
|
+
await client.setEmotion('happy');
|
|
129
162
|
|
|
130
|
-
|
|
163
|
+
// React to user sentiment
|
|
164
|
+
await client.setEmotion('sad');
|
|
131
165
|
|
|
166
|
+
// Return to neutral
|
|
167
|
+
await client.setEmotion('neutral');
|
|
132
168
|
```
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
│ Microphone │──PCM 16kHz──▶│ │
|
|
136
|
-
│ ↓ │ │ │
|
|
137
|
-
│ Voice AI Agent │ │ AvatarSession │
|
|
138
|
-
│ ↓ │ │ │
|
|
139
|
-
│ PersonaSession │──DataStream─▶│ ↓ │
|
|
140
|
-
│ ↑ │ │ Inference │
|
|
141
|
-
│ Video Element │◀──WebRTC────│ ↓ │
|
|
142
|
-
└─────────────────┘ │ Video │
|
|
143
|
-
└─────────────────┘
|
|
144
|
-
```
|
|
169
|
+
|
|
170
|
+
The avatar will blend its facial expression and demeanor to match the specified emotion. This can be triggered manually or in response to sentiment analysis, LLM output, or other signals from your application.
|
|
145
171
|
|
|
146
172
|
## License
|
|
147
173
|
|
|
148
|
-
MIT
|
|
174
|
+
MIT
|
package/dist/PersonaSession.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Receiving video from "persona"
|
|
9
9
|
* - Interrupt signaling
|
|
10
10
|
*/
|
|
11
|
-
import type { PersonaSessionOptions, SessionState } from './types.js';
|
|
11
|
+
import type { Emotion, PersonaSessionOptions, SessionState } from './types.js';
|
|
12
12
|
/**
|
|
13
13
|
* PersonaSession manages the connection between your app and a Persona avatar.
|
|
14
14
|
*
|
|
@@ -81,6 +81,15 @@ export declare class PersonaSession {
|
|
|
81
81
|
* while the agent is still talking).
|
|
82
82
|
*/
|
|
83
83
|
interrupt(): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Set the avatar's emotional expression.
|
|
86
|
+
*
|
|
87
|
+
* Changes the avatar's facial expression and demeanor to match
|
|
88
|
+
* the specified emotion.
|
|
89
|
+
*
|
|
90
|
+
* @param emotion - The emotion to express ('neutral', 'angry', 'sad', 'happy')
|
|
91
|
+
*/
|
|
92
|
+
setEmotion(emotion: Emotion): Promise<void>;
|
|
84
93
|
/**
|
|
85
94
|
* Close the session and clean up resources.
|
|
86
95
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonaSession.d.ts","sourceRoot":"","sources":["../src/PersonaSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,KAAK,EAEV,qBAAqB,EACrB,YAAY,EACb,MAAM,YAAY,CAAC;AA2BpB;;;;;;;;;;;;;;;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;IAOhB;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B9B,OAAO,CAAC,kBAAkB;IAiC1B;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;IA2BpC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAazB;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;;;;OAMG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBnC;;;;;;;;OAQG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBhC;;;;;;;OAOG;IACG,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBjD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CA4B7B"}
|
package/dist/PersonaSession.js
CHANGED
|
@@ -29,7 +29,7 @@ const AUDIO_STREAM_TOPIC = 'lk.audio_stream';
|
|
|
29
29
|
/** DataStream topic for control messages (interrupt, etc.) */
|
|
30
30
|
const CONTROL_STREAM_TOPIC = 'lk.control';
|
|
31
31
|
/** Auto-flush timeout in ms after last audio chunk */
|
|
32
|
-
const AUTO_FLUSH_TIMEOUT_MS =
|
|
32
|
+
const AUTO_FLUSH_TIMEOUT_MS = 500;
|
|
33
33
|
/**
|
|
34
34
|
* PersonaSession manages the connection between your app and a Persona avatar.
|
|
35
35
|
*
|
|
@@ -233,18 +233,36 @@ export class PersonaSession {
|
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
235
|
try {
|
|
236
|
-
console.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
destinationIdentities: [this.options.agentIdentity],
|
|
240
|
-
});
|
|
241
|
-
await writer.write(new TextEncoder().encode('interrupt'));
|
|
242
|
-
await writer.close();
|
|
236
|
+
console.log('[PersonaSession] Sending interrupt');
|
|
237
|
+
await this.room.localParticipant.publishData(new TextEncoder().encode('interrupt'), { reliable: false, topic: CONTROL_STREAM_TOPIC, destinationIdentities: [this.options.agentIdentity] });
|
|
238
|
+
console.log('[PersonaSession] Interrupt sent');
|
|
243
239
|
}
|
|
244
240
|
catch (error) {
|
|
245
241
|
console.warn('[PersonaSession] Failed to send interrupt:', error);
|
|
246
242
|
}
|
|
247
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Set the avatar's emotional expression.
|
|
246
|
+
*
|
|
247
|
+
* Changes the avatar's facial expression and demeanor to match
|
|
248
|
+
* the specified emotion.
|
|
249
|
+
*
|
|
250
|
+
* @param emotion - The emotion to express ('neutral', 'angry', 'sad', 'happy')
|
|
251
|
+
*/
|
|
252
|
+
async setEmotion(emotion) {
|
|
253
|
+
if (!this.room || this._state !== 'connected') {
|
|
254
|
+
console.warn('[PersonaSession] setEmotion() called but not connected');
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
console.log('[PersonaSession] Setting emotion:', emotion);
|
|
259
|
+
await this.room.localParticipant.publishData(new TextEncoder().encode(`emotion:${emotion}`), { reliable: false, topic: CONTROL_STREAM_TOPIC, destinationIdentities: [this.options.agentIdentity] });
|
|
260
|
+
console.log('[PersonaSession] Emotion sent:', emotion);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
console.warn('[PersonaSession] Failed to set emotion:', error);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
248
266
|
/**
|
|
249
267
|
* Close the session and clean up resources.
|
|
250
268
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonaSession.js","sourceRoot":"","sources":["../src/PersonaSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,IAAI,EACJ,SAAS,EACT,KAAK,EAGL,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"PersonaSession.js","sourceRoot":"","sources":["../src/PersonaSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA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,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CACtG,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,yBAAyB;QACzB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC;QAED,qDAAqD;QACrD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QAEnB,oBAAoB;QACpB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;YACtC,CAAC;YAAC,MAAM,CAAC;gBACP,sBAAsB;YACxB,CAAC;YACD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC/B,CAAC;QAED,uBAAuB;QACvB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAChC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,6 @@ import type { PersonaSessionOptions } from './types.js';
|
|
|
30
30
|
*/
|
|
31
31
|
declare const createClient: (options: PersonaSessionOptions) => PersonaSession;
|
|
32
32
|
export { createClient, PersonaSession };
|
|
33
|
-
export type { CloseReason, PersonaSessionOptions, SessionState, } from './types.js';
|
|
33
|
+
export type { CloseReason, Emotion, PersonaSessionOptions, SessionState, } from './types.js';
|
|
34
34
|
export { SAMPLE_RATE, base64ToBytes, bytesToBase64, createEventEmitter, resamplePcm, } from './audio-utils.js';
|
|
35
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;GAKG;AACH,QAAA,MAAM,YAAY,GAAI,SAAS,qBAAqB,KAAG,cAEtD,CAAC;AAGF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAGxC,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,WAAW,GACZ,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;GAKG;AACH,QAAA,MAAM,YAAY,GAAI,SAAS,qBAAqB,KAAG,cAEtD,CAAC;AAGF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAGxC,YAAY,EACV,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,WAAW,GACZ,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CAAC,OAA8B,EAAkB,EAAE;IACtE,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,OAAO;AACP,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CAAC,OAA8B,EAAkB,EAAE;IACtE,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,OAAO;AACP,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAUxC,YAAY;AACZ,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,WAAW,GACZ,MAAM,kBAAkB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared types for Persona SDK.
|
|
3
3
|
*/
|
|
4
|
+
/** Emotion states for avatar expression */
|
|
5
|
+
export type Emotion = 'neutral' | 'angry' | 'sad' | 'happy';
|
|
4
6
|
/** Session state machine */
|
|
5
7
|
export type SessionState = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
6
8
|
/** Reason for session close */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],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4C;AAC5C,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,gBAAgB,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IAEtB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEjD,2CAA2C;IAC3C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEjD,wCAAwC;IACxC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAE9C,sBAAsB;IACtB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CACzC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyframelabs/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "The universal, low-level SDK for Keyframe Labs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|