realtime-avatar 0.24.1 → 0.26.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/dist/react.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { RegisteredTool, ToolRegistration } from './tools.js';
2
- import { aj as SessionLifecycleRoomBridgeProps, h as AvatarSessionClient, A as AvatarVideoFit } from './proxy-client-DlFXaXtn.js';
3
- export { a as AdaptivePlayoutController, b as AdaptivePlayoutDecision, c as AdaptivePlayoutOptions, d as AdaptivePlayoutSample, e as ApproachingEndEvent, f as ApproachingEndReason, g as AvatarConnectionDetails, aQ as AvatarVideoSurface, aR as AvatarVideoSurfaceProps, B as BehaviorSnapshot, C as CallTranscript, i as CallTranscriptSegment, j as CartesiaTtsModel, k as ClipResult, l as ClosingTurnResult, m as CreditsLowEvent, D as DEFAULT_APPROACHING_END_LEAD_SECONDS, n as DEFAULT_CREDITS_LOW_LEAD_SECONDS, o as DEFAULT_GOVERNOR_CONFIG, p as DEFAULT_GRACE_CEILING_SECONDS, q as DEFAULT_GRACE_WINDOW_LEAD_SECONDS, r as DEFAULT_IDLE_SECONDS, s as DEFAULT_IDLE_WARN_LEAD_SECONDS, t as DEFAULT_TURN_TIMEOUT_SECONDS, u as DeclaredInputSource, E as EndReason, v as EndedEvent, w as ExtendResult, F as FishTtsModel, x as FreezeReadingFn, G as Governor, y as GovernorAction, z as GovernorConfig, H as GovernorSignal, I as GovernorState, J as GraceWindowClosedEvent, K as GraceWindowOpenEvent, M as GraceWindowState, N as IdleWarningEvent, O as InboundRtpCursor, P as InboundRtpReading, Q as KnownBehaviorState, R as LLMProvider, S as LLMSelection, T as LiveKitAvatarGrantState, U as LiveKitAvatarGrantStatus, V as LiveKitCapacityState, W as LiveKitConnectionStatus, X as LiveKitSessionRequest, Y as LiveKitSessionStartResult, aS as LivePlaybackKeeper, Z as MAX_RECONNECT_ATTEMPTS, _ as MAX_SESSION_INSTRUCTIONS_CHARS, aT as MIC_LEASE_ENDED_TIMEOUT_MS, aU as MicLease, aV as NETWORK_QUALITY_POLICY, aW as NetworkQualityStatus, aX as PlayableVideoElement, $ as ProxyClientOptions, a0 as QualityCap, a1 as RECONNECT_BACKOFF_MS, aY as RealtimeAvatarCapacityError, aZ as RealtimeAvatarLiveKitRoom, a_ as RealtimeAvatarLiveKitRoomProps, a2 as RealtimeAvatarRequestOptions, a3 as RealtimeSessionApi, a4 as RealtimeSessionMedia, a5 as RealtimeSessionRoomSinks, a6 as ReconnectPolicy, a7 as ReconnectingEvent, a8 as RecoveryState, a9 as RetryStep, aa as SendTurnOptions, ab as SessionBehavior, ac as SessionClip, ad as SessionClocks, ae as SessionEndReason, af as SessionLifecycleApi, ag as SessionLifecyclePhase, ah as SessionLifecyclePhaseKind, ai as SessionLifecycleRoomBridge, ak as SurfaceLayers, al as TranscriptSender, am as TranscriptSenderOptions, an as TurnState, ao as TurnTimeoutEvent, ap as UseAvatarQualityGovernorInput, aq as UseLiveKitAvatarGrantInput, ar as UseRealtimeSessionInput, as as UseSessionLifecycleInput, at as VoiceSpec, au as VoiceSpecInput, av as capacityErrorFromBusy, aw as capacityStateFromGrant, ax as createProxyClient, az as knownBehaviorStates, aA as mapTurnState, aB as readInboundRtp, aC as sessionBehaviorSchema, aD as sessionClipSchema, a$ as shouldReplayPendingTurn, aE as splitCallTranscript, aF as useAvatarAdaptivePlayoutDelay, aG as useAvatarCamera, aH as useAvatarPlayoutDelay, aI as useAvatarQualityGovernor, aJ as useCallTranscript, aK as useLiveKitAvatarGrant, aM as useMicLease, aN as useRealtimeSession, aO as useReleaseMicLeaseOnTrackEnded, aP as useSessionLifecycle } from './proxy-client-DlFXaXtn.js';
4
- import { ReactNode } from 'react';
1
+ import { ToolRegistration, RegisteredTool } from './tools.js';
2
+ import { aj as SessionLifecycleRoomBridgeProps, h as AvatarSessionClient, A as AvatarVideoFit, aQ as CallMicrophone, aR as CallAudioPlayback, aS as CallMicrophoneProblem } from './proxy-client-C8M_G_Kk.js';
3
+ export { a as AdaptivePlayoutController, b as AdaptivePlayoutDecision, c as AdaptivePlayoutOptions, d as AdaptivePlayoutSample, e as ApproachingEndEvent, f as ApproachingEndReason, g as AvatarConnectionDetails, aT as AvatarVideoSurface, aU as AvatarVideoSurfaceProps, B as BehaviorSnapshot, C as CallTranscript, i as CallTranscriptSegment, j as CartesiaTtsModel, k as ClipResult, l as ClosingTurnResult, m as CreditsLowEvent, D as DEFAULT_APPROACHING_END_LEAD_SECONDS, n as DEFAULT_CREDITS_LOW_LEAD_SECONDS, o as DEFAULT_GOVERNOR_CONFIG, p as DEFAULT_GRACE_CEILING_SECONDS, q as DEFAULT_GRACE_WINDOW_LEAD_SECONDS, r as DEFAULT_IDLE_SECONDS, s as DEFAULT_IDLE_WARN_LEAD_SECONDS, t as DEFAULT_TURN_TIMEOUT_SECONDS, u as DeclaredInputSource, E as EndReason, v as EndedEvent, w as ExtendResult, F as FishTtsModel, x as FreezeReadingFn, G as Governor, y as GovernorAction, z as GovernorConfig, H as GovernorSignal, I as GovernorState, J as GraceWindowClosedEvent, K as GraceWindowOpenEvent, M as GraceWindowState, N as IdleWarningEvent, O as InboundRtpCursor, P as InboundRtpReading, Q as KnownBehaviorState, R as LLMProvider, S as LLMSelection, T as LiveKitAvatarGrantState, U as LiveKitAvatarGrantStatus, V as LiveKitCapacityState, W as LiveKitConnectionStatus, X as LiveKitSessionRequest, Y as LiveKitSessionStartResult, aV as LivePlaybackKeeper, Z as MAX_RECONNECT_ATTEMPTS, _ as MAX_SESSION_INSTRUCTIONS_CHARS, aW as MIC_LEASE_ENDED_TIMEOUT_MS, aX as MicLease, aY as NETWORK_QUALITY_POLICY, aZ as NetworkQualityStatus, a_ as PlayableVideoElement, $ as ProxyClientOptions, a0 as QualityCap, a1 as RECONNECT_BACKOFF_MS, a$ as RealtimeAvatarCapacityError, b0 as RealtimeAvatarLiveKitRoom, b1 as RealtimeAvatarLiveKitRoomProps, a2 as RealtimeAvatarRequestOptions, a3 as RealtimeSessionApi, a4 as RealtimeSessionMedia, a5 as RealtimeSessionRoomSinks, a6 as ReconnectPolicy, a7 as ReconnectingEvent, a8 as RecoveryState, a9 as RetryStep, aa as SendTurnOptions, ab as SessionBehavior, ac as SessionClip, ad as SessionClocks, ae as SessionEndReason, af as SessionLifecycleApi, ag as SessionLifecyclePhase, ah as SessionLifecyclePhaseKind, ai as SessionLifecycleRoomBridge, ak as SurfaceLayers, al as TranscriptSender, am as TranscriptSenderOptions, an as TurnState, ao as TurnTimeoutEvent, ap as UseAvatarQualityGovernorInput, aq as UseLiveKitAvatarGrantInput, ar as UseRealtimeSessionInput, as as UseSessionLifecycleInput, at as VoiceSpec, au as VoiceSpecInput, av as capacityErrorFromBusy, aw as capacityStateFromGrant, ax as createProxyClient, az as knownBehaviorStates, aA as mapTurnState, aB as readInboundRtp, aC as sessionBehaviorSchema, aD as sessionClipSchema, b2 as shouldReplayPendingTurn, aE as splitCallTranscript, aF as useAvatarAdaptivePlayoutDelay, aG as useAvatarCamera, aH as useAvatarPlayoutDelay, aI as useAvatarQualityGovernor, aJ as useCallTranscript, aK as useLiveKitAvatarGrant, aM as useMicLease, aN as useRealtimeSession, aO as useReleaseMicLeaseOnTrackEnded, aP as useSessionLifecycle } from './proxy-client-C8M_G_Kk.js';
4
+ import { CSSProperties, ReactNode } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { R as RecordingArtifact } from './recording-DjswTx5B.js';
7
- export { D as DEFAULT_AVATAR_PLAYOUT_DELAY_SECONDS } from './playout-delay-DWOc8iCl.js';
7
+ export { D as DEFAULT_AVATAR_PLAYOUT_DELAY_SECONDS } from './playout-delay-CtRZdtsj.js';
8
8
  import 'zod';
