@celljs/ta-web 4.26.0 → 4.28.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 (290) hide show
  1. package/esm/browser/assistant/assistant-role.d.ts +9 -4
  2. package/esm/browser/assistant/assistant-role.js +17 -5
  3. package/esm/browser/assistant/assistant-task-util.d.ts +6 -0
  4. package/esm/browser/assistant/assistant-task-util.js +12 -1
  5. package/esm/browser/assistant/assistant-view.js +4 -1
  6. package/esm/browser/assistant/assistant.d.ts +2 -1
  7. package/esm/browser/assistant/assistant.js +9 -7
  8. package/esm/browser/assistant/call-conversing.d.ts +45 -0
  9. package/esm/browser/assistant/call-conversing.js +91 -0
  10. package/esm/browser/assistant/call-face.d.ts +13 -0
  11. package/esm/browser/assistant/call-face.js +81 -0
  12. package/esm/browser/assistant/call-keeper.d.ts +8 -4
  13. package/esm/browser/assistant/call-keeper.js +32 -11
  14. package/esm/browser/assistant/call-partnering.d.ts +37 -0
  15. package/esm/browser/assistant/call-partnering.js +79 -0
  16. package/esm/browser/assistant/call-scenes.d.ts +25 -0
  17. package/esm/browser/assistant/call-scenes.js +82 -0
  18. package/esm/browser/assistant/call-screen.d.ts +3 -0
  19. package/esm/browser/assistant/call-screen.js +15 -0
  20. package/esm/browser/assistant/mic-sense.d.ts +31 -0
  21. package/esm/browser/assistant/mic-sense.js +119 -0
  22. package/esm/browser/assistant/noise-gate.d.ts +32 -0
  23. package/esm/browser/assistant/noise-gate.js +66 -0
  24. package/esm/browser/assistant/pcm-util.d.ts +10 -0
  25. package/esm/browser/assistant/pcm-util.js +55 -0
  26. package/esm/browser/assistant/read-aloud.d.ts +2 -1
  27. package/esm/browser/assistant/realtime-voice-protocol.d.ts +84 -0
  28. package/esm/browser/assistant/realtime-voice-protocol.js +40 -0
  29. package/esm/browser/assistant/realtime-voice.d.ts +50 -62
  30. package/esm/browser/assistant/realtime-voice.js +213 -134
  31. package/esm/browser/assistant/spoken-timeline.d.ts +27 -0
  32. package/esm/browser/assistant/spoken-timeline.js +49 -0
  33. package/esm/browser/assistant/voice-call-bar.d.ts +9 -2
  34. package/esm/browser/assistant/voice-call-bar.js +81 -31
  35. package/esm/browser/assistant/voice-call-protocol.d.ts +61 -4
  36. package/esm/browser/assistant/voice-call.d.ts +16 -23
  37. package/esm/browser/assistant/voice-call.js +134 -117
  38. package/esm/browser/assistant/voice-reading.d.ts +83 -0
  39. package/esm/browser/assistant/voice-reading.js +150 -0
  40. package/esm/browser/avatar/dino-talk.d.ts +15 -0
  41. package/esm/browser/avatar/dino-talk.js +34 -0
  42. package/esm/browser/components/chat-home.d.ts +6 -4
  43. package/esm/browser/components/chat-home.js +7 -7
  44. package/esm/browser/components/chat-icon.js +9 -5
  45. package/esm/browser/components/chat-list-hooks.d.ts +14 -4
  46. package/esm/browser/components/chat-list-hooks.js +11 -5
  47. package/esm/browser/components/chat-list-row.d.ts +7 -4
  48. package/esm/browser/components/chat-list-row.js +22 -10
  49. package/esm/browser/components/chat-list.js +6 -11
  50. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  51. package/esm/browser/components/conversation-scroll-util.d.ts +8 -1
  52. package/esm/browser/components/conversation-scroll-util.js +21 -0
  53. package/esm/browser/components/conversation-scroll.js +10 -11
  54. package/esm/browser/components/gallery.js +28 -7
  55. package/esm/browser/components/host-view.d.ts +1 -1
  56. package/esm/browser/components/image-pull.d.ts +64 -0
  57. package/esm/browser/components/image-pull.js +202 -0
  58. package/esm/browser/components/kept-call-bar.js +2 -1
  59. package/esm/browser/components/lightbox.d.ts +1 -1
  60. package/esm/browser/components/lightbox.js +57 -2
  61. package/esm/browser/components/markdown.d.ts +3 -1
  62. package/esm/browser/components/markdown.js +8 -4
  63. package/esm/browser/components/partner-row.js +2 -1
  64. package/esm/browser/components/relay-services.d.ts +9 -3
  65. package/esm/browser/components/relay-services.js +73 -35
  66. package/esm/browser/components/session-view.js +4 -2
  67. package/esm/browser/components/settings-parts.js +2 -0
  68. package/esm/browser/components/ta-avatar.d.ts +15 -1
  69. package/esm/browser/components/ta-avatar.js +72 -11
  70. package/esm/browser/components/voice-services.js +6 -1
  71. package/esm/browser/extension/web-api-call.d.ts +64 -2
  72. package/esm/browser/extension/web-api-contributions.d.ts +1 -0
  73. package/esm/browser/extension/web-api-partners.d.ts +2 -0
  74. package/esm/browser/extension/web-extension-api.d.ts +6 -6
  75. package/esm/browser/extension/web-extension-context.js +1 -0
  76. package/esm/browser/extension/web-extension-protocol.d.ts +3 -1
  77. package/esm/browser/extension/web-extension-run.d.ts +3 -2
  78. package/esm/browser/extension/web-extension-run.js +2 -0
  79. package/esm/browser/hosts.d.ts +2 -0
  80. package/esm/browser/hosts.js +22 -3
  81. package/esm/browser/i18n/locales.d.ts +24 -5
  82. package/esm/browser/i18n/messages-ja.js +25 -6
  83. package/esm/browser/i18n/messages-zh-tw.js +25 -6
  84. package/esm/browser/i18n/messages.d.ts +23 -4
  85. package/esm/browser/i18n/messages.js +50 -12
  86. package/esm/browser/markdown/code-renderers.d.ts +2 -0
  87. package/esm/browser/markdown/code-renderers.js +2 -0
  88. package/esm/browser/screen/page-answers.d.ts +2 -1
  89. package/esm/browser/screen/page-answers.js +7 -4
  90. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  91. package/esm/browser/settings/settings-protocol.js +2 -0
  92. package/esm/browser/style/chat-list.d.ts +1 -1
  93. package/esm/browser/style/chat-list.js +1 -1
  94. package/esm/browser/style/conversation.d.ts +1 -1
  95. package/esm/browser/style/conversation.js +6 -1
  96. package/esm/browser/style/device.js +1 -0
  97. package/esm/browser/style/dialogs.d.ts +1 -1
  98. package/esm/browser/style/dialogs.js +1 -1
  99. package/esm/browser/style/layout.d.ts +1 -1
  100. package/esm/browser/style/layout.js +135 -57
  101. package/esm/browser/style/shell.d.ts +1 -1
  102. package/esm/browser/style/shell.js +8 -0
  103. package/esm/browser/style/video-call.d.ts +2 -0
  104. package/esm/browser/style/video-call.js +52 -0
  105. package/esm/browser/style.js +2 -0
  106. package/esm/browser/util/desktop.d.ts +10 -1
  107. package/esm/browser/util/desktop.js +10 -0
  108. package/esm/browser/util/image-pull.d.ts +61 -0
  109. package/esm/browser/util/image-pull.js +88 -0
  110. package/esm/browser/util/spoken.d.ts +3 -3
  111. package/esm/browser/util/spoken.js +4 -4
  112. package/esm/browser/video-call/call-camera.d.ts +59 -0
  113. package/esm/browser/video-call/call-camera.js +188 -0
  114. package/esm/browser/video-call/call-window.d.ts +19 -0
  115. package/esm/browser/video-call/call-window.js +80 -0
  116. package/esm/browser/video-call/clip-plan.d.ts +47 -0
  117. package/esm/browser/video-call/clip-plan.js +60 -0
  118. package/esm/browser/video-call/face-clips.d.ts +33 -0
  119. package/esm/browser/video-call/face-clips.js +93 -0
  120. package/esm/browser/video-call/face-files.d.ts +31 -0
  121. package/esm/browser/video-call/face-files.js +77 -0
  122. package/esm/browser/video-call/video-call-view.d.ts +19 -0
  123. package/esm/browser/video-call/video-call-view.js +214 -0
  124. package/esm/browser/video-call/video-face.d.ts +13 -0
  125. package/esm/browser/video-call/video-face.js +497 -0
  126. package/esm/browser/workbench-hosts.d.ts +1 -0
  127. package/esm/browser/workbench-hosts.js +8 -4
  128. package/esm/browser/workbench-lists.d.ts +16 -1
  129. package/esm/browser/workbench-lists.js +38 -3
  130. package/esm/browser/workbench-protocol.d.ts +2 -0
  131. package/esm/browser/workbench-util.d.ts +5 -0
  132. package/esm/browser/workbench-util.js +18 -0
  133. package/esm/browser/workbench.d.ts +6 -0
  134. package/esm/browser/workbench.js +36 -5
  135. package/lib/browser/assistant/assistant-role.d.ts +9 -4
  136. package/lib/browser/assistant/assistant-role.js +17 -5
  137. package/lib/browser/assistant/assistant-task-util.d.ts +6 -0
  138. package/lib/browser/assistant/assistant-task-util.js +11 -0
  139. package/lib/browser/assistant/assistant-view.js +3 -0
  140. package/lib/browser/assistant/assistant.d.ts +2 -1
  141. package/lib/browser/assistant/assistant.js +9 -7
  142. package/lib/browser/assistant/call-conversing.d.ts +46 -0
  143. package/lib/browser/assistant/call-conversing.js +96 -0
  144. package/lib/browser/assistant/call-face.d.ts +14 -0
  145. package/lib/browser/assistant/call-face.js +117 -0
  146. package/lib/browser/assistant/call-keeper.d.ts +8 -4
  147. package/lib/browser/assistant/call-keeper.js +32 -11
  148. package/lib/browser/assistant/call-partnering.d.ts +38 -0
  149. package/lib/browser/assistant/call-partnering.js +83 -0
  150. package/lib/browser/assistant/call-scenes.d.ts +26 -0
  151. package/lib/browser/assistant/call-scenes.js +85 -0
  152. package/lib/browser/assistant/call-screen.d.ts +3 -0
  153. package/lib/browser/assistant/call-screen.js +15 -0
  154. package/lib/browser/assistant/mic-sense.d.ts +32 -0
  155. package/lib/browser/assistant/mic-sense.js +123 -0
  156. package/lib/browser/assistant/noise-gate.d.ts +33 -0
  157. package/lib/browser/assistant/noise-gate.js +71 -0
  158. package/lib/browser/assistant/pcm-util.d.ts +11 -0
  159. package/lib/browser/assistant/pcm-util.js +58 -0
  160. package/lib/browser/assistant/read-aloud.d.ts +2 -1
  161. package/lib/browser/assistant/realtime-voice-protocol.d.ts +85 -0
  162. package/lib/browser/assistant/realtime-voice-protocol.js +43 -0
  163. package/lib/browser/assistant/realtime-voice.d.ts +50 -62
  164. package/lib/browser/assistant/realtime-voice.js +217 -138
  165. package/lib/browser/assistant/spoken-timeline.d.ts +28 -0
  166. package/lib/browser/assistant/spoken-timeline.js +53 -0
  167. package/lib/browser/assistant/voice-call-bar.d.ts +9 -2
  168. package/lib/browser/assistant/voice-call-bar.js +81 -30
  169. package/lib/browser/assistant/voice-call-protocol.d.ts +61 -4
  170. package/lib/browser/assistant/voice-call.d.ts +16 -23
  171. package/lib/browser/assistant/voice-call.js +134 -117
  172. package/lib/browser/assistant/voice-reading.d.ts +84 -0
  173. package/lib/browser/assistant/voice-reading.js +156 -0
  174. package/lib/browser/avatar/dino-talk.d.ts +16 -0
  175. package/lib/browser/avatar/dino-talk.js +37 -0
  176. package/lib/browser/components/chat-home.d.ts +6 -4
  177. package/lib/browser/components/chat-home.js +8 -9
  178. package/lib/browser/components/chat-icon.js +9 -5
  179. package/lib/browser/components/chat-list-hooks.d.ts +14 -4
  180. package/lib/browser/components/chat-list-hooks.js +12 -6
  181. package/lib/browser/components/chat-list-row.d.ts +7 -4
  182. package/lib/browser/components/chat-list-row.js +23 -12
  183. package/lib/browser/components/chat-list.js +5 -10
  184. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  185. package/lib/browser/components/conversation-scroll-util.d.ts +8 -1
  186. package/lib/browser/components/conversation-scroll-util.js +21 -0
  187. package/lib/browser/components/conversation-scroll.js +10 -11
  188. package/lib/browser/components/gallery.js +28 -7
  189. package/lib/browser/components/host-view.d.ts +1 -1
  190. package/lib/browser/components/image-pull.d.ts +65 -0
  191. package/lib/browser/components/image-pull.js +206 -0
  192. package/lib/browser/components/kept-call-bar.js +2 -1
  193. package/lib/browser/components/lightbox.d.ts +1 -1
  194. package/lib/browser/components/lightbox.js +57 -2
  195. package/lib/browser/components/markdown.d.ts +3 -1
  196. package/lib/browser/components/markdown.js +7 -3
  197. package/lib/browser/components/partner-row.js +2 -1
  198. package/lib/browser/components/relay-services.d.ts +9 -3
  199. package/lib/browser/components/relay-services.js +71 -33
  200. package/lib/browser/components/session-view.js +3 -1
  201. package/lib/browser/components/settings-parts.js +2 -0
  202. package/lib/browser/components/ta-avatar.d.ts +15 -1
  203. package/lib/browser/components/ta-avatar.js +72 -11
  204. package/lib/browser/components/voice-services.js +5 -0
  205. package/lib/browser/extension/web-api-call.d.ts +64 -2
  206. package/lib/browser/extension/web-api-contributions.d.ts +1 -0
  207. package/lib/browser/extension/web-api-partners.d.ts +2 -0
  208. package/lib/browser/extension/web-extension-api.d.ts +6 -6
  209. package/lib/browser/extension/web-extension-context.js +1 -0
  210. package/lib/browser/extension/web-extension-protocol.d.ts +3 -1
  211. package/lib/browser/extension/web-extension-run.d.ts +3 -2
  212. package/lib/browser/extension/web-extension-run.js +2 -0
  213. package/lib/browser/hosts.d.ts +2 -0
  214. package/lib/browser/hosts.js +22 -3
  215. package/lib/browser/i18n/locales.d.ts +24 -5
  216. package/lib/browser/i18n/messages-ja.js +25 -6
  217. package/lib/browser/i18n/messages-zh-tw.js +25 -6
  218. package/lib/browser/i18n/messages.d.ts +23 -4
  219. package/lib/browser/i18n/messages.js +50 -12
  220. package/lib/browser/markdown/code-renderers.d.ts +2 -0
  221. package/lib/browser/markdown/code-renderers.js +3 -1
  222. package/lib/browser/screen/page-answers.d.ts +2 -1
  223. package/lib/browser/screen/page-answers.js +7 -4
  224. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  225. package/lib/browser/settings/settings-protocol.js +2 -0
  226. package/lib/browser/style/chat-list.d.ts +1 -1
  227. package/lib/browser/style/chat-list.js +1 -1
  228. package/lib/browser/style/conversation.d.ts +1 -1
  229. package/lib/browser/style/conversation.js +6 -1
  230. package/lib/browser/style/device.js +1 -0
  231. package/lib/browser/style/dialogs.d.ts +1 -1
  232. package/lib/browser/style/dialogs.js +1 -1
  233. package/lib/browser/style/layout.d.ts +1 -1
  234. package/lib/browser/style/layout.js +135 -57
  235. package/lib/browser/style/shell.d.ts +1 -1
  236. package/lib/browser/style/shell.js +8 -0
  237. package/lib/browser/style/video-call.d.ts +3 -0
  238. package/lib/browser/style/video-call.js +55 -0
  239. package/lib/browser/style.js +2 -0
  240. package/lib/browser/util/desktop.d.ts +10 -1
  241. package/lib/browser/util/desktop.js +10 -0
  242. package/lib/browser/util/image-pull.d.ts +62 -0
  243. package/lib/browser/util/image-pull.js +91 -0
  244. package/lib/browser/util/spoken.d.ts +3 -3
  245. package/lib/browser/util/spoken.js +4 -4
  246. package/lib/browser/video-call/call-camera.d.ts +60 -0
  247. package/lib/browser/video-call/call-camera.js +192 -0
  248. package/lib/browser/video-call/call-window.d.ts +20 -0
  249. package/lib/browser/video-call/call-window.js +83 -0
  250. package/lib/browser/video-call/clip-plan.d.ts +48 -0
  251. package/lib/browser/video-call/clip-plan.js +64 -0
  252. package/lib/browser/video-call/face-clips.d.ts +34 -0
  253. package/lib/browser/video-call/face-clips.js +96 -0
  254. package/lib/browser/video-call/face-files.d.ts +32 -0
  255. package/lib/browser/video-call/face-files.js +82 -0
  256. package/lib/browser/video-call/video-call-view.d.ts +20 -0
  257. package/lib/browser/video-call/video-call-view.js +250 -0
  258. package/lib/browser/video-call/video-face.d.ts +14 -0
  259. package/lib/browser/video-call/video-face.js +533 -0
  260. package/lib/browser/workbench-hosts.d.ts +1 -0
  261. package/lib/browser/workbench-hosts.js +8 -4
  262. package/lib/browser/workbench-lists.d.ts +16 -1
  263. package/lib/browser/workbench-lists.js +38 -3
  264. package/lib/browser/workbench-protocol.d.ts +2 -0
  265. package/lib/browser/workbench-util.d.ts +5 -0
  266. package/lib/browser/workbench-util.js +18 -0
  267. package/lib/browser/workbench.d.ts +6 -0
  268. package/lib/browser/workbench.js +35 -4
  269. package/package.json +7 -7
  270. package/public/faces/README.md +27 -0
  271. package/public/faces/clap.mp4 +0 -0
  272. package/public/faces/dance.mp4 +0 -0
  273. package/public/faces/happy.mp4 +0 -0
  274. package/public/faces/heart.mp4 +0 -0
  275. package/public/faces/idle-1.mp4 +0 -0
  276. package/public/faces/idle-2.mp4 +0 -0
  277. package/public/faces/idle-3.mp4 +0 -0
  278. package/public/faces/laugh.mp4 +0 -0
  279. package/public/faces/lips.json +1 -0
  280. package/public/faces/listening.mp4 +0 -0
  281. package/public/faces/poster.jpg +0 -0
  282. package/public/faces/shy.mp4 +0 -0
  283. package/public/faces/sorry.mp4 +0 -0
  284. package/public/faces/stretch.mp4 +0 -0
  285. package/public/faces/surprised.mp4 +0 -0
  286. package/public/faces/talk-1.mp4 +0 -0
  287. package/public/faces/talk-2.mp4 +0 -0
  288. package/public/faces/think-2.mp4 +0 -0
  289. package/public/faces/thinking.mp4 +0 -0
  290. package/public/faces/wave.mp4 +0 -0
