@celljs/ta-web 4.42.0 → 4.44.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 (400) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/apps/app-window.js +2 -2
  4. package/esm/browser/apps/web-apps.d.ts +4 -0
  5. package/esm/browser/apps/web-apps.js +14 -3
  6. package/esm/browser/assistant/assistant-chat-list.js +2 -1
  7. package/esm/browser/assistant/assistant-extension.js +16 -2
  8. package/esm/browser/assistant/assistant-protocol.d.ts +6 -0
  9. package/esm/browser/assistant/assistant-task-source.js +3 -0
  10. package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
  11. package/esm/browser/assistant/assistant-task-util.js +5 -0
  12. package/esm/browser/assistant/assistant.d.ts +3 -0
  13. package/esm/browser/assistant/assistant.js +26 -2
  14. package/esm/browser/assistant/ta-hearing.d.ts +85 -0
  15. package/esm/browser/assistant/ta-hearing.js +272 -0
  16. package/esm/browser/components/app-shell-hooks.d.ts +2 -1
  17. package/esm/browser/components/app-shell-hooks.js +4 -3
  18. package/esm/browser/components/app-shell-state.js +2 -2
  19. package/esm/browser/components/auth-view.js +1 -1
  20. package/esm/browser/components/board.js +9 -1
  21. package/esm/browser/components/chat-list-row.js +4 -4
  22. package/esm/browser/components/chat-list-util.d.ts +2 -2
  23. package/esm/browser/components/clipboard-link-host.d.ts +2 -0
  24. package/esm/browser/components/clipboard-link-host.js +27 -0
  25. package/esm/browser/components/cloud-network.js +1 -1
  26. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  27. package/esm/browser/components/custom-host.d.ts +4 -1
  28. package/esm/browser/components/custom-host.js +8 -2
  29. package/esm/browser/components/custom-provider-advanced.js +8 -8
  30. package/esm/browser/components/custom-provider-view.js +12 -12
  31. package/esm/browser/components/earlier-messages.d.ts +4 -1
  32. package/esm/browser/components/earlier-messages.js +5 -2
  33. package/esm/browser/components/empty-state.d.ts +2 -1
  34. package/esm/browser/components/empty-state.js +6 -2
  35. package/esm/browser/components/folder-picker.js +2 -2
  36. package/esm/browser/components/gallery.js +8 -9
  37. package/esm/browser/components/hearing-host.d.ts +5 -0
  38. package/esm/browser/components/hearing-host.js +58 -0
  39. package/esm/browser/components/host-view.d.ts +1 -1
  40. package/esm/browser/components/link-dialog.js +4 -0
  41. package/esm/browser/components/loading.d.ts +3 -2
  42. package/esm/browser/components/loading.js +7 -3
  43. package/esm/browser/components/markdown.d.ts +3 -1
  44. package/esm/browser/components/markdown.js +10 -5
  45. package/esm/browser/components/media.d.ts +10 -4
  46. package/esm/browser/components/media.js +60 -14
  47. package/esm/browser/components/message-list.js +2 -1
  48. package/esm/browser/components/message-steps.js +8 -5
  49. package/esm/browser/components/people-picker.d.ts +17 -0
  50. package/esm/browser/components/people-picker.js +129 -0
  51. package/esm/browser/components/relay-view.js +1 -1
  52. package/esm/browser/components/settings-choices.d.ts +2 -1
  53. package/esm/browser/components/settings-choices.js +2 -1
  54. package/esm/browser/components/settings-parts.js +25 -3
  55. package/esm/browser/components/share-dialog.d.ts +2 -2
  56. package/esm/browser/components/share-dialog.js +7 -4
  57. package/esm/browser/components/share-friends.d.ts +18 -2
  58. package/esm/browser/components/share-friends.js +64 -13
  59. package/esm/browser/components/share-item-sheet.d.ts +12 -0
  60. package/esm/browser/components/share-item-sheet.js +39 -0
  61. package/esm/browser/components/share-sheet.d.ts +12 -4
  62. package/esm/browser/components/share-sheet.js +15 -6
  63. package/esm/browser/components/sign-in-setup.js +4 -4
  64. package/esm/browser/components/trusted-domains.js +1 -1
  65. package/esm/browser/components/view-room.d.ts +25 -0
  66. package/esm/browser/components/view-room.js +136 -0
  67. package/esm/browser/components/voice-services.js +6 -6
  68. package/esm/browser/device/device-protocol.d.ts +9 -6
  69. package/esm/browser/device/device-protocol.js +7 -4
  70. package/esm/browser/device/launch-screen.d.ts +11 -1
  71. package/esm/browser/device/launch-screen.js +22 -4
  72. package/esm/browser/extension/share-sheet-compat.d.ts +2 -0
  73. package/esm/browser/extension/share-sheet-compat.js +12 -2
  74. package/esm/browser/extension/web-api-chats.d.ts +23 -0
  75. package/esm/browser/extension/web-api-code.d.ts +11 -0
  76. package/esm/browser/extension/web-api-components.d.ts +8 -1
  77. package/esm/browser/extension/web-api-contributions.d.ts +30 -1
  78. package/esm/browser/extension/web-api-desktop.d.ts +2 -1
  79. package/esm/browser/extension/web-api-file-views.d.ts +38 -0
  80. package/esm/browser/extension/web-api-file-views.js +2 -0
  81. package/esm/browser/extension/web-api-host.d.ts +47 -0
  82. package/esm/browser/extension/web-api-host.js +3 -0
  83. package/esm/browser/extension/web-api-menus.d.ts +46 -0
  84. package/esm/browser/extension/web-api-partners.d.ts +58 -1
  85. package/esm/browser/extension/web-api-skins.d.ts +95 -0
  86. package/esm/browser/extension/web-api-skins.js +2 -0
  87. package/esm/browser/extension/web-api-spec.js +9 -0
  88. package/esm/browser/extension/web-extension-api.d.ts +13 -34
  89. package/esm/browser/extension/web-extension-context.d.ts +2 -8
  90. package/esm/browser/extension/web-extension-context.js +15 -39
  91. package/esm/browser/extension/web-extension-marks.d.ts +10 -0
  92. package/esm/browser/extension/web-extension-marks.js +29 -0
  93. package/esm/browser/extension/web-extension-protocol.d.ts +13 -1
  94. package/esm/browser/extension/web-extension-protocol.js +4 -0
  95. package/esm/browser/extension/web-extension-run.d.ts +16 -2
  96. package/esm/browser/extension/web-extension-run.js +80 -0
  97. package/esm/browser/extension/web-extensions-running.d.ts +5 -1
  98. package/esm/browser/extension/web-extensions-running.js +16 -0
  99. package/esm/browser/extension/web-extensions.d.ts +2 -1
  100. package/esm/browser/extension/web-extensions.js +3 -0
  101. package/esm/browser/extension/web-home.js +3 -1
  102. package/esm/browser/extension/web-host-values.d.ts +66 -0
  103. package/esm/browser/extension/web-host-values.js +191 -0
  104. package/esm/browser/extension/web-hosts.d.ts +7 -2
  105. package/esm/browser/extension/web-hosts.js +16 -4
  106. package/esm/browser/extension/web-share-ui.d.ts +7 -0
  107. package/esm/browser/extension/web-share-ui.js +20 -0
  108. package/esm/browser/extension/web-share.d.ts +18 -0
  109. package/esm/browser/extension/web-share.js +42 -0
  110. package/esm/browser/i18n/en/assistant.d.ts +4 -0
  111. package/esm/browser/i18n/en/assistant.js +4 -0
  112. package/esm/browser/i18n/en/chat.d.ts +10 -0
  113. package/esm/browser/i18n/en/chat.js +10 -0
  114. package/esm/browser/i18n/en/common.d.ts +15 -0
  115. package/esm/browser/i18n/en/common.js +15 -0
  116. package/esm/browser/i18n/en/discover.d.ts +11 -1
  117. package/esm/browser/i18n/en/discover.js +11 -1
  118. package/esm/browser/i18n/en/settings.d.ts +10 -0
  119. package/esm/browser/i18n/en/settings.js +10 -0
  120. package/esm/browser/i18n/ja/assistant.js +4 -0
  121. package/esm/browser/i18n/ja/chat.js +10 -0
  122. package/esm/browser/i18n/ja/common.js +15 -0
  123. package/esm/browser/i18n/ja/discover.js +11 -1
  124. package/esm/browser/i18n/ja/settings.js +10 -0
  125. package/esm/browser/i18n/locales.d.ts +51 -2
  126. package/esm/browser/i18n/messages.d.ts +50 -1
  127. package/esm/browser/i18n/zh/assistant.js +4 -0
  128. package/esm/browser/i18n/zh/chat.js +10 -0
  129. package/esm/browser/i18n/zh/common.js +15 -0
  130. package/esm/browser/i18n/zh/discover.js +11 -1
  131. package/esm/browser/i18n/zh/settings.js +10 -0
  132. package/esm/browser/i18n/zh-tw/assistant.js +4 -0
  133. package/esm/browser/i18n/zh-tw/chat.js +10 -0
  134. package/esm/browser/i18n/zh-tw/common.js +15 -0
  135. package/esm/browser/i18n/zh-tw/discover.js +11 -1
  136. package/esm/browser/i18n/zh-tw/settings.js +10 -0
  137. package/esm/browser/launch-art/art-palette.d.ts +41 -0
  138. package/esm/browser/launch-art/art-palette.js +72 -0
  139. package/esm/browser/launch-art/cyclic-automaton.d.ts +45 -0
  140. package/esm/browser/launch-art/cyclic-automaton.js +176 -0
  141. package/esm/browser/launch-art/fractal-tree.d.ts +43 -0
  142. package/esm/browser/launch-art/fractal-tree.js +48 -0
  143. package/esm/browser/launch-art/launch-art.d.ts +98 -0
  144. package/esm/browser/launch-art/launch-art.js +420 -0
  145. package/esm/browser/launch-art/launch-sky.d.ts +66 -0
  146. package/esm/browser/launch-art/launch-sky.js +153 -0
  147. package/esm/browser/links/clipboard-links.d.ts +85 -0
  148. package/esm/browser/links/clipboard-links.js +261 -0
  149. package/esm/browser/links/link-text.d.ts +29 -0
  150. package/esm/browser/links/link-text.js +97 -0
  151. package/esm/browser/links/links-protocol.d.ts +12 -1
  152. package/esm/browser/links/links.d.ts +8 -2
  153. package/esm/browser/links/links.js +33 -3
  154. package/esm/browser/markdown/code-renderers.d.ts +4 -0
  155. package/esm/browser/markdown/code-renderers.js +4 -0
  156. package/esm/browser/partners/group-picker.js +23 -29
  157. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  158. package/esm/browser/sandbox/work/work-senses.js +1 -1
  159. package/esm/browser/settings/settings-protocol.d.ts +26 -0
  160. package/esm/browser/settings/settings-protocol.js +11 -0
  161. package/esm/browser/settings/settings.d.ts +4 -1
  162. package/esm/browser/settings/settings.js +16 -3
  163. package/esm/browser/skin/skin-layer.d.ts +8 -0
  164. package/esm/browser/skin/skin-layer.js +118 -0
  165. package/esm/browser/skin/skin-util.d.ts +40 -0
  166. package/esm/browser/skin/skin-util.js +120 -0
  167. package/esm/browser/style/base.d.ts +1 -1
  168. package/esm/browser/style/base.js +10 -6
  169. package/esm/browser/style/chat-list.d.ts +1 -1
  170. package/esm/browser/style/chat-list.js +28 -15
  171. package/esm/browser/style/conversation-column.d.ts +1 -1
  172. package/esm/browser/style/conversation.d.ts +1 -1
  173. package/esm/browser/style/conversation.js +5 -4
  174. package/esm/browser/style/dialogs.d.ts +1 -1
  175. package/esm/browser/style/dialogs.js +2 -5
  176. package/esm/browser/style/forms.d.ts +5 -0
  177. package/esm/browser/style/forms.js +65 -0
  178. package/esm/browser/style/layout.d.ts +1 -1
  179. package/esm/browser/style/pages.d.ts +1 -1
  180. package/esm/browser/style/pages.js +14 -24
  181. package/esm/browser/style/phone.d.ts +1 -1
  182. package/esm/browser/style/shared.d.ts +1 -1
  183. package/esm/browser/style/shell.d.ts +1 -1
  184. package/esm/browser/style/shell.js +1 -6
  185. package/esm/browser/style/skins.d.ts +9 -0
  186. package/esm/browser/style/skins.js +107 -0
  187. package/esm/browser/style/surfaces.d.ts +1 -1
  188. package/esm/browser/style/surfaces.js +8 -6
  189. package/esm/browser/style/tasks.d.ts +1 -1
  190. package/esm/browser/style.js +4 -0
  191. package/esm/browser/util/fresh-rows.d.ts +21 -0
  192. package/esm/browser/util/fresh-rows.js +36 -0
  193. package/esm/browser/util/process.d.ts +12 -22
  194. package/esm/browser/util/process.js +49 -39
  195. package/esm/browser/util/voice.d.ts +18 -0
  196. package/esm/browser/util/voice.js +111 -3
  197. package/esm/browser/workbench-protocol.d.ts +2 -0
  198. package/esm/browser/workbench-services.d.ts +2 -0
  199. package/esm/browser/workbench-services.js +5 -0
  200. package/esm/browser/workbench.js +5 -0
  201. package/lib/browser/apps/app-window.js +2 -2
  202. package/lib/browser/apps/web-apps.d.ts +4 -0
  203. package/lib/browser/apps/web-apps.js +14 -3
  204. package/lib/browser/assistant/assistant-chat-list.js +2 -1
  205. package/lib/browser/assistant/assistant-extension.js +15 -1
  206. package/lib/browser/assistant/assistant-protocol.d.ts +6 -0
  207. package/lib/browser/assistant/assistant-task-source.js +3 -0
  208. package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
  209. package/lib/browser/assistant/assistant-task-util.js +5 -0
  210. package/lib/browser/assistant/assistant.d.ts +3 -0
  211. package/lib/browser/assistant/assistant.js +26 -2
  212. package/lib/browser/assistant/ta-hearing.d.ts +86 -0
  213. package/lib/browser/assistant/ta-hearing.js +277 -0
  214. package/lib/browser/components/app-shell-hooks.d.ts +2 -1
  215. package/lib/browser/components/app-shell-hooks.js +4 -3
  216. package/lib/browser/components/app-shell-state.js +2 -2
  217. package/lib/browser/components/auth-view.js +1 -1
  218. package/lib/browser/components/board.js +9 -1
  219. package/lib/browser/components/chat-list-row.js +4 -4
  220. package/lib/browser/components/chat-list-util.d.ts +2 -2
  221. package/lib/browser/components/clipboard-link-host.d.ts +3 -0
  222. package/lib/browser/components/clipboard-link-host.js +63 -0
  223. package/lib/browser/components/cloud-network.js +1 -1
  224. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  225. package/lib/browser/components/custom-host.d.ts +4 -1
  226. package/lib/browser/components/custom-host.js +8 -2
  227. package/lib/browser/components/custom-provider-advanced.js +8 -8
  228. package/lib/browser/components/custom-provider-view.js +12 -12
  229. package/lib/browser/components/earlier-messages.d.ts +4 -1
  230. package/lib/browser/components/earlier-messages.js +5 -2
  231. package/lib/browser/components/empty-state.d.ts +2 -1
  232. package/lib/browser/components/empty-state.js +6 -2
  233. package/lib/browser/components/folder-picker.js +2 -2
  234. package/lib/browser/components/gallery.js +7 -8
  235. package/lib/browser/components/hearing-host.d.ts +6 -0
  236. package/lib/browser/components/hearing-host.js +94 -0
  237. package/lib/browser/components/host-view.d.ts +1 -1
  238. package/lib/browser/components/link-dialog.js +4 -0
  239. package/lib/browser/components/loading.d.ts +3 -2
  240. package/lib/browser/components/loading.js +7 -3
  241. package/lib/browser/components/markdown.d.ts +3 -1
  242. package/lib/browser/components/markdown.js +9 -4
  243. package/lib/browser/components/media.d.ts +10 -4
  244. package/lib/browser/components/media.js +61 -14
  245. package/lib/browser/components/message-list.js +2 -1
  246. package/lib/browser/components/message-steps.js +8 -5
  247. package/lib/browser/components/people-picker.d.ts +18 -0
  248. package/lib/browser/components/people-picker.js +166 -0
  249. package/lib/browser/components/relay-view.js +1 -1
  250. package/lib/browser/components/settings-choices.d.ts +2 -1
  251. package/lib/browser/components/settings-choices.js +2 -1
  252. package/lib/browser/components/settings-parts.js +23 -1
  253. package/lib/browser/components/share-dialog.d.ts +2 -2
  254. package/lib/browser/components/share-dialog.js +7 -4
  255. package/lib/browser/components/share-friends.d.ts +18 -2
  256. package/lib/browser/components/share-friends.js +67 -13
  257. package/lib/browser/components/share-item-sheet.d.ts +13 -0
  258. package/lib/browser/components/share-item-sheet.js +75 -0
  259. package/lib/browser/components/share-sheet.d.ts +12 -4
  260. package/lib/browser/components/share-sheet.js +14 -4
  261. package/lib/browser/components/sign-in-setup.js +4 -4
  262. package/lib/browser/components/trusted-domains.js +1 -1
  263. package/lib/browser/components/view-room.d.ts +26 -0
  264. package/lib/browser/components/view-room.js +173 -0
  265. package/lib/browser/components/voice-services.js +6 -6
  266. package/lib/browser/device/device-protocol.d.ts +9 -6
  267. package/lib/browser/device/device-protocol.js +7 -4
  268. package/lib/browser/device/launch-screen.d.ts +11 -1
  269. package/lib/browser/device/launch-screen.js +22 -4
  270. package/lib/browser/extension/share-sheet-compat.d.ts +2 -0
  271. package/lib/browser/extension/share-sheet-compat.js +13 -2
  272. package/lib/browser/extension/web-api-chats.d.ts +23 -0
  273. package/lib/browser/extension/web-api-code.d.ts +11 -0
  274. package/lib/browser/extension/web-api-components.d.ts +8 -1
  275. package/lib/browser/extension/web-api-contributions.d.ts +30 -1
  276. package/lib/browser/extension/web-api-desktop.d.ts +2 -1
  277. package/lib/browser/extension/web-api-file-views.d.ts +39 -0
  278. package/lib/browser/extension/web-api-file-views.js +3 -0
  279. package/lib/browser/extension/web-api-host.d.ts +48 -0
  280. package/lib/browser/extension/web-api-host.js +4 -0
  281. package/lib/browser/extension/web-api-menus.d.ts +46 -0
  282. package/lib/browser/extension/web-api-partners.d.ts +58 -1
  283. package/lib/browser/extension/web-api-skins.d.ts +96 -0
  284. package/lib/browser/extension/web-api-skins.js +3 -0
  285. package/lib/browser/extension/web-api-spec.js +9 -0
  286. package/lib/browser/extension/web-extension-api.d.ts +13 -34
  287. package/lib/browser/extension/web-extension-context.d.ts +2 -8
  288. package/lib/browser/extension/web-extension-context.js +15 -39
  289. package/lib/browser/extension/web-extension-marks.d.ts +11 -0
  290. package/lib/browser/extension/web-extension-marks.js +65 -0
  291. package/lib/browser/extension/web-extension-protocol.d.ts +13 -1
  292. package/lib/browser/extension/web-extension-protocol.js +4 -0
  293. package/lib/browser/extension/web-extension-run.d.ts +16 -2
  294. package/lib/browser/extension/web-extension-run.js +80 -0
  295. package/lib/browser/extension/web-extensions-running.d.ts +5 -1
  296. package/lib/browser/extension/web-extensions-running.js +16 -0
  297. package/lib/browser/extension/web-extensions.d.ts +2 -1
  298. package/lib/browser/extension/web-extensions.js +3 -0
  299. package/lib/browser/extension/web-home.js +3 -1
  300. package/lib/browser/extension/web-host-values.d.ts +67 -0
  301. package/lib/browser/extension/web-host-values.js +229 -0
  302. package/lib/browser/extension/web-hosts.d.ts +7 -2
  303. package/lib/browser/extension/web-hosts.js +16 -4
  304. package/lib/browser/extension/web-share-ui.d.ts +8 -0
  305. package/lib/browser/extension/web-share-ui.js +56 -0
  306. package/lib/browser/extension/web-share.d.ts +19 -0
  307. package/lib/browser/extension/web-share.js +45 -0
  308. package/lib/browser/i18n/en/assistant.d.ts +4 -0
  309. package/lib/browser/i18n/en/assistant.js +4 -0
  310. package/lib/browser/i18n/en/chat.d.ts +10 -0
  311. package/lib/browser/i18n/en/chat.js +10 -0
  312. package/lib/browser/i18n/en/common.d.ts +15 -0
  313. package/lib/browser/i18n/en/common.js +15 -0
  314. package/lib/browser/i18n/en/discover.d.ts +11 -1
  315. package/lib/browser/i18n/en/discover.js +11 -1
  316. package/lib/browser/i18n/en/settings.d.ts +10 -0
  317. package/lib/browser/i18n/en/settings.js +10 -0
  318. package/lib/browser/i18n/ja/assistant.js +4 -0
  319. package/lib/browser/i18n/ja/chat.js +10 -0
  320. package/lib/browser/i18n/ja/common.js +15 -0
  321. package/lib/browser/i18n/ja/discover.js +11 -1
  322. package/lib/browser/i18n/ja/settings.js +10 -0
  323. package/lib/browser/i18n/locales.d.ts +51 -2
  324. package/lib/browser/i18n/messages.d.ts +50 -1
  325. package/lib/browser/i18n/zh/assistant.js +4 -0
  326. package/lib/browser/i18n/zh/chat.js +10 -0
  327. package/lib/browser/i18n/zh/common.js +15 -0
  328. package/lib/browser/i18n/zh/discover.js +11 -1
  329. package/lib/browser/i18n/zh/settings.js +10 -0
  330. package/lib/browser/i18n/zh-tw/assistant.js +4 -0
  331. package/lib/browser/i18n/zh-tw/chat.js +10 -0
  332. package/lib/browser/i18n/zh-tw/common.js +15 -0
  333. package/lib/browser/i18n/zh-tw/discover.js +11 -1
  334. package/lib/browser/i18n/zh-tw/settings.js +10 -0
  335. package/lib/browser/launch-art/art-palette.d.ts +42 -0
  336. package/lib/browser/launch-art/art-palette.js +76 -0
  337. package/lib/browser/launch-art/cyclic-automaton.d.ts +46 -0
  338. package/lib/browser/launch-art/cyclic-automaton.js +180 -0
  339. package/lib/browser/launch-art/fractal-tree.d.ts +44 -0
  340. package/lib/browser/launch-art/fractal-tree.js +52 -0
  341. package/lib/browser/launch-art/launch-art.d.ts +99 -0
  342. package/lib/browser/launch-art/launch-art.js +424 -0
  343. package/lib/browser/launch-art/launch-sky.d.ts +67 -0
  344. package/lib/browser/launch-art/launch-sky.js +157 -0
  345. package/lib/browser/links/clipboard-links.d.ts +86 -0
  346. package/lib/browser/links/clipboard-links.js +266 -0
  347. package/lib/browser/links/link-text.d.ts +30 -0
  348. package/lib/browser/links/link-text.js +100 -0
  349. package/lib/browser/links/links-protocol.d.ts +12 -1
  350. package/lib/browser/links/links.d.ts +8 -2
  351. package/lib/browser/links/links.js +33 -3
  352. package/lib/browser/markdown/code-renderers.d.ts +4 -0
  353. package/lib/browser/markdown/code-renderers.js +5 -1
  354. package/lib/browser/partners/group-picker.js +23 -29
  355. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  356. package/lib/browser/sandbox/work/work-senses.js +1 -1
  357. package/lib/browser/settings/settings-protocol.d.ts +26 -0
  358. package/lib/browser/settings/settings-protocol.js +12 -1
  359. package/lib/browser/settings/settings.d.ts +4 -1
  360. package/lib/browser/settings/settings.js +16 -3
  361. package/lib/browser/skin/skin-layer.d.ts +9 -0
  362. package/lib/browser/skin/skin-layer.js +154 -0
  363. package/lib/browser/skin/skin-util.d.ts +41 -0
  364. package/lib/browser/skin/skin-util.js +123 -0
  365. package/lib/browser/style/base.d.ts +1 -1
  366. package/lib/browser/style/base.js +10 -6
  367. package/lib/browser/style/chat-list.d.ts +1 -1
  368. package/lib/browser/style/chat-list.js +28 -15
  369. package/lib/browser/style/conversation-column.d.ts +1 -1
  370. package/lib/browser/style/conversation.d.ts +1 -1
  371. package/lib/browser/style/conversation.js +5 -4
  372. package/lib/browser/style/dialogs.d.ts +1 -1
  373. package/lib/browser/style/dialogs.js +2 -5
  374. package/lib/browser/style/forms.d.ts +6 -0
  375. package/lib/browser/style/forms.js +68 -0
  376. package/lib/browser/style/layout.d.ts +1 -1
  377. package/lib/browser/style/pages.d.ts +1 -1
  378. package/lib/browser/style/pages.js +14 -24
  379. package/lib/browser/style/phone.d.ts +1 -1
  380. package/lib/browser/style/shared.d.ts +1 -1
  381. package/lib/browser/style/shell.d.ts +1 -1
  382. package/lib/browser/style/shell.js +1 -6
  383. package/lib/browser/style/skins.d.ts +10 -0
  384. package/lib/browser/style/skins.js +110 -0
  385. package/lib/browser/style/surfaces.d.ts +1 -1
  386. package/lib/browser/style/surfaces.js +8 -6
  387. package/lib/browser/style/tasks.d.ts +1 -1
  388. package/lib/browser/style.js +4 -0
  389. package/lib/browser/util/fresh-rows.d.ts +22 -0
  390. package/lib/browser/util/fresh-rows.js +40 -0
  391. package/lib/browser/util/process.d.ts +12 -22
  392. package/lib/browser/util/process.js +49 -40
  393. package/lib/browser/util/voice.d.ts +18 -0
  394. package/lib/browser/util/voice.js +111 -3
  395. package/lib/browser/workbench-protocol.d.ts +2 -0
  396. package/lib/browser/workbench-services.d.ts +2 -0
  397. package/lib/browser/workbench-services.js +5 -0
  398. package/lib/browser/workbench.js +5 -0
  399. package/package.json +8 -8
  400. package/public/launch.svg +3 -3
