@voqalize/avatar 0.2.2 → 0.4.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.
Files changed (265) hide show
  1. package/LICENSE +21 -661
  2. package/LICENSE-CC-BY-4.0 +396 -0
  3. package/README.md +191 -662
  4. package/assets/README.md +48 -0
  5. package/assets/tanya.glb +0 -0
  6. package/assets/tara.glb +0 -0
  7. package/assets/tushar.glb +0 -0
  8. package/client/Avatar.tsx +57 -0
  9. package/client/AvatarClient.ts +818 -0
  10. package/client/arjun.ts +26 -0
  11. package/client/createAvatar.ts +177 -0
  12. package/client/createCanvasAvatar.ts +72 -0
  13. package/client/index.ts +44 -0
  14. package/client/internal.ts +108 -0
  15. package/client/interviewer-female.ts +4 -0
  16. package/client/interviewer-male.ts +4 -0
  17. package/client/ishita.ts +26 -0
  18. package/client/kabir.ts +26 -0
  19. package/client/meera.ts +26 -0
  20. package/client/naina.ts +26 -0
  21. package/client/playout.ts +95 -0
  22. package/client/professional-female-a.ts +4 -0
  23. package/client/professional-female-b.ts +4 -0
  24. package/client/professional-male-a.ts +4 -0
  25. package/client/professional-male-b.ts +4 -0
  26. package/client/react.ts +13 -0
  27. package/client/supports.ts +28 -0
  28. package/client/three/assets.ts +24 -0
  29. package/client/three/budgets.ts +27 -0
  30. package/client/three/holds.ts +64 -0
  31. package/client/three/internal.ts +54 -0
  32. package/client/three/motion-limits.json +116 -0
  33. package/client/three/sequences.ts +281 -0
  34. package/client/three/tanya.ts +69 -0
  35. package/client/three/tara-rig.ts +1562 -0
  36. package/client/three/tara.ts +76 -0
  37. package/client/three/tushar.ts +65 -0
  38. package/client/types.ts +235 -0
  39. package/client/useAvatar.ts +74 -0
  40. package/client/vikram.ts +26 -0
  41. package/dist/Avatar.d.ts +44 -0
  42. package/dist/Avatar.d.ts.map +1 -0
  43. package/{client/dist → dist}/Avatar.js +2 -2
  44. package/dist/Avatar.js.map +1 -0
  45. package/dist/AvatarClient.d.ts +274 -0
  46. package/dist/AvatarClient.d.ts.map +1 -0
  47. package/dist/AvatarClient.js +712 -0
  48. package/dist/AvatarClient.js.map +1 -0
  49. package/dist/arjun.d.ts +7 -0
  50. package/dist/arjun.d.ts.map +1 -0
  51. package/dist/arjun.js +20 -0
  52. package/dist/arjun.js.map +1 -0
  53. package/dist/createAvatar.d.ts +135 -0
  54. package/dist/createAvatar.d.ts.map +1 -0
  55. package/dist/createAvatar.js +75 -0
  56. package/dist/createAvatar.js.map +1 -0
  57. package/dist/createCanvasAvatar.d.ts +22 -0
  58. package/dist/createCanvasAvatar.d.ts.map +1 -0
  59. package/dist/createCanvasAvatar.js +47 -0
  60. package/dist/createCanvasAvatar.js.map +1 -0
  61. package/dist/index.d.ts +34 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +33 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/internal.d.ts +34 -0
  66. package/dist/internal.d.ts.map +1 -0
  67. package/dist/internal.js +41 -0
  68. package/dist/internal.js.map +1 -0
  69. package/dist/interviewer-female.d.ts +4 -0
  70. package/dist/interviewer-female.d.ts.map +1 -0
  71. package/dist/interviewer-female.js +3 -0
  72. package/dist/interviewer-female.js.map +1 -0
  73. package/dist/interviewer-male.d.ts +4 -0
  74. package/dist/interviewer-male.d.ts.map +1 -0
  75. package/dist/interviewer-male.js +3 -0
  76. package/dist/interviewer-male.js.map +1 -0
  77. package/dist/ishita.d.ts +7 -0
  78. package/dist/ishita.d.ts.map +1 -0
  79. package/dist/ishita.js +20 -0
  80. package/dist/ishita.js.map +1 -0
  81. package/dist/kabir.d.ts +7 -0
  82. package/dist/kabir.d.ts.map +1 -0
  83. package/dist/kabir.js +20 -0
  84. package/dist/kabir.js.map +1 -0
  85. package/dist/meera.d.ts +7 -0
  86. package/dist/meera.d.ts.map +1 -0
  87. package/dist/meera.js +20 -0
  88. package/dist/meera.js.map +1 -0
  89. package/dist/naina.d.ts +7 -0
  90. package/dist/naina.d.ts.map +1 -0
  91. package/dist/naina.js +20 -0
  92. package/dist/naina.js.map +1 -0
  93. package/dist/playout.d.ts +42 -0
  94. package/dist/playout.d.ts.map +1 -0
  95. package/dist/playout.js +85 -0
  96. package/dist/playout.js.map +1 -0
  97. package/dist/professional-female-a.d.ts +4 -0
  98. package/dist/professional-female-a.d.ts.map +1 -0
  99. package/dist/professional-female-a.js +3 -0
  100. package/dist/professional-female-a.js.map +1 -0
  101. package/dist/professional-female-b.d.ts +4 -0
  102. package/dist/professional-female-b.d.ts.map +1 -0
  103. package/dist/professional-female-b.js +3 -0
  104. package/dist/professional-female-b.js.map +1 -0
  105. package/dist/professional-male-a.d.ts +4 -0
  106. package/dist/professional-male-a.d.ts.map +1 -0
  107. package/dist/professional-male-a.js +3 -0
  108. package/dist/professional-male-a.js.map +1 -0
  109. package/dist/professional-male-b.d.ts +4 -0
  110. package/dist/professional-male-b.d.ts.map +1 -0
  111. package/dist/professional-male-b.js +3 -0
  112. package/dist/professional-male-b.js.map +1 -0
  113. package/dist/react.d.ts +13 -0
  114. package/dist/react.d.ts.map +1 -0
  115. package/dist/react.js +13 -0
  116. package/dist/react.js.map +1 -0
  117. package/dist/supports.d.ts +20 -0
  118. package/dist/supports.d.ts.map +1 -0
  119. package/dist/supports.js +26 -0
  120. package/dist/supports.js.map +1 -0
  121. package/dist/three/assets.d.ts +24 -0
  122. package/dist/three/assets.d.ts.map +1 -0
  123. package/dist/three/assets.js +22 -0
  124. package/dist/three/assets.js.map +1 -0
  125. package/dist/three/budgets.d.ts +17 -0
  126. package/dist/three/budgets.d.ts.map +1 -0
  127. package/dist/three/budgets.js +21 -0
  128. package/dist/three/budgets.js.map +1 -0
  129. package/dist/three/holds.d.ts +33 -0
  130. package/dist/three/holds.d.ts.map +1 -0
  131. package/dist/three/holds.js +56 -0
  132. package/dist/three/holds.js.map +1 -0
  133. package/dist/three/internal.d.ts +52 -0
  134. package/dist/three/internal.d.ts.map +1 -0
  135. package/dist/three/internal.js +49 -0
  136. package/dist/three/internal.js.map +1 -0
  137. package/dist/three/motion-limits.json +116 -0
  138. package/dist/three/sequences.d.ts +71 -0
  139. package/dist/three/sequences.d.ts.map +1 -0
  140. package/dist/three/sequences.js +262 -0
  141. package/dist/three/sequences.js.map +1 -0
  142. package/dist/three/tanya.d.ts +35 -0
  143. package/dist/three/tanya.d.ts.map +1 -0
  144. package/dist/three/tanya.js +51 -0
  145. package/dist/three/tanya.js.map +1 -0
  146. package/dist/three/tara-rig.d.ts +403 -0
  147. package/dist/three/tara-rig.d.ts.map +1 -0
  148. package/dist/three/tara-rig.js +1500 -0
  149. package/dist/three/tara-rig.js.map +1 -0
  150. package/dist/three/tara.d.ts +35 -0
  151. package/dist/three/tara.d.ts.map +1 -0
  152. package/dist/three/tara.js +58 -0
  153. package/dist/three/tara.js.map +1 -0
  154. package/dist/three/tushar.d.ts +31 -0
  155. package/dist/three/tushar.d.ts.map +1 -0
  156. package/dist/three/tushar.js +47 -0
  157. package/dist/three/tushar.js.map +1 -0
  158. package/dist/types.d.ts +149 -0
  159. package/dist/types.d.ts.map +1 -0
  160. package/dist/types.js +140 -0
  161. package/dist/types.js.map +1 -0
  162. package/dist/useAvatar.d.ts +39 -0
  163. package/dist/useAvatar.d.ts.map +1 -0
  164. package/dist/useAvatar.js +35 -0
  165. package/dist/useAvatar.js.map +1 -0
  166. package/dist/vikram.d.ts +7 -0
  167. package/dist/vikram.d.ts.map +1 -0
  168. package/dist/vikram.js +20 -0
  169. package/dist/vikram.js.map +1 -0
  170. package/package.json +110 -25
  171. package/src/avatar.d.ts +218 -120
  172. package/src/avatar.js +950 -213
  173. package/src/behavior.d.ts +42 -0
  174. package/src/behavior.js +114 -0
  175. package/src/camera.js +29 -0
  176. package/src/canvas/author/parts/eye.mjs +722 -0
  177. package/src/canvas/author/parts/hand.mjs +1156 -0
  178. package/src/canvas/author/parts/mouth.mjs +741 -0
  179. package/src/canvas/author/parts/nose.mjs +100 -0
  180. package/src/canvas/author/parts/skin-detail.mjs +67 -0
  181. package/src/canvas/author/path.mjs +283 -0
  182. package/src/canvas/author/rig.mjs +405 -0
  183. package/src/canvas/avatars/round/face.d.mts +3 -0
  184. package/src/canvas/avatars/round/face.mjs +1307 -0
  185. package/src/canvas/create-rig.d.ts +15 -0
  186. package/src/canvas/create-rig.js +100 -0
  187. package/src/canvas/data/img/professional-female-a-hair-back.webp +0 -0
  188. package/src/canvas/data/img/professional-female-a-hair-front.webp +0 -0
  189. package/src/canvas/data/img/professional-female-a-top-body.webp +0 -0
  190. package/src/canvas/data/img/professional-female-b-hair-back.webp +0 -0
  191. package/src/canvas/data/img/professional-female-b-hair-front.webp +0 -0
  192. package/src/canvas/data/img/professional-female-b-top-body.webp +0 -0
  193. package/src/canvas/data/img/professional-male-a-hair-back.webp +0 -0
  194. package/src/canvas/data/img/professional-male-a-hair-front.webp +0 -0
  195. package/src/canvas/data/img/professional-male-a-top-body.webp +0 -0
  196. package/src/canvas/data/img/professional-male-b-hair-back.webp +0 -0
  197. package/src/canvas/data/img/professional-male-b-hair-front.webp +0 -0
  198. package/src/canvas/data/img/professional-male-b-top-body.webp +0 -0
  199. package/src/canvas/data/img/round-m3-hair-back.webp +0 -0
  200. package/src/canvas/data/img/round-m3-hair-front.webp +0 -0
  201. package/src/canvas/data/img/round-m3-top-body.webp +0 -0
  202. package/src/canvas/data/img/round-w1-hair-back.webp +0 -0
  203. package/src/canvas/data/img/round-w1-hair-front.webp +0 -0
  204. package/src/canvas/data/img/round-w1-top-body.webp +0 -0
  205. package/src/canvas/data/interviewer-female.rig.json +1 -0
  206. package/src/canvas/data/interviewer-male.rig.json +1 -0
  207. package/src/canvas/data/professional-female-a.rig.json +1 -0
  208. package/src/canvas/data/professional-female-b.rig.json +1 -0
  209. package/src/canvas/data/professional-male-a.rig.json +1 -0
  210. package/src/canvas/data/professional-male-b.rig.json +1 -0
  211. package/src/canvas/src/live.js +508 -0
  212. package/src/canvas/src/render2d.js +218 -0
  213. package/src/canvas/src/rig.js +297 -0
  214. package/src/canvas/src/vocab.js +96 -0
  215. package/src/clips.js +18 -7
  216. package/src/conformance.js +119 -0
  217. package/src/emotions.js +8 -5
  218. package/src/face-core.js +27 -1
  219. package/src/face-myna.d.ts +7 -0
  220. package/src/face-myna.js +192 -131
  221. package/src/face-peep-control-plane.js +167 -0
  222. package/src/face-peep.d.ts +7 -0
  223. package/src/face-peep.js +274 -116
  224. package/src/face-wren.d.ts +7 -0
  225. package/src/face-wren.js +17 -19
  226. package/src/faces.d.ts +12 -0
  227. package/src/faces.js +53 -0
  228. package/src/gaze.js +434 -58
  229. package/src/hand.js +120 -91
  230. package/src/head.js +134 -0
  231. package/src/idle.js +227 -119
  232. package/src/interjections.js +200 -31
  233. package/src/params.js +8 -4
  234. package/src/perform.js +7 -9
  235. package/src/prosody.js +647 -0
  236. package/src/rig.d.ts +24 -0
  237. package/src/rig.js +32 -0
  238. package/src/speech-timing.js +23 -0
  239. package/src/visemes.js +110 -24
  240. package/client/dist/Avatar.d.ts +0 -27
  241. package/client/dist/Avatar.d.ts.map +0 -1
  242. package/client/dist/Avatar.js.map +0 -1
  243. package/client/dist/AvatarClient.d.ts +0 -139
  244. package/client/dist/AvatarClient.d.ts.map +0 -1
  245. package/client/dist/AvatarClient.js +0 -223
  246. package/client/dist/AvatarClient.js.map +0 -1
  247. package/client/dist/index.d.ts +0 -22
  248. package/client/dist/index.d.ts.map +0 -1
  249. package/client/dist/index.js +0 -22
  250. package/client/dist/index.js.map +0 -1
  251. package/client/dist/types.d.ts +0 -86
  252. package/client/dist/types.d.ts.map +0 -1
  253. package/client/dist/types.js +0 -31
  254. package/client/dist/types.js.map +0 -1
  255. package/client/dist/useAvatar.d.ts +0 -42
  256. package/client/dist/useAvatar.d.ts.map +0 -1
  257. package/client/dist/useAvatar.js +0 -51
  258. package/client/dist/useAvatar.js.map +0 -1
  259. package/client/src/Avatar.tsx +0 -33
  260. package/client/src/AvatarClient.ts +0 -270
  261. package/client/src/index.ts +0 -22
  262. package/client/src/types.ts +0 -104
  263. package/client/src/useAvatar.ts +0 -85
  264. package/docs/contract-avatar.md +0 -371
  265. package/docs/contract-protocol.md +0 -461