@@ -1,12 +1,15 @@
1
1
  import { useInject } from '@celljs/react';
2
- import { Captions, CaptionsOff, Pause, Phone, PhoneOff } from 'lucide-react';
2
+ import { Captions, CaptionsOff, Pause, Phone, PhoneOff, Video } from 'lucide-react';
3
3
  import * as React from 'react';
4
4
  import { Icon } from '../components/icon.js';
5
5
  import { useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
6
6
  import { useT } from '../i18n/use-t.js';
7
7
  import { ScreenUtil } from '../screen/screen-protocol.js';
8
8
  import { SpokenReply } from '../util/spoken.js';
9
+ import { CallCameras } from '../video-call/call-camera.js';
10
+ import { CallWindow } from '../video-call/call-window.js';
9
11
  import { TaCallKeeper } from './call-keeper.js';
12
+ import { CallScenes } from './call-scenes.js';
10
13
  import { CallScreen } from './call-screen.js';
11
14
  import { RealtimeVoice } from './realtime-voice.js';
12
15
  import { VoiceCall } from './voice-call.js';
@@ -49,30 +52,49 @@ export function useVoiceCall(options, target, title) {
49
52
  function made() {
50
53
  const latest = { current: options };
51
54
  const partnering = { current: { callPartner, target } };
52
- return {
53
- refs: { latest, partnering },
54
- call: new VoiceCall({
55
- language: () => latest.current.language(),
56
- voice: () => latest.current.voice(),
57
- // What the user says goes with the note that asks for what to say back (SpokenReply).
58
- send: text => latest.current.send(SpokenReply.asked(text)),
59
- ended: (reason, detail) => { var _a, _b; return (_b = (_a = latest.current).ended) === null || _b === void 0 ? void 0 : _b.call(_a, reason, detail); },
60
- openVoice: async () => {
61
- await online();
62
- // A Ta of before, or one let in who may not see the settings: the voice of the device.
63
- const voices = await bench.voice.listVoices().catch(() => undefined);
64
- return (voices === null || voices === void 0 ? void 0 : voices.use) ? new RealtimeVoice(bench).open(latest.current.language()) : undefined;
65
- },
66
- openPartner: () => {
67
- const { callPartner: partner, target: called } = partnering.current;
68
- return partner && called
69
- ? online().then(() => CallPartnerUtil.open(partner, { ...called, language: latest.current.language() }))
70
- : undefined;
71
- },
72
- }),
73
- };
55
+ const call = new VoiceCall({
56
+ language: () => latest.current.language(),
57
+ voice: () => latest.current.voice(),
58
+ // What the user says goes with the note that asks for what to say back (SpokenReply), and what is new of the call.
59
+ send: text => latest.current.send(SpokenReply.asked(text, CallScenes.next(call, bench.pages.device))),
60
+ ended: (reason, detail) => { var _a, _b; return (_b = (_a = latest.current).ended) === null || _b === void 0 ? void 0 : _b.call(_a, reason, detail); },
61
+ openVoice: async (opening) => {
62
+ var _a;
63
+ await online();
64
+ // A Ta of before, or one let in who may not see the settings: the voice of the device.
65
+ const voices = await bench.voice.listVoices().catch(() => undefined);
66
+ if (!(voices === null || voices === void 0 ? void 0 : voices.use)) {
67
+ return undefined;
68
+ }
69
+ // The service's own model answers with the brain of the partner opened for it (docs/design/ta-voice.md 8).
70
+ const brain = CallPartnerUtil.voiced(voices) ? (_a = (await opening)) === null || _a === void 0 ? void 0 : _a.brain : undefined;
71
+ return new RealtimeVoice(bench).open(latest.current.language(), brain ? { brain } : {});
72
+ },
73
+ openPartner: plain => {
74
+ const { callPartner: partner, target: called } = partnering.current;
75
+ return partner && called
76
+ ? online().then(async () => {
77
+ const voiced = !plain && CallPartnerUtil.voiced(await bench.voice.listVoices().catch(() => undefined));
78
+ const device = bench.pages.device;
79
+ const scene = CallScenes.of(call, device);
80
+ const target = { ...called, language: latest.current.language(), device, scene, ...(voiced ? { voiced } : {}) };
81
+ return CallPartnerUtil.open(partner, target, text => CallCameras.frame(call, text), changed => CallScenes.watch(call, device, changed));
82
+ })
83
+ : undefined;
84
+ },
85
+ });
86
+ return { refs: { latest, partnering }, call };
74
87
  }
75
88
  const state = React.useSyncExternalStore(listener => call.subscribe(listener), () => call.state);
89
+ // The conversation of the call going on took its own id (one loaded again is known by its file first): the keeper knows it by it.
90
+ const targetId = target === null || target === void 0 ? void 0 : target.sessionId;
91
+ React.useEffect(() => {
92
+ var _a;
93
+ var _b;
94
+ if (targetId && call.state.active) {
95
+ keeper.begin({ sessionId: targetId, double: (_a = held.refs.partnering.current.target) === null || _a === void 0 ? void 0 : _a.double, title: (_b = named.current) !== null && _b !== void 0 ? _b : '', held });
96
+ }
97
+ }, [targetId, call, held, keeper]);
76
98
  React.useEffect(() => {
77
99
  // The call going on is the keeper's as it begins: it floats while its conversation is not in front (KeptCallBar).
78
100
  const begun = () => {
@@ -86,11 +108,12 @@ export function useVoiceCall(options, target, title) {
86
108
  const offBegun = call.subscribe(begun);
87
109
  // Its call went on as the page went away (it loaded again, the app restarted): it goes on.
88
110
  const { target: called } = held.refs.partnering.current;
89
- if (called && !call.state.active && keeper.resume(called.sessionId, called.double)) {
90
- call.start();
111
+ const resumed = called && !call.state.active ? keeper.resume(called.sessionId, called.double) : undefined;
112
+ if (resumed) {
113
+ call.start(undefined, { video: resumed.video === true });
91
114
  }
92
115
  // Another app in front or the screen locked: the device stops listening and reading, so the call waits.
93
- const shown = () => (document.visibilityState === 'hidden' ? call.pause() : call.resume());
116
+ const shown = () => (CallWindow.hidden() ? call.pause() : call.resume());
94
117
  document.addEventListener('visibilitychange', shown);
95
118
  window.addEventListener('pagehide', shown);
96
119
  return () => {
@@ -126,36 +149,52 @@ export function talkCall(call) {
126
149
  }
127
150
  export var CallPartnerUtil;
128
151
  (function (CallPartnerUtil) {
152
+ /** Calls are answered by the voice service's own model: the user chose it, and the service in use thinks. */
153
+ function voiced(voices) {
154
+ var _a;
155
+ const service = (voices === null || voices === void 0 ? void 0 : voices.use) ? voices.services.find(each => each.id === voices.use) : undefined;
156
+ return (voices === null || voices === void 0 ? void 0 : voices.brain) === 'service' && !!service && !!((_a = voices.types.find(type => type.type === service.type)) === null || _a === void 0 ? void 0 : _a.thinks);
157
+ }
158
+ CallPartnerUtil.voiced = voiced;
129
159
  /**
130
160
  * The side of a call of a partner of an extension, its replies said whole (SpokenReply.whole: they are written for
131
161
  * the ear); undefined when it leaves the call to the conversation.
132
162
  */
133
- async function open(partner, target) {
163
+ async function open(partner, target, look, scenes) {
134
164
  const session = await partner.open(target);
135
165
  let closed = false;
166
+ // How the call changes (video or voice, the camera, how it shows) goes to the partner as it does.
167
+ const offScenes = (session === null || session === void 0 ? void 0 : session.scene) ? scenes === null || scenes === void 0 ? void 0 : scenes(scene => { var _a; return (_a = session.scene) === null || _a === void 0 ? void 0 : _a.call(session, scene); }) : undefined;
168
+ // In a video call, what the camera sees goes with what the user said, when it changed (CallCameras.frame).
169
+ const seen = (text) => {
170
+ const image = look === null || look === void 0 ? void 0 : look(text);
171
+ return image ? { images: [image] } : {};
172
+ };
136
173
  return (session && {
137
174
  say: async (text, options) => {
138
- const reply = await session.say(text, options);
175
+ const reply = await session.say(text, { ...options, ...seen(text) });
139
176
  return reply ? SpokenReply.whole(reply) : undefined;
140
177
  },
141
- ...(session.draft ? { draft: (text) => CallPartnerUtil.draft(session, text) } : {}),
178
+ ...(session.draft ? { draft: (text) => CallPartnerUtil.draft(session, text, seen(text)) } : {}),
142
179
  news: listener => {
143
180
  if (session.next) {
144
181
  void CallPartnerUtil.follow(session.next.bind(session), () => closed, text => listener(SpokenReply.whole(text)));
145
182
  }
146
183
  },
147
184
  ending: () => { var _a; return ((_a = session.ending) === null || _a === void 0 ? void 0 : _a.call(session)) === true; },
185
+ ...(session.brain ? { brain: session.brain } : {}),
148
186
  close: () => {
149
187
  closed = true;
188
+ offScenes === null || offScenes === void 0 ? void 0 : offScenes();
150
189
  session.close();
151
190
  },
152
191
  });
153
192
  }
154
193
  CallPartnerUtil.open = open;
155
194
  /** An answer begun by the partner before the user was known to be done, its reply said whole. */
156
- function draft(session, text) {
195
+ function draft(session, text, options) {
157
196
  var _a;
158
- const begun = (_a = session.draft) === null || _a === void 0 ? void 0 : _a.call(session, text);
197
+ const begun = (_a = session.draft) === null || _a === void 0 ? void 0 : _a.call(session, text, options);
159
198
  return {
160
199
  reply: begun ? begun.reply.then(reply => (reply ? SpokenReply.whole(reply) : undefined)) : Promise.reject(new Error('No drafts.')),
161
200
  keep: () => begun === null || begun === void 0 ? void 0 : begun.keep(),
@@ -242,6 +281,17 @@ export function callAction(state, call, t) {
242
281
  run: () => call.start(),
243
282
  };
244
283
  }
284
+ /** Video call, beside Call: Ta shows as a person who speaks, and sees the user once they turn their camera on (docs/design/ta-call.md 12). */
285
+ export function videoCallAction(state, call, t) {
286
+ return {
287
+ key: 'videoCall',
288
+ label: t('ta.call.video'),
289
+ title: t('ta.call.videoTitle'),
290
+ icon: React.createElement(Icon, { icon: Video, size: 16 }),
291
+ disabled: state.active,
292
+ run: () => call.start(undefined, { video: true }),
293
+ };
294
+ }
245
295
  /**
246
296
  * A caption in the one line of the bar of a call, as a ticker: what the user says keeps its newest words in sight as
247
297
  * it grows (`follow`); a sentence Ta reads shows from its start and scrolls on to its end, about as fast as it is read
@@ -1,3 +1,4 @@
1
+ import type { TaVoiceBrainRef } from '@celljs/ta-protocol';
1
2
  import type { Voice } from '../util/voice.js';
2
3
  import type { CallTurnTimes } from './call-turn-end.js';
3
4
  /** Where a call is: Ta listens to the user, works on what they said, or says its answer. */
@@ -20,6 +21,10 @@ export interface CallState {
20
21
  partnered?: boolean;
21
22
  /** Its voice hears the user cut in while Ta speaks: no need to tap. */
22
23
  bargeIn?: boolean;
24
+ /** A video call: Ta shows as a person who speaks (docs/design/ta-call.md 12), and sees the user once they turn their camera on. */
25
+ video?: boolean;
26
+ /** When the call began (ms since the epoch). */
27
+ since?: number;
23
28
  }
24
29
  /** What a call uses of the page's voice: Voice by default, a service of voices.json (RealtimeVoice), a fake in tests. */
25
30
  export interface CallVoice {
@@ -32,6 +37,50 @@ export interface CallVoice {
32
37
  readonly cutsIn?: boolean;
33
38
  /** The call ended: it lets go of what it holds (the microphone, the service). */
34
39
  stop?(): void;
40
+ /**
41
+ * Its own model answers (a voice service that thinks, docs/design/ta-voice.md 8): it hears, thinks and speaks by
42
+ * itself, and the call only shows what goes on (converse); it neither listens nor speaks by turns.
43
+ */
44
+ readonly thinks?: boolean;
45
+ /** Of one that thinks: what goes on in the call is told `talk`. */
46
+ converse?(talk: CallTalk): void;
47
+ /** Of one that thinks: the microphone goes quiet (the page hidden), or on again. */
48
+ mute?(muted: boolean): void;
49
+ /** How loud what it plays now is (RMS, 0 to 1), for the face of the call to speak by; one without cannot tell. */
50
+ level?(): number;
51
+ /** Of a voice that plays what a service reads: what it reads now, on the clock of its sound (CallReading). */
52
+ nowReading?(): CallReading | undefined;
53
+ /** The sound of what it reads as it comes, PCM16 mono at `rate`; `pcm` undefined once all of it came. */
54
+ onSound?(listener: (say: number, pcm: Uint8Array | undefined, rate: number) => void): () => void;
55
+ /** Each reading plays `ms` after its sound began to come: what is drawn with it has the time to be ready. */
56
+ hold?(ms: number): void;
57
+ }
58
+ /**
59
+ * What a voice reads now (CallVoice.reading), on the clock of its sound: the captions, the clip of the person of a
60
+ * video call and the frames of her mouth all follow it (docs/design/ta-call.md 12).
61
+ */
62
+ export interface CallReading {
63
+ say: number;
64
+ pieces: readonly string[];
65
+ /** Where it is, in seconds of its sound; negative before it plays (held). */
66
+ now(): number;
67
+ /** The sentence heard at that second of it, the same for every one who asks (SpokenTimeline). */
68
+ pieceAt(seconds: number): number;
69
+ }
70
+ /** What goes on in a call a voice that thinks answers (CallVoice.converse). */
71
+ export interface CallTalk {
72
+ /** What the user says so far; `final` once they are done with it. */
73
+ heard(text: string, final: boolean): void;
74
+ /** Its answer so far, as it says it; `paced`: its sentences show as they are heard (reading), not all at once. */
75
+ replying(text: string, paced?: boolean): void;
76
+ /** The sentence of its answer heard now, as its sound plays. */
77
+ reading?(pieces: string[], at: number): void;
78
+ /** It said all of its answer; `end`: it hung up. */
79
+ replied(end: boolean): void;
80
+ /** The user began to speak: what it said stops. */
81
+ cut(): void;
82
+ /** The service is gone (ta serve restarted, the connection dropped). */
83
+ lost(error: string): void;
35
84
  }
36
85
  /**
37
86
  * Who answers in a call in place of the conversation itself: a front that only talks, handing the work to the
@@ -51,6 +100,8 @@ export interface CallPartner {
51
100
  draft?(text: string): CallDraft;
52
101
  /** Whether it ended the call (WebCallSession.ending): Ta hangs up once its reply is said. */
53
102
  ending?(): boolean;
103
+ /** Of a call the voice service answers: the brain its voice opens with (WebCallSession.brain). */
104
+ brain?: TaVoiceBrainRef;
54
105
  close(): void;
55
106
  }
56
107
  /** An answer begun before the user was known to be done (CallPartner.draft). */
@@ -69,10 +120,16 @@ export interface CallOptions extends CallTurnTimes {
69
120
  send(text: string): Promise<unknown>;
70
121
  /** The call ended by itself: why, for a notice; `detail` what the voice service said. */
71
122
  ended?(reason: CallEnd, detail?: string): void;
72
- /** The voice of a service the call opens as it starts; undefined for that of the device. */
73
- openVoice?(): Promise<CallVoice | undefined> | undefined;
74
- /** Who answers in its place, opened as the call starts; undefined (or failing) for the conversation itself. */
75
- openPartner?(): Promise<CallPartner | undefined> | undefined;
123
+ /**
124
+ * The voice of a service the call opens as it starts; undefined for that of the device. With the partner opening,
125
+ * a service that thinks may answer with its brain (CallPartner.brain).
126
+ */
127
+ openVoice?(partner?: Promise<CallPartner | undefined>): Promise<CallVoice | undefined> | undefined;
128
+ /**
129
+ * Who answers in its place, opened as the call starts; undefined (or failing) for the conversation itself. `plain`:
130
+ * one that answers itself, never leaving it to the voice service.
131
+ */
132
+ openPartner?(plain?: boolean): Promise<CallPartner | undefined> | undefined;
76
133
  /** How long nobody may speak before the call ends by itself; default SILENT_MS. */
77
134
  silentMs?: number;
78
135
  }
@@ -1,6 +1,9 @@
1
1
  import { Voice } from '../util/voice.js';
2
+ import { CallConversing, CallDrafts } from './call-conversing.js';
3
+ import { CallPartnering } from './call-partnering.js';
2
4
  import { CallTurnEnd } from './call-turn-end.js';
3
- import type { CallDraft, CallEnd, CallOptions, CallPartner, CallState, CallVoice } from './voice-call-protocol.js';
5
+ import type { CallEnd, CallOptions, CallPartner, CallState, CallVoice } from './voice-call-protocol.js';
6
+ import { CallSounds } from './voice-reading.js';
4
7
  import { VoiceReopen } from './voice-reopen.js';
5
8
  /**
6
9
  * A call with a conversation (the double's, or any other), by the voice of the page: Ta listens until the user pauses, sends what they said, reads
@@ -33,30 +36,27 @@ export declare class VoiceCall {
33
36
  protected opening: boolean;
34
37
  protected waiting?: string;
35
38
  /** Who answers in this call in place of the conversation (CallOptions.openPartner), once open. */
36
- protected partner?: CallPartner;
39
+ protected readonly partners: CallPartnering;
37
40
  /** Its voice service opening again (revoice). */
38
41
  protected reopening?: VoiceReopen;
39
- /** The answer begun on what the user said so far (CallPartner.draft), and those words. */
40
- protected drafted?: {
41
- text: string;
42
- draft: CallDraft;
43
- };
44
- /** A partner whose draft failed (an older Ta): it answers once the user is done only. */
45
- protected draftless?: CallPartner;
42
+ /** The answer begun on what the user said so far (CallPartner.draft). */
43
+ protected readonly drafts: CallDrafts;
44
+ /** Of a voice that thinks, which answers by itself. */
45
+ protected readonly conversing: CallConversing;
46
46
  constructor(options: CallOptions, device?: CallVoice);
47
47
  subscribe(listener: () => void): () => void;
48
48
  /**
49
49
  * Begins the call: Ta listens. With what the user said as they called (let go over 通话 of a talk), already being
50
50
  * sent by the box, Ta waits for its turn and reads the answer instead; should the sending fail, it listens.
51
- * `direct`: the conversation's voice kept on (let go over 持续说), the conversation answering, no partner.
52
- */
51
+ * `direct`: the conversation's voice kept on (let go over 持续说), no partner; `video`: a video call (CallState.video). */
53
52
  start(said?: {
54
53
  text: string;
55
54
  sent: Promise<unknown>;
56
- }, { direct }?: {
55
+ }, { direct, video }?: {
57
56
  direct?: boolean;
57
+ video?: boolean;
58
58
  }): void;
59
- /** The voice of a service is the call's now: it hears the user cut in. */
59
+ /** The voice of a service is the call's now: it hears the user cut in, or answers by itself (thinks). */
60
60
  protected takeVoice(voice: CallVoice): void;
61
61
  /** Its voice is there: the answer that came meanwhile is read, a turn at work is waited for, else Ta listens. */
62
62
  protected voiced(): void;
@@ -83,6 +83,9 @@ export declare class VoiceCall {
83
83
  pause(): void;
84
84
  /** The page shows again: the answer that waits is read, a turn at work is waited for, else Ta listens. */
85
85
  resume(): void;
86
+ /** For the face of the call (CallSounds): Ta's voice, whichever the call has (it opens after the call shows). */
87
+ readonly sounds: CallSounds;
88
+ readonly level: () => number | undefined;
86
89
  /** While Ta speaks (an answer, or news it tells by itself): it stops and listens to the user, before any more news. */
87
90
  interrupt(): void;
88
91
  /** The run of the turn the call asked has started: its reply is the first after `before`. */
@@ -130,18 +133,8 @@ export declare class VoiceCall {
130
133
  * should they be done with these words (take), dropped as they say more (docs/design/ta-call.md 10).
131
134
  */
132
135
  protected suspect(text: string): void;
133
- /** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
134
- protected kept(draft: CallDraft, said: string): void;
135
- protected dropDraft(): void;
136
136
  /** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
137
137
  protected open(direct: boolean): Promise<[CallVoice | undefined, CallPartner | undefined]> | undefined;
138
- /** The partner answers what the user said; its reply is read as a turn's is. */
139
- protected ask(text: string, sent?: boolean): void;
140
- /**
141
- * The partner did not answer (the Ta service restarted, its side of the call is gone): it opens again once and
142
- * answers what was said; failing that, the conversation answers from then on. The call goes on either way.
143
- */
144
- protected reopen(failed: CallPartner, text: string, sent?: boolean): void;
145
138
  /** What the user said did not go: not in the captions as if it had, and Ta listens again. */
146
139
  protected unsent(): void;
147
140
  protected end(reason: CallEnd, detail?: string): void;