@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
@@ -131,6 +131,24 @@ export var WorkbenchUtil;
131
131
  return credential ? HostUtil.use({ hosts: [] }, serverOf(credential, pageHost()), credential, now) : { hosts: [] };
132
132
  }
133
133
  WorkbenchUtil.readHosts = readHosts;
134
+ /**
135
+ * A pairing with the ways to its computer that computer told (TaServerInfo.relays), the same credential when they did not
136
+ * change or it told none (a ta serve of before), or it is no pairing.
137
+ */
138
+ function routed(credential, relays) {
139
+ if (!('pairing' in credential) || !Array.isArray(relays)) {
140
+ return credential;
141
+ }
142
+ const told = RelayPairingUtil.routes(relays);
143
+ const before = RelayPairingUtil.routes(credential.pairing.relays);
144
+ if (told.join(' ') === before.join(' ')) {
145
+ return credential;
146
+ }
147
+ const { relays: _before, ...pairing } = credential.pairing;
148
+ // Its own relay alone is what a pairing without ways does.
149
+ return { pairing: told.length && told.join(' ') !== pairing.relay ? { ...pairing, relays: told } : pairing };
150
+ }
151
+ WorkbenchUtil.routed = routed;
134
152
  /** Which ta serve a credential reaches, to know whose lists were kept: that of the page (`host`) for a token alone. */
