@voqalize/avatar 0.4.4 → 0.5.1

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 (180) hide show
  1. package/README.md +65 -154
  2. package/dist/index.d.ts +37 -26
  3. package/dist/index.js +48 -25
  4. package/dist/pin.d.ts +2 -0
  5. package/dist/pin.js +3 -0
  6. package/dist/react.d.ts +21 -6
  7. package/dist/react.js +24 -6
  8. package/package.json +8 -67
  9. package/LICENSE-APACHE-2.0 +0 -201
  10. package/LICENSE-CC-BY-4.0 +0 -396
  11. package/assets/README.md +0 -60
  12. package/assets/tanvi.glb +0 -0
  13. package/assets/tanya.glb +0 -0
  14. package/assets/tara.glb +0 -0
  15. package/assets/tess.glb +0 -0
  16. package/assets/tushar.glb +0 -0
  17. package/client/Avatar.tsx +0 -57
  18. package/client/AvatarClient.ts +0 -818
  19. package/client/createAvatar.ts +0 -177
  20. package/client/index.ts +0 -44
  21. package/client/internal.ts +0 -132
  22. package/client/playout.ts +0 -95
  23. package/client/react.ts +0 -13
  24. package/client/supports.ts +0 -27
  25. package/client/three/assets.ts +0 -26
  26. package/client/three/budgets.ts +0 -27
  27. package/client/three/character-rig.ts +0 -1746
  28. package/client/three/createCharacter.ts +0 -109
  29. package/client/three/holds.ts +0 -69
  30. package/client/three/internal.ts +0 -55
  31. package/client/three/motion-limits.json +0 -124
  32. package/client/three/sequences.ts +0 -281
  33. package/client/three/tanvi-asset.ts +0 -6
  34. package/client/three/tanvi.ts +0 -30
  35. package/client/three/tanya-asset.ts +0 -6
  36. package/client/three/tanya.ts +0 -29
  37. package/client/three/tara-asset.ts +0 -25
  38. package/client/three/tara.ts +0 -36
  39. package/client/three/tess-asset.ts +0 -6
  40. package/client/three/tess.ts +0 -30
  41. package/client/three/tushar-asset.ts +0 -6
  42. package/client/three/tushar.ts +0 -28
  43. package/client/types.ts +0 -235
  44. package/client/useAvatar.ts +0 -74
  45. package/dist/Avatar.d.ts +0 -44
  46. package/dist/Avatar.d.ts.map +0 -1
  47. package/dist/Avatar.js +0 -7
  48. package/dist/Avatar.js.map +0 -1
  49. package/dist/AvatarClient.d.ts +0 -274
  50. package/dist/AvatarClient.d.ts.map +0 -1
  51. package/dist/AvatarClient.js +0 -712
  52. package/dist/AvatarClient.js.map +0 -1
  53. package/dist/createAvatar.d.ts +0 -135
  54. package/dist/createAvatar.d.ts.map +0 -1
  55. package/dist/createAvatar.js +0 -75
  56. package/dist/createAvatar.js.map +0 -1
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/index.js.map +0 -1
  59. package/dist/internal.d.ts +0 -34
  60. package/dist/internal.d.ts.map +0 -1
  61. package/dist/internal.js +0 -56
  62. package/dist/internal.js.map +0 -1
  63. package/dist/playout.d.ts +0 -42
  64. package/dist/playout.d.ts.map +0 -1
  65. package/dist/playout.js +0 -85
  66. package/dist/playout.js.map +0 -1
  67. package/dist/react.d.ts.map +0 -1
  68. package/dist/react.js.map +0 -1
  69. package/dist/supports.d.ts +0 -19
  70. package/dist/supports.d.ts.map +0 -1
  71. package/dist/supports.js +0 -25
  72. package/dist/supports.js.map +0 -1
  73. package/dist/three/assets.d.ts +0 -10
  74. package/dist/three/assets.d.ts.map +0 -1
  75. package/dist/three/assets.js +0 -23
  76. package/dist/three/assets.js.map +0 -1
  77. package/dist/three/budgets.d.ts +0 -17
  78. package/dist/three/budgets.d.ts.map +0 -1
  79. package/dist/three/budgets.js +0 -21
  80. package/dist/three/budgets.js.map +0 -1
  81. package/dist/three/character-rig.d.ts +0 -366
  82. package/dist/three/character-rig.d.ts.map +0 -1
  83. package/dist/three/character-rig.js +0 -1644
  84. package/dist/three/character-rig.js.map +0 -1
  85. package/dist/three/createCharacter.d.ts +0 -60
  86. package/dist/three/createCharacter.d.ts.map +0 -1
  87. package/dist/three/createCharacter.js +0 -84
  88. package/dist/three/createCharacter.js.map +0 -1
  89. package/dist/three/holds.d.ts +0 -38
  90. package/dist/three/holds.d.ts.map +0 -1
  91. package/dist/three/holds.js +0 -61
  92. package/dist/three/holds.js.map +0 -1
  93. package/dist/three/internal.d.ts +0 -52
  94. package/dist/three/internal.d.ts.map +0 -1
  95. package/dist/three/internal.js +0 -49
  96. package/dist/three/internal.js.map +0 -1
  97. package/dist/three/motion-limits.json +0 -124
  98. package/dist/three/sequences.d.ts +0 -71
  99. package/dist/three/sequences.d.ts.map +0 -1
  100. package/dist/three/sequences.js +0 -262
  101. package/dist/three/sequences.js.map +0 -1
  102. package/dist/three/tanvi-asset.d.ts +0 -7
  103. package/dist/three/tanvi-asset.d.ts.map +0 -1
  104. package/dist/three/tanvi-asset.js +0 -7
  105. package/dist/three/tanvi-asset.js.map +0 -1
  106. package/dist/three/tanvi.d.ts +0 -24
  107. package/dist/three/tanvi.d.ts.map +0 -1
  108. package/dist/three/tanvi.js +0 -24
  109. package/dist/three/tanvi.js.map +0 -1
  110. package/dist/three/tanya-asset.d.ts +0 -7
  111. package/dist/three/tanya-asset.d.ts.map +0 -1
  112. package/dist/three/tanya-asset.js +0 -7
  113. package/dist/three/tanya-asset.js.map +0 -1
  114. package/dist/three/tanya.d.ts +0 -23
  115. package/dist/three/tanya.d.ts.map +0 -1
  116. package/dist/three/tanya.js +0 -23
  117. package/dist/three/tanya.js.map +0 -1
  118. package/dist/three/tara-asset.d.ts +0 -26
  119. package/dist/three/tara-asset.d.ts.map +0 -1
  120. package/dist/three/tara-asset.js +0 -26
  121. package/dist/three/tara-asset.js.map +0 -1
  122. package/dist/three/tara.d.ts +0 -30
  123. package/dist/three/tara.d.ts.map +0 -1
  124. package/dist/three/tara.js +0 -30
  125. package/dist/three/tara.js.map +0 -1
  126. package/dist/three/tess-asset.d.ts +0 -7
  127. package/dist/three/tess-asset.d.ts.map +0 -1
  128. package/dist/three/tess-asset.js +0 -7
  129. package/dist/three/tess-asset.js.map +0 -1
  130. package/dist/three/tess.d.ts +0 -24
  131. package/dist/three/tess.d.ts.map +0 -1
  132. package/dist/three/tess.js +0 -24
  133. package/dist/three/tess.js.map +0 -1
  134. package/dist/three/tushar-asset.d.ts +0 -7
  135. package/dist/three/tushar-asset.d.ts.map +0 -1
  136. package/dist/three/tushar-asset.js +0 -7
  137. package/dist/three/tushar-asset.js.map +0 -1
  138. package/dist/three/tushar.d.ts +0 -22
  139. package/dist/three/tushar.d.ts.map +0 -1
  140. package/dist/three/tushar.js +0 -22
  141. package/dist/three/tushar.js.map +0 -1
  142. package/dist/types.d.ts +0 -149
  143. package/dist/types.d.ts.map +0 -1
  144. package/dist/types.js +0 -140
  145. package/dist/types.js.map +0 -1
  146. package/dist/useAvatar.d.ts +0 -39
  147. package/dist/useAvatar.d.ts.map +0 -1
  148. package/dist/useAvatar.js +0 -35
  149. package/dist/useAvatar.js.map +0 -1
  150. package/src/avatar.d.ts +0 -436
  151. package/src/avatar.js +0 -1378
  152. package/src/behavior.d.ts +0 -42
  153. package/src/behavior.js +0 -114
  154. package/src/camera.js +0 -29
  155. package/src/clips.js +0 -155
  156. package/src/conformance.js +0 -119
  157. package/src/emotions.js +0 -58
  158. package/src/face-core.js +0 -180
  159. package/src/face-myna.d.ts +0 -7
  160. package/src/face-myna.js +0 -786
  161. package/src/face-peep-control-plane.js +0 -167
  162. package/src/face-peep.d.ts +0 -7
  163. package/src/face-peep.js +0 -925
  164. package/src/face-wren.d.ts +0 -7
  165. package/src/face-wren.js +0 -468
  166. package/src/faces.d.ts +0 -12
  167. package/src/faces.js +0 -53
  168. package/src/gaze.js +0 -504
  169. package/src/hand.js +0 -709
  170. package/src/head.js +0 -134
  171. package/src/idle.js +0 -668
  172. package/src/interjections.js +0 -747
  173. package/src/line-art.js +0 -137
  174. package/src/params.js +0 -180
  175. package/src/perform.js +0 -107
  176. package/src/prosody.js +0 -741
  177. package/src/rig.d.ts +0 -31
  178. package/src/rig.js +0 -32
  179. package/src/speech-timing.js +0 -51
  180. package/src/visemes.js +0 -410