9
9
  import 'livekit-client';
10
10
  import '@livekit/components-react';
@@ -18,6 +18,22 @@ import '@livekit/components-react';
18
18
  */
19
19
  declare const DEFAULT_AVATAR_UNSTABLE_STALL_MS = 4000;
20
20
 
21
+ /**
22
+ * Where her tools stand in this call.
23
+ *
24
+ * - `idle`: the room is not connected, so there is nothing to register with.
25
+ * - `registering`: publishing the manifest; `attempt` counts from 1 and rises on each retry.
26
+ * - `ready`: armed; `registered` is what the agent accepted, `rejected` what it dropped and why.
27
+ * - `error`: registration failed for good while connected; `error` says why. A tool that is not
28
+ * armed is silently uncallable, which reads exactly like the model ignoring it.
29
+ */
30
+ type CharacterToolsState = {
31
+ status: "idle" | "registering" | "ready" | "error";
32
+ registered: string[];
33
+ rejected: ToolRegistration["rejected"];
34
+ error?: string;
35
+ attempt?: number;
36
+ };
21
37
  declare function useCharacterTools(tools: Record<string, RegisteredTool>, options?: {
22
38
  onResult?: (event: {
23
39
  name: string;
@@ -25,12 +41,7 @@ declare function useCharacterTools(tools: Record<string, RegisteredTool>, option
25
41
  ok: boolean;
26
42
  error?: string;
27
43
  }) => void;
28
- }): {
29
- status: "idle" | "registering" | "ready" | "error";
30
- registered: string[];
31
- rejected: ToolRegistration["rejected"];
32
- error?: string;
33
- };
44
+ }): CharacterToolsState;
34
45
 