135
153
  function serverOf(credential, host) {
136
154
  if ('pairing' in credential) {
@@ -1,4 +1,5 @@
1
1
  import { TaConnection } from '@celljs/ta-client';
2
+ import { type TaServerInfo } from '@celljs/ta-protocol';
2
3
  import { PresenceReporter } from './presence/presence-reporter.js';
3
4
  import { PageAnswers } from './screen/page-answers.js';
4
5
  import { WorkbenchCalls } from './workbench-calls.js';
@@ -12,6 +13,10 @@ export declare class TaWorkbenchImpl extends WorkbenchHosts implements TaWorkben
12
13
  /** What ta serve may ask this page, and what it is told of the page (docs/design/ta-app-use.md 4.1). */
13
14
  readonly pages: PageAnswers;
14
15
  protected retryTimer?: ReturnType<typeof setTimeout>;
16
+ /** By computer, what it said a direct connection to it takes (TaServerInfo.direct), for the connections of later. */
17
+ protected readonly directs: Map<string, {
18
+ stun: string[];
19
+ }>;
15
20
  /** A restart asked for: whether a build was installed over the one running, and whether its connection closed yet. */
16
21
  protected restart?: {
17
22
  update: boolean;
@@ -59,6 +64,7 @@ export declare class TaWorkbenchImpl extends WorkbenchHosts implements TaWorkben
59
64
  protected open(credential: Credential): {
60
65
  connection: TaConnection;
61
66
  refused(): Promise<boolean>;
67
+ direct?(server: TaServerInfo): void;
62
68
  };
63
69
  /**
64
70
  * Back to the sign-in, loaded again: what the page holds of the computer (the double's and the open
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Component } from '@celljs/core';
8
8
  import { TaConnection } from '@celljs/ta-client';
9
9
  import { TaErrorCode, TaRoomWatchUtil } from '@celljs/ta-protocol';
10
- import { RelaySocket } from '@celljs/ta-relay';
10
+ import { RelayRouteSocket } from '@celljs/ta-relay';
11
11
  import { HostUtil } from './hosts.js';
12
12
  import { PresenceReporter } from './presence/presence-reporter.js';
13
13
  import { PageAnswers } from './screen/page-answers.js';
@@ -47,6 +47,8 @@ let TaWorkbenchImpl = class TaWorkbenchImpl extends WorkbenchHosts {
47
47
  this.connection.pages.attach(info).catch(() => undefined);
48
48
  }
49
49
  }, { agent: ScreenUtil.agent(), desktop: typeof globalThis.taDesktop === 'object' });
50
+ /** By computer, what it said a direct connection to it takes (TaServerInfo.direct), for the connections of later. */
51
+ this.directs = new Map();
50
52
  this.attempts = 0;
51
53
  this.graceMs = GRACE_MS;
52
54
  /**
@@ -193,7 +195,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl extends WorkbenchHosts {
193
195
  /** Tries again later while ta serve is not running, until a sign-in or sign-out of later replaces it. */
194
196
  async connect(credential) {
195
197
  const generation = this.generation;
196
- const { connection, refused } = this.open(credential);
198
+ const { connection, refused, direct } = this.open(credential);
197
199
  try {
198
200
  await connection.connect();
199
201
  }
@@ -304,7 +306,10 @@ let TaWorkbenchImpl = class TaWorkbenchImpl extends WorkbenchHosts {
304
306
  if (generation !== this.generation) {
305
307
  return;
306
308
  }
307
- this.keepHosts(HostUtil.use(this.list, WorkbenchUtil.serverOf(credential, pageHost()), credential, Date.now(), { user: server.user, host: server.host }));
309
+ direct === null || direct === void 0 ? void 0 : direct(server);
310
+ // Through a relay, the ways to the computer it tells now are kept, tried in order the next time.
311
+ const kept = WorkbenchUtil.routed(credential, server.relays);
312
+ this.keepHosts(HostUtil.use(this.list, WorkbenchUtil.serverOf(credential, pageHost()), kept, Date.now(), { user: server.user, host: server.host }));
308
313
  this.update({ status: 'online', error: undefined, retryAt: undefined, server });
309
314
  this.presence.resend();
310
315
  this.pages.tell();
@@ -314,13 +319,39 @@ let TaWorkbenchImpl = class TaWorkbenchImpl extends WorkbenchHosts {
314
319
  open(credential) {
315
320
  if ('pairing' in credential) {
316
321
  let socket;
322
+ const id = WorkbenchUtil.serverOf(credential, pageHost());
317
323
  const connection = new TaConnection({
318
324
  url: credential.pairing.relay,
319
325
  token: '',
320
- createSocket: () => (socket = new RelaySocket(credential.pairing)),
326
+ createSocket: () => {
327
+ var _a;
328
+ // By the first of the ways to the computer that opens (docs/design/ta-relays.md 12), held at the relays
329
+ // while it is away (Ta restarting, the computer waking): open the moment it is back.
330
+ const saved = (_a = this.list.hosts.find(one => one.id === id)) === null || _a === void 0 ? void 0 : _a.credential;
331
+ // Once in, directly to the computer when it said it can (docs/design/ta-relays.md 12.5): known from the last time.
332
+ socket = new RelayRouteSocket(saved && 'pairing' in saved ? saved.pairing : credential.pairing, {
333
+ wait: true,
334
+ direct: () => this.directs.get(id),
335
+ });
336
+ socket.onwait = () => this.current.status === 'connecting' && this.update({ status: 'offline', error: 'away', retryAt: undefined });
337
+ return socket;
338
+ },
321
339
  });
322
340
  // Through a relay, the host says so when it refuses.
323
- return { connection, refused: async () => (socket === null || socket === void 0 ? void 0 : socket.closeCode) === RelaySocket.REFUSED };
341
+ return {
342
+ connection,
343
+ refused: async () => (socket === null || socket === void 0 ? void 0 : socket.closeCode) === RelayRouteSocket.REFUSED,
344
+ direct: server => {
345
+ // What the computer says now, for the connections of later; the first one tries it at once.
346
+ if (server.direct) {
347
+ this.directs.set(id, server.direct);
348
+ socket === null || socket === void 0 ? void 0 : socket.direct(server.direct);
349
+ }
350
+ else {
351
+ this.directs.delete(id);
352
+ }
353
+ },
354
+ };
324
355
  }
325
356
  const serve = WorkbenchUtil.serveUrl(credential);
326
357
  const connection = new TaConnection({ url: WorkbenchUtil.socketUrl(serve), token: credential.token });
@@ -1,12 +1,13 @@
1
1
  import { type TaDelegateLevel } from '@celljs/ta-protocol';
2
2
  /** The role of ta in its conversation with the user. */
3
- export declare const ASSISTANT_PROMPT = "You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.\n- To hand out work, call start_task with a short title and complete, self-contained instructions: a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.\n- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.\n- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.\n- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as \"bun test\", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.\n- When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.\n- When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.\n- Ask before anything risky or irreversible the user did not clearly ask for.\n- Your replies are read aloud: short plain sentences, no tables, no code unless asked. Reply in the user's language.";
3
+ export declare const ASSISTANT_PROMPT = "You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.\n- To hand out work, call start_task with a short title and complete, self-contained instructions: a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.\n- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.\n- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.\n- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as \"bun test\", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.\n- When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.\n- When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.\n- What the user says is often spoken and transcribed, with wrong words and sentences cut off: read it for what they mean, with what was said before. A message from a call ([ta:from @celljs/ta-call \u2026]) is the user's own request, retold by the call: \"the user wants X\" means they ask you for X.\n- When they ask for something to be done (\"\u5E2E\u6211\u5F04\", \"\u5E2E\u6211\u6539\", \"\u6362\u4E00\u4E2A\", \"\u88C5\u4E0A\", \"\u6253\u5F00\u2026\"), that is their go: start it now, in this turn, then say in one sentence what you started, with asked: true. Do not ask first whether to start, nor offer to, nor stop at saying what you would do.\n- A short go (\"\u6765\", \"\u597D\", \"\u5F00\u59CB\", \"\u884C\", \"\u55EF\") answers what you said last: do what you proposed, or the most likely of what waits for them (the step they usually take next, as installing what was just changed, before what needs their taste), with asked: true, and say in one sentence which you took. Ask only when two are as likely, and then one yes-or-no question with your best guess (\"\u88C5\u5230\u624B\u673A\u4E0A\uFF0C\u5BF9\u5427\uFF1F\"), never a card of choices.\n- What a task can find out (which voices a service has, where a setting is, which file) is no question for the user: the task finds it, picks what fits, does it and tries it. A taste they did not say (a man's or a woman's voice) is yours to pick: say what you picked, so they can change it.\n- Instructions of a task say to get it done and checked: the result the user wants, how the task shows it works (it tries it, as the user would), and that it asks them only before what is risky or cannot be undone.\n- What the user asks of their screen (open a page, look at what is wrong, press something) is done on the page in front of them, on the device they use, a phone's on a phone: do it yourself, with app_look, app_go and app_do; a message from a call says which device. Never the computer's desktop (screenshots, tools that drive the computer) unless they name the computer.\n- When you cannot tell what they want at all (words that ask for nothing, a sentence cut off), say in one short sentence what you heard and ask them to say it again; never answer nothing.\n- Ask first only before what is risky or cannot be undone (deleting, publishing, sending or paying for them) that they did not clearly ask for.\n- Your replies are read aloud: short plain sentences, no tables, no code unless asked. Short is not vague: say what you started, picked or found. Reply in the user's language.";
4
4
  /**
5
- * In the role while the user wants to be asked first (Settings.confirmTasks). The team tools of ta-channels
6
- * read the same words in the system prompt to ask before they build a team: keep them as they are.
5
+ * In the role while the user wants to be asked first (Settings.confirmTasks): of what the double starts of its own
6
+ * accord only, never twice (docs/design/ta-double.md, 听懂与派活). The team tools of ta-channels read the same words in the
7
+ * system prompt to ask before they build a team: keep them as they are.
7
8
  */
8
9
  export declare const ASK_FIRST_MARK = "Ask the user before you hand out work";
9
- export declare const ASK_FIRST_PROMPT = "- Ask the user before you hand out work: say in a few short lines what you would start (the tasks, or the agents of a team and what each does) and wait for their go. They confirm each start besides; a start they turn down is not to be tried again unasked.";
10
+ export declare const ASK_FIRST_PROMPT = "- Ask the user before you hand out work you start of your own accord (a next step, a check, a guess the user did not ask for): start it without asked, and the user agrees to it on their screen; you need not ask in words first. Work they asked for in their message (asked: true) starts at once. A start they turn down is not to be tried again unasked.";
10
11
  /**
11
12
  * How much the double hands out (Settings.delegate), each with its mark (TaDelegateUtil.mark), which the guard of ta
12
13
  * serve reads to turn down what the level leaves to tasks.
@@ -45,6 +46,10 @@ export declare const ASSISTANT_TOOLS: {
45
46
  readonly type: 'string';
46
47
  readonly description: "The id of the task this one checks: its first line, PASS or FAIL, is that task's verdict.";
47
48
  };
49
+ readonly asked: {
50
+ readonly type: 'boolean';
51
+ readonly description: "The user asked for this very work in their last message (in so many words, or a short go to what you proposed): it starts at once, without the card the user's settings show for work you start of your own accord.";
52
+ };
48
53
  };
49
54
  readonly required: readonly ['title', 'instructions'];
50
55
  };
@@ -11,14 +11,22 @@ exports.ASSISTANT_PROMPT = `You are Ta, the user's personal agent: a little gree
11
11
  - Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as "bun test", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.
12
12
  - When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.
13
13
  - When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.
14
- - Ask before anything risky or irreversible the user did not clearly ask for.
15
- - Your replies are read aloud: short plain sentences, no tables, no code unless asked. Reply in the user's language.`;
14
+ - What the user says is often spoken and transcribed, with wrong words and sentences cut off: read it for what they mean, with what was said before. A message from a call ([ta:from @celljs/ta-call …]) is the user's own request, retold by the call: "the user wants X" means they ask you for X.
15
+ - When they ask for something to be done ("帮我弄", "帮我改", "换一个", "装上", "打开…"), that is their go: start it now, in this turn, then say in one sentence what you started, with asked: true. Do not ask first whether to start, nor offer to, nor stop at saying what you would do.
16
+ - A short go ("来", "好", "开始", "行", "嗯") answers what you said last: do what you proposed, or the most likely of what waits for them (the step they usually take next, as installing what was just changed, before what needs their taste), with asked: true, and say in one sentence which you took. Ask only when two are as likely, and then one yes-or-no question with your best guess ("装到手机上,对吧?"), never a card of choices.
17
+ - What a task can find out (which voices a service has, where a setting is, which file) is no question for the user: the task finds it, picks what fits, does it and tries it. A taste they did not say (a man's or a woman's voice) is yours to pick: say what you picked, so they can change it.
18
+ - Instructions of a task say to get it done and checked: the result the user wants, how the task shows it works (it tries it, as the user would), and that it asks them only before what is risky or cannot be undone.
19
+ - What the user asks of their screen (open a page, look at what is wrong, press something) is done on the page in front of them, on the device they use, a phone's on a phone: do it yourself, with app_look, app_go and app_do; a message from a call says which device. Never the computer's desktop (screenshots, tools that drive the computer) unless they name the computer.
20
+ - When you cannot tell what they want at all (words that ask for nothing, a sentence cut off), say in one short sentence what you heard and ask them to say it again; never answer nothing.
21
+ - Ask first only before what is risky or cannot be undone (deleting, publishing, sending or paying for them) that they did not clearly ask for.
22
+ - Your replies are read aloud: short plain sentences, no tables, no code unless asked. Short is not vague: say what you started, picked or found. Reply in the user's language.`;
16
23
  /**
17
- * In the role while the user wants to be asked first (Settings.confirmTasks). The team tools of ta-channels
18
- * read the same words in the system prompt to ask before they build a team: keep them as they are.
24
+ * In the role while the user wants to be asked first (Settings.confirmTasks): of what the double starts of its own
25
+ * accord only, never twice (docs/design/ta-double.md, 听懂与派活). The team tools of ta-channels read the same words in the
26
+ * system prompt to ask before they build a team: keep them as they are.
19
27
  */
20
28
  exports.ASK_FIRST_MARK = 'Ask the user before you hand out work';
21
- exports.ASK_FIRST_PROMPT = `- ${exports.ASK_FIRST_MARK}: say in a few short lines what you would start (the tasks, or the agents of a team and what each does) and wait for their go. They confirm each start besides; a start they turn down is not to be tried again unasked.`;
29
+ exports.ASK_FIRST_PROMPT = `- ${exports.ASK_FIRST_MARK} you start of your own accord (a next step, a check, a guess the user did not ask for): start it without asked, and the user agrees to it on their screen; you need not ask in words first. Work they asked for in their message (asked: true) starts at once. A start they turn down is not to be tried again unasked.`;
22
30
  /**
23
31
  * How much the double hands out (Settings.delegate), each with its mark (TaDelegateUtil.mark), which the guard of ta
24
32
  * serve reads to turn down what the level leaves to tasks.
@@ -53,6 +61,10 @@ exports.ASSISTANT_TOOLS = {
53
61
  description: 'Only for a risky change: the one check to run once it ends, a command or one thing to look at. Its update then asks for a check.',
54
62
  },
55
63
  verifies: { type: 'string', description: "The id of the task this one checks: its first line, PASS or FAIL, is that task's verdict." },
64
+ asked: {
65
+ type: 'boolean',
66
+ description: "The user asked for this very work in their last message (in so many words, or a short go to what you proposed): it starts at once, without the card the user's settings show for work you start of your own accord.",
67
+ },
56
68
  },
57
69
  required: ['title', 'instructions'],
58
70
  },
@@ -68,6 +68,12 @@ export declare namespace AssistantTaskUtil {
68
68
  path: string;
69
69
  branch: string;
70
70
  };
71
+ /**
72
+ * Whether the run going on answers the user: the last message of the user's role is theirs (typed, said, or sent
73
+ * for them with TaMessageSource.mark, a call's among them), not a note of a task nor a notice of Ta. Only then may
74
+ * the double start what it says they asked for without the card of Settings.confirmTasks (docs/design/ta-double.md, 听懂与派活).
75
+ */
76
+ function askedByUser(messages: readonly SessionMessage[]): boolean;
71
77
  /** The note of a task `text` is (updateNote, adoptedNote, renamedNote), if it is one. */
72
78
  function noteOf(text: string): TaTaskNote | undefined;
73
79
  /**
@@ -182,6 +182,17 @@ var AssistantTaskUtil;
182
182
  return { path: `${root.replace(/\/+$/, '')}-ta-${name}`, branch: `ta/${name}${words ? `-${words}` : ''}` };
183
183
  }
184
184
  AssistantTaskUtil.worktreeOf = worktreeOf;
185
+ /**
186
+ * Whether the run going on answers the user: the last message of the user's role is theirs (typed, said, or sent
187
+ * for them with TaMessageSource.mark, a call's among them), not a note of a task nor a notice of Ta. Only then may
188
+ * the double start what it says they asked for without the card of Settings.confirmTasks (docs/design/ta-double.md, 听懂与派活).
189
+ */
190
+ function askedByUser(messages) {
191
+ const last = [...messages].reverse().find(message => role(message) === 'user');
192
+ const text = last ? message_1.MessageUtil.text(message_1.MessageUtil.blocks(last)) : '';
193
+ return !!text.trim() && !noteOf(text) && !ta_protocol_1.TaMessageSource.isNotice(text);
194
+ }
195
+ AssistantTaskUtil.askedByUser = askedByUser;
185
196
  /** The note of a task `text` is (updateNote, adoptedNote, renamedNote), if it is one. */
186
197
  function noteOf(text) {
187
198
  return ta_protocol_1.TaTaskNote.parse(text);
@@ -66,6 +66,7 @@ const assistant_state_1 = require("./assistant-state");
66
66
  const assistant_task_util_1 = require("./assistant-task-util");
67
67
  const assistant_tasks_1 = require("./assistant-tasks");
68
68
  const assistant_thread_1 = require("./assistant-thread");
69
+ const call_face_1 = require("./call-face");
69
70
  const task_views_1 = require("./task-views");
70
71
  const voice_call_bar_1 = require("./voice-call-bar");
71
72
  var assistant_tasks_2 = require("./assistant-tasks");
@@ -287,6 +288,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
287
288
  ...(voice_1.Voice.canSpeak() && voice_1.Voice.canListen()
288
289
  ? [
289
290
  (0, voice_call_bar_1.callAction)(callState, call, t),
291
+ (0, voice_call_bar_1.videoCallAction)(callState, call, t),
290
292
  {
291
293
  key: 'speakTalk',
292
294
  label: t('ta.assistant.speakTalkShort'),
@@ -336,6 +338,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
336
338
  ...addons.actions,
337
339
  ];
338
340
  return (React.createElement(React.Fragment, null,
341
+ React.createElement(call_face_1.CallFace, { state: callState, call: call }),
339
342
  React.createElement("div", { className: "ta-chat-scroll ta-conversation", ref: scroller },
340
343
  React.createElement("div", { className: "ta-chat-col" }, state.messages.length === 0 ? (React.createElement("div", { className: "ta-hero" },
341
344
  React.createElement(ta_avatar_1.TaAvatar, { mood: mood, size: 112, className: "ta-hero-avatar", roam: true }),
@@ -64,13 +64,14 @@ export declare class TaAssistantImpl extends AssistantConversation implements Ta
64
64
  cwd: string;
65
65
  }[];
66
66
  /** `call`: the id of the call of start_task, which an ask of it has. */
67
- protected startTask({ title, instructions, cwd, isolate, verify, verifies, }: {
67
+ protected startTask({ title, instructions, cwd, isolate, verify, verifies, asked, }: {
68
68
  title: string;
69
69
  instructions: string;
70
70
  cwd?: string;
71
71
  isolate?: boolean;
72
72
  verify?: string;
73
73
  verifies?: string;
74
+ asked?: boolean;
74
75
  }, call: string): Promise<string>;
75
76
  /**
76
77
  * A git worktree for a task, beside the repository of `where`, on a branch of its own from what the repository
@@ -290,16 +290,18 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
290
290
  });
291
291
  }
292
292
  /** `call`: the id of the call of start_task, which an ask of it has. */
293
- async startTask({ title, instructions, cwd, isolate, verify, verifies, }, call) {
294
- var _a;
295
- var _b;
293
+ async startTask({ title, instructions, cwd, isolate, verify, verifies, asked, }, call) {
294
+ var _a, _b;
295
+ var _c, _d;
296
296
  const { confirmTasks, maxTasks } = this.settings.state.settings;
297
297
  const running = this.current.tasks.filter(task => task.status === 'running').length;
298
298
  if (maxTasks > 0 && running >= maxTasks) {
299
299
  throw new Error(`${running} tasks run already, as many as the user lets run at once: wait for one to end (a <task_update> comes), or stop one.`);
300
300
  }
301
301
  const where = cwd || ((_a = this.workbench.state.server) === null || _a === void 0 ? void 0 : _a.cwd) || '.';
302
- if (confirmTasks) {
302
+ // Work the user asked for in the message this run answers is started at once: the card is for what the double
303
+ // starts of its own accord (docs/design/ta-double.md, 听懂与派活), never a second question after their go.
304
+ if (confirmTasks && !(asked === true && assistant_task_util_1.AssistantTaskUtil.askedByUser((_c = (_b = this.store()) === null || _b === void 0 ? void 0 : _b.state.messages) !== null && _c !== void 0 ? _c : []))) {
303
305
  const started = await this.asks.ask({ id: call, title, instructions, cwd: where, at: Date.now() });
304
306
  this.initiative.record(started ? 'accepted' : 'declined', title);
305
307
  if (!started) {
@@ -312,7 +314,7 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
312
314
  }
313
315
  const id = this.book.nextId();
314
316
  const worktree = isolate ? await this.makeWorktree(where, id, title) : undefined;
315
- const info = await this.server.openSession({ cwd: (_b = worktree === null || worktree === void 0 ? void 0 : worktree.cwd) !== null && _b !== void 0 ? _b : where });
317
+ const info = await this.server.openSession({ cwd: (_d = worktree === null || worktree === void 0 ? void 0 : worktree.cwd) !== null && _d !== void 0 ? _d : where });
316
318
  await this.server.setSessionName(info.sessionId, title);
317
319
  await this.setModel(info.sessionId, this.settings.state.settings.taskModel).catch(error => {
318
320
  throw new Error(`The model of the tasks (${this.settings.state.settings.taskModel}) cannot be used: ${error instanceof Error ? error.message : String(error)}`);
@@ -331,8 +333,8 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
331
333
  };
332
334
  this.book.add(task);
333
335
  const store = await this.follow(task);
334
- const asked = verifies && !instructions.includes(assistant_task_util_1.AssistantTaskUtil.CHECK_ANSWER) ? `${instructions}\n\n${assistant_task_util_1.AssistantTaskUtil.CHECK_ANSWER}` : instructions;
335
- await store.prompt(ta_protocol_1.TaMessageSource.mark(asked, ta_protocol_1.TaMessageSource.DOUBLE));
336
+ const told = verifies && !instructions.includes(assistant_task_util_1.AssistantTaskUtil.CHECK_ANSWER) ? `${instructions}\n\n${assistant_task_util_1.AssistantTaskUtil.CHECK_ANSWER}` : instructions;
337
+ await store.prompt(ta_protocol_1.TaMessageSource.mark(told, ta_protocol_1.TaMessageSource.DOUBLE));
336
338
  const { sessionFile } = await this.server.getState(info.sessionId);
337
339
  this.book.change(task, { sessionFile });
338
340
  const apart = worktree ? ` (a git worktree on the branch ${worktree.worktree.branch})` : '';
@@ -0,0 +1,46 @@
1
+ import type { CallDraft, CallEnd, CallPartner, CallState, CallTalk } from './voice-call-protocol';
2
+ /** What of a call (VoiceCall) a voice that thinks changes as it talks. */
3
+ export interface ConversingCall {
4
+ readonly state: CallState;
5
+ set(change: Partial<CallState>): void;
6
+ hangUp(): void;
7
+ end(reason: CallEnd): void;
8
+ /** Its voice is gone: it opens again. */
9
+ lost(): void;
10
+ }
11
+ /**
12
+ * A call the voice service's own model answers (docs/design/ta-voice.md 8): it hears the user, thinks, speaks and
13
+ * reaches the work by its tools; the call shows what goes on, the user's voice always cuts in, and a call nobody spoke
14
+ * in for `silentMs` ends.
15
+ */
16
+ export declare class CallConversing {
17
+ protected readonly call: ConversingCall;
18
+ protected readonly silentMs: number;
19
+ protected spoke: number;
20
+ protected timer?: ReturnType<typeof setInterval>;
21
+ constructor(call: ConversingCall, silentMs?: number);
22
+ /** What the voice tells of the call; `live` while it is the call going on. */
23
+ talk(live: () => boolean): CallTalk;
24
+ /** The page shows again: the silence counts from now. */
25
+ resumed(): void;
26
+ stop(): void;
27
+ }
28
+ /**
29
+ * The answer a partner began on what the user said so far (CallPartner.draft, docs/design/ta-call.md 10), and the
30
+ * partners whose drafts failed (an older Ta), which answer once the user is done only.
31
+ */
32
+ export declare class CallDrafts {
33
+ protected drafted?: {
34
+ text: string;
35
+ draft: CallDraft;
36
+ };
37
+ protected failed?: CallPartner;
38
+ /** Begins one on `said`, unless one is on these words already or the partner cannot. */
39
+ begin(partner: CallPartner | undefined, said: string): void;
40
+ /** The user said more than its words: it goes. */
41
+ heard(text: string): void;
42
+ /** The user is done with `said`: the draft on these words, to keep; another goes. */
43
+ take(said: string): CallDraft | undefined;
44
+ drop(): void;
45
+ }
46
+ //# sourceMappingURL=call-conversing.d.ts.map
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CallDrafts = exports.CallConversing = void 0;
4
+ const call_turn_end_1 = require("./call-turn-end");
5
+ /**
6
+ * A call the voice service's own model answers (docs/design/ta-voice.md 8): it hears the user, thinks, speaks and
7
+ * reaches the work by its tools; the call shows what goes on, the user's voice always cuts in, and a call nobody spoke
8
+ * in for `silentMs` ends.
9
+ */
10
+ class CallConversing {
11
+ constructor(call, silentMs = call_turn_end_1.SILENT_MS) {
12
+ this.call = call;
13
+ this.silentMs = silentMs;
14
+ this.spoke = 0;
15
+ }
16
+ /** What the voice tells of the call; `live` while it is the call going on. */
17
+ talk(live) {
18
+ const { call } = this;
19
+ this.stop();
20
+ this.spoke = Date.now();
21
+ call.set({ phase: 'listening', heard: '', bargeIn: true });
22
+ this.timer = setInterval(() => {
23
+ if (live() && !call.state.paused && Date.now() - this.spoke >= this.silentMs) {
24
+ call.end('silent');
25
+ }
26
+ }, call_turn_end_1.RETRY_MS * 5);
27
+ const spoke = () => {
28
+ this.spoke = Date.now();
29
+ return true;
30
+ };
31
+ return {
32
+ heard: (text, final) => live() &&
33
+ text.trim() &&
34
+ spoke() &&
35
+ call.set(final
36
+ ? { phase: 'thinking', heard: '', said: text, reading: undefined }
37
+ : { phase: 'listening', heard: text, said: undefined, reading: undefined }),
38
+ replying: (text, paced) => live() && spoke() && call.set(paced ? { phase: 'speaking', heard: '' } : { phase: 'speaking', heard: '', reading: { pieces: [text], at: 0 } }),
39
+ reading: (pieces, at) => live() && call.set({ reading: { pieces, at } }),
40
+ replied: end => live() && spoke() && (end ? call.hangUp() : call.set({ phase: 'listening' })),
41
+ cut: () => live() && call.set({ phase: 'listening', heard: '' }),
42
+ lost: () => live() && call.lost(),
43
+ };
44
+ }
45
+ /** The page shows again: the silence counts from now. */
46
+ resumed() {
47
+ this.spoke = Date.now();
48
+ }
49
+ stop() {
50
+ clearInterval(this.timer);
51
+ this.timer = undefined;
52
+ }
53
+ }
54
+ exports.CallConversing = CallConversing;
55
+ /**
56
+ * The answer a partner began on what the user said so far (CallPartner.draft, docs/design/ta-call.md 10), and the
57
+ * partners whose drafts failed (an older Ta), which answer once the user is done only.
58
+ */
59
+ class CallDrafts {
60
+ /** Begins one on `said`, unless one is on these words already or the partner cannot. */
61
+ begin(partner, said) {
62
+ var _a;
63
+ if (!(partner === null || partner === void 0 ? void 0 : partner.draft) || this.failed === partner || ((_a = this.drafted) === null || _a === void 0 ? void 0 : _a.text) === said) {
64
+ return;
65
+ }
66
+ this.drop();
67
+ const draft = partner.draft(said);
68
+ draft.reply.catch(() => {
69
+ this.failed = partner;
70
+ });
71
+ this.drafted = { text: said, draft };
72
+ }
73
+ /** The user said more than its words: it goes. */
74
+ heard(text) {
75
+ if (this.drafted && this.drafted.text !== text.trim()) {
76
+ this.drop();
77
+ }
78
+ }
79
+ /** The user is done with `said`: the draft on these words, to keep; another goes. */
80
+ take(said) {
81
+ const drafted = this.drafted;
82
+ this.drafted = undefined;
83
+ if ((drafted === null || drafted === void 0 ? void 0 : drafted.text) === said) {
84
+ return drafted.draft;
85
+ }
86
+ drafted === null || drafted === void 0 ? void 0 : drafted.draft.drop();
87
+ return undefined;
88
+ }
89
+ drop() {
90
+ const drafted = this.drafted;
91
+ this.drafted = undefined;
92
+ drafted === null || drafted === void 0 ? void 0 : drafted.draft.drop();
93
+ }
94
+ }
95
+ exports.CallDrafts = CallDrafts;
96
+ //# sourceMappingURL=call-conversing.js.map
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import type { VoiceCall } from './voice-call';
3
+ import type { CallState } from './voice-call-protocol';
4
+ /**
5
+ * Ta's face in a call (docs/design/ta-call.md 11): a small window at a top corner of the conversation, as the other side
6
+ * of a video call is. Drawn here on the device from what plays, nothing of video goes over the connection: its mouth
7
+ * moves by the sound of Ta's voice, it nods to the user's words, listens, thinks and dozes as the call does. Dragged, it
8
+ * keeps to the nearer side; tapped while Ta speaks, Ta stops for the user.
9
+ */
10
+ export declare function CallFace({ state, call }: {
11
+ state: CallState;
12
+ call: VoiceCall;
13
+ }): React.JSX.Element | null;
14
+ //# sourceMappingURL=call-face.d.ts.map
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CallFace = CallFace;
37
+ const React = __importStar(require("react"));
38
+ const ta_avatar_1 = require("../components/ta-avatar");
39
+ const hooks_1 = require("../hooks");
40
+ const use_t_1 = require("../i18n/use-t");
41
+ const call_screen_1 = require("./call-screen");
42
+ /** How far a finger or the mouse moves before the window of the face is dragged rather than tapped, in pixels. */
43
+ const DRAG_PX = 6;
44
+ /** The side of the conversation the face of a call keeps to, as the user last dragged it: the same in every call. */
45
+ let side = 'right';
46
+ /**
47
+ * Ta's face in a call (docs/design/ta-call.md 11): a small window at a top corner of the conversation, as the other side
48
+ * of a video call is. Drawn here on the device from what plays, nothing of video goes over the connection: its mouth
49
+ * moves by the sound of Ta's voice, it nods to the user's words, listens, thinks and dozes as the call does. Dragged, it
50
+ * keeps to the nearer side; tapped while Ta speaks, Ta stops for the user.
51
+ */
52
+ function CallFace({ state, call }) {
53
+ const t = (0, use_t_1.useT)();
54
+ const [{ settings }] = (0, hooks_1.useSettings)();
55
+ const [at, setAt] = React.useState(side);
56
+ const [drag, setDrag] = React.useState(undefined);
57
+ const start = React.useRef(undefined);
58
+ const box = React.useRef(null);
59
+ // The user's words as they come: each change may be a nod.
60
+ const nods = state.phase === 'listening' ? state.heard.length : 0;
61
+ const talk = React.useMemo(() => ({ level: () => call.level(), nods }), [call, nods]);
62
+ if (!state.active || state.video || !settings.callFace) {
63
+ return null;
64
+ }
65
+ const mood = call_screen_1.CallScreen.mood(state);
66
+ const cut = !state.paused && state.phase === 'speaking';
67
+ const label = call_screen_1.CallScreen.phase(t, { phase: state.phase, paused: state.paused, heard: !!state.heard.trim() });
68
+ const down = (event) => {
69
+ var _a, _b;
70
+ start.current = { x: event.clientX, id: event.pointerId, moved: false };
71
+ // Its moves are its own until it is let go, though the pointer leaves it as it drags.
72
+ (_b = (_a = event.currentTarget).setPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, event.pointerId);
73
+ };
74
+ const move = (event) => {
75
+ const begun = start.current;
76
+ if (!begun || begun.id !== event.pointerId) {
77
+ return;
78
+ }
79
+ const dx = event.clientX - begun.x;
80
+ if (!begun.moved && Math.abs(dx) < DRAG_PX) {
81
+ return;
82
+ }
83
+ begun.moved = true;
84
+ setDrag(dx);
85
+ };
86
+ const up = (event) => {
87
+ const begun = start.current;
88
+ start.current = undefined;
89
+ if (!begun || begun.id !== event.pointerId) {
90
+ return;
91
+ }
92
+ if (!begun.moved) {
93
+ if (cut) {
94
+ call.interrupt();
95
+ }
96
+ return;
97
+ }
98
+ // It goes to the side its middle is nearer.
99
+ const element = box.current;
100
+ const parent = element === null || element === void 0 ? void 0 : element.offsetParent;
101
+ if (element && parent) {
102
+ const rect = element.getBoundingClientRect();
103
+ const room = parent.getBoundingClientRect();
104
+ const next = rect.left + rect.width / 2 < room.left + room.width / 2 ? 'left' : 'right';
105
+ side = next;
106
+ setAt(next);
107
+ }
108
+ setDrag(undefined);
109
+ };
110
+ return (React.createElement("div", { ref: box, className: `ta-call-face ta-call-face-${at}${drag === undefined ? '' : ' ta-dragging'}`, style: drag === undefined ? undefined : { transform: `translate3d(${drag}px, 0, 0)` }, role: "img", "aria-label": label, title: cut ? t('ta.call.interrupt') : label, onPointerDown: down, onPointerMove: move, onPointerUp: up, onPointerCancel: () => {
111
+ start.current = undefined;
112
+ setDrag(undefined);
113
+ } },
114
+ React.createElement(ta_avatar_1.DinoFace, { mood: mood, size: 160, talk: talk, fill: true, className: "ta-call-face-dino" }),
115
+ React.createElement("span", { className: "ta-call-face-phase" }, label)));
116
+ }
117
+ //# sourceMappingURL=call-face.js.map