@@ -0,0 +1,274 @@
1
+ /**
2
+ * AvatarClient — the avatar's server-message dispatcher, turn clock, and cue
3
+ * splice, framework-free (no React; the hook and component wrap this).
4
+ *
5
+ * ## Turn clock anchoring
6
+ *
7
+ * Base Pipecat TTS gives each serialized TTS context an opaque `context_id`.
8
+ * The server uses it only to group and splice cue chunks. `botStartedSpeaking`
9
+ * has no context payload, so the browser FIFO-claims the next buffered context
10
+ * at that Pipecat output-lifecycle event. `botStoppedSpeaking` closes it. No
11
+ * avatar-specific speech marker exists.
12
+ *
13
+ * The event says *which* audio is starting, not *when* it is heard, and the
14
+ * turn clock is anchored to the sound itself (`playout.ts` has the
15
+ * measurements that forced it). `attach()` listens to the bot's audio track;
16
+ * at the event, the turn's zero is backdated to a sound that has already begun,
17
+ * or the mouth is held shut until one does. When the track cannot be heard —
18
+ * no `attach()`, no track, a suspended audio graph, or a sound that never
19
+ * arrives within `ONSET_WAIT_MS` — the event is the anchor, as it always was.
20
+ * Which one won is logged once per turn, at `info`, because a desync report is
21
+ * unanswerable without it.
22
+ *
23
+ * The clock then runs `VISUAL_LEAD_MS` ahead of the sound, since the mixer's
24
+ * smoothing makes every mouth shape late by about that much. It is pulled back
25
+ * by any output-device latency beyond what the display already matches (a
26
+ * Bluetooth headset). Within a turn, each resumption after a pause in the
27
+ * track is a second chance to hear where the sound really is — but a mouth
28
+ * opens before its sound, so a resumption heard within the track's usual
29
+ * anticipation of it agrees with the clock. Only a disagreement beyond that is
30
+ * slewed out, at no more than 10 % of clock rate, never jumped, because a
31
+ * mouth that skips is seen and one that runs briefly fast is not.
32
+ *
33
+ * `attach()` subscribes to the avatar server-message channel *and* Pipecat's
34
+ * standard lifecycle events. Server messages carry only what Pipecat cannot:
35
+ * correlated speech/cue timing and deliberate application instructions. The
36
+ * lifecycle events project the factual presence states locally. The server
37
+ * supplies only the three lower-priority states and deliberate,
38
+ * self-completing actions. This keeps the face tied to Pipecat's output truth
39
+ * even if a server state is delayed or stale.
40
+ *
41
+ * ## Cue splice
42
+ *
43
+ * The widget has two cue-track primitives: `speak({cues, clock})` (a full
44
+ * replace) and `pushCues(cues)` (a pure union that can only grow the track,
45
+ * never shrink it). Neither is "discard queued cues at or after `from_ms`,
46
+ * then append" on its own — `pushCues` has no way to drop a stale tail. So
47
+ * this client keeps the turn's canonical cue array itself (kept portion +
48
+ * every appended chunk, spliced on each `cues` message) and picks the cheapest
49
+ * widget call that stays correct:
50
+ *
51
+ * - if the splice's `from_ms` doesn't reach back into anything already
52
+ * queued — the common case past a turn's first sentence, since only the
53
+ * first sentence genuinely plays fast-leg cues — nothing needs discarding:
54
+ * `pushCues(newCues)` is the cheap, correct append.
55
+ * - if it does reach back (a real fast→accurate splice), `pushCues` cannot
56
+ * express the discard; we call `speak()` again with the full spliced
57
+ * canonical array on the turn's original clock. `speak()` is otherwise
58
+ * documented as also killing an in-flight spoken interjection and
59
+ * re-entering `SPEAKING` — both harmless mid-splice (an interjection
60
+ * should not be running while a server track owns the mouth; re-entering
61
+ * an unchanged state is a no-op past the profile/gaze reset the widget
62
+ * already does for a same-name `setState`).
63
+ *
64
+ * Cues commonly arrive **before** `botStartedSpeaking` — the fast leg starts
65
+ * the moment a sentence is handed to TTS, well before bot output begins.
66
+ * Chunks that arrive before the clock is anchored are spliced into the
67
+ * canonical array but not yet handed to the widget; `botStartedSpeaking` hands over
68
+ * whatever has accumulated as the turn's first `speak()` call. So "the first
69
+ * chunk of a turn starts speak()" means the first *widget* call, not
70
+ * necessarily the first *message*.
71
+ */
72
+ import type { PipecatClient } from "@pipecat-ai/client-js";
73
+ import { type PlayoutProbe } from "./playout.js";
74
+ import { type AvatarCommand, type AvatarCue } from "./types.js";
75
+ /**
76
+ * How far the cue clock runs ahead of the sound. The mixer eases every mouth
77
+ * channel toward its target with a 42 ms time constant
78
+ * (`MOUTH_RESPONSE_TAU_S`), which delays a shape by about that much, and a
79
+ * frame is drawn on average half a frame after its time. Picture ahead of sound
80
+ * is the side people forgive (ITU-R BT.1359: sound leading is noticed at about
81
+ * 45 ms, picture leading at about 125 ms), so a small surplus is the safe error.
82
+ */
83
+ export declare const VISUAL_LEAD_MS = 50;
84
+ /**
85
+ * The private renderer-side vocabulary the lifecycle driver actually uses.
86
+ *
87
+ * This stays narrower than `AvatarApi` on purpose. The latter is the SVG
88
+ * mixer's driving API; requiring a second renderer to impersonate every one
89
+ * of its inspection and authoring methods would turn that implementation
90
+ * detail into a renderer contract. The public seam remains `createAvatar`.
91
+ */
92
+ export interface AvatarDriver {
93
+ setState(name: string): unknown;
94
+ /**
95
+ * One motion by name — a core intent or one of this avatar's own. **A name
96
+ * it does not have is a no-op, not a throw**: the wire's action vocabulary is
97
+ * open, so a face that cannot do the thing is as expected as a newer server.
98
+ */
99
+ action(id: string): unknown;
100
+ speak(options: {
101
+ cues: AvatarCue[];
102
+ clock: () => number;
103
+ }): unknown;
104
+ pushCues(cues: AvatarCue[]): unknown;
105
+ stopSpeaking(): unknown;
106
+ setUserSpeaking(speaking: boolean | null): unknown;
107
+ }
108
+ /**
109
+ * Internal. Not exported from the package — the public surface is
110
+ * `createAvatar({ mount, client })` and nothing else.
111
+ *
112
+ * There is deliberately no `accept` predicate here any more. Avatar commands
113
+ * travel in one envelope, `{type:"avatar"}`, in both directions and from every
114
+ * source: a `AvatarProcessor` in the pipeline and a brain driving the face
115
+ * out of band emit the same shape. A per-deployment predicate meant the
116
+ * library could not state what an avatar message *is*, which is the one thing
117
+ * a wire format has to be able to say.
118
+ */
119
+ export interface AvatarClientOptions {
120
+ /** A dispatch threw (e.g. an unknown state or interjection id, which the
121
+ * widget throws on). Defaults to `console.warn`. */
122
+ onError?: (err: unknown, msg: AvatarCommand) => void;
123
+ /** Override for tests. Defaults to `performance.now`. */
124
+ now?: () => number;
125
+ /** Override for tests. Defaults to listening to the bot's audio track, once
126
+ * `attach()` has found one. */
127
+ playoutProbe?: PlayoutProbe;
128
+ /** Quiet time in listening before the client-owned idle loop begins. */
129
+ idleDelayMs?: number;
130
+ /** Timer seams keep lifecycle behavior deterministic in tests. */
131
+ setTimeout?: typeof setTimeout;
132
+ clearTimeout?: typeof clearTimeout;
133
+ /**
134
+ * Internal, for Studio's inspector — the resolved projection, so a developer
135
+ * tool can show what the lifecycle decided. It is *not* on the public
136
+ * surface and must not become one: a presence callback is a contract, and
137
+ * publishing it would oblige every avatar implementation to emit these seven
138
+ * states with this precedence, which is exactly the second public contract
139
+ * the design exists to avoid.
140
+ */
141
+ onPresenceChange?: (state: AvatarPresenceState) => void;
142
+ }
143
+ /**
144
+ * The one `RTVIEvent` member `attach()` subscribes to, spelled as its value.
145
+ *
146
+ * Written out rather than imported because that enum was this module's *only*
147
+ * runtime reference to `@pipecat-ai/client-js`, and one runtime reference makes
148
+ * the whole `/pipecat` subpath fail to load without the peer installed — even
149
+ * for a host that drives `dispatch()` from its own transport and never calls
150
+ * `attach()`. The peer is declared optional; this is what makes that true
151
+ * rather than aspirational.
152
+ *
153
+ * String enums are nominal in TypeScript, so the compiler cannot check these
154
+ * against the real ones from a type-only import. `packages/avatar/test/AvatarClient.test.ts`
155
+ * does it instead, against the actual enum — the devDependency is present
156
+ * exactly where the check belongs and absent from what we ship.
157
+ */
158
+ export declare const RTVI_EVENTS: {
159
+ readonly serverMessage: "serverMessage";
160
+ readonly connected: "connected";
161
+ readonly disconnected: "disconnected";
162
+ readonly botReady: "botReady";
163
+ readonly error: "error";
164
+ readonly userStartedSpeaking: "userStartedSpeaking";
165
+ readonly userStoppedSpeaking: "userStoppedSpeaking";
166
+ readonly botStartedSpeaking: "botStartedSpeaking";
167
+ readonly botStoppedSpeaking: "botStoppedSpeaking";
168
+ readonly trackStarted: "trackStarted";
169
+ readonly userMuteStarted: "userMuteStarted";
170
+ readonly userMuteStopped: "userMuteStopped";
171
+ };
172
+ /** The resolved, factual presence state a host may render around the avatar. */
173
+ export type AvatarPresenceState = "IDLE" | "LISTENING" | "CANT_HEAR" | "THINKING" | "WORKING" | "MUTED" | "SPEAKING" | "DEGRADED" | "OFFLINE";
174
+ export declare class AvatarClient {
175
+ private readonly avatar;
176
+ /** Maps factual/wire intent into the broader client behavior catalog. */
177
+ private readonly behavior;
178
+ private readonly opts;
179
+ private readonly now;
180
+ private turn;
181
+ private readonly turns;
182
+ private readonly pendingCtxs;
183
+ private readonly closedCtxs;
184
+ private projected;
185
+ private serverState;
186
+ private userSpeaking;
187
+ private botSpeaking;
188
+ private muted;
189
+ private listening;
190
+ private idle;
191
+ private failure;
192
+ private idleTimer;
193
+ private pendingInterruptedAction;
194
+ private discardQueuedContextsOnBotStop;
195
+ private readonly idleDelayMs;
196
+ private readonly setTimer;
197
+ private readonly clearTimer;
198
+ private probe;
199
+ private probeTrack;
200
+ /** Whether the probe has ever heard an onset. One that has not, and times
201
+ * out, is deaf to this track rather than early to it. */
202
+ private probeHeard;
203
+ private onsetTimer;
204
+ private reanchorTimer;
205
+ constructor(avatar: AvatarDriver, opts?: AvatarClientOptions);
206
+ /** The active turn's ctx, or `null` between turns. For tests and telemetry. */
207
+ get turnCtx(): string | null;
208
+ /** The active turn's canonical (already-spliced) cue track. For tests and telemetry. */
209
+ get turnCues(): AvatarCue[];
210
+ /** Current resolved projection. Internal — for tests and Studio's inspector.
211
+ * Before the first lifecycle fact the renderer is simply at its ready rest
212
+ * pose, so `LISTENING` is the safe value; it is not a session status. */
213
+ get presenceState(): AvatarPresenceState;
214
+ /** Re-apply the currently resolved factual projection after an embedding
215
+ * tool has temporarily used raw renderer controls. This does not invent a
216
+ * lifecycle event or cancel a finite action. */
217
+ restoreProjection(): void;
218
+ /** Dispatch one server message. Anything that isn't in the avatar envelope
219
+ * is not ours and is ignored; so is an envelope carrying a `cmd` this build
220
+ * has never heard of, per the wire protocol's forward-compat rule. */
221
+ dispatch(raw: unknown): void;
222
+ private handleState;
223
+ private handleAction;
224
+ private playAction;
225
+ private ensureTurn;
226
+ private handleCues;
227
+ private activateNextTurn;
228
+ /** Put the turn's zero where its sound began — see the header. */
229
+ private anchor;
230
+ private anchored;
231
+ /** The lead for a turn starting now — see `VISUAL_LEAD_MS`. */
232
+ private leadMs;
233
+ /** The first resumption after `after` (track ms) that follows a pause long
234
+ * enough to be heard as one. */
235
+ private nextResumption;
236
+ /** Listen for the sound at the turn's next resumption, once. */
237
+ private scheduleReanchor;
238
+ private clearReanchorTimer;
239
+ private clearOnsetTimer;
240
+ private dropProbe;
241
+ /** Listen to the bot's audio track, if the transport has one yet. */
242
+ private listenTo;
243
+ private discardQueuedTurns;
244
+ private lifecycleState;
245
+ private applyProjection;
246
+ private clearIdleTimer;
247
+ private armIdleIfEligible;
248
+ private eligibleForIdle;
249
+ private enterListening;
250
+ private clearServerStateForTurnBoundary;
251
+ private maybePlayInterrupted;
252
+ private clearRecoverableFailure;
253
+ private onUserStartedSpeaking;
254
+ private onUserStoppedSpeaking;
255
+ private onBotStartedSpeaking;
256
+ private onBotStoppedSpeaking;
257
+ private onUserMuteStarted;
258
+ private onUserMuteStopped;
259
+ private onError;
260
+ private onDisconnected;
261
+ private onConnectedOrReady;
262
+ /**
263
+ * Subscribe to a live `PipecatClient`. Standard client events own the normal
264
+ * lifecycle projection; avatar server-messages carry correlated visemes and
265
+ * explicit application intent. Never throws on malformed or irrelevant
266
+ * server messages.
267
+ *
268
+ * @returns an unsubscribe function; call it on unmount or disconnect.
269
+ */
270
+ attach(client: PipecatClient): () => void;
271
+ /** Dispose controller-owned timers when its mounted avatar is destroyed. */
272
+ destroy(): void;
273
+ }
274
+ //# sourceMappingURL=AvatarClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvatarClient.d.ts","sourceRoot":"","sources":["../client/AvatarClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,uBAAuB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