@@ -1,30 +0,0 @@
1
- /**
2
- * tara — the first 3-D character, as a complete `createAvatar` module.
3
- *
4
- * Structurally this is the canvas avatars' shape, one layer down: the mixer
5
- * (`@voqalize/avatar/internal`) does states, layers, gaze, idle, blinks, clips
6
- * and per-channel smoothing exactly as it does for every SVG face, and the only
7
- * thing a Blender character replaces is the renderer at the end of it. That is
8
- * the whole argument for authoring her morph targets under the library's pose
9
- * channel names: nothing above this line knows there is a GPU involved, and
10
- * every clip, viseme and co-articulation rule the SVG faces have works here
11
- * unmodified.
12
- *
13
- * How a Blender character is driven is `createCharacter.ts`, and it is the same
14
- * for all of them. What is hers is the mesh — and, until 2026-09-23, rather
15
- * more than that: this file was the original, the others were copies of it, and
16
- * the performance every character inherits was measured on her face. It is the
17
- * house performance now (`CHARACTER_TUNING`), which changes nothing about how
18
- * she looks and everything about where it is decided.
19
- *
20
- * The Three.js import lives behind this module rather than in the barrel so an
21
- * SVG or Canvas consumer never downloads it.
22
- */
23
- import { character } from "./createCharacter.js";
24
- import { BLENDER_SUPPORTS } from "./sequences.js";
25
- import { TARA_GLB } from "./tara-asset.js";
26
- /** The optional driving-UI declaration; one list for every Blender character
27
- * (`sequences.ts`), because they are one rig. */
28
- export const supports = BLENDER_SUPPORTS;
29
- export const createAvatar = character("tara", TARA_GLB);
30
- //# sourceMappingURL=tara.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tara.js","sourceRoot":"","sources":["../../client/three/tara.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAK3C;kDACkD;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Where tess's compiled GLB is. One character, one module — see
3
- * [tara-asset.ts](./tara-asset.ts) for why that separation is load-bearing and
4
- * why the `new URL` literal is spelled exactly this way.
5
- */
6
- export declare const TESS_GLB: string;
7
- //# sourceMappingURL=tess-asset.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tess-asset.d.ts","sourceRoot":"","sources":["../../client/three/tess-asset.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAyD,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Where tess's compiled GLB is. One character, one module — see
3
- * [tara-asset.ts](./tara-asset.ts) for why that separation is load-bearing and
4
- * why the `new URL` literal is spelled exactly this way.
5
- */
6
- export const TESS_GLB = new URL("../../assets/tess.glb", import.meta.url).href;
7
- //# sourceMappingURL=tess-asset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tess-asset.js","sourceRoot":"","sources":["../../client/three/tess-asset.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * tess — American, and the leanest character in the forge.
3
- *
4
- * Her GLB is the shared scripts run with her landmarks (`characters/tess/`,
5
- * whose README has the provenance and the commands). She is back inside tara's
6
- * atlas window — her hair is drawn into a low tail that clears both ears and
7
- * reaches |u| 0.492 against a window that stops at 0.64 — so unlike tanya she
8
- * needs no `face_texture.py` of her own, and her `Hair` shell gives up no roll:
9
- * nothing of hers hangs past the jaw to lag. One supplied sheet, no paid edit,
10
- * no module of her own; she is what a new character costs at the floor, which
11
- * is why the README builds its template from her.
12
- *
13
- * Her head angles have not been read off her yet. `motion-limits.json` says so
14
- * rather than guessing, and `headHold` gives her the tightest budget any face
15
- * is still vouched for until the owner drives her.
16
- */
17
- import type { CharacterAvatarOptions } from "./createCharacter.js";
18
- export type { CharacterAvatarOptions as AvatarOptions };
19
- export type { AvatarInstance } from "./createCharacter.js";
20
- /** The optional driving-UI declaration; one list for every Blender character
21
- * (`sequences.ts`), because they are one rig. */
22
- export declare const supports: import("../createAvatar.js").AvatarSupport;
23
- export declare const createAvatar: import("../createAvatar.js").AvatarFactory<CharacterAvatarOptions>;
24
- //# sourceMappingURL=tess.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tess.d.ts","sourceRoot":"","sources":["../../client/three/tess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAInE,YAAY,EAAE,sBAAsB,IAAI,aAAa,EAAE,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;kDACkD;AAClD,eAAO,MAAM,QAAQ,4CAAmB,CAAC;AAEzC,eAAO,MAAM,YAAY,oEAA8B,CAAC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * tess — American, and the leanest character in the forge.
3
- *
4
- * Her GLB is the shared scripts run with her landmarks (`characters/tess/`,
5
- * whose README has the provenance and the commands). She is back inside tara's
6
- * atlas window — her hair is drawn into a low tail that clears both ears and
7
- * reaches |u| 0.492 against a window that stops at 0.64 — so unlike tanya she
8
- * needs no `face_texture.py` of her own, and her `Hair` shell gives up no roll:
9
- * nothing of hers hangs past the jaw to lag. One supplied sheet, no paid edit,
10
- * no module of her own; she is what a new character costs at the floor, which
11
- * is why the README builds its template from her.
12
- *
13
- * Her head angles have not been read off her yet. `motion-limits.json` says so
14
- * rather than guessing, and `headHold` gives her the tightest budget any face
15
- * is still vouched for until the owner drives her.
16
- */
17
- import { character } from "./createCharacter.js";
18
- import { BLENDER_SUPPORTS } from "./sequences.js";
19
- import { TESS_GLB } from "./tess-asset.js";
20
- /** The optional driving-UI declaration; one list for every Blender character
21
- * (`sequences.ts`), because they are one rig. */
22
- export const supports = BLENDER_SUPPORTS;
23
- export const createAvatar = character("tess", TESS_GLB);
24
- //# sourceMappingURL=tess.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tess.js","sourceRoot":"","sources":["../../client/three/tess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAK3C;kDACkD;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Where tushar's compiled GLB is. One character, one module — see
3
- * [tara-asset.ts](./tara-asset.ts) for why that separation is load-bearing and
4
- * why the `new URL` literal is spelled exactly this way.
5
- */
6
- export declare const TUSHAR_GLB: string;
7
- //# sourceMappingURL=tushar-asset.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tushar-asset.d.ts","sourceRoot":"","sources":["../../client/three/tushar-asset.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAA2D,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Where tushar's compiled GLB is. One character, one module — see
3
- * [tara-asset.ts](./tara-asset.ts) for why that separation is load-bearing and
4
- * why the `new URL` literal is spelled exactly this way.
5
- */
6
- export const TUSHAR_GLB = new URL("../../assets/tushar.glb", import.meta.url).href;
7
- //# sourceMappingURL=tushar-asset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tushar-asset.js","sourceRoot":"","sources":["../../client/three/tushar-asset.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,yBAAyB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC"}
@@ -1,22 +0,0 @@
1
- /**
2
- * tushar — the second 3-D character, and the one who proved the factory.
3
- *
4
- * His GLB is the shared scripts run with his landmarks and atlas layout in
5
- * place of tara's (`characters/tushar/`, whose README has the provenance and
6
- * the commands). He was a deliberate copy of `tara.ts` for as long as there was
7
- * a `tara.ts` to copy; since 2026-09-23 there is one Blender entry point and he
8
- * is its second caller rather than her second draft (`createCharacter.ts`).
9
- *
10
- * He is also the face that turned the ledger from a question into a decision.
11
- * What was marked TARA-SPECIFIC was marked that way because one face cannot
12
- * tell a convention from a coincidence; he agreed with her, and so did the two
13
- * after him.
14
- */
15
- import type { CharacterAvatarOptions } from "./createCharacter.js";
16
- export type { CharacterAvatarOptions as AvatarOptions };
17
- export type { AvatarInstance } from "./createCharacter.js";
18
- /** The optional driving-UI declaration; one list for every Blender character
19
- * (`sequences.ts`), because they are one rig. */
20
- export declare const supports: import("../createAvatar.js").AvatarSupport;
21
- export declare const createAvatar: import("../createAvatar.js").AvatarFactory<CharacterAvatarOptions>;
22
- //# sourceMappingURL=tushar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tushar.d.ts","sourceRoot":"","sources":["../../client/three/tushar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAInE,YAAY,EAAE,sBAAsB,IAAI,aAAa,EAAE,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;kDACkD;AAClD,eAAO,MAAM,QAAQ,4CAAmB,CAAC;AAEzC,eAAO,MAAM,YAAY,oEAAkC,CAAC"}
@@ -1,22 +0,0 @@
1
- /**
2
- * tushar — the second 3-D character, and the one who proved the factory.
3
- *
4
- * His GLB is the shared scripts run with his landmarks and atlas layout in
5
- * place of tara's (`characters/tushar/`, whose README has the provenance and
6
- * the commands). He was a deliberate copy of `tara.ts` for as long as there was
7
- * a `tara.ts` to copy; since 2026-09-23 there is one Blender entry point and he
8
- * is its second caller rather than her second draft (`createCharacter.ts`).
9
- *
10
- * He is also the face that turned the ledger from a question into a decision.
11
- * What was marked TARA-SPECIFIC was marked that way because one face cannot
12
- * tell a convention from a coincidence; he agreed with her, and so did the two
13
- * after him.
14
- */
15
- import { character } from "./createCharacter.js";
16
- import { BLENDER_SUPPORTS } from "./sequences.js";
17
- import { TUSHAR_GLB } from "./tushar-asset.js";
18
- /** The optional driving-UI declaration; one list for every Blender character
19
- * (`sequences.ts`), because they are one rig. */
20
- export const supports = BLENDER_SUPPORTS;
21
- export const createAvatar = character("tushar", TUSHAR_GLB);
22
- //# sourceMappingURL=tushar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tushar.js","sourceRoot":"","sources":["../../client/three/tushar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C;kDACkD;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,149 +0,0 @@
1
- /**
2
- * types.ts — the avatar wire vocabulary, client side.
3
- *
4
- * The binding definition is `docs/contract-wire.md`; this file is its
5
- * TypeScript restatement and must not drift from it. The Python half of the
6
- * same vocabulary is `packages/avatar-py/src/voqalize_avatar/messages.py` — the three are
7
- * maintained together, and a command added to one without the others is
8
- * incomplete.
9
- *
10
- * A server pushes these as RTVI `server-message`s under the envelope
11
- * `{ type: "avatar", ...cmd-specific fields }`. {@link AvatarCommand} describes
12
- * what rides inside that envelope; {@link isAvatarMessage} is the envelope
13
- * itself, and is the only definition of "this message is for the avatar" the
14
- * client has. There is no protocol version field — an unknown `cmd` is simply
15
- * ignored, which is the whole forward-compatibility rule.
16
- */
17
- import type { VisemeLetter } from "../src/avatar.js";
18
- /** A viseme cue: `t` is a ms offset into the utterance's clock, `v` is a Rhubarb A–H (or X) letter. */
19
- export interface AvatarCue {
20
- t: number;
21
- v: VisemeLetter;
22
- /** 0..1 loudness. Absent means full. */
23
- i?: number;
24
- /**
25
- * The phone being articulated under `v`, absent during silence.
26
- *
27
- * `v` is a nine-way projection of the recogniser's ~40 phones and the loss is
28
- * concentrated — `B` alone absorbs IY, IH, T, D, CH, JH, TH, DH, S, Z, SH,
29
- * ZH, N and Y — so a renderer with a mouth for "tongue between the teeth"
30
- * cannot ask for it from `v` and can from here. **Not a closed set**: it is
31
- * whatever the engine labels its own segments with, which today is Arpabet
32
- * plus `Schwa` and four non-speech labels, and a later engine may say
33
- * something else. Validated as an identifier and passed through unread —
34
- * the letter stays the thing every face must handle, and a face that wants
35
- * the finer signal opts in.
36
- */
37
- p?: string;
38
- }
39
- /**
40
- * A durable, lower-priority server state. `null` explicitly clears it.
41
- *
42
- * Three values, and the server can send no others: the remaining six of the
43
- * nine are Pipecat facts the browser already holds, and a server spelling of a
44
- * fact would be a second, lower-authority copy of it. It was `cmd: "claim"`
45
- * until the wire redesign, when the concept and the command were given the one
46
- * name the rest of the system already used for it.
47
- */
48
- export interface AvatarStateCmd {
49
- cmd: "state";
50
- state: "CANT_HEAR" | "THINKING" | "WORKING" | null;
51
- }
52
- /**
53
- * One self-completing motion, by name: face, body, and optionally a hand.
54
- *
55
- * **The id is open.** Two of them — {@link CORE_ACTION_IDS} — are intents every
56
- * renderer owes a server and are the only ones a server may send without
57
- * knowing what is mounted. Everything else is a name from the mounted avatar's
58
- * own catalogue, and **an unknown one is ignored, not an error**: that is the
59
- * same forward-compatibility rule an unknown `cmd` gets, arrived at from the
60
- * other direction. There, a newer server meets an older widget; here, any
61
- * server meets a face that cannot do the thing. Neither is worth breaking a
62
- * call over, and there is deliberately no fallback — an action sits on top of a
63
- * state, so nothing is missing when one is dropped.
64
- *
65
- * This replaced a closed seven-id vocabulary plus a second command,
66
- * `sequence`, for a renderer's own motions. The split cost a promotion ritual
67
- * for every new portable intent and still could not say what the closed set was
68
- * for: the listening research separates a continuer nod from an assessment nod
69
- * from a realisation, and all three were the one id `ACK_NOD` spelled. Now the
70
- * server says *when* to acknowledge and the avatar owns the variety.
71
- */
72
- export interface AvatarActionCmd {
73
- cmd: "action";
74
- id: string;
75
- }
76
- /**
77
- * The two actions every renderer must answer to.
78
- *
79
- * `ACKNOWLEDGE` is the whole backchannel family in one word — receipt, nod,
80
- * realisation, empathy — because which of those a face does is a rendering
81
- * decision and the server is not the one holding the drawing.
82
- * `RESPONSE_INTERRUPTED` is the one transition a server can explain and the
83
- * browser cannot infer.
84
- *
85
- * A renderer may draw either in its own shape; it may never redefine one, and
86
- * a name in its own catalogue never shadows one of these.
87
- */
88
- export declare const CORE_ACTION_IDS: readonly ["ACKNOWLEDGE", "RESPONSE_INTERRUPTED"];
89
- export type CoreActionId = (typeof CORE_ACTION_IDS)[number];
90
- export interface AvatarCuesCmd {
91
- cmd: "cues";
92
- ctx: string;
93
- /** Discard queued cues at or after this offset (ms), then append `cues`. */
94
- from_ms: number;
95
- cues: AvatarCue[];
96
- /**
97
- * True on the one chunk that completes this turn's track: the TTS context is
98
- * closed, so no further chunk will splice into `ctx`. What a client may
99
- * assume, exactly — nothing about playout. The audio it describes is still
100
- * ahead, and Pipecat's `botStoppedSpeaking` remains the end of the turn. It
101
- * is safe to stop expecting more cue chunks after `final`.
102
- *
103
- * Absent on an interrupted turn, deliberately: a turn that was cut never
104
- * claims to have completed. Absent chunks are the normal case — the widget's
105
- * own track already completes on the trailing `X`, so ignoring `final`
106
- * entirely is a correct implementation.
107
- */
108
- final?: boolean;
109
- }
110
- export type AvatarCommand = AvatarStateCmd | AvatarActionCmd | AvatarCuesCmd;
111
- /** The full server-message payload: the envelope plus its command. */
112
- export type AvatarServerMessage = AvatarCommand & {
113
- type: "avatar";
114
- };
115
- /** An envelope addressed to the avatar, before its payload has been read. */
116
- export type AvatarEnvelope = {
117
- type: "avatar";
118
- cmd: string;
119
- } & Record<string, unknown>;
120
- /**
121
- * Is this server-message payload the avatar's? The envelope is the whole
122
- * answer: `{type:"avatar"}` with a string `cmd`. It used to be a per-deployment
123
- * `accept` predicate on the client, which meant the library could not state
124
- * what an avatar message *is*.
125
- *
126
- * Addressed to us is not the same as understood by us: {@link parseAvatarCommand}
127
- * is the second half.
128
- */
129
- export declare function isAvatarMessage(msg: unknown): msg is AvatarEnvelope;
130
- /**
131
- * Read an envelope's payload into the wire vocabulary, or `null` if this build
132
- * cannot act on it — an unknown `cmd`, a state outside the three, an action id
133
- * that is not a name, a malformed `cues` chunk.
134
- *
135
- * `null` is the forward-compat rule with a type attached: a newer server
136
- * talking to an older widget is *expected*, and the older widget ignores what
137
- * it does not know rather than guessing. Doing the check here rather than at
138
- * each use site is what lets the wire types be closed unions instead of
139
- * `string` — the boundary is one function, so it can be the only place that
140
- * has to be honest about untrusted input.
141
- *
142
- * Cues survive individually: one unrecognised letter in a chunk drops that cue,
143
- * not the utterance around it. Losing a frame of articulation is a far smaller
144
- * regression than losing a sentence of it.
145
- */
146
- export declare function parseAvatarCommand(msg: AvatarEnvelope): AvatarCommand | null;
147
- /** The envelope `type` the protocol reserves for avatar traffic. */
148
- export declare const AVATAR_MESSAGE_TYPE = "avatar";
149
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../client/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,uGAAuG;AACvG,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,YAAY,CAAC;IAChB,wCAAwC;IAC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AAc,GAAG,aAAa,GAAG,IAAI,CAwD5E;AAED,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,WAAW,CAAC"}
package/dist/types.js DELETED
@@ -1,140 +0,0 @@
1
- /**
2
- * types.ts — the avatar wire vocabulary, client side.
3
- *
4
- * The binding definition is `docs/contract-wire.md`; this file is its
5
- * TypeScript restatement and must not drift from it. The Python half of the
6
- * same vocabulary is `packages/avatar-py/src/voqalize_avatar/messages.py` — the three are
7
- * maintained together, and a command added to one without the others is
8
- * incomplete.
9
- *
10
- * A server pushes these as RTVI `server-message`s under the envelope
11
- * `{ type: "avatar", ...cmd-specific fields }`. {@link AvatarCommand} describes
12
- * what rides inside that envelope; {@link isAvatarMessage} is the envelope
13
- * itself, and is the only definition of "this message is for the avatar" the
14
- * client has. There is no protocol version field — an unknown `cmd` is simply
15
- * ignored, which is the whole forward-compatibility rule.
16
- */
17
- import { VISEME_LETTERS } from "../src/avatar.js";
18
- /**
19
- * The two actions every renderer must answer to.
20
- *
21
- * `ACKNOWLEDGE` is the whole backchannel family in one word — receipt, nod,
22
- * realisation, empathy — because which of those a face does is a rendering
23
- * decision and the server is not the one holding the drawing.
24
- * `RESPONSE_INTERRUPTED` is the one transition a server can explain and the
25
- * browser cannot infer.
26
- *
27
- * A renderer may draw either in its own shape; it may never redefine one, and
28
- * a name in its own catalogue never shadows one of these.
29
- */
30
- export const CORE_ACTION_IDS = Object.freeze(["ACKNOWLEDGE", "RESPONSE_INTERRUPTED"]);
31
- /**
32
- * Is this server-message payload the avatar's? The envelope is the whole
33
- * answer: `{type:"avatar"}` with a string `cmd`. It used to be a per-deployment
34
- * `accept` predicate on the client, which meant the library could not state
35
- * what an avatar message *is*.
36
- *
37
- * Addressed to us is not the same as understood by us: {@link parseAvatarCommand}
38
- * is the second half.
39
- */
40
- export function isAvatarMessage(msg) {
41
- if (typeof msg !== "object" || msg === null)
42
- return false;
43
- const m = msg;
44
- return m.type === AVATAR_MESSAGE_TYPE && typeof m.cmd === "string";
45
- }
46
- /**
47
- * What an action id may look like. Not which ones exist — that is the mounted
48
- * avatar's business and this function has never met it. `CATEGORY_INTENT` in
49
- * upper case, bounded so a malformed or hostile message cannot smuggle
50
- * anything through as a name.
51
- */
52
- const ACTION_ID = /^[A-Z][A-Z0-9_]{1,63}$/;
53
- const LETTERS = new Set(VISEME_LETTERS);
54
- /**
55
- * What a phone label may look like. Letters only, because every label any
56
- * engine we have seen is one word of them — `AO`, `NG`, `Schwa`, `Breath` —
57
- * and the bound is what stops a name being a payload.
58
- */
59
- const PHONE_LABEL = /^[A-Za-z]{1,12}$/;
60
- /**
61
- * Read an envelope's payload into the wire vocabulary, or `null` if this build
62
- * cannot act on it — an unknown `cmd`, a state outside the three, an action id
63
- * that is not a name, a malformed `cues` chunk.
64
- *
65
- * `null` is the forward-compat rule with a type attached: a newer server
66
- * talking to an older widget is *expected*, and the older widget ignores what
67
- * it does not know rather than guessing. Doing the check here rather than at
68
- * each use site is what lets the wire types be closed unions instead of
69
- * `string` — the boundary is one function, so it can be the only place that
70
- * has to be honest about untrusted input.
71
- *
72
- * Cues survive individually: one unrecognised letter in a chunk drops that cue,
73
- * not the utterance around it. Losing a frame of articulation is a far smaller
74
- * regression than losing a sentence of it.
75
- */
76
- export function parseAvatarCommand(msg) {
77
- switch (msg.cmd) {
78
- // `claim` was this command's name, and `STRAINING` one of its values, until
79
- // the wire redesign. Both are accepted and translated here, in the one
80
- // place that reads untrusted input, so no layer above has ever heard of
81
- // either spelling. Servers that predate the rename keep working; the old
82
- // names appear nowhere else and come out when the last one has shipped.
83
- case "claim":
84
- case "state": {
85
- const state = msg.state === "STRAINING" ? "CANT_HEAR" : msg.state;
86
- if (state === null || state === "CANT_HEAR" || state === "THINKING" || state === "WORKING") {
87
- return { cmd: "state", state };
88
- }
89
- return null;
90
- }
91
- // `sequence` was a second command for the same thing: a name resolved
92
- // against the mounted avatar rather than against a closed list. Now that
93
- // `action` is that, the two are one command and the old one is an alias.
94
- case "sequence":
95
- case "action":
96
- // Shape only, both for a core id and for one of the avatar's own. There
97
- // is nothing to check a name against here — the catalogue belongs to
98
- // whatever is mounted, and this function has never met it.
99
- return typeof msg.id === "string" && ACTION_ID.test(msg.id)
100
- ? { cmd: "action", id: msg.id }
101
- : null;
102
- case "cues": {
103
- if (typeof msg.ctx !== "string" || !Number.isFinite(msg.from_ms) || !Array.isArray(msg.cues)) {
104
- return null;
105
- }
106
- const cues = [];
107
- for (const c of msg.cues) {
108
- if (typeof c !== "object" || c === null)
109
- continue;
110
- const { t, v, i, p } = c;
111
- if (typeof t !== "number" || !Number.isFinite(t))
112
- continue;
113
- if (typeof v !== "string" || !LETTERS.has(v))
114
- continue;
115
- const cue = { t, v: v };
116
- if (typeof i === "number")
117
- cue.i = i;
118
- // Bounded as a name, not checked against a list. The set belongs to
119
- // whatever produced the cue, so enumerating it here would make this
120
- // library the thing that has to be released before a better recogniser
121
- // can say a new word.
122
- if (typeof p === "string" && PHONE_LABEL.test(p))
123
- cue.p = p;
124
- cues.push(cue);
125
- }
126
- return {
127
- cmd: "cues",
128
- ctx: msg.ctx,
129
- from_ms: msg.from_ms,
130
- cues,
131
- ...(msg.final === true ? { final: true } : {}),
132
- };
133
- }
134
- default:
135
- return null;
136
- }
137
- }
138
- /** The envelope `type` the protocol reserves for avatar traffic. */
139
- export const AVATAR_MESSAGE_TYPE = "avatar";
140
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../client/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgElD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,sBAAsB,CAAU,CAAC,CAAC;AAoC/F;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1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;gBACL,GAAG,EAAE,MAAM;gBACX,GAAG,EAAE,GAAG,CAAC,GAAG;gBACZ,OAAO,EAAE,GAAG,CAAC,OAAiB;gBAC9B,IAAI;gBACJ,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD,CAAC;QACJ,CAAC;QACD;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC"}
@@ -1,39 +0,0 @@
1
- /**
2
- * useAvatar — mount an avatar into a ref'd element for as long as there is a
3
- * client to embody, and tear it down after.
4
- *
5
- * Internal; `<Avatar>` is the only thing the React entry exports. The whole
6
- * hook is one effect, because the factory takes the client at construction:
7
- * there is no separate attach step to keep in its own lifecycle any more.
8
- */
9
- import type { PipecatClient } from "@pipecat-ai/client-js";
10
- import { type AvatarFactory, type AvatarOptions, type SvgAvatarOptions } from "./createAvatar.js";
11
- export interface UseAvatarOptions<O extends AvatarOptions = SvgAvatarOptions> {
12
- /** The live `PipecatClient`, or `null` before connect. Nothing mounts until
13
- * this is non-null — an avatar with nothing to embody has nothing to do. */
14
- client?: PipecatClient | null;
15
- /** The avatar implementation. Defaults to the bundled SVG faces. */
16
- create?: AvatarFactory<O>;
17
- /** Implementation options, forwarded verbatim. Read at mount only. */
18
- options?: Omit<O, keyof AvatarOptions>;
19
- }
20
- /**
21
- * The mount ref's type, written out rather than named as React's `RefObject`.
22
- *
23
- * React 18 and 19 declare that alias with different type arguments — 18's
24
- * `useRef<T>(null)` yields `RefObject<T>`, 19's yields `RefObject<T | null>` —
25
- * and because both are the *same alias*, TypeScript compares them by variance
26
- * and rejects whichever one we didn't pick. An anonymous shape forces a
27
- * structural comparison instead, which both versions satisfy, and which the
28
- * `ref` prop accepts on both. This is the only place the 18-vs-19 split shows
29
- * up in the binding; keep it that way.
30
- */
31
- export type AvatarMountRef = {
32
- current: HTMLDivElement | null;
33
- };
34
- export interface UseAvatarHandle {
35
- /** Attach to the mount element: `<div ref={containerRef} />`. */
36
- containerRef: AvatarMountRef;
37
- }
38
- export declare function useAvatar<O extends AvatarOptions = SvgAvatarOptions>({ client, create, options }?: UseAvatarOptions<O>): UseAvatarHandle;
39
- //# sourceMappingURL=useAvatar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAvatar.d.ts","sourceRoot":"","sources":["../client/useAvatar.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,aAAa,GAAG,gBAAgB;IAC1E;gFAC4E;IAC5E,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,oEAAoE;IACpE,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC1B,sEAAsE;IACtE,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,aAAa,CAAC,CAAC;CACxC;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE,CAAC;AAEhE,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,aAAa,GAAG,gBAAgB,EAClE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAE,gBAAgB,CAAC,CAAC,CAAM,GACpD,eAAe,CAyBjB"}
package/dist/useAvatar.js DELETED
@@ -1,35 +0,0 @@
1
- /**
2
- * useAvatar — mount an avatar into a ref'd element for as long as there is a
3
- * client to embody, and tear it down after.
4
- *
5
- * Internal; `<Avatar>` is the only thing the React entry exports. The whole
6
- * hook is one effect, because the factory takes the client at construction:
7
- * there is no separate attach step to keep in its own lifecycle any more.
8
- */
9
- import { useEffect, useRef } from "react";
10
- import { createAvatar as createSvgAvatar, } from "./createAvatar.js";
11
- export function useAvatar({ client, create, options } = {}) {
12
- const containerRef = useRef(null);
13
- // Latest-options ref, so the mount effect reads the live values without
14
- // remounting the face every time a caller passes a fresh object literal.
15
- const optionsRef = useRef(options);
16
- optionsRef.current = options;
17
- useEffect(() => {
18
- const mount = containerRef.current;
19
- if (!mount || !client)
20
- return;
21
- const factory = (create ?? createSvgAvatar);
22
- // The cast is the seam between "O minus the two we supply" and O. It is
23
- // sound by construction and TypeScript cannot see through the spread of a
24
- // generic; the two halves are typed at the boundary the caller touches.
25
- const instance = factory({ mount, client, ...optionsRef.current });
26
- return () => instance.destroy();
27
- // A new client identity is a new thing to embody, so the avatar is rebuilt
28
- // rather than re-pointed. Hosts keep one `PipecatClient` across
29
- // connect/disconnect cycles, so this does not fire on an ordinary
30
- // reconnect; if yours constructs a fresh client per session, expect the
31
- // face to remount with it.
32
- }, [client, create]);
33
- return { containerRef };
34
- }
35
- //# sourceMappingURL=useAvatar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAvatar.js","sourceRoot":"","sources":["../client/useAvatar.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EACL,YAAY,IAAI,eAAe,GAIhC,MAAM,mBAAmB,CAAC;AA8B3B,MAAM,UAAU,SAAS,CACvB,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAA0B,EAAE;IAErD,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,wEAAwE;IACxE,yEAAyE;IACzE,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC;QACnC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM;YAAE,OAAO;QAC9B,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,eAAe,CAAqB,CAAC;QAChE,wEAAwE;QACxE,0EAA0E;QAC1E,wEAAwE;QACxE,MAAM,QAAQ,GAAG,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,EAAkB,CAAC,CAAC;QACnF,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QAChC,2EAA2E;QAC3E,gEAAgE;QAChE,kEAAkE;QAClE,wEAAwE;QACxE,2BAA2B;IAC7B,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAErB,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC"}