@keyframelabs/elements 0.0.9 → 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/README.md +2 -2
- package/dist/PersonaEmbed.d.ts +1 -1
- package/dist/PersonaView.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -11
- package/dist/types.d.ts +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ Currently, only the ElevenLabs agent emits emotion events.
|
|
|
125
125
|
| `apiBaseUrl` | `string` | `'https://api.keyframelabs.com'` | Base URL for the Keyframe API. |
|
|
126
126
|
| `videoFit` | `'cover' \| 'contain'` | `'cover'` | Video scaling mode (`object-fit`). |
|
|
127
127
|
| `onStateChange` | `(status: EmbedStatus) => void` | — | Fired when connection status changes. |
|
|
128
|
-
| `onAgentStateChange` | `(state: AgentState) => void` | — | Fired when
|
|
128
|
+
| `onAgentStateChange` | `(state: AgentState) => void` | — | Fired when avatar playback state changes. Signaled by the GPU node via RPC, not the voice agent. |
|
|
129
129
|
| `onDisconnect` | `() => void` | — | Fired when the session disconnects. |
|
|
130
130
|
| `onError` | `(err: Error) => void` | — | Fired on fatal errors. |
|
|
131
131
|
|
|
@@ -142,7 +142,7 @@ Currently, only the ElevenLabs agent emits emotion events.
|
|
|
142
142
|
| Property | Type | Description |
|
|
143
143
|
| -------------- | ------------------ | -------------------------------------------------------------------------------------- |
|
|
144
144
|
| `status` | `EmbedStatus` | Current connection status: `'connecting' \| 'connected' \| 'disconnected' \| 'error'`. |
|
|
145
|
-
| `agentState` | `AgentState` |
|
|
145
|
+
| `agentState` | `AgentState` | Avatar playback state: `'listening' \| 'speaking'`. Set by the GPU node, not the voice agent. |
|
|
146
146
|
| `isMuted` | `boolean` | Whether the microphone is currently muted. |
|
|
147
147
|
| `videoElement` | `HTMLVideoElement` | The underlying video element used for rendering. |
|
|
148
148
|
| `audioElement` | `HTMLAudioElement` | The underlying audio element used for playback. |
|
package/dist/PersonaEmbed.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentState } from '
|
|
1
|
+
import { AgentState } from '@keyframelabs/sdk';
|
|
2
2
|
import { EmbedStatus, VideoFit, BaseCallbacks } from './types';
|
|
3
3
|
export type { EmbedStatus, VideoFit } from './types';
|
|
4
4
|
export interface PersonaEmbedOptions extends BaseCallbacks {
|
package/dist/PersonaView.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentState } from '
|
|
1
|
+
import { AgentState } from '@keyframelabs/sdk';
|
|
2
2
|
import { EmbedStatus, VideoFit, VoiceAgentDetails, SessionDetails, BaseCallbacks } from './types';
|
|
3
3
|
export interface PersonaViewOptions extends BaseCallbacks {
|
|
4
4
|
/** Target container element */
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export { PersonaView } from './PersonaView';
|
|
|
4
4
|
export type { PersonaViewOptions } from './PersonaView';
|
|
5
5
|
export type { EmbedStatus, VideoFit, VoiceAgentDetails, SessionDetails, BaseCallbacks, } from './types';
|
|
6
6
|
export { createAgent, GeminiLiveAgent, ElevenLabsAgent, CartesiaAgent, BaseAgent, AGENT_REGISTRY, getAgentInfo, } from './agents';
|
|
7
|
-
export type { AgentType,
|
|
7
|
+
export type { AgentType, AgentConfig, AgentEventMap, Agent, AnyAgent, AgentTypeInfo, GeminiLiveConfig, ElevenLabsConfig, CartesiaConfig, } from './agents';
|
|
8
|
+
export type { AgentState } from '@keyframelabs/sdk';
|
|
8
9
|
export { floatTo16BitPCM, resamplePcm, base64ToBytes, bytesToBase64, SAMPLE_RATE, createEventEmitter, } from './agents';
|
|
9
10
|
export { ApiError as KeyframeApiError } from './ApiError';
|
|
10
11
|
export type { ApiErrorPayload as KeyframeApiErrorPayload } from './ApiError';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createClient as
|
|
1
|
+
import { createClient as f } from "@keyframelabs/sdk";
|
|
2
2
|
const l = 24e3;
|
|
3
3
|
function g(i) {
|
|
4
4
|
const e = atob(i), t = new Uint8Array(e.length);
|
|
@@ -41,7 +41,7 @@ function E() {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function w(i) {
|
|
45
45
|
const e = new Int16Array(i.length);
|
|
46
46
|
for (let t = 0; t < i.length; t++) {
|
|
47
47
|
const s = Math.max(-1, Math.min(1, i[t]));
|
|
@@ -574,7 +574,7 @@ class K {
|
|
|
574
574
|
stream = null;
|
|
575
575
|
abortController = null;
|
|
576
576
|
_status = "disconnected";
|
|
577
|
-
_agentState = "
|
|
577
|
+
_agentState = "listening";
|
|
578
578
|
_isMuted = !1;
|
|
579
579
|
mounted = !0;
|
|
580
580
|
constructor(e) {
|
|
@@ -666,7 +666,7 @@ class K {
|
|
|
666
666
|
return t.json();
|
|
667
667
|
}
|
|
668
668
|
async initSession(e) {
|
|
669
|
-
this.session =
|
|
669
|
+
this.session = f({
|
|
670
670
|
serverUrl: e.session_details.server_url,
|
|
671
671
|
participantToken: e.session_details.participant_token,
|
|
672
672
|
agentIdentity: e.session_details.agent_identity,
|
|
@@ -680,6 +680,9 @@ class K {
|
|
|
680
680
|
onStateChange: (t) => {
|
|
681
681
|
this.mounted && t === "disconnected" && (this.setStatus("disconnected"), this.callbacks.onDisconnect?.());
|
|
682
682
|
},
|
|
683
|
+
onAgentStateChange: (t) => {
|
|
684
|
+
this.mounted && this.setAgentState(t);
|
|
685
|
+
},
|
|
683
686
|
onError: (t) => {
|
|
684
687
|
this.mounted && this.callbacks.onError?.(t);
|
|
685
688
|
},
|
|
@@ -688,7 +691,7 @@ class K {
|
|
|
688
691
|
}
|
|
689
692
|
}), this.agent = y(e.voice_agent_details.type), this.agent.on("audio", (t) => this.session?.sendAudio(t)), this.agent.on("turnEnd", () => this.session?.endAudioTurn()), this.agent.on("interrupted", () => {
|
|
690
693
|
this.session?.endAudioTurn(), this.session?.interrupt();
|
|
691
|
-
}), this.agent.on("
|
|
694
|
+
}), this.agent.on("closed", () => {
|
|
692
695
|
this.mounted && this.callbacks.onDisconnect?.();
|
|
693
696
|
}), this.agent instanceof S && this.agent.on("emotion", (t) => this.session?.setEmotion(t)), await this.session.connect();
|
|
694
697
|
}
|
|
@@ -699,7 +702,7 @@ class K {
|
|
|
699
702
|
const e = this.audioContext.createMediaStreamSource(this.stream);
|
|
700
703
|
this.processor = this.audioContext.createScriptProcessor(4096, 1, 1), this.processor.onaudioprocess = (t) => {
|
|
701
704
|
if (!this._isMuted) {
|
|
702
|
-
const s =
|
|
705
|
+
const s = w(t.inputBuffer.getChannelData(0));
|
|
703
706
|
this.agent?.sendAudio(s);
|
|
704
707
|
}
|
|
705
708
|
}, e.connect(this.processor), this.processor.connect(this.audioContext.destination);
|
|
@@ -744,7 +747,7 @@ class B {
|
|
|
744
747
|
processor = null;
|
|
745
748
|
stream = null;
|
|
746
749
|
_status = "disconnected";
|
|
747
|
-
_agentState = "
|
|
750
|
+
_agentState = "listening";
|
|
748
751
|
_isMuted = !1;
|
|
749
752
|
mounted = !0;
|
|
750
753
|
constructor(e) {
|
|
@@ -803,7 +806,7 @@ class B {
|
|
|
803
806
|
this._agentState !== e && (this._agentState = e, this.callbacks.onAgentStateChange?.(e));
|
|
804
807
|
}
|
|
805
808
|
async initSession() {
|
|
806
|
-
this.session =
|
|
809
|
+
this.session = f({
|
|
807
810
|
serverUrl: this.sessionDetails.server_url,
|
|
808
811
|
participantToken: this.sessionDetails.participant_token,
|
|
809
812
|
agentIdentity: this.sessionDetails.agent_identity,
|
|
@@ -817,6 +820,9 @@ class B {
|
|
|
817
820
|
onStateChange: (e) => {
|
|
818
821
|
this.mounted && e === "disconnected" && (this.setStatus("disconnected"), this.callbacks.onDisconnect?.());
|
|
819
822
|
},
|
|
823
|
+
onAgentStateChange: (e) => {
|
|
824
|
+
this.mounted && this.setAgentState(e);
|
|
825
|
+
},
|
|
820
826
|
onError: (e) => {
|
|
821
827
|
this.mounted && this.callbacks.onError?.(e);
|
|
822
828
|
},
|
|
@@ -825,7 +831,7 @@ class B {
|
|
|
825
831
|
}
|
|
826
832
|
}), this.agent = y(this.voiceAgentDetails.type), this.agent.on("audio", (e) => this.session?.sendAudio(e)), this.agent.on("turnEnd", () => this.session?.endAudioTurn()), this.agent.on("interrupted", () => {
|
|
827
833
|
this.session?.endAudioTurn(), this.session?.interrupt();
|
|
828
|
-
}), this.agent.on("
|
|
834
|
+
}), this.agent.on("closed", () => {
|
|
829
835
|
this.mounted && this.callbacks.onDisconnect?.();
|
|
830
836
|
}), this.agent instanceof S && this.agent.on("emotion", (e) => this.session?.setEmotion(e)), await this.session.connect();
|
|
831
837
|
}
|
|
@@ -836,7 +842,7 @@ class B {
|
|
|
836
842
|
const e = this.audioContext.createMediaStreamSource(this.stream);
|
|
837
843
|
this.processor = this.audioContext.createScriptProcessor(4096, 1, 1), this.processor.onaudioprocess = (t) => {
|
|
838
844
|
if (!this._isMuted) {
|
|
839
|
-
const s =
|
|
845
|
+
const s = w(t.inputBuffer.getChannelData(0));
|
|
840
846
|
this.agent?.sendAudio(s);
|
|
841
847
|
}
|
|
842
848
|
}, e.connect(this.processor), this.processor.connect(this.audioContext.destination);
|
|
@@ -879,7 +885,7 @@ export {
|
|
|
879
885
|
m as bytesToBase64,
|
|
880
886
|
y as createAgent,
|
|
881
887
|
E as createEventEmitter,
|
|
882
|
-
|
|
888
|
+
w as floatTo16BitPCM,
|
|
883
889
|
F as getAgentInfo,
|
|
884
890
|
c as resamplePcm
|
|
885
891
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AgentType
|
|
1
|
+
import { AgentType } from './agents';
|
|
2
|
+
import { AgentState } from '@keyframelabs/sdk';
|
|
2
3
|
export type EmbedStatus = 'connecting' | 'connected' | 'error' | 'disconnected';
|
|
3
4
|
export type VideoFit = 'cover' | 'contain';
|
|
4
5
|
export type VoiceAgentDetails = {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0
|
|
7
|
+
"version": "0.1.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@keyframelabs/sdk": "0.1.
|
|
22
|
+
"@keyframelabs/sdk": "0.1.8"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^25.0.9",
|