@@ -5,6 +5,7 @@ export class WorkbenchServices {
5
5
  this.terminalListeners = new Set();
6
6
  this.reconnectListeners = new Set();
7
7
  this.extensionDataListeners = new Set();
8
+ this.hostChangedListeners = new Set();
8
9
  this.authListeners = new Set();
9
10
  this.remoteListeners = new Set();
10
11
  this.voiceListeners = new Set();
@@ -113,6 +114,10 @@ export class WorkbenchServices {
113
114
  this.extensionDataListeners.add(listener);
114
115
  return () => this.extensionDataListeners.delete(listener);
115
116
  }
117
+ onHostChanged(listener) {
118
+ this.hostChangedListeners.add(listener);
119
+ return () => this.hostChangedListeners.delete(listener);
120
+ }
116
121
  onAuthEvent(listener) {
117
122
  this.authListeners.add(listener);
118
123
  return () => this.authListeners.delete(listener);
@@ -250,6 +250,11 @@ let TaWorkbenchImpl = class TaWorkbenchImpl extends WorkbenchHosts {
250
250
  listener(name, keys, cwd);
251
251
  }
252
252
  });
253
+ connection.onHostChanged((name, topics) => {
254
+ for (const listener of this.hostChangedListeners) {
255
+ listener(name, topics);
256
+ }
257
+ });
253
258
  connection.onAuthEvent((loginId, event) => {
254
259
  for (const listener of this.authListeners) {
255
260
  listener(loginId, event);
@@ -62,7 +62,7 @@ function AppWindow({ id }) {
62
62
  const t = (0, use_t_1.useT)();
63
63
  const [workbench, bench] = (0, hooks_1.useWorkbench)();
64
64
  const [extensions, host] = (0, hooks_1.useWebExtensions)();
65
- const [{ theme }] = (0, hooks_1.useSettings)();
65
+ const [{ theme, skinColor }] = (0, hooks_1.useSettings)();
66
66
  const files = (0, react_1.useInject)(files_protocol_1.TaFiles);
67
67
  const fileUrl = React.useCallback(async (path, box) => files.loadable(thumbnail_1.ThumbnailUtil.boxed(await bench.workspace.fileUrl(path), box)), [bench, files]);
68
68
  const openLink = (0, hooks_1.useOpenLink)(undefined);
@@ -71,7 +71,7 @@ function AppWindow({ id }) {
71
71
  const reachable = online || workbench.status === 'offline';
72
72
  (0, workbench_view_1.useDocument)();
73
73
  (0, app_shell_hooks_1.useRefresh)(online);
74
- (0, app_shell_hooks_1.useTitlebarColor)(workbench.status !== 'signed-out', theme);
74
+ (0, app_shell_hooks_1.useTitlebarColor)(workbench.status !== 'signed-out', theme, skinColor);
75
75
  React.useEffect(() => {
76
76
  void bench.start();
77
77
  }, [bench]);
@@ -10,6 +10,8 @@ export interface WebAppsHost {
10
10
  readonly notices: TaNotices;
11
11
  /** Drawn for a page without a glyph of its own, or one a sandbox draws. */
12
12
  readonly fallbackIcon: WebIcon;
13
+ /** The extension it is given to stopped: it installs, opens and removes nothing more (WebExtensionContext). */
14
+ stopped?(): boolean;
13
15
  }
14
16
  /**
15
17
  * `ui.apps` (docs/design/ta-install-as-app.md 2): a page installed with the title and the tile the launcher shows it
@@ -26,5 +28,7 @@ export declare class TaWebApps implements WebApps {
26
28
  install(id: string): Promise<void>;
27
29
  remove(id: string): Promise<void>;
28
30
  open(id: string): Promise<void>;
31
+ /** What acts for the user: refused once the extension stopped. */
32
+ protected live(): void;
29
33
  }
30
34
  //# sourceMappingURL=web-apps.d.ts.map
@@ -20,13 +20,15 @@ class TaWebApps {
20
20
  return desktop ? new TaWebApps(desktop, host) : undefined;
21
21
  }
22
22
  get installable() {
23
- return this.host.settings.state.settings.installApps;
23
+ var _a, _b;
24
+ return !((_b = (_a = this.host).stopped) === null || _b === void 0 ? void 0 : _b.call(_a)) && this.host.settings.state.settings.installApps;
24
25
  }
25
26
  async list() {
26
27
  return (await this.desktop.list()).map(({ id, name, installedAt }) => ({ id, name, installedAt }));
27
28
  }
28
29
  async install(id) {
29
30
  var _a, _b;
31
+ this.live();
30
32
  const say = (0, use_t_1.translator)(this.host.settings.state.language);
31
33
  if (!this.installable) {
32
34
  throw new Error(say('ta.apps.off'));
@@ -50,12 +52,21 @@ class TaWebApps {
50
52
  this.host.notices.notify(say('ta.apps.installed', { name: page.title }));
51
53
  }
52
54
  }
53
- remove(id) {
55
+ async remove(id) {
56
+ this.live();
54
57
  return this.desktop.remove(id);
55
58
  }
56
- open(id) {
59
+ async open(id) {
60
+ this.live();
57
61
  return this.desktop.open(id);
58
62
  }
63
+ /** What acts for the user: refused once the extension stopped. */
64
+ live() {
65
+ var _a, _b;
66
+ if ((_b = (_a = this.host).stopped) === null || _b === void 0 ? void 0 : _b.call(_a)) {
67
+ throw new Error('The web extension has stopped.');
68
+ }
69
+ }
59
70
  }
60
71
  exports.TaWebApps = TaWebApps;
61
72
  //# sourceMappingURL=web-apps.js.map
@@ -139,7 +139,8 @@ function AssistantChatList(props) {
139
139
  // By the id of its session, and by its file: a task's conversation is marked once saved too.
140
140
  tasks: new Map(tasks
141
141
  .filter(task => !task.takenOver)
142
- .flatMap(task => [[task.sessionId, task.status], ...(task.sessionFile ? [[task.sessionFile, task.status]] : [])])),
142
+ .map(task => [task, task.paused && task.status !== 'running' ? 'paused' : task.status])
143
+ .flatMap(([task, status]) => [[task.sessionId, status], ...(task.sessionFile ? [[task.sessionFile, status]] : [])])),
143
144
  session,
144
145
  sessionFile,
145
146
  name,
@@ -343,6 +343,14 @@ let AssistantWebExtension = class AssistantWebExtension {
343
343
  .catch(error => pi.ui.notify(error instanceof Error ? error.message : String(error), 'error'));
344
344
  };
345
345
  const stop = act(() => this.assistant.stop());
346
+ const { tasks } = this.assistant.state;
347
+ const running = tasks.filter(task => task.status === 'running' && !task.takenOver).length;
348
+ const paused = tasks.filter(task => task.paused && !task.takenOver).length;
349
+ const pauseTasks = act(async () => {
350
+ const count = await this.assistant.pauseTasks();
351
+ pi.ui.notify(t('ta.assistant.pausedTasks').replace('{count}', String(count)), 'info');
352
+ });
353
+ const resumeTasks = act(() => this.assistant.resumeTasks());
346
354
  const restart = act(async () => {
347
355
  if (await pi.ui.confirm(t('ta.assistant.restartTitle'), t('ta.assistant.restartHint'))) {
348
356
  await this.assistant.restart();
@@ -392,6 +400,12 @@ let AssistantWebExtension = class AssistantWebExtension {
392
400
  { key: 'stop', label: t('ta.assistant.stop'), icon: lucide_react_1.Square, disabled: !(store === null || store === void 0 ? void 0 : store.state.working), run: stop },
393
401
  { key: 'restart', label: t('ta.assistant.restart'), icon: lucide_react_1.RotateCcw, disabled: !store, run: restart },
394
402
  ],
403
+ [
404
+ ...(running ? [{ key: 'pauseTasks', label: t('ta.assistant.pauseTasks'), icon: lucide_react_1.Pause, run: pauseTasks }] : []),
405
+ ...(paused
406
+ ? [{ key: 'resumeTasks', label: t('ta.assistant.resumeTasks').replace('{count}', String(paused)), icon: lucide_react_1.Play, run: resumeTasks }]
407
+ : []),
408
+ ],
395
409
  [
396
410
  { key: 'rename', label: t('ta.assistant.rename'), icon: lucide_react_1.Pencil, run: rename },
397
411
  { key: 'look', label: t('ta.assistant.look'), icon: lucide_react_1.Sparkles, run: () => dino_look_picker_1.DinoLookPicker.open() },
@@ -399,7 +413,7 @@ let AssistantWebExtension = class AssistantWebExtension {
399
413
  { key: 'copyCwd', label: t('ta.assistant.copyCwd'), icon: lucide_react_1.Copy, disabled: !cwd, run: copyCwd },
400
414
  ],
401
415
  [{ key: 'export', label: t('ta.assistant.export'), icon: lucide_react_1.Download, run: exportMarkdown }],
402
- ];
416
+ ].filter(section => section.length > 0);
403
417
  }
404
418
  };
405
419
  exports.AssistantWebExtension = AssistantWebExtension;
@@ -17,6 +17,8 @@ export interface AssistantTask {
17
17
  origin?: string;
18
18
  /** The user took it over: the double no longer follows it. */
19
19
  takenOver?: boolean;
20
+ /** The user paused it (pauseTasks): stopped until they resume it (resumeTasks). */
21
+ paused?: boolean;
20
22
  /** It works in a git worktree of its own (start_task's isolate): where, on which branch, from which commit. */
21
23
  worktree?: {
22
24
  path: string;
@@ -91,6 +93,10 @@ export interface TaAssistant {
91
93
  /** Says something to ta: a new message, or, while it works, one it reads at its next step. */
92
94
  say(text: string, images?: ComposerImage[]): Promise<void>;
93
95
  stopTask(taskId: string): Promise<void>;
96
+ /** Stops every task that runs, marked paused; how many. */
97
+ pauseTasks(): Promise<number>;
98
+ /** Has every paused task go on where it stopped; how many. */
99
+ resumeTasks(): Promise<number>;
94
100
  /** The user lets the task start, or not. */
95
101
  answer(askId: string, start: boolean): void;
96
102
  /** The user takes the task over: the double stops following it; its session, opened again if it closed since, is what to show. */
@@ -15,6 +15,9 @@ function activity(task, state, t) {
15
15
  // A check's words follow its verdict, which the list says in words of the user's language.
16
16
  const said = task.verifies ? assistant_task_util_1.AssistantTaskUtil.verdictReason(task.result) : task.result;
17
17
  // A card of its reply (ta-glance) is drawn in its conversation, not read out here.
18
+ if (task.paused && task.status !== 'running') {
19
+ return t('ta.task.paused');
20
+ }
18
21
  return task.status === 'running' ? t('ta.task.running') : ta_protocol_1.TaSaid.line(said !== null && said !== void 0 ? said : '', { chars: 80 }) || t(`ta.task.${task.status}`);
19
22
  }
20
23
  /** How a task came out of a check: its own verdict for a check that ended, else the verdict of the check of it. */
@@ -12,6 +12,8 @@ export declare const MAX_TASKS = 50;
12
12
  export declare namespace AssistantTaskUtil {
13
13
  /** What a task whose session is gone ended with: the Ta service closed it, or restarted. */
14
14
  const CLOSED_RESULT = "Its session closed while nobody watched (the Ta service restarted, or closed it).";
15
+ /** What a paused task is told as the user resumes it. */
16
+ const RESUME_MESSAGE = "The user paused this task and now resumes it: go on where you left off.";
15
17
  /**
16
18
  * The tasks of both lists, each in its newer copy (the higher `rev`; the server's, `theirs`, when
17
19
  * both are as new, so that the pages end with the same), in the order of their ids; the last MAX_TASKS.
@@ -16,6 +16,8 @@ var AssistantTaskUtil;
16
16
  (function (AssistantTaskUtil) {
17
17
  /** What a task whose session is gone ended with: the Ta service closed it, or restarted. */
18
18
  AssistantTaskUtil.CLOSED_RESULT = 'Its session closed while nobody watched (the Ta service restarted, or closed it).';
19
+ /** What a paused task is told as the user resumes it. */
20
+ AssistantTaskUtil.RESUME_MESSAGE = 'The user paused this task and now resumes it: go on where you left off.';
19
21
  /**
20
22
  * The tasks of both lists, each in its newer copy (the higher `rev`; the server's, `theirs`, when
21
23
  * both are as new, so that the pages end with the same), in the order of their ids; the last MAX_TASKS.
@@ -120,6 +122,9 @@ var AssistantTaskUtil;
120
122
  function updateNote(task) {
121
123
  var _a, _b;
122
124
  const lines = [((_a = task.result) !== null && _a !== void 0 ? _a : '').slice(0, RESULT_CHARS)];
125
+ if (task.paused) {
126
+ lines.push('The user paused it, with the other tasks that ran: leave it until they resume it.');
127
+ }
123
128
  if (task.worktree) {
124
129
  lines.push(`It worked in the git worktree ${task.worktree.path}, on the branch ${task.worktree.branch} (from ${task.worktree.base.slice(0, 12)}).`);
125
130
  }
@@ -29,6 +29,9 @@ export declare class TaAssistantImpl extends AssistantConversation implements Ta
29
29
  * does not run (it ended unseen, or closed) stops here: an abort would change nothing.
30
30
  */
31
31
  stopTask(taskId: string): Promise<void>;
32
+ pauseTasks(): Promise<number>;
33
+ /** Each paused task told to go on, in its conversation opened again if it closed since; one that fails stays paused. */
34
+ resumeTasks(): Promise<number>;
32
35
  /**
33
36
  * The user lets a task the double asked for start, or not: started here, and the double told, as a message of its
34
37
  * conversation; its turn ended when it asked (deferred, docs/design/ta-always-on.md 3.10).
@@ -130,6 +130,24 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
130
130
  this.book.change(task, { status: 'stopped', endedAt: Date.now() });
131
131
  }
132
132
  }
133
+ async pauseTasks() {
134
+ const running = this.current.tasks.filter(task => task.status === 'running' && !task.takenOver);
135
+ for (const task of running) {
136
+ this.book.change(task, { paused: true });
137
+ }
138
+ await Promise.all(running.map(task => this.stopTask(task.id)));
139
+ return running.length;
140
+ }
141
+ /** Each paused task told to go on, in its conversation opened again if it closed since; one that fails stays paused. */
142
+ async resumeTasks() {
143
+ const paused = this.current.tasks.filter(task => task.paused && !task.takenOver);
144
+ const resumed = await Promise.allSettled(paused.map(async (task) => {
145
+ const store = await this.openTask(task.id);
146
+ await store.prompt(ta_protocol_1.TaMessageSource.mark(assistant_task_util_1.AssistantTaskUtil.RESUME_MESSAGE, ta_protocol_1.TaMessageSource.DOUBLE));
147
+ this.book.change(task.id, { paused: undefined });
148
+ }));
149
+ return resumed.filter(result => result.status === 'fulfilled').length;
150
+ }
133
151
  /**
134
152
  * The user lets a task the double asked for start, or not: started here, and the double told, as a message of its
135
153
  * conversation; its turn ended when it asked (deferred, docs/design/ta-always-on.md 3.10).
@@ -256,11 +274,12 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
256
274
  const run = {
257
275
  start_task: (input, request) => this.startTask(input, request.id),
258
276
  list_tasks: () => JSON.stringify({
259
- tasks: this.current.tasks.map(({ id, title, status, result, takenOver }) => ({
277
+ tasks: this.current.tasks.map(({ id, title, status, result, takenOver, paused }) => ({
260
278
  id,
261
279
  title,
262
280
  status,
263
281
  takenOver,
282
+ paused,
264
283
  result: result === null || result === void 0 ? void 0 : result.slice(0, 200),
265
284
  })),
266
285
  conversations: this.conversationsGoingOn(),
@@ -278,6 +297,10 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
278
297
  }
279
298
  // Its session closed since (idle, or the service restarted): opened again from its file.
280
299
  const store = await this.openTask(id);
300
+ // The double goes on with one the user paused: it is no longer waiting for them.
301
+ if (task.paused) {
302
+ this.book.change(task, { paused: undefined });
303
+ }
281
304
  await store.prompt(ta_protocol_1.TaMessageSource.mark(message, ta_protocol_1.TaMessageSource.DOUBLE), { streamingBehavior: 'steer' });
282
305
  return `Sent to task ${id}.`;
283
306
  },
@@ -423,7 +446,8 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
423
446
  // Not ended after all: the double hears of it when it ends again.
424
447
  this.notes.delete(id);
425
448
  if (task.status !== 'running') {
426
- this.book.change(id, { status: 'running', endedAt: undefined, result: undefined });
449
+ // Going on again, whoever said so: no longer paused.
450
+ this.book.change(id, { status: 'running', endedAt: undefined, result: undefined, paused: undefined });
427
451
  }
428
452
  }
429
453
  else if (task.status === 'running' && assistant_task_util_1.AssistantTaskUtil.ended(state)) {
@@ -0,0 +1,86 @@
1
+ import type { Voice } from '../util/voice';
2
+ import { RealtimeVoice } from './realtime-voice';
3
+ import type { RealtimeVoiceHost } from './realtime-voice-protocol';
4
+ /** The package whose host writes speech down on the computer (ta-voice's hear.ts). */
5
+ export declare const HEAR_PACKAGE = "@celljs/ta-voice";
6
+ /** What the computer says of its speech recognition (ta-voice's `hearing`): on, downloading, ready or failed. */
7
+ export interface HearingStatus {
8
+ on: boolean;
9
+ state: 'off' | 'getting' | 'ready' | 'failed';
10
+ supported: boolean;
11
+ /** The size of its model, in bytes. */
12
+ bytes: number;
13
+ done?: number;
14
+ total?: number;
15
+ error?: {
16
+ code: string;
17
+ detail?: string;
18
+ };
19
+ }
20
+ export interface TaHearingHost {
21
+ /** Connected to ta serve: it can hear. */
22
+ online(): boolean;
23
+ /** A method of ta-voice's host: `hearing`, `hear`. */
24
+ call(method: string, params: unknown[]): Promise<unknown>;
25
+ /** Where a voice service of Settings is opened. */
26
+ readonly voices: RealtimeVoiceHost;
27
+ /**
28
+ * The computer cannot write speech down yet (`status` undefined: nothing of it answered): the user is told why,
29
+ * and offered to turn it on.
30
+ */
31
+ tell(status: HearingStatus | undefined): void;
32
+ microphone?(): Promise<MediaStream>;
33
+ }
34
+ /**
35
+ * Ta listening where the recognizer of the device does not (Voice.Fallback, docs/design/ta-voice.md 11): with the
36
+ * voice service of Settings → Voice when one is chosen, else with the model of the computer (ta-voice's hear, a
37
+ * need of ta-local-models). The microphone's sound goes to ta serve as PCM16 at 16 kHz in pieces as the user speaks;
38
+ * what was said so far comes back about each second, and all of it once they stop.
39
+ */
40
+ export declare class TaHearing implements Voice.Fallback {
41
+ protected readonly host: TaHearingHost;
42
+ /** Each piece sent, ms. */
43
+ static readonly PIECE_MS = 250;
44
+ /** What was said so far is asked at most this often, ms. */
45
+ static readonly INTERIM_MS = 1000;
46
+ /** Not past this much sound, ms: longer, only the end is written down. */
47
+ static readonly INTERIM_MAX_MS = 60000;
48
+ /** A silence this long after speech ends what is said to it (not what a finger holds), ms. */
49
+ static readonly SILENCE_MS = 1200;
50
+ /** No speech this long ends it, ms. */
51
+ static readonly NO_SPEECH_MS = 8000;
52
+ /** The longest one utterance, and one held, ms. */
53
+ static readonly MAX_MS = 60000;
54
+ static readonly MAX_HELD_MS = 300000;
55
+ /** The level (RMS) of speech, at least; in noise, louder than it. */
56
+ static readonly LEVEL = 0.015;
57
+ static readonly RATE = 16000;
58
+ constructor(host: TaHearingHost);
59
+ available(): boolean;
60
+ listen(language: string, onText: (text: string, final: boolean) => void, onEnd: (error?: string) => void, options?: Voice.ListenOptions): Voice.Listening;
61
+ /** With the voice service of Settings: one utterance, or all said till stopped, a sentence after another. */
62
+ protected withService(service: RealtimeVoice, language: string, onText: (text: string, final: boolean) => void, end: (error?: string) => void, options: Voice.ListenOptions): Voice.Listening | undefined;
63
+ /** With the model of the computer. */
64
+ protected locally(onText: (text: string, final: boolean) => void, end: (error?: string) => void, options: Voice.ListenOptions): Promise<Voice.Listening | undefined>;
65
+ }
66
+ /**
67
+ * The sound of a listening as it comes: PCM16 at 16 kHz not sent yet, how long it is, and whether it was speech, by its
68
+ * level above the noise there is; a silence after speech, no speech at all or too long a one ends what is said to it.
69
+ */
70
+ export declare class HeardSound {
71
+ protected readonly held: boolean;
72
+ protected pieces: Uint8Array[];
73
+ protected samples: number;
74
+ protected noise: number;
75
+ protected spokeAt: number;
76
+ spoke: boolean;
77
+ constructor(held: boolean);
78
+ /** How long it is, ms. */
79
+ get ms(): number;
80
+ add(samples: Float32Array, rate: number): void;
81
+ /** What came since it was last taken. */
82
+ take(): Uint8Array;
83
+ /** It is over: too long, or, said to it rather than held, a silence after speech or no speech at all. */
84
+ over(): boolean;
85
+ }
86
+ //# sourceMappingURL=ta-hearing.d.ts.map
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HeardSound = exports.TaHearing = exports.HEAR_PACKAGE = void 0;
4
+ const mini_program_1 = require("../device/mini-program");
5
+ const transcription_1 = require("../util/transcription");
6
+ const mic_capture_1 = require("./mic-capture");
7
+ const pcm_util_1 = require("./pcm-util");
8
+ const realtime_voice_1 = require("./realtime-voice");
9
+ /** The package whose host writes speech down on the computer (ta-voice's hear.ts). */
10
+ exports.HEAR_PACKAGE = '@celljs/ta-voice';
11
+ /**
12
+ * Ta listening where the recognizer of the device does not (Voice.Fallback, docs/design/ta-voice.md 11): with the
13
+ * voice service of Settings → Voice when one is chosen, else with the model of the computer (ta-voice's hear, a
14
+ * need of ta-local-models). The microphone's sound goes to ta serve as PCM16 at 16 kHz in pieces as the user speaks;
15
+ * what was said so far comes back about each second, and all of it once they stop.
16
+ */
17
+ class TaHearing {
18
+ constructor(host) {
19
+ this.host = host;
20
+ }
21
+ available() {
22
+ var _a;
23
+ return !mini_program_1.MiniProgram.inside() && this.host.online() && typeof navigator !== 'undefined' && !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia);
24
+ }
25
+ listen(language, onText, onEnd, options = {}) {
26
+ let ended = false;
27
+ let stopped = false;
28
+ let inner;
29
+ const end = (error) => {
30
+ if (!ended) {
31
+ ended = true;
32
+ onEnd(error);
33
+ }
34
+ };
35
+ void (async () => {
36
+ const voices = await this.host.voices.voice.listVoices().catch(() => undefined);
37
+ if ((voices === null || voices === void 0 ? void 0 : voices.use) && !stopped) {
38
+ const service = await new realtime_voice_1.RealtimeVoice(this.host.voices).open(language).catch(() => undefined);
39
+ if (service && stopped) {
40
+ service.stop();
41
+ }
42
+ if (service && !stopped) {
43
+ inner = this.withService(service, language, onText, end, options);
44
+ return;
45
+ }
46
+ }
47
+ if (stopped) {
48
+ return end();
49
+ }
50
+ const status = (await this.host.call('hearing', []).catch(() => undefined));
51
+ if ((status === null || status === void 0 ? void 0 : status.state) !== 'ready') {
52
+ this.host.tell(status);
53
+ return end();
54
+ }
55
+ if (stopped) {
56
+ return end();
57
+ }
58
+ inner = await this.locally(onText, end, options);
59
+ if (stopped) {
60
+ inner === null || inner === void 0 ? void 0 : inner.stop();
61
+ }
62
+ })().catch(() => end('network'));
63
+ return {
64
+ stop: () => {
65
+ stopped = true;
66
+ inner === null || inner === void 0 ? void 0 : inner.stop();
67
+ },
68
+ };
69
+ }
70
+ /** With the voice service of Settings: one utterance, or all said till stopped, a sentence after another. */
71
+ withService(service, language, onText, end, options) {
72
+ let said = '';
73
+ let heard = '';
74
+ const done = (error) => {
75
+ service.stop();
76
+ end(error);
77
+ };
78
+ if (!options.continuous) {
79
+ const listening = service.listen(language, (text, final) => {
80
+ heard = text;
81
+ onText(text, final);
82
+ }, done);
83
+ if (!listening) {
84
+ done('unavailable');
85
+ return undefined;
86
+ }
87
+ return {
88
+ stop: () => {
89
+ listening.stop();
90
+ if (heard.trim()) {
91
+ onText(heard, true);
92
+ }
93
+ done();
94
+ },
95
+ };
96
+ }
97
+ const joined = (more) => [said, more].filter(part => part.trim()).join(' ');
98
+ const transcribing = transcription_1.Transcription.start(service, language, {
99
+ onText: (text, final) => {
100
+ if (final) {
101
+ said = joined(text);
102
+ heard = '';
103
+ onText(said, false);
104
+ }
105
+ else {
106
+ heard = text;
107
+ onText(joined(text), false);
108
+ }
109
+ },
110
+ onEnd: error => {
111
+ if (said.trim()) {
112
+ onText(said, true);
113
+ }
114
+ done(error);
115
+ },
116
+ }, { hints: options.hints });
117
+ if (!transcribing) {
118
+ done('unavailable');
119
+ return undefined;
120
+ }
121
+ return { stop: () => transcribing.stop() };
122
+ }
123
+ /** With the model of the computer. */
124
+ async locally(onText, end, options) {
125
+ var _a, _b;
126
+ var _c, _d;
127
+ let stream;
128
+ try {
129
+ stream = await ((_c = (_b = (_a = this.host).microphone) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : navigator.mediaDevices.getUserMedia({ audio: { echoCancellation: true, noiseSuppression: true, autoGainControl: true, channelCount: 1 } }));
130
+ }
131
+ catch (error) {
132
+ const name = error === null || error === void 0 ? void 0 : error.name;
133
+ end(name === 'NotAllowedError' || name === 'SecurityError' ? 'not-allowed' : 'audio-capture');
134
+ return undefined;
135
+ }
136
+ const id = `h-${crypto.randomUUID()}`;
137
+ const heard = new HeardSound(options.continuous === true);
138
+ let chain = Promise.resolve();
139
+ let finished = false;
140
+ let decoding = false;
141
+ let decodedAt = 0;
142
+ let latest = '';
143
+ const Context = (_d = globalThis.AudioContext) !== null && _d !== void 0 ? _d : globalThis.webkitAudioContext;
144
+ const context = new Context();
145
+ const send = (decode) => {
146
+ const piece = heard.take();
147
+ const audio = piece.length ? pcm_util_1.PcmUtil.base64(piece) : '';
148
+ const sent = chain.then(() => this.host.call('hear', decode ? [id, audio, decode] : [id, audio]));
149
+ chain = sent.catch(() => undefined);
150
+ return sent;
151
+ };
152
+ const finish = (error) => {
153
+ if (finished) {
154
+ return;
155
+ }
156
+ finished = true;
157
+ clearInterval(timer);
158
+ capture.stop();
159
+ void context.close().catch(() => undefined);
160
+ if (error) {
161
+ return end(error);
162
+ }
163
+ send('final').then(answer => {
164
+ var _a;
165
+ const text = String((_a = answer === null || answer === void 0 ? void 0 : answer.text) !== null && _a !== void 0 ? _a : '').trim() || latest;
166
+ if (text) {
167
+ onText(text, true);
168
+ }
169
+ end();
170
+ }, () => end('network'));
171
+ };
172
+ const capture = new mic_capture_1.MicCapture(stream, error => finish(error));
173
+ await context.resume().catch(() => undefined);
174
+ capture.hear(context, samples => heard.add(samples, context.sampleRate));
175
+ const timer = setInterval(() => {
176
+ if (finished) {
177
+ return;
178
+ }
179
+ if (!this.host.online()) {
180
+ return finish('network');
181
+ }
182
+ if (heard.over()) {
183
+ return finish();
184
+ }
185
+ const now = Date.now();
186
+ const ask = heard.spoke && !decoding && now - decodedAt >= TaHearing.INTERIM_MS && heard.ms <= TaHearing.INTERIM_MAX_MS;
187
+ if (!ask) {
188
+ send().catch(() => finish('network'));
189
+ return;
190
+ }
191
+ decoding = true;
192
+ decodedAt = now;
193
+ send('interim').then(answer => {
194
+ var _a;
195
+ decoding = false;
196
+ const text = String((_a = answer === null || answer === void 0 ? void 0 : answer.text) !== null && _a !== void 0 ? _a : '').trim();
197
+ if (text && !finished) {
198
+ latest = text;
199
+ onText(text, false);
200
+ }
201
+ }, () => finish('network'));
202
+ }, TaHearing.PIECE_MS);
203
+ return { stop: () => finish() };
204
+ }
205
+ }
206
+ exports.TaHearing = TaHearing;
207
+ /** Each piece sent, ms. */
208
+ TaHearing.PIECE_MS = 250;
209
+ /** What was said so far is asked at most this often, ms. */
210
+ TaHearing.INTERIM_MS = 1000;
211
+ /** Not past this much sound, ms: longer, only the end is written down. */
212
+ TaHearing.INTERIM_MAX_MS = 60000;
213
+ /** A silence this long after speech ends what is said to it (not what a finger holds), ms. */
214
+ TaHearing.SILENCE_MS = 1200;
215
+ /** No speech this long ends it, ms. */
216
+ TaHearing.NO_SPEECH_MS = 8000;
217
+ /** The longest one utterance, and one held, ms. */
218
+ TaHearing.MAX_MS = 60000;
219
+ TaHearing.MAX_HELD_MS = 300000;
220
+ /** The level (RMS) of speech, at least; in noise, louder than it. */
221
+ TaHearing.LEVEL = 0.015;
222
+ TaHearing.RATE = 16000;
223
+ /**
224
+ * The sound of a listening as it comes: PCM16 at 16 kHz not sent yet, how long it is, and whether it was speech, by its
225
+ * level above the noise there is; a silence after speech, no speech at all or too long a one ends what is said to it.
226
+ */
227
+ class HeardSound {
228
+ constructor(held) {
229
+ this.held = held;
230
+ this.pieces = [];
231
+ this.samples = 0;
232
+ this.noise = 0;
233
+ this.spokeAt = 0;
234
+ this.spoke = false;
235
+ }
236
+ /** How long it is, ms. */
237
+ get ms() {
238
+ return (this.samples / TaHearing.RATE) * 1000;
239
+ }
240
+ add(samples, rate) {
241
+ const pcm = pcm_util_1.PcmUtil.toPcm16(samples, rate, TaHearing.RATE);
242
+ this.pieces.push(pcm);
243
+ this.samples += pcm.length / 2;
244
+ const level = pcm_util_1.PcmUtil.rms(samples);
245
+ if (level >= Math.max(TaHearing.LEVEL, this.noise * 2.5)) {
246
+ this.spoke = true;
247
+ this.spokeAt = this.ms;
248
+ }
249
+ else {
250
+ this.noise = this.noise ? this.noise * 0.95 + level * 0.05 : level;
251
+ }
252
+ }
253
+ /** What came since it was last taken. */
254
+ take() {
255
+ const bytes = this.pieces.reduce((sum, piece) => sum + piece.length, 0);
256
+ const out = new Uint8Array(bytes);
257
+ let at = 0;
258
+ for (const piece of this.pieces) {
259
+ out.set(piece, at);
260
+ at += piece.length;
261
+ }
262
+ this.pieces = [];
263
+ return out;
264
+ }
265
+ /** It is over: too long, or, said to it rather than held, a silence after speech or no speech at all. */
266
+ over() {
267
+ if (this.held) {
268
+ return this.ms >= TaHearing.MAX_HELD_MS;
269
+ }
270
+ if (this.ms >= TaHearing.MAX_MS) {
271
+ return true;
272
+ }
273
+ return this.spoke ? this.ms - this.spokeAt >= TaHearing.SILENCE_MS : this.ms >= TaHearing.NO_SPEECH_MS;
274
+ }
275
+ }
276
+ exports.HeardSound = HeardSound;
277
+ //# sourceMappingURL=ta-hearing.js.map