35
46
  /**
36
47
  * The CONNECT surface (client half) — one component that puts a live character on screen.
@@ -67,8 +78,34 @@ type AvatarCallStatus =
67
78
  | "ended";
68
79
  /** Why a call ended — the only vocabulary an end screen needs. */
69
80
  type AvatarCallEndReason = "user_ended" | "session_cap" | "idle" | "disconnected" | "out_of_credits" | "agent_ended" | "failed";
81
+ /**
82
+ * The user's microphone: `off` | `pending` | `on` | `muted`, or `blocked` / `unavailable` with
83
+ * the cause (`reason`), what the browser said (`message`) and what to do about it (`hint`).
84
+ */
85
+ type AvatarCallMicrophone = CallMicrophone;
86
+ /** The microphone states that carry a problem — what `onMicrophoneProblem` receives. */
87
+ type AvatarCallMicrophoneProblem = CallMicrophoneProblem;
88
+ /** Whether her audio can play: `unknown` before the room connects, `allowed`, or `blocked`. */
89
+ type AvatarCallAudio = CallAudioPlayback;
70
90
  type AvatarCallHandle = {
71
91
  status: AvatarCallStatus;
92
+ /** Can she hear the user? A `blocked` or `unavailable` microphone means she cannot. */
93
+ microphone: AvatarCallMicrophone;
94
+ /** Can the user hear her? `blocked` means silent until `startAudio()` runs in a gesture. */
95
+ audio: AvatarCallAudio;
96
+ /**
97
+ * Unblock her audio. Call it from a click or tap handler; outside one the browser refuses.
98
+ * Never rejects: resolves whether playback is allowed afterwards.
99
+ */
100
+ startAudio: () => Promise<boolean>;
101
+ /**
102
+ * Mute (`false`) or unmute (`true`) the user's microphone. Never rejects. While waiting or
103
+ * connecting it records the choice and nothing is captured; a mute made then is kept when the
104
+ * call goes live. After `end()` it does nothing.
105
+ */
106
+ setMicrophoneEnabled: (enabled: boolean) => Promise<void>;
107
+ /** Ask for the microphone again, after the user fixed what `microphone.hint` names. */
108
+ retryMicrophone: () => Promise<void>;
72
109
  /** Place in line while `status === "waiting"`, else null. */
73
110
  queuePosition: number | null;
74
111
  /** Seconds until the hard cap, or null before the clock lands. */
@@ -86,7 +123,11 @@ type AvatarCallHandle = {
86
123
  };
87
124
  type AvatarCallProps = Pick<SessionLifecycleRoomBridgeProps, "onConnectionDetailsChange"> & {
88
125
  client: AvatarSessionClient;
89
- /** Which character. */
126
+ /**
127
+ * Which character. Changing it starts a new call, EXCEPT after `end()`: an ended call stays
128
+ * ended until you remount `AvatarCall` (a `key` is the usual way), so no prop change can start
129
+ * a billed call the user hung up on.
130
+ */
90
131
  avatarId: string;
91
132
  /** `voice` is audio-only and cheaper; `avatar` (default) is the full call. */
92
133
  mode?: "avatar" | "voice";
@@ -97,7 +138,10 @@ type AvatarCallProps = Pick<SessionLifecycleRoomBridgeProps, "onConnectionDetail
97
138
  /** A still shown before the idle clip is playable. */
98
139
  poster?: string | null;
99
140
  fit?: AvatarVideoFit;
141
+ /** Adds your classes to the call's box. The box sizes itself inline; to resize it, use `style`. */
100
142
  className?: string;
143
+ /** Inline style for the call's box, spread over its own (`height`, `aspectRatio`, …). */
144
+ style?: CSSProperties;
101
145
  /** Your remaining balance in ms, if you want `onLowBalance`. */
102
146
  balanceMs?: number;
103
147
  onStatusChange?: (status: AvatarCallStatus) => void;
@@ -117,7 +161,24 @@ type AvatarCallProps = Pick<SessionLifecycleRoomBridgeProps, "onConnectionDetail
117
161
  onLowBalance?: (event: {
118
162
  secondsLeft: number;
119
163
  }) => void;
120
- /** Overlay your own UI on the video; receives the same handle as `useAvatarCall`. */
164
+ /**
165
+ * The microphone became `blocked` or `unavailable`: she cannot hear the user, though the call
166
+ * is live. Fires once per distinct problem. Show `hint`, then offer `retryMicrophone()`.
167
+ */
168
+ onMicrophoneProblem?: (problem: AvatarCallMicrophoneProblem) => void;
169
+ /**
170
+ * What to show while `audio` is `blocked` (the browser is muting her until a gesture):
171
+ * - `true` (default): a "Tap to turn on sound" button, top-centre over the video.
172
+ * - a function: your own affordance, with your own words; wire it to `call.startAudio()`.
173
+ * - `false`: nothing; draw your own from `call.audio` anywhere.
174
+ * The first two render inside a polite live region, above your overlay.
175
+ */
176
+ audioUnlockPrompt?: boolean | ((call: AvatarCallHandle) => ReactNode);
177
+ /**
178
+ * Overlay your own UI on the video; receives the same handle as `useAvatarCall`. Rendered in a
179
+ * layer above the video and the live badge that fills the call's box, so `position: absolute`
180
+ * places a control against the box and it stays clickable while she is live.
181
+ */
121
182
  children?: (call: AvatarCallHandle) => ReactNode;
122
183
  };
123
184
  /**
@@ -141,4 +202,4 @@ declare function RecordingPlayer({ assets, className }: {
141
202
  className?: string;
142
203
  }): react_jsx_runtime.JSX.Element;
143
204
 
144
- export { AvatarCall, type AvatarCallEndReason, type AvatarCallHandle, type AvatarCallProps, type AvatarCallStatus, AvatarSessionClient, AvatarVideoFit, DEFAULT_AVATAR_UNSTABLE_STALL_MS, type RecordingPlaybackAsset, RecordingPlayer, SessionLifecycleRoomBridgeProps, useAvatarCall, useCharacterTools };
205
+ export { AvatarCall, type AvatarCallAudio, type AvatarCallEndReason, type AvatarCallHandle, type AvatarCallMicrophone, type AvatarCallMicrophoneProblem, type AvatarCallProps, type AvatarCallStatus, AvatarSessionClient, AvatarVideoFit, type CharacterToolsState, DEFAULT_AVATAR_UNSTABLE_STALL_MS, type RecordingPlaybackAsset, RecordingPlayer, SessionLifecycleRoomBridgeProps, useAvatarCall, useCharacterTools };