realtime-avatar 0.3.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.
@@ -0,0 +1,107 @@
1
+ import { ReactNode } from 'react';
2
+ import { A as AvatarSessionClient, a as AvatarVideoFit } from './proxy-client-cZyX50-O.js';
3
+ export { b as ApproachingEndEvent, c as ApproachingEndReason, d as AvatarVideoSurface, e as AvatarVideoSurfaceProps, B as BehaviorSnapshot, C as CallTranscript, f as CallTranscriptSegment, g as CartesiaTtsModel, h as ClipResult, i as ClosingTurnResult, j as CreditsLowEvent, D as DEFAULT_APPROACHING_END_LEAD_SECONDS, k as DEFAULT_AVATAR_PLAYOUT_DELAY_SECONDS, l as DEFAULT_CREDITS_LOW_LEAD_SECONDS, m as DEFAULT_GOVERNOR_CONFIG, n as DEFAULT_GRACE_CEILING_SECONDS, o as DEFAULT_GRACE_WINDOW_LEAD_SECONDS, p as DEFAULT_IDLE_SECONDS, q as DEFAULT_IDLE_WARN_LEAD_SECONDS, r as DEFAULT_TURN_TIMEOUT_SECONDS, E as EndReason, s as EndedEvent, t as ExtendResult, F as FishTtsModel, u as FreezeReadingFn, G as Governor, v as GovernorAction, w as GovernorConfig, x as GovernorSignal, y as GovernorState, z as GraceWindowClosedEvent, H as GraceWindowOpenEvent, I as GraceWindowState, J as IdleWarningEvent, K as KnownBehaviorState, L as LLMProvider, M as LLMSelection, N as LiveKitAvatarGrantState, O as LiveKitAvatarGrantStatus, P as LiveKitCapacityState, Q as LiveKitConnectionStatus, R as LiveKitSessionRequest, S as LiveKitSessionStartResult, T as LivePlaybackKeeper, U as MAX_RECONNECT_ATTEMPTS, V as MAX_SESSION_INSTRUCTIONS_CHARS, W as MIC_LEASE_ENDED_TIMEOUT_MS, X as MicLease, Y as PlayableVideoElement, Z as ProxyClientOptions, _ as QualityCap, $ as RECONNECT_BACKOFF_MS, a0 as RealtimeAvatarCapacityError, a1 as RealtimeAvatarLiveKitRoom, a2 as RealtimeAvatarLiveKitRoomProps, a3 as RealtimeAvatarRequestOptions, a4 as RealtimeSessionApi, a5 as RealtimeSessionMedia, a6 as RealtimeSessionRoomSinks, a7 as ReconnectPolicy, a8 as ReconnectingEvent, a9 as RecoveryState, aa as RetryStep, ab as SessionBehavior, ac as SessionClip, ad as SessionClocks, ae as SessionEndReason, af as SessionLifecycleApi, ag as SessionLifecyclePhase, ah as SessionLifecyclePhaseKind, ai as SessionLifecycleRoomBridge, aj as SessionLifecycleRoomBridgeProps, ak as SurfaceLayers, al as TurnState, am as TurnTimeoutEvent, an as UseAvatarQualityGovernorInput, ao as UseLiveKitAvatarGrantInput, ap as UseRealtimeSessionInput, aq as UseSessionLifecycleInput, ar as VoiceSpec, as as VoiceSpecInput, at as capacityErrorFromBusy, au as capacityStateFromGrant, av as createProxyClient, aw as knownBehaviorStates, ax as mapTurnState, ay as sessionBehaviorSchema, az as sessionClipSchema, aA as shouldReplayPendingTurn, aB as splitCallTranscript, aC as useAvatarPlayoutDelay, aD as useAvatarQualityGovernor, aE as useCallTranscript, aF as useLiveKitAvatarGrant, aG as useMicLease, aH as useRealtimeSession, aI as useReleaseMicLeaseOnTrackEnded, aJ as useSessionLifecycle } from './proxy-client-cZyX50-O.js';
4
+ import '@livekit/components-react';
5
+ import 'livekit-client';
6
+ import 'zod';
7
+
8
+ /**
9
+ * The CONNECT surface (client half) — one component that puts a live character on screen.
10
+ *
11
+ * WHY THIS EXISTS. The lower-level surface is deliberately LiveKit-first: the app owns the
12
+ * room, mounts the lifecycle bridge, maps a nine-arm phase union to its own copy, and wires
13
+ * the video surface. That is the right shape for a team that wants to own media policy, and
14
+ * it is far too much surface for a team that wants a character on screen. Worse, it makes
15
+ * the transport part of the integration contract: an app that names `RealtimeAvatarLiveKitRoom`
16
+ * and `SessionLifecycleRoomBridge` is coupled to WebRTC-via-LiveKit forever.
17
+ *
18
+ * `<AvatarCall>` closes that hole. It mounts the room, the bridge, and the video surface, and
19
+ * reports a FIVE-arm status that says nothing about how the pixels arrive. Swapping the
20
+ * transport underneath is then our problem, not the integrator's.
21
+ *
22
+ * Everything the lower-level API offers is still exported and still supported — this is
23
+ * additive. Reach for it when you genuinely need to own the room.
24
+ */
25
+
26
+ /**
27
+ * What the app renders a banner for. Deliberately NOT the internal phase union: those arms
28
+ * name connection mechanics, and an integrator should never write `case "reconnectable"`.
29
+ */
30
+ type AvatarCallStatus =
31
+ /** Getting the character ready. */
32
+ "connecting"
33
+ /** Every slot is busy; we are holding a place in line. Not an error. */
34
+ | "waiting"
35
+ /** She is there. */
36
+ | "live"
37
+ /** A blip; recovering automatically. */
38
+ | "recovering"
39
+ /** Over. `onEnded` already told you why. */
40
+ | "ended";
41
+ /** Why a call ended — the only vocabulary an end screen needs. */
42
+ type AvatarCallEndReason = "user_ended" | "session_cap" | "idle" | "disconnected" | "out_of_credits" | "agent_ended" | "failed";
43
+ type AvatarCallHandle = {
44
+ status: AvatarCallStatus;
45
+ /** Place in line while `status === "waiting"`, else null. */
46
+ queuePosition: number | null;
47
+ /** Seconds until the hard cap, or null before the clock lands. */
48
+ secondsRemaining: number | null;
49
+ /** Say something to her. Optional `steer` shapes THIS reply only (tool results go here). */
50
+ say: (text: string, options?: {
51
+ steer?: string;
52
+ }) => Promise<void>;
53
+ /** Speak one exact line, verbatim, then end. For goodbyes and disclosures. */
54
+ sayAndEnd: (text: string) => void;
55
+ /** The user is still here — postpones the idle disconnect. */
56
+ keepAlive: () => void;
57
+ /** End now. */
58
+ end: () => void;
59
+ };
60
+ type AvatarCallProps = {
61
+ client: AvatarSessionClient;
62
+ /** Which character. */
63
+ avatarId: string;
64
+ /** `voice` is audio-only and cheaper; `avatar` (default) is the full call. */
65
+ mode?: "avatar" | "voice";
66
+ /** Listen to the user's microphone. Default true. */
67
+ listen?: boolean;
68
+ /** A looping clip shown before she is live and whenever the stream is not producing. */
69
+ idleVideoUrl?: string | null;
70
+ /** A still shown before the idle clip is playable. */
71
+ poster?: string | null;
72
+ fit?: AvatarVideoFit;
73
+ className?: string;
74
+ /** Your remaining balance in ms, if you want `onLowBalance`. */
75
+ balanceMs?: number;
76
+ onStatusChange?: (status: AvatarCallStatus) => void;
77
+ onEnded?: (event: {
78
+ reason: AvatarCallEndReason;
79
+ }) => void;
80
+ /** She is nearly out of time — write her goodbye and pass it to `sayAndEnd`. */
81
+ onEnding?: (event: {
82
+ secondsLeft: number;
83
+ call: AvatarCallHandle;
84
+ }) => void;
85
+ /** The user went quiet. */
86
+ onQuiet?: (event: {
87
+ secondsLeft: number;
88
+ }) => void;
89
+ /** Balance running low. */
90
+ onLowBalance?: (event: {
91
+ secondsLeft: number;
92
+ }) => void;
93
+ /** Overlay your own UI on the video; receives the same handle as `useAvatarCall`. */
94
+ children?: (call: AvatarCallHandle) => ReactNode;
95
+ };
96
+ /**
97
+ * The connect-level hook, for apps that want their own layout around the video. Returns the
98
+ * same handle `<AvatarCall>` hands its children, plus the element to render.
99
+ */
100
+ declare function useAvatarCall(props: AvatarCallProps): {
101
+ call: AvatarCallHandle;
102
+ view: ReactNode;
103
+ };
104
+ /** One component: a live character on screen. */
105
+ declare function AvatarCall(props: AvatarCallProps): ReactNode;
106
+
107
+ export { AvatarCall, type AvatarCallEndReason, type AvatarCallHandle, type AvatarCallProps, type AvatarCallStatus, AvatarSessionClient, AvatarVideoFit, useAvatarCall };