@celljs/ta-web 4.17.0 → 4.19.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 (599) hide show
  1. package/README.en.md +2 -1
  2. package/README.md +2 -1
  3. package/esm/browser/account/account-side.d.ts +13 -0
  4. package/esm/browser/account/account-side.js +74 -0
  5. package/esm/browser/account/device-account.d.ts +69 -0
  6. package/esm/browser/account/device-account.js +215 -0
  7. package/esm/browser/assistant/assistant-chat-list.d.ts +4 -4
  8. package/esm/browser/assistant/assistant-chat-list.js +74 -4
  9. package/esm/browser/assistant/assistant-export.js +6 -2
  10. package/esm/browser/assistant/assistant-extension.js +70 -15
  11. package/esm/browser/assistant/assistant-role.d.ts +2 -2
  12. package/esm/browser/assistant/assistant-role.js +7 -4
  13. package/esm/browser/assistant/assistant-task-source.d.ts +4 -0
  14. package/esm/browser/assistant/assistant-task-source.js +18 -4
  15. package/esm/browser/assistant/assistant-task-util.d.ts +8 -0
  16. package/esm/browser/assistant/assistant-task-util.js +14 -3
  17. package/esm/browser/assistant/assistant-tasks.js +2 -2
  18. package/esm/browser/assistant/assistant-thread.js +5 -1
  19. package/esm/browser/assistant/assistant-view.js +3 -5
  20. package/esm/browser/assistant/assistant.js +2 -1
  21. package/esm/browser/assistant/call-keeper.d.ts +142 -0
  22. package/esm/browser/assistant/call-keeper.js +292 -0
  23. package/esm/browser/assistant/call-screen.d.ts +39 -0
  24. package/esm/browser/assistant/call-screen.js +75 -0
  25. package/esm/browser/assistant/chat-task-source.d.ts +16 -18
  26. package/esm/browser/assistant/chat-task-source.js +27 -52
  27. package/esm/browser/assistant/realtime-voice.d.ts +62 -1
  28. package/esm/browser/assistant/realtime-voice.js +188 -29
  29. package/esm/browser/assistant/task-views.d.ts +9 -6
  30. package/esm/browser/assistant/task-views.js +28 -10
  31. package/esm/browser/assistant/voice-call-bar.d.ts +11 -4
  32. package/esm/browser/assistant/voice-call-bar.js +102 -46
  33. package/esm/browser/assistant/voice-call.d.ts +33 -1
  34. package/esm/browser/assistant/voice-call.js +131 -28
  35. package/esm/browser/assistant/voice-reopen.d.ts +18 -0
  36. package/esm/browser/assistant/voice-reopen.js +54 -0
  37. package/esm/browser/chat/chat-view.js +5 -8
  38. package/esm/browser/cloud/cloud-sign-in.d.ts +100 -0
  39. package/esm/browser/cloud/cloud-sign-in.js +239 -0
  40. package/esm/browser/cloud/device-page.d.ts +15 -0
  41. package/esm/browser/cloud/device-page.js +39 -0
  42. package/esm/browser/components/access-view.js +25 -1
  43. package/esm/browser/components/account-menu.d.ts +1 -1
  44. package/esm/browser/components/account-menu.js +7 -2
  45. package/esm/browser/components/account-view.d.ts +17 -0
  46. package/esm/browser/components/account-view.js +216 -0
  47. package/esm/browser/components/app-contexts.d.ts +12 -0
  48. package/esm/browser/components/app-contexts.js +28 -0
  49. package/esm/browser/components/app-nav.d.ts +5 -3
  50. package/esm/browser/components/app-nav.js +11 -8
  51. package/esm/browser/components/app-shell-state.d.ts +2 -2
  52. package/esm/browser/components/app-shell-state.js +33 -28
  53. package/esm/browser/components/app-view.js +113 -82
  54. package/esm/browser/components/auth-view.js +3 -5
  55. package/esm/browser/components/call-pill.d.ts +11 -0
  56. package/esm/browser/components/call-pill.js +19 -0
  57. package/esm/browser/components/chat-home-util.d.ts +112 -0
  58. package/esm/browser/components/chat-home-util.js +123 -0
  59. package/esm/browser/components/chat-home.d.ts +54 -0
  60. package/esm/browser/components/chat-home.js +125 -0
  61. package/esm/browser/components/chat-icon.d.ts +4 -2
  62. package/esm/browser/components/chat-icon.js +15 -5
  63. package/esm/browser/components/chat-list-hooks.d.ts +30 -0
  64. package/esm/browser/components/chat-list-hooks.js +81 -0
  65. package/esm/browser/components/chat-list-props.d.ts +54 -0
  66. package/esm/browser/components/chat-list-props.js +2 -0
  67. package/esm/browser/components/chat-list-row.d.ts +14 -2
  68. package/esm/browser/components/chat-list-row.js +27 -17
  69. package/esm/browser/components/chat-list-util.d.ts +40 -9
  70. package/esm/browser/components/chat-list-util.js +72 -9
  71. package/esm/browser/components/chat-list.d.ts +4 -49
  72. package/esm/browser/components/chat-list.js +118 -87
  73. package/esm/browser/components/cloud-sign-in-view.d.ts +65 -0
  74. package/esm/browser/components/cloud-sign-in-view.js +351 -0
  75. package/esm/browser/components/code-editor.js +2 -1
  76. package/esm/browser/components/composer-box.js +7 -0
  77. package/esm/browser/components/connection-bar.js +22 -3
  78. package/esm/browser/components/context-menu.d.ts +11 -2
  79. package/esm/browser/components/context-menu.js +14 -3
  80. package/esm/browser/components/conversation-scroll.d.ts +2 -0
  81. package/esm/browser/components/conversation-scroll.js +14 -0
  82. package/esm/browser/components/device-sign-in-page.d.ts +12 -0
  83. package/esm/browser/components/device-sign-in-page.js +74 -0
  84. package/esm/browser/components/diff-editor.js +2 -1
  85. package/esm/browser/components/entry-holds.d.ts +22 -0
  86. package/esm/browser/components/entry-holds.js +49 -0
  87. package/esm/browser/components/environment-view.js +8 -8
  88. package/esm/browser/components/face.d.ts +1 -1
  89. package/esm/browser/components/fold-text.js +3 -1
  90. package/esm/browser/components/fork-view.js +2 -4
  91. package/esm/browser/components/gallery.js +2 -1
  92. package/esm/browser/components/held-talk.d.ts +6 -2
  93. package/esm/browser/components/held-talk.js +20 -2
  94. package/esm/browser/components/host-view.d.ts +11 -4
  95. package/esm/browser/components/host-view.js +60 -14
  96. package/esm/browser/components/image-swipe.d.ts +50 -0
  97. package/esm/browser/components/image-swipe.js +139 -0
  98. package/esm/browser/components/image-viewer.d.ts +10 -114
  99. package/esm/browser/components/image-viewer.js +46 -365
  100. package/esm/browser/components/image-zoom.d.ts +112 -0
  101. package/esm/browser/components/image-zoom.js +355 -0
  102. package/esm/browser/components/kept-call-bar.d.ts +12 -0
  103. package/esm/browser/components/kept-call-bar.js +99 -0
  104. package/esm/browser/components/lightbox.d.ts +6 -2
  105. package/esm/browser/components/lightbox.js +4 -3
  106. package/esm/browser/components/link-dialog.d.ts +2 -1
  107. package/esm/browser/components/link-dialog.js +5 -1
  108. package/esm/browser/components/link.d.ts +4 -0
  109. package/esm/browser/components/link.js +11 -0
  110. package/esm/browser/components/loading.d.ts +12 -0
  111. package/esm/browser/components/loading.js +18 -0
  112. package/esm/browser/components/markdown.js +2 -1
  113. package/esm/browser/components/mermaid-view.js +14 -7
  114. package/esm/browser/components/message-images.js +1 -1
  115. package/esm/browser/components/message-list.js +12 -7
  116. package/esm/browser/components/message-steps.js +31 -23
  117. package/esm/browser/components/message-user.d.ts +10 -1
  118. package/esm/browser/components/message-user.js +48 -13
  119. package/esm/browser/components/model-picker.d.ts +3 -1
  120. package/esm/browser/components/model-picker.js +14 -3
  121. package/esm/browser/components/nav-places.d.ts +7 -12
  122. package/esm/browser/components/nav-places.js +10 -13
  123. package/esm/browser/components/phone-shell.d.ts +1 -1
  124. package/esm/browser/components/scan-screen.d.ts +4 -2
  125. package/esm/browser/components/scan-screen.js +46 -20
  126. package/esm/browser/components/search-page.js +3 -2
  127. package/esm/browser/components/secret-peek.d.ts +3 -0
  128. package/esm/browser/components/secret-peek.js +19 -0
  129. package/esm/browser/components/secret-text.d.ts +41 -0
  130. package/esm/browser/components/secret-text.js +80 -0
  131. package/esm/browser/components/session-view.js +44 -13
  132. package/esm/browser/components/settings-choices.d.ts +3 -3
  133. package/esm/browser/components/settings-choices.js +9 -29
  134. package/esm/browser/components/settings-parts.js +5 -2
  135. package/esm/browser/components/settings-view.js +2 -2
  136. package/esm/browser/components/share-dialog.d.ts +2 -3
  137. package/esm/browser/components/share-dialog.js +6 -41
  138. package/esm/browser/components/share-friends.d.ts +18 -0
  139. package/esm/browser/components/share-friends.js +56 -0
  140. package/esm/browser/components/share-sheet.d.ts +15 -0
  141. package/esm/browser/components/share-sheet.js +79 -0
  142. package/esm/browser/components/side-lists.d.ts +16 -4
  143. package/esm/browser/components/side-lists.js +28 -12
  144. package/esm/browser/components/sign-in-accounts.d.ts +2 -1
  145. package/esm/browser/components/sign-in-accounts.js +59 -5
  146. package/esm/browser/components/sign-in-label.d.ts +5 -0
  147. package/esm/browser/components/sign-in-label.js +10 -0
  148. package/esm/browser/components/system-link-host.d.ts +2 -0
  149. package/esm/browser/components/system-link-host.js +17 -0
  150. package/esm/browser/components/tool-result.d.ts +3 -2
  151. package/esm/browser/components/tool-result.js +5 -3
  152. package/esm/browser/components/tool-view.d.ts +21 -3
  153. package/esm/browser/components/tool-view.js +103 -35
  154. package/esm/browser/components/unseen-drop.d.ts +2 -1
  155. package/esm/browser/components/unseen-drop.js +1 -1
  156. package/esm/browser/components/voice-services.js +26 -3
  157. package/esm/browser/components/workbench-view.d.ts +1 -1
  158. package/esm/browser/components/workbench-view.js +42 -5
  159. package/esm/browser/device/code-scan.d.ts +23 -10
  160. package/esm/browser/device/code-scan.js +48 -43
  161. package/esm/browser/device/edge-back.d.ts +17 -0
  162. package/esm/browser/device/edge-back.js +52 -0
  163. package/esm/browser/device/launch-screen.d.ts +1 -1
  164. package/esm/browser/device/launch-screen.js +2 -2
  165. package/esm/browser/device/screen-awake.d.ts +24 -0
  166. package/esm/browser/device/screen-awake.js +59 -0
  167. package/esm/browser/extension/icons.js +13 -2
  168. package/esm/browser/extension/share-sheet-compat.d.ts +11 -0
  169. package/esm/browser/extension/share-sheet-compat.js +27 -0
  170. package/esm/browser/extension/web-api-chats.d.ts +49 -0
  171. package/esm/browser/extension/web-api-chats.js +2 -0
  172. package/esm/browser/extension/web-api-components.d.ts +61 -6
  173. package/esm/browser/extension/web-api-contributions.d.ts +28 -53
  174. package/esm/browser/extension/web-api-screen-share.d.ts +10 -0
  175. package/esm/browser/extension/web-api-screen-share.js +3 -0
  176. package/esm/browser/extension/web-api-services.d.ts +50 -0
  177. package/esm/browser/extension/web-api-services.js +2 -0
  178. package/esm/browser/extension/web-extension-api.d.ts +45 -65
  179. package/esm/browser/extension/web-extension-context.d.ts +5 -10
  180. package/esm/browser/extension/web-extension-context.js +33 -21
  181. package/esm/browser/extension/web-extension-protocol.d.ts +8 -3
  182. package/esm/browser/extension/web-extension-run.js +0 -1
  183. package/esm/browser/extension/web-extensions.d.ts +4 -1
  184. package/esm/browser/extension/web-extensions.js +12 -0
  185. package/esm/browser/extension/web-tasks.d.ts +6 -1
  186. package/esm/browser/extension/web-tasks.js +11 -3
  187. package/esm/browser/extension/web-view-util.d.ts +0 -1
  188. package/esm/browser/extension/web-view-util.js +4 -5
  189. package/esm/browser/files/files.d.ts +1 -0
  190. package/esm/browser/files/files.js +14 -3
  191. package/esm/browser/game/game-control.d.ts +118 -0
  192. package/esm/browser/game/game-control.js +341 -0
  193. package/esm/browser/game/game-host.d.ts +14 -2
  194. package/esm/browser/game/game-host.js +22 -5
  195. package/esm/browser/game/game-protocol.d.ts +15 -0
  196. package/esm/browser/game/game-runner.d.ts +3 -1
  197. package/esm/browser/game/game-runner.js +6 -0
  198. package/esm/browser/game/game-util.d.ts +3 -0
  199. package/esm/browser/game/game-util.js +3 -0
  200. package/esm/browser/game/game-view.d.ts +5 -2
  201. package/esm/browser/game/game-view.js +4 -4
  202. package/esm/browser/game/game3d-protocol.d.ts +5 -1
  203. package/esm/browser/game/game3d-runner.d.ts +3 -1
  204. package/esm/browser/game/game3d-runner.js +14 -0
  205. package/esm/browser/gateway/console-agents.d.ts +11 -0
  206. package/esm/browser/gateway/console-agents.js +128 -0
  207. package/esm/browser/gateway/console-extension.js +0 -1
  208. package/esm/browser/gateway/console-limits.d.ts +19 -0
  209. package/esm/browser/gateway/console-limits.js +164 -0
  210. package/esm/browser/gateway/console-parts.d.ts +29 -22
  211. package/esm/browser/gateway/console-parts.js +67 -137
  212. package/esm/browser/gateway/console-tenant.d.ts +2 -4
  213. package/esm/browser/gateway/console-tenant.js +117 -209
  214. package/esm/browser/gateway/console-trend.js +6 -4
  215. package/esm/browser/gateway/console-view.js +136 -109
  216. package/esm/browser/hooks.js +1 -3
  217. package/esm/browser/hosts.d.ts +7 -0
  218. package/esm/browser/hosts.js +23 -2
  219. package/esm/browser/i18n/locales.d.ts +169 -14
  220. package/esm/browser/i18n/messages-ja.js +178 -23
  221. package/esm/browser/i18n/messages-zh-tw.js +178 -23
  222. package/esm/browser/i18n/messages.d.ts +166 -11
  223. package/esm/browser/i18n/messages.js +357 -47
  224. package/esm/browser/index.d.ts +1 -0
  225. package/esm/browser/index.js +1 -0
  226. package/esm/browser/links/links-protocol.d.ts +10 -1
  227. package/esm/browser/links/links.d.ts +11 -2
  228. package/esm/browser/links/links.js +65 -7
  229. package/esm/browser/links/system-links.d.ts +21 -0
  230. package/esm/browser/links/system-links.js +54 -0
  231. package/esm/browser/markdown/hooks.d.ts +3 -1
  232. package/esm/browser/markdown/hooks.js +11 -3
  233. package/esm/browser/markdown/mermaid.d.ts +18 -4
  234. package/esm/browser/markdown/mermaid.js +117 -17
  235. package/esm/browser/screen/screen-protocol.d.ts +74 -1
  236. package/esm/browser/screen/screen-protocol.js +15 -0
  237. package/esm/browser/screen/screen-scroll.d.ts +55 -0
  238. package/esm/browser/screen/screen-scroll.js +182 -0
  239. package/esm/browser/screen/screen.d.ts +34 -1
  240. package/esm/browser/screen/screen.js +172 -2
  241. package/esm/browser/settings/navigation.d.ts +9 -21
  242. package/esm/browser/settings/navigation.js +11 -31
  243. package/esm/browser/settings/settings-protocol.d.ts +9 -0
  244. package/esm/browser/settings/settings-protocol.js +18 -0
  245. package/esm/browser/settings/settings.d.ts +7 -1
  246. package/esm/browser/settings/settings.js +31 -7
  247. package/esm/browser/share/shared-extensions.js +4 -3
  248. package/esm/browser/share/shared-page.js +2 -2
  249. package/esm/browser/style/base.d.ts +1 -1
  250. package/esm/browser/style/base.js +8 -1
  251. package/esm/browser/style/chat-list.d.ts +1 -1
  252. package/esm/browser/style/chat-list.js +0 -3
  253. package/esm/browser/style/conversation.d.ts +1 -1
  254. package/esm/browser/style/conversation.js +42 -4
  255. package/esm/browser/style/dialogs.d.ts +1 -1
  256. package/esm/browser/style/dialogs.js +31 -1
  257. package/esm/browser/style/layout.d.ts +1 -1
  258. package/esm/browser/style/layout.js +7 -15
  259. package/esm/browser/style/pages.d.ts +1 -1
  260. package/esm/browser/style/pages.js +168 -112
  261. package/esm/browser/style/phone.d.ts +1 -1
  262. package/esm/browser/style/phone.js +10 -3
  263. package/esm/browser/style/shared.d.ts +1 -1
  264. package/esm/browser/style/shared.js +1 -0
  265. package/esm/browser/style/shell.d.ts +1 -1
  266. package/esm/browser/style/shell.js +12 -0
  267. package/esm/browser/style/surfaces.d.ts +1 -1
  268. package/esm/browser/style/surfaces.js +38 -13
  269. package/esm/browser/style/tasks.d.ts +1 -1
  270. package/esm/browser/style/tasks.js +16 -2
  271. package/esm/browser/style/tints.d.ts +5 -4
  272. package/esm/browser/style/tints.js +9 -9
  273. package/esm/browser/util/desktop.d.ts +7 -1
  274. package/esm/browser/util/desktop.js +17 -0
  275. package/esm/browser/util/image-swipe.d.ts +42 -0
  276. package/esm/browser/util/image-swipe.js +66 -0
  277. package/esm/browser/util/process.d.ts +31 -3
  278. package/esm/browser/util/process.js +75 -8
  279. package/esm/browser/util/share-link.d.ts +5 -0
  280. package/esm/browser/util/share-link.js +10 -0
  281. package/esm/browser/util/shell-words.d.ts +18 -0
  282. package/esm/browser/util/shell-words.js +397 -0
  283. package/esm/browser/util/spoken.d.ts +5 -0
  284. package/esm/browser/util/spoken.js +11 -2
  285. package/esm/browser/util/tool.d.ts +9 -0
  286. package/esm/browser/util/tool.js +71 -6
  287. package/esm/browser/util/transcript.js +3 -1
  288. package/esm/browser/util/turn-end.d.ts +17 -0
  289. package/esm/browser/util/turn-end.js +164 -0
  290. package/esm/browser/workbench-hosts.d.ts +8 -1
  291. package/esm/browser/workbench-hosts.js +22 -2
  292. package/esm/browser/workbench-protocol.d.ts +25 -3
  293. package/esm/browser/workbench-services.d.ts +10 -1
  294. package/esm/browser/workbench-services.js +41 -0
  295. package/esm/browser/workbench-util.d.ts +9 -3
  296. package/esm/browser/workbench-util.js +24 -4
  297. package/esm/browser/workbench.d.ts +3 -0
  298. package/esm/browser/workbench.js +36 -9
  299. package/lib/browser/account/account-side.d.ts +14 -0
  300. package/lib/browser/account/account-side.js +111 -0
  301. package/lib/browser/account/device-account.d.ts +70 -0
  302. package/lib/browser/account/device-account.js +219 -0
  303. package/lib/browser/assistant/assistant-chat-list.d.ts +4 -4
  304. package/lib/browser/assistant/assistant-chat-list.js +73 -3
  305. package/lib/browser/assistant/assistant-export.js +5 -1
  306. package/lib/browser/assistant/assistant-extension.js +69 -14
  307. package/lib/browser/assistant/assistant-role.d.ts +2 -2
  308. package/lib/browser/assistant/assistant-role.js +7 -4
  309. package/lib/browser/assistant/assistant-task-source.d.ts +4 -0
  310. package/lib/browser/assistant/assistant-task-source.js +19 -4
  311. package/lib/browser/assistant/assistant-task-util.d.ts +8 -0
  312. package/lib/browser/assistant/assistant-task-util.js +14 -3
  313. package/lib/browser/assistant/assistant-tasks.js +2 -2
  314. package/lib/browser/assistant/assistant-thread.js +4 -0
  315. package/lib/browser/assistant/assistant-view.js +3 -5
  316. package/lib/browser/assistant/assistant.js +2 -1
  317. package/lib/browser/assistant/call-keeper.d.ts +143 -0
  318. package/lib/browser/assistant/call-keeper.js +295 -0
  319. package/lib/browser/assistant/call-screen.d.ts +40 -0
  320. package/lib/browser/assistant/call-screen.js +78 -0
  321. package/lib/browser/assistant/chat-task-source.d.ts +16 -18
  322. package/lib/browser/assistant/chat-task-source.js +28 -53
  323. package/lib/browser/assistant/realtime-voice.d.ts +62 -1
  324. package/lib/browser/assistant/realtime-voice.js +188 -29
  325. package/lib/browser/assistant/task-views.d.ts +9 -6
  326. package/lib/browser/assistant/task-views.js +29 -10
  327. package/lib/browser/assistant/voice-call-bar.d.ts +11 -4
  328. package/lib/browser/assistant/voice-call-bar.js +102 -46
  329. package/lib/browser/assistant/voice-call.d.ts +33 -1
  330. package/lib/browser/assistant/voice-call.js +132 -29
  331. package/lib/browser/assistant/voice-reopen.d.ts +19 -0
  332. package/lib/browser/assistant/voice-reopen.js +58 -0
  333. package/lib/browser/chat/chat-view.js +5 -8
  334. package/lib/browser/cloud/cloud-sign-in.d.ts +101 -0
  335. package/lib/browser/cloud/cloud-sign-in.js +244 -0
  336. package/lib/browser/cloud/device-page.d.ts +16 -0
  337. package/lib/browser/cloud/device-page.js +42 -0
  338. package/lib/browser/components/access-view.js +24 -0
  339. package/lib/browser/components/account-menu.d.ts +1 -1
  340. package/lib/browser/components/account-menu.js +6 -1
  341. package/lib/browser/components/account-view.d.ts +18 -0
  342. package/lib/browser/components/account-view.js +255 -0
  343. package/lib/browser/components/app-contexts.d.ts +13 -0
  344. package/lib/browser/components/app-contexts.js +64 -0
  345. package/lib/browser/components/app-nav.d.ts +5 -3
  346. package/lib/browser/components/app-nav.js +11 -8
  347. package/lib/browser/components/app-shell-state.d.ts +2 -2
  348. package/lib/browser/components/app-shell-state.js +33 -28
  349. package/lib/browser/components/app-view.js +109 -78
  350. package/lib/browser/components/auth-view.js +3 -5
  351. package/lib/browser/components/call-pill.d.ts +12 -0
  352. package/lib/browser/components/call-pill.js +55 -0
  353. package/lib/browser/components/chat-home-util.d.ts +113 -0
  354. package/lib/browser/components/chat-home-util.js +126 -0
  355. package/lib/browser/components/chat-home.d.ts +55 -0
  356. package/lib/browser/components/chat-home.js +164 -0
  357. package/lib/browser/components/chat-icon.d.ts +4 -2
  358. package/lib/browser/components/chat-icon.js +15 -5
  359. package/lib/browser/components/chat-list-hooks.d.ts +31 -0
  360. package/lib/browser/components/chat-list-hooks.js +120 -0
  361. package/lib/browser/components/chat-list-props.d.ts +55 -0
  362. package/lib/browser/components/chat-list-props.js +3 -0
  363. package/lib/browser/components/chat-list-row.d.ts +14 -2
  364. package/lib/browser/components/chat-list-row.js +27 -16
  365. package/lib/browser/components/chat-list-util.d.ts +40 -9
  366. package/lib/browser/components/chat-list-util.js +73 -10
  367. package/lib/browser/components/chat-list.d.ts +4 -49
  368. package/lib/browser/components/chat-list.js +121 -90
  369. package/lib/browser/components/cloud-sign-in-view.d.ts +66 -0
  370. package/lib/browser/components/cloud-sign-in-view.js +394 -0
  371. package/lib/browser/components/code-editor.js +2 -1
  372. package/lib/browser/components/composer-box.js +7 -0
  373. package/lib/browser/components/connection-bar.js +22 -3
  374. package/lib/browser/components/context-menu.d.ts +11 -2
  375. package/lib/browser/components/context-menu.js +14 -3
  376. package/lib/browser/components/conversation-scroll.d.ts +2 -0
  377. package/lib/browser/components/conversation-scroll.js +14 -0
  378. package/lib/browser/components/device-sign-in-page.d.ts +13 -0
  379. package/lib/browser/components/device-sign-in-page.js +110 -0
  380. package/lib/browser/components/diff-editor.js +2 -1
  381. package/lib/browser/components/entry-holds.d.ts +23 -0
  382. package/lib/browser/components/entry-holds.js +86 -0
  383. package/lib/browser/components/environment-view.js +8 -8
  384. package/lib/browser/components/face.d.ts +1 -1
  385. package/lib/browser/components/fold-text.js +3 -1
  386. package/lib/browser/components/fork-view.js +2 -4
  387. package/lib/browser/components/gallery.js +2 -1
  388. package/lib/browser/components/held-talk.d.ts +6 -2
  389. package/lib/browser/components/held-talk.js +20 -2
  390. package/lib/browser/components/host-view.d.ts +11 -4
  391. package/lib/browser/components/host-view.js +60 -13
  392. package/lib/browser/components/image-swipe.d.ts +51 -0
  393. package/lib/browser/components/image-swipe.js +143 -0
  394. package/lib/browser/components/image-viewer.d.ts +10 -114
  395. package/lib/browser/components/image-viewer.js +47 -368
  396. package/lib/browser/components/image-zoom.d.ts +113 -0
  397. package/lib/browser/components/image-zoom.js +359 -0
  398. package/lib/browser/components/kept-call-bar.d.ts +13 -0
  399. package/lib/browser/components/kept-call-bar.js +135 -0
  400. package/lib/browser/components/lightbox.d.ts +6 -2
  401. package/lib/browser/components/lightbox.js +4 -3
  402. package/lib/browser/components/link-dialog.d.ts +2 -1
  403. package/lib/browser/components/link-dialog.js +5 -1
  404. package/lib/browser/components/link.d.ts +4 -0
  405. package/lib/browser/components/link.js +12 -0
  406. package/lib/browser/components/loading.d.ts +13 -0
  407. package/lib/browser/components/loading.js +55 -0
  408. package/lib/browser/components/markdown.js +2 -1
  409. package/lib/browser/components/mermaid-view.js +13 -6
  410. package/lib/browser/components/message-images.js +1 -1
  411. package/lib/browser/components/message-list.js +12 -7
  412. package/lib/browser/components/message-steps.js +31 -23
  413. package/lib/browser/components/message-user.d.ts +10 -1
  414. package/lib/browser/components/message-user.js +48 -12
  415. package/lib/browser/components/model-picker.d.ts +3 -1
  416. package/lib/browser/components/model-picker.js +14 -3
  417. package/lib/browser/components/nav-places.d.ts +7 -12
  418. package/lib/browser/components/nav-places.js +10 -13
  419. package/lib/browser/components/phone-shell.d.ts +1 -1
  420. package/lib/browser/components/scan-screen.d.ts +4 -2
  421. package/lib/browser/components/scan-screen.js +47 -20
  422. package/lib/browser/components/search-page.js +3 -2
  423. package/lib/browser/components/secret-peek.d.ts +4 -0
  424. package/lib/browser/components/secret-peek.js +55 -0
  425. package/lib/browser/components/secret-text.d.ts +42 -0
  426. package/lib/browser/components/secret-text.js +118 -0
  427. package/lib/browser/components/session-view.js +43 -12
  428. package/lib/browser/components/settings-choices.d.ts +3 -3
  429. package/lib/browser/components/settings-choices.js +8 -28
  430. package/lib/browser/components/settings-parts.js +4 -1
  431. package/lib/browser/components/settings-view.js +2 -2
  432. package/lib/browser/components/share-dialog.d.ts +2 -3
  433. package/lib/browser/components/share-dialog.js +5 -40
  434. package/lib/browser/components/share-friends.d.ts +19 -0
  435. package/lib/browser/components/share-friends.js +93 -0
  436. package/lib/browser/components/share-sheet.d.ts +16 -0
  437. package/lib/browser/components/share-sheet.js +115 -0
  438. package/lib/browser/components/side-lists.d.ts +16 -4
  439. package/lib/browser/components/side-lists.js +28 -12
  440. package/lib/browser/components/sign-in-accounts.d.ts +2 -1
  441. package/lib/browser/components/sign-in-accounts.js +59 -5
  442. package/lib/browser/components/sign-in-label.d.ts +6 -0
  443. package/lib/browser/components/sign-in-label.js +13 -0
  444. package/lib/browser/components/system-link-host.d.ts +3 -0
  445. package/lib/browser/components/system-link-host.js +53 -0
  446. package/lib/browser/components/tool-result.d.ts +3 -2
  447. package/lib/browser/components/tool-result.js +5 -3
  448. package/lib/browser/components/tool-view.d.ts +21 -3
  449. package/lib/browser/components/tool-view.js +104 -36
  450. package/lib/browser/components/unseen-drop.d.ts +2 -1
  451. package/lib/browser/components/unseen-drop.js +1 -1
  452. package/lib/browser/components/voice-services.js +23 -0
  453. package/lib/browser/components/workbench-view.d.ts +1 -1
  454. package/lib/browser/components/workbench-view.js +42 -5
  455. package/lib/browser/device/code-scan.d.ts +23 -10
  456. package/lib/browser/device/code-scan.js +47 -42
  457. package/lib/browser/device/edge-back.d.ts +18 -0
  458. package/lib/browser/device/edge-back.js +89 -0
  459. package/lib/browser/device/launch-screen.d.ts +1 -1
  460. package/lib/browser/device/launch-screen.js +2 -2
  461. package/lib/browser/device/screen-awake.d.ts +25 -0
  462. package/lib/browser/device/screen-awake.js +63 -0
  463. package/lib/browser/extension/icons.js +12 -1
  464. package/lib/browser/extension/share-sheet-compat.d.ts +12 -0
  465. package/lib/browser/extension/share-sheet-compat.js +30 -0
  466. package/lib/browser/extension/web-api-chats.d.ts +50 -0
  467. package/lib/browser/extension/web-api-chats.js +3 -0
  468. package/lib/browser/extension/web-api-components.d.ts +61 -6
  469. package/lib/browser/extension/web-api-contributions.d.ts +28 -53
  470. package/lib/browser/extension/web-api-screen-share.d.ts +11 -0
  471. package/lib/browser/extension/web-api-screen-share.js +6 -0
  472. package/lib/browser/extension/web-api-services.d.ts +51 -0
  473. package/lib/browser/extension/web-api-services.js +3 -0
  474. package/lib/browser/extension/web-extension-api.d.ts +45 -65
  475. package/lib/browser/extension/web-extension-context.d.ts +5 -10
  476. package/lib/browser/extension/web-extension-context.js +33 -21
  477. package/lib/browser/extension/web-extension-protocol.d.ts +8 -3
  478. package/lib/browser/extension/web-extension-run.js +0 -1
  479. package/lib/browser/extension/web-extensions.d.ts +4 -1
  480. package/lib/browser/extension/web-extensions.js +12 -0
  481. package/lib/browser/extension/web-tasks.d.ts +6 -1
  482. package/lib/browser/extension/web-tasks.js +11 -3
  483. package/lib/browser/extension/web-view-util.d.ts +0 -1
  484. package/lib/browser/extension/web-view-util.js +4 -5
  485. package/lib/browser/files/files.d.ts +1 -0
  486. package/lib/browser/files/files.js +14 -3
  487. package/lib/browser/game/game-control.d.ts +119 -0
  488. package/lib/browser/game/game-control.js +345 -0
  489. package/lib/browser/game/game-host.d.ts +14 -2
  490. package/lib/browser/game/game-host.js +22 -5
  491. package/lib/browser/game/game-protocol.d.ts +15 -0
  492. package/lib/browser/game/game-runner.d.ts +3 -1
  493. package/lib/browser/game/game-runner.js +6 -0
  494. package/lib/browser/game/game-util.d.ts +3 -0
  495. package/lib/browser/game/game-util.js +3 -0
  496. package/lib/browser/game/game-view.d.ts +5 -2
  497. package/lib/browser/game/game-view.js +4 -4
  498. package/lib/browser/game/game3d-protocol.d.ts +5 -1
  499. package/lib/browser/game/game3d-runner.d.ts +3 -1
  500. package/lib/browser/game/game3d-runner.js +14 -0
  501. package/lib/browser/gateway/console-agents.d.ts +12 -0
  502. package/lib/browser/gateway/console-agents.js +165 -0
  503. package/lib/browser/gateway/console-extension.js +0 -1
  504. package/lib/browser/gateway/console-limits.d.ts +20 -0
  505. package/lib/browser/gateway/console-limits.js +200 -0
  506. package/lib/browser/gateway/console-parts.d.ts +29 -22
  507. package/lib/browser/gateway/console-parts.js +72 -141
  508. package/lib/browser/gateway/console-tenant.d.ts +2 -4
  509. package/lib/browser/gateway/console-tenant.js +115 -208
  510. package/lib/browser/gateway/console-trend.js +6 -4
  511. package/lib/browser/gateway/console-view.js +134 -107
  512. package/lib/browser/hooks.js +1 -3
  513. package/lib/browser/hosts.d.ts +7 -0
  514. package/lib/browser/hosts.js +23 -2
  515. package/lib/browser/i18n/locales.d.ts +169 -14
  516. package/lib/browser/i18n/messages-ja.js +178 -23
  517. package/lib/browser/i18n/messages-zh-tw.js +178 -23
  518. package/lib/browser/i18n/messages.d.ts +166 -11
  519. package/lib/browser/i18n/messages.js +357 -47
  520. package/lib/browser/index.d.ts +1 -0
  521. package/lib/browser/index.js +1 -0
  522. package/lib/browser/links/links-protocol.d.ts +10 -1
  523. package/lib/browser/links/links.d.ts +11 -2
  524. package/lib/browser/links/links.js +65 -7
  525. package/lib/browser/links/system-links.d.ts +22 -0
  526. package/lib/browser/links/system-links.js +58 -0
  527. package/lib/browser/markdown/hooks.d.ts +3 -1
  528. package/lib/browser/markdown/hooks.js +12 -3
  529. package/lib/browser/markdown/mermaid.d.ts +18 -4
  530. package/lib/browser/markdown/mermaid.js +117 -17
  531. package/lib/browser/screen/screen-protocol.d.ts +74 -1
  532. package/lib/browser/screen/screen-protocol.js +15 -0
  533. package/lib/browser/screen/screen-scroll.d.ts +56 -0
  534. package/lib/browser/screen/screen-scroll.js +185 -0
  535. package/lib/browser/screen/screen.d.ts +34 -1
  536. package/lib/browser/screen/screen.js +172 -2
  537. package/lib/browser/settings/navigation.d.ts +9 -21
  538. package/lib/browser/settings/navigation.js +11 -31
  539. package/lib/browser/settings/settings-protocol.d.ts +9 -0
  540. package/lib/browser/settings/settings-protocol.js +19 -1
  541. package/lib/browser/settings/settings.d.ts +7 -1
  542. package/lib/browser/settings/settings.js +31 -7
  543. package/lib/browser/share/shared-extensions.js +4 -3
  544. package/lib/browser/share/shared-page.js +2 -2
  545. package/lib/browser/style/base.d.ts +1 -1
  546. package/lib/browser/style/base.js +8 -1
  547. package/lib/browser/style/chat-list.d.ts +1 -1
  548. package/lib/browser/style/chat-list.js +0 -3
  549. package/lib/browser/style/conversation.d.ts +1 -1
  550. package/lib/browser/style/conversation.js +42 -4
  551. package/lib/browser/style/dialogs.d.ts +1 -1
  552. package/lib/browser/style/dialogs.js +31 -1
  553. package/lib/browser/style/layout.d.ts +1 -1
  554. package/lib/browser/style/layout.js +7 -15
  555. package/lib/browser/style/pages.d.ts +1 -1
  556. package/lib/browser/style/pages.js +168 -112
  557. package/lib/browser/style/phone.d.ts +1 -1
  558. package/lib/browser/style/phone.js +10 -3
  559. package/lib/browser/style/shared.d.ts +1 -1
  560. package/lib/browser/style/shared.js +1 -0
  561. package/lib/browser/style/shell.d.ts +1 -1
  562. package/lib/browser/style/shell.js +12 -0
  563. package/lib/browser/style/surfaces.d.ts +1 -1
  564. package/lib/browser/style/surfaces.js +38 -13
  565. package/lib/browser/style/tasks.d.ts +1 -1
  566. package/lib/browser/style/tasks.js +16 -2
  567. package/lib/browser/style/tints.d.ts +5 -4
  568. package/lib/browser/style/tints.js +9 -9
  569. package/lib/browser/util/desktop.d.ts +7 -1
  570. package/lib/browser/util/desktop.js +17 -0
  571. package/lib/browser/util/image-swipe.d.ts +43 -0
  572. package/lib/browser/util/image-swipe.js +69 -0
  573. package/lib/browser/util/process.d.ts +31 -3
  574. package/lib/browser/util/process.js +74 -7
  575. package/lib/browser/util/share-link.d.ts +5 -0
  576. package/lib/browser/util/share-link.js +10 -0
  577. package/lib/browser/util/shell-words.d.ts +19 -0
  578. package/lib/browser/util/shell-words.js +400 -0
  579. package/lib/browser/util/spoken.d.ts +5 -0
  580. package/lib/browser/util/spoken.js +10 -1
  581. package/lib/browser/util/tool.d.ts +9 -0
  582. package/lib/browser/util/tool.js +71 -6
  583. package/lib/browser/util/transcript.js +3 -1
  584. package/lib/browser/util/turn-end.d.ts +18 -0
  585. package/lib/browser/util/turn-end.js +167 -0
  586. package/lib/browser/workbench-hosts.d.ts +8 -1
  587. package/lib/browser/workbench-hosts.js +22 -2
  588. package/lib/browser/workbench-protocol.d.ts +25 -3
  589. package/lib/browser/workbench-services.d.ts +10 -1
  590. package/lib/browser/workbench-services.js +41 -0
  591. package/lib/browser/workbench-util.d.ts +9 -3
  592. package/lib/browser/workbench-util.js +24 -4
  593. package/lib/browser/workbench.d.ts +3 -0
  594. package/lib/browser/workbench.js +35 -8
  595. package/package.json +7 -7
  596. package/esm/browser/components/list-skeleton.d.ts +0 -10
  597. package/esm/browser/components/list-skeleton.js +0 -31
  598. package/lib/browser/components/list-skeleton.d.ts +0 -11
  599. package/lib/browser/components/list-skeleton.js +0 -68
package/README.en.md CHANGED
@@ -23,9 +23,10 @@ Initially, the interface shows only conversations. You tell Ta what you want thi
23
23
  Everything new in the interface comes from **web extensions** within packages, using the same mechanism and terminology as pi extensions:
24
24
 
25
25
  - **Packages** are pi packages. In the `pi` field of `package.json`, `extensions` are extensions for Ta (terminal and server), and `web` are extensions for this page; when not declared, modules in the `web/` directory are used. Packages can be placed in `~/.ta/agent/extensions/<name>/` or the project's `.ta/extensions/` to take effect, or installed with `ta install`.
26
- - **Web extensions** are ES modules without import statements, with a default export of a function that the page calls with `pi`; the returned function is called on unload. The `pi` interface follows pi's ExtensionAPI naming: `ui.setWidget` (default above the input box, same as pi; `placement: 'panel'` puts it in the right workbench's card tabs), `registerView` (pages in the navigation bar, or a list of the sidebar at the top of the navigation bar; `location: 'panel'` is a tool in the right workbench; `discover: true` keeps a page not used every day under Discover until the user pins it), `registerMessageRenderer` (displays custom messages sent by pi extensions with `sendMessage`), `registerCodeRenderer` (draws the fenced blocks of a language in replies and in `ui.Markdown` as a card of the extension's own; the component gets `{ code, language, closed, send, answer }`, `closed` false while the block streams, `send` sending words as the user to the conversation the block is in (the replies on the double's home too, a conversation like any other; none in a page's `ui.Markdown`; older Ta apps pass none, use `sendUserMessage` there), `answer` what the user said after the reply, once they did (a choice the block offers is made, tapped or typed, on every device; older Ta apps pass no such key), and a renderer that throws shows the block as code, as the `ta-glance` cards of `@celljs/ta-glance`), `registerTool` (tools executed by the browser in conversations opened on the page), `registerToolRenderer` (as pi's, a resolver `(toolName, next) => renderer` that chooses how calls of any tool read in conversations: `renderCall(args)` gives a verb, a target and a small icon in the language of the page, in place of the tool's name; `next()` is what the resolvers after it would use), `registerSettings` (a section of the settings, after those of Ta: rows of a label, a description and a control the extension draws, the values kept with `storage`; a row with an empty label is a panel that says what it is itself, found by `search`), `registerTasks` / `ui.useTasks` (work done for the user, listed by the double with its own tasks and those of other extensions; see docs/design/ta-double.md. A task with `remove` and `removeHint` can be swiped away in the lists, or selected with others and deleted at once; `ui.removeTasks` asks the user; a row with `gathered` stands for several things the user does themselves, as the double's row of the conversations going on, and the lists count what `gathered` counts, not the row), `ui.SelectCheck` / `ui.SelectBar` (the round mark at the start of a row and the bar under a list while it selects several, as the lists of the page), `registerOpener` (opens links in replies: files and their lines, directories, web pages, asked in registration order, returns true if opened), `registerComposerAddon` (adds to the message box of every conversation: `actions(conversation)` are entries of the + menu, each a tile of its grid (four by two a page, more a page to swipe to): `setting: true` shows its value (`detail`) under its label, `toggle: true` is a switch (`checked` is on, its icon lit; turning it leaves the menu open), and entries may have `items`, a list in its place; `above` is drawn above the box; `subscribe` says the entries changed. `conversation` says which: `sessionId`, `sessionFile`, `cwd`, `kind` `double` or `chat`, `group`, `title`; the double, agents and plain conversations all have it), `ui.Game3D` (a 3D game on Three.js: `setup(context)` gets a renderer, a scene, a camera and OrbitControls, fills the scene and returns what to do each frame; loaded, asleep and ended as `ui.Game`, its scene and WebGL context given back at the end), `ui.FullScreen` (covers all of the page: the shell, its head and side columns under it, under the notch and the home bar, below the title bar of the desktop app and above the keyboard; its touches are all its own, an edge brings out no panel of Ta; for a game held sideways or a world to walk in, `??` back to its place in an app older than it), `data-own-gestures` (an attribute of an element whose touches are its own: the slides of Ta start there only from an edge of the screen, a held finger opens no menu; games carry it), `ui.Game` (a game on Phaser 4, the game engine of the page, loaded when the first game starts; it fills its parent, sleeps while out of sight and ends when it unmounts, takes the keyboard only while it has the focus, and finds the colors of the theme in its registry; see docs/design/ta-games.md), `ui.QrCode` (a QR code of a text, black on white whatever the theme), `ui.ImageViewer` (a picture to look at closely: all of it at first and never larger than its own pixels, pinched with two fingers or a trackpad, zoomed with Ctrl/⌘ and the wheel or a double click or tap, dragged or scrolled once zoomed, with − / the scale / + / fit to window / actual size below it, and given `onPrevious` / `onNext` the pictures beside it by buttons at its sides and, unless zoomed, ← →; the previews of pictures in the workbench and the large pictures of a conversation are this), `on` (events of the current conversation), `sendUserMessage` (sends to the current conversation; a `/command` runs a command of a pi extension. What an extension sends as the user, by `sendUserMessage`, `server.prompt`, the `send` of a block or `prompt` of its host, says where it came from in the last line of its `<context>`, `[ta:from <package>]` (`TaMessageSource`), and the conversation shows the name and icon of the package above the bubble), `switchSession` (shows another session open in ta serve as the current conversation; given a Promise of the session id it switches at once and shows "Opening", `opening` giving the title meanwhile), `openChat` (opens the conversation of a session file as the lists do: at once from what the page or the device has, opened again in one round trip when it closed; false when no conversation has it), `openLink` (opens a link as a click on a link of a reply does: the openers of extensions first, as of a share or an agent's card, else the browser of the workbench), `callHost` (calls a method of the package's `pi.host`, through `callPackageHost`), `reloadExtensions` (after an extension installed, imported or removed packages itself, reloads the web extensions and the pi extensions of the current conversation as at the end of a reply), `ui.showView` / `ui.useView` (shows and reads any extension's view), `ui.showChats` (shows the list of chats, on a phone its tab; with `busy` only the conversations going on, under a chip Going on that clears it), `ui.Composer` / `ui.Markdown` (the message box and the Markdown of the conversations, the microphone and the hold to talk too; with `commands`, `/` lists the commands a new conversation in `cwd` will have; `voiceSends`, `onTalkSent`, `onListening`, `working` / `onStop` and `after` are those of the double's box: what is heard is sent at once, the page knows what was said by voice to read its answer aloud, that the user talks now, the send button stops what answers, buttons of its own on the right), `ui.HoldToTalk` (a button held to talk, as the bar of the message box: the page dims and listens with its recognizer, 取消 and 编辑 to slide onto, the words given as the finger lets go; nothing where the page cannot listen), `ui.voice` (`canListen` / `canSpeak` / `speak` / `hush`: read aloud in the voice of the settings), the `send` of a view (a page that is a conversation takes a message from another extension as if typed in its box; the double's page has it, its answer comes as its `preview`), `ui.useChatScroll` (scrolls as the conversations: at the bottom it follows new messages, scrolled up it is never pulled back and what is read does not jump, a part opened by a click stays where it was; `sent` is how many messages the user sent, one more of which goes to the bottom), `ui.Empty` (what a list or a view shows while empty: a title and at most one line of hint, centred in its space; `compact` in menus, pickers and dialogs; `picture` puts a picture above), `ui.Picture` / `ui.PictureCards` (small pictures as those of Ta: the shapes of an SVG take the classes `ta-pic-*` and follow the theme; a row of picture cards to click, with a label and a line of description), `ui.Dialog` (a dialog over the page), `preview` of `ui.openEditor` (a preview tab opened by a click, its title in italics, replaced by the next preview, kept by a double click or `ui.pinEditor`), `ui.setEditorDirty` (the tab shows an unsaved dot and asks before closing), `ui.useActiveEditor` (the current tab of the workbench), `ui.DiffEditor` (Monaco's diff editor, side by side or inline, the right side editable), `confirmLabel` / `danger` of `ui.confirm`, `head` of a view (a top bar of its own), `ui.input` / `ui.editor` (asks the user for a line or lines of text, `undefined` when cancelled), the page's `menu` (floating … menu when the page is listed in sidebar) and `pages` (pages listed in sidebar, navigation bar no longer lists them separately), `ui.notify` (notifications in bottom right of page), `ui.notifySession` (tells the user what a conversation said, as a messenger does: nothing while they look at it, nothing of a task the double follows unless it asks; nothing that pops up on a phone or a tablet, the unread dots of the list and of the Chats tab telling; on a computer in front, a banner with the face and name of the conversation, a tap opening it, its `options` buttons that send that answer once from whichever page; a notice of the system while it is not, silent for an answer; without those, a banner that waits for the user when it asks or failed), `ui.confirm` (confirm before continuing, returns whether user agreed), `ui.theme`, `ui.language`, `ui.supportsWebview` (whether a view can show a site in a `<webview>`, as in Ta Desktop, rather than an iframe), `ui.debugWebview` (Ta Desktop: a command of the Chrome DevTools Protocol to the page of such a webview, limited to the page itself), `ui.desktop.browserData` (Ta Desktop on macOS and Windows: the cookies of a profile of the user's browser taken into the browser of Ta once the user says yes in a dialog of the app, and clearing that browser's data), `registerChatIcon` (an icon for conversations of the extension that are no agent, such as a brief it writes or a question it asks, in the lists and on their notices in place of the letter of their directory; given a `folder`, those of the same folder fold into one row of the list of conversations that opens a list of their own, closed ones of the extension's group too, as the runs of scheduled tasks), `registerHomeItems` / `ui.useHomeItems` (rows of the double's home under the double, for what the user looks at each day, such as a daily brief), `registerInitiative` (how far the page goes on its own with what it does for the user, as the double starting a task: the extension that keeps the user's trust answers, the first registered; ta-initiative does), `ui.pinChat` (pins a conversation by its session file, or unpins it, as the user does with Pin), `registerSessionMenu` (a section of entries of its own in the menu of a conversation of a list, a right click or a held finger on its row), `ui.custom` (a component of the extension over the page wherever the user is, as pi's `ctx.ui.custom`, closed when the extension stops), `ui.useSessions` / `ui.useSavedSessions` (the open sessions of ta serve and the conversations saved lately, as the lists of the page have them, without a poll of its own), `ui.useAsks` (the conversations that wait for the user to decide, as the top of the list of chats shows them: their last turn asked (`TaSessionInfo.asking`) and the user neither answered nor let it go, or a dialog waits; the latest first), `ui.Face` / `ui.GroupFace` (the face of one who is not Ta, as the agents of channels have, the same for the same `seed` on every device; a group of them), `ui.Stack` (a level pushed over the page as a list pushes what was tapped in it, closed on a phone by the swipe from the left edge and the back of the system too), `ui.useBusy` (what waits on ta serve shows it is busy, so that the user sees the click took), `ui.Switch` (the switch of the settings: an `onChange` that returns a promise shows the new state at once, and the old one again if it fails), and page services: `server` (session, pi's RPC commands), `workspace` (files and commands in directory), `terminals` (terminals), `packages` (packages), and `rooms`, rooms shared with other Ta through the relay (what happens in them comes by `onRoomEvent`, no more once the extension stops) (types see `WebExtensionAPI`).
26
+ - **Web extensions** are ES modules without import statements, with a default export of a function that the page calls with `pi`; the returned function is called on unload. The `pi` interface follows pi's ExtensionAPI naming: `ui.setWidget` (default above the input box, same as pi; `placement: 'panel'` puts it in the right workbench's card tabs), `registerView` (pages in the navigation bar, or a list of the sidebar at the top of the navigation bar; `location: 'panel'` is a tool in the right workbench; a page is under Discover until the user pins it), `registerMessageRenderer` (displays custom messages sent by pi extensions with `sendMessage`), `registerCodeRenderer` (draws the fenced blocks of a language in replies and in `ui.Markdown` as a card of the extension's own; the component gets `{ code, language, closed, send, answer }`, `closed` false while the block streams, `send` sending words as the user to the conversation the block is in (the replies on the double's home too, a conversation like any other; none in a page's `ui.Markdown`; older Ta apps pass none, use `sendUserMessage` there), `answer` what the user said after the reply, once they did (a choice the block offers is made, tapped or typed, on every device; older Ta apps pass no such key), and a renderer that throws shows the block as code, as the `ta-glance` cards of `@celljs/ta-glance`), `registerTool` (tools executed by the browser in conversations opened on the page), `registerToolRenderer` (as pi's, a resolver `(toolName, next) => renderer` that chooses how calls of any tool read in conversations: `renderCall(args)` gives a verb, a target and a small icon in the language of the page, in place of the tool's name; `next()` is what the resolvers after it would use), `registerSettings` (a section of the settings, after those of Ta: rows of a label, a description and a control the extension draws, the values kept with `storage`; a row with an empty label is a panel that says what it is itself, found by `search`), `registerTasks` / `ui.useTasks` (work done for the user, listed by the double with its own tasks and those of other extensions; see docs/design/ta-double.md. A task with `remove` and `removeHint` can be swiped away in the lists, or selected with others and deleted at once; `ui.removeTasks` asks the user; a row with `gathered` stands for several things the user does themselves, as the double's row of the conversations going on, and the lists count what `gathered` counts, not the row), `ui.SelectCheck` / `ui.SelectBar` (the round mark at the start of a row and the bar under a list while it selects several, as the lists of the page), `registerOpener` (opens links in replies: files and their lines, directories, web pages, asked in registration order, returns true if opened), `registerComposerAddon` (adds to the message box of every conversation: `actions(conversation)` are entries of the + menu, each a tile of its grid (four by two a page, more a page to swipe to): `setting: true` shows its value (`detail`) under its label, `toggle: true` is a switch (`checked` is on, its icon lit; turning it leaves the menu open), and entries may have `items`, a list in its place; `above` is drawn above the box; `subscribe` says the entries changed. `conversation` says which: `sessionId`, `sessionFile`, `cwd`, `kind` `double` or `chat`, `group`, `title`; the double, agents and plain conversations all have it), `ui.Game3D` (a 3D game on Three.js: `setup(context)` gets a renderer, a scene, a camera and OrbitControls, fills the scene and returns what to do each frame; loaded, asleep and ended as `ui.Game`, its scene and WebGL context given back at the end), `ui.FullScreen` (covers all of the page: the shell, its head and side columns under it, under the notch and the home bar, below the title bar of the desktop app and above the keyboard; its touches are all its own, an edge brings out no panel of Ta; for a game held sideways or a world to walk in, `??` back to its place in an app older than it), `data-own-gestures` (an attribute of an element whose touches are its own: the slides of Ta start there only from an edge of the screen, a held finger opens no menu; games carry it), `ui.Game` (a game on Phaser 4, the game engine of the page, loaded when the first game starts; it fills its parent, sleeps while out of sight and ends when it unmounts, takes the keyboard only while it has the focus, and finds the colors of the theme in its registry; see docs/design/ta-games.md. Each is a part of the screen (`game-<n>`) that Ta plays for the user: `app_do` taps, moves the pointer, presses a key or holds on its canvas; under its `title`, else the title of the package, and with its score and whether its round is over once the game sets `score` and `over` in its registry, or returns them from `state()` of the loop of `ui.Game3D`), `ui.QrCode` (a QR code of a text, black on white whatever the theme), `ui.ImageViewer` (a picture to look at closely: all of it at first and never larger than its own pixels, pinched with two fingers or a trackpad, zoomed with Ctrl/⌘ and the wheel or a double click or tap, dragged or scrolled once zoomed, with − / the scale / + / fit to window / actual size below it, and given `onPrevious` / `onNext` the pictures beside it by buttons at its sides and, unless zoomed, ← →; the previews of pictures in the workbench and the large pictures of a conversation are this), `on` (events of the current conversation), `sendUserMessage` (sends to the current conversation; a `/command` runs a command of a pi extension. What an extension sends as the user, by `sendUserMessage`, `server.prompt`, the `send` of a block or `prompt` of its host, says where it came from in the last line of its `<context>`, `[ta:from <package>]` (`TaMessageSource`), and the conversation shows the name and icon of the package above the bubble), `switchSession` (shows another session open in ta serve as the current conversation; given a Promise of the session id it switches at once and shows "Opening", `opening` giving the title meanwhile), `openChat` (opens the conversation of a session file as the lists do: at once from what the page or the device has, opened again in one round trip when it closed; false when no conversation has it), `openLink` (opens a link as a click on a link of a reply does: the openers of extensions first, as of a share or an agent's card, else the browser of the workbench), `callHost` (calls a method of the package's `pi.host`, through `callPackageHost`), `reloadExtensions` (after an extension installed, imported or removed packages itself, reloads the web extensions and the pi extensions of the current conversation as at the end of a reply), `ui.showView` / `ui.useView` (shows and reads any extension's view), `ui.showChats` (shows the list of chats, on a phone its tab; with `busy` only the conversations going on, under a chip Going on that clears it), `ui.Composer` / `ui.Markdown` (the message box and the Markdown of the conversations, the microphone and the hold to talk too; with `commands`, `/` lists the commands a new conversation in `cwd` will have; `voiceSends`, `onTalkSent`, `onListening`, `working` / `onStop` and `after` are those of the double's box: what is heard is sent at once, the page knows what was said by voice to read its answer aloud, that the user talks now, the send button stops what answers, buttons of its own on the right), `ui.HoldToTalk` (a button held to talk, as the bar of the message box: the page dims and listens with its recognizer, 取消 and 编辑 to slide onto, the words given as the finger lets go; nothing where the page cannot listen), `ui.voice` (`canListen` / `canSpeak` / `speak` / `hush`: read aloud in the voice of the settings), the `send` of a view (a page that is a conversation takes a message from another extension as if typed in its box; the double's page has it, its answer comes as its `preview`), `ui.useChatScroll` (scrolls as the conversations: at the bottom it follows new messages, scrolled up it is never pulled back and what is read does not jump, a part opened by a click stays where it was; `sent` is how many messages the user sent, one more of which goes to the bottom), `ui.Empty` (what a list or a view shows while empty: a title and at most one line of hint, centred in its space; `compact` in menus, pickers and dialogs; `picture` puts a picture above), `ui.Picture` / `ui.PictureCards` (small pictures as those of Ta: the shapes of an SVG take the classes `ta-pic-*` and follow the theme; a row of picture cards to click, with a label and a line of description), `ui.Dialog` (a dialog over the page), `preview` of `ui.openEditor` (a preview tab opened by a click, its title in italics, replaced by the next preview, kept by a double click or `ui.pinEditor`), `ui.setEditorDirty` (the tab shows an unsaved dot and asks before closing), `ui.useActiveEditor` (the current tab of the workbench), `ui.DiffEditor` (Monaco's diff editor, side by side or inline, the right side editable), `confirmLabel` / `danger` of `ui.confirm`, `head` of a view (a top bar of its own), `ui.input` / `ui.editor` (asks the user for a line or lines of text, `undefined` when cancelled), the page's `menu` (floating … menu when the page is listed in sidebar) and `pages` (pages listed in sidebar, navigation bar no longer lists them separately), `ui.notify` (notifications in bottom right of page), `ui.notifySession` (tells the user what a conversation said, as a messenger does: nothing while they look at it, nothing of a task the double follows unless it asks; nothing that pops up on a phone or a tablet, the unread dots of the list and of the Chats tab telling; on a computer in front, a banner with the face and name of the conversation, a tap opening it, its `options` buttons that send that answer once from whichever page; a notice of the system while it is not, silent for an answer; without those, a banner that waits for the user when it asks or failed), `ui.confirm` (confirm before continuing, returns whether user agreed), `ui.theme`, `ui.language`, `ui.supportsWebview` (whether a view can show a site in a `<webview>`, as in Ta Desktop, rather than an iframe), `ui.debugWebview` (Ta Desktop: a command of the Chrome DevTools Protocol to the page of such a webview, limited to the page itself), `ui.desktop.browserData` (Ta Desktop on macOS and Windows: the cookies of a profile of the user's browser taken into the browser of Ta once the user says yes in a dialog of the app, and clearing that browser's data), `registerChatIcon` (an icon for conversations of the extension that are no agent, such as a brief it writes or a question it asks, in the lists and on their notices in place of the letter of their directory; given a `folder`, those of the same folder fold into one row of the list of conversations that opens a list of their own, closed ones of the extension's group too, as the runs of scheduled tasks, pinned to the top the first time it is there), `registerHomeItems` / `ui.useHomeItems` (rows of the double's list, pinned to the top the first time they are there, for what the user looks at each day, such as a daily brief; given a `sessionFile` the conversation it stands for is not listed again), `registerInitiative` (how far the page goes on its own with what it does for the user, as the double starting a task: the extension that keeps the user's trust answers, the first registered; ta-initiative does), `ui.pinChat` (pins a conversation by its session file, or unpins it, as the user does with Pin), `registerSessionMenu` (a section of entries of its own in the menu of a conversation of a list, a right click or a held finger on its row), `ui.custom` (a component of the extension over the page wherever the user is, as pi's `ctx.ui.custom`, closed when the extension stops), `ui.useSessions` / `ui.useSavedSessions` (the open sessions of ta serve and the conversations saved lately, as the lists of the page have them, without a poll of its own), `ui.useAsks` (the conversations that wait for the user to decide, as the top of the list of chats shows them: their last turn asked (`TaSessionInfo.asking`) and the user neither answered nor let it go, or a dialog waits; the latest first), `ui.Face` / `ui.GroupFace` (the face of one who is not Ta, as the agents of channels have, the same for the same `seed` on every device; a group of them), `ui.Stack` (a level pushed over the page as a list pushes what was tapped in it, closed on a phone by the swipe from the left edge and the back of the system too), `ui.useBusy` (what waits on ta serve shows it is busy, so that the user sees the click took), `ui.Switch` (the switch of the settings: an `onChange` that returns a promise shows the new state at once, and the old one again if it fails), and page services: `server` (session, pi's RPC commands), `workspace` (files and commands in directory), `terminals` (terminals), `packages` (packages), and `rooms`, rooms shared with other Ta through the relay (what happens in them comes by `onRoomEvent`, no more once the extension stops) (types see `WebExtensionAPI`).
27
27
  - **The bytes of files**: `pi.files` gives the bytes of a file of the workspace. When the page is served by ta serve itself, `byUrl` is true and the URL of `workspace.fileUrl` loads as it is; in the app on a phone, or when the page is opened through a relay, that URL is not there to load, `byUrl` is false, and `pi.files.read(url)` gives `{ type, size, data }` over the WebSocket (sealed end to end: the relay reads none of it). The previews of @celljs/ta-workspace are built on it: pictures, videos, sounds and PDFs as `blob:` URLs, an HTML report from the text of the file in a sandboxed frame.
28
28
  - **Make packages with natural language**: the built-in extension [@celljs/ta-extensions](../ta-extensions/README.md) includes the skill `ta-package` (also available in the Ta terminal) and adds an "Extensions" page in the navigation bar (create an extension in one sentence, export or import). It documents package format, the web extension interface, and validation steps. At the end of each reply in the current conversation, the page reloads web extensions: new ones load, changed ones reload, and deleted ones unload; when tools change, the conversation reopens that part in the same session file (only for conversations opened on this page); when packages change, the session reloads pi extensions. The page checks again when redisplayed (packages might change in the terminal too).
29
+ - **Ta works an extension's page for the user**: `ui.useScreenPart({ id, title, state?, items?, actions?, scroll?, floats? })` says what a part of the page is, its rows and what it does, for Ta's `app_look` / `app_do` to read and work it as the user does; mark the elements `data-ta-part`, `data-ta-item`, `data-ta-action`. A part that floats over every page (as Ta's own call bar, there on any page while a call goes on) says `floats: true`: it is listed first, and never taken for what the page scrolls. What scrolls under a part's mark Ta scrolls too (`app_do` with `scroll`: a screen down or up, to the top or the bottom, or a row into sight), and `app_look` lists only the rows in sight and says where it is (an item outside what scrolls, a dialog over it, says `fixed: true` and is always listed); a list that loads as it scrolls says at which end more comes with `scroll.more()` and that it loads with `scroll.loading()`. `ui.screen.scroll(part, to)` / `ui.screen.pageScroll()` do the same.
29
30
  - **Stable**: each extension owns what it registers and removes it all on unload; if one extension fails to load or render, only that extension's area shows an error, without affecting the page or other extensions.
30
31
 
31
32
  **Settings → More → Extensions** (the "Extensions" in the gear menu) lists installed extensions (each is a package with web extensions that can be removed or reloaded); **Built-in Extensions** lists packages and web extensions provided with Ta and can be toggled here:
package/README.md CHANGED
@@ -23,9 +23,10 @@ Web 客户端可以装成桌面或手机上的应用:Chrome / Edge 地址栏
23
23
  界面上新增的一切都来自包里的 **Web 扩展**,和 pi 的扩展同一套机制、同一套叫法:
24
24
 
25
25
  - **包**就是 pi 的包。`package.json` 的 `pi` 里,`extensions` 是给 Ta(终端和服务端)的扩展,`web` 是给这个页面的扩展;没有声明时取 `web/` 目录下的模块。包放在 `~/.ta/agent/extensions/<名字>/`(项目的 `.ta/extensions/`)即可生效,也可以用 `ta install` 安装。
26
- - **Web 扩展**是一个不带 import 的 ES 模块,默认导出一个函数,页面用 `pi` 调用它;返回的函数在卸载时调用。`pi` 的接口照 pi 的 ExtensionAPI 命名:`ui.setWidget`(默认在输入框上方,和 pi 一样;`placement: 'panel'` 放进右侧工作台的卡片标签)、`registerView`(导航栏里的页面,或导航栏上方的一个侧栏列表;`location: 'panel'` 是右侧工作台的工具)、`registerMessageRenderer`(显示 pi 扩展用 `sendMessage` 发出的自定义消息)、`registerCodeRenderer`(把回复和 `ui.Markdown` 里某种语言的代码块画成扩展自己的卡片,组件拿到 `{ code, language, closed, send, answer }`,流式时 `closed` 为假,`send` 把文字作为用户消息发到代码块所在的对话(分身首页的回复也有,它也是普通对话;页面的 `ui.Markdown` 里没有;旧版 App 不传,用 `sendUserMessage`),`answer` 是用户在这条回复之后说的话(点选或打字回答后才有,各设备一致,代码块给的选择就算做了;旧版 App 没有这个键);抛错时显示为代码,如 `@celljs/ta-glance` 的 `ta-glance` 卡片)、`registerTool`(页面打开的对话里由浏览器执行的工具)、`registerToolRenderer`(照 pi 的同名接口传一个 resolver `(toolName, next) => renderer`,决定任意工具的调用在对话里怎么读:`renderCall(args)` 给出页面语言的动词、对象和可选的小图标,代替工具名;`next()` 是后面的 resolver 的结果)、`registerSettings`(设置里的一个分区,排在 Ta 自己的分区之后:每行是标签、说明和扩展自己画的控件,值用 `storage` 保存;标签为空的行是自带说明的整块面板,靠 `search` 被搜到)、`registerTasks` / `ui.useTasks`(替用户做的事,由分身和其他扩展的任务一起列出,见 docs/design/ta-double.md;任务带 `remove` 和 `removeHint` 时,列表里可以左滑删除、多选后批量删除,询问统一由 `ui.removeTasks` 做;带 `gathered` 的一行代表多件用户自己在做的事,如分身任务里的"进行中的对话",列表按 `gathered` 里各状态的个数计数,不把这一行当成一个任务)、`ui.SelectCheck` / `ui.SelectBar`(列表多选时行首的圆形勾选和列表底部的操作栏,样式与页面一致)、`registerOpener`(打开回复里的链接:文件及其行、目录、网页,按注册顺序询问,返回 true 表示已打开)、`registerComposerAddon`(给所有对话的输入框加东西:`actions(conversation)` 是 + 菜单里的条目,每个都是一个图标方块(每页 4×2,多了左右滑动翻页):`setting: true` 在名字下显示当前值(`detail`),`toggle: true` 是开关(`checked` 表示开着,图标点亮,点了不关菜单),条目可以带 `items` 二级列表;`above` 画在输入框上方;`subscribe` 通知条目变了。`conversation` 说明是哪个对话:`sessionId`、`sessionFile`、`cwd`、`kind` 为 `double` 或 `chat`、`group`、`title`;分身、智能体和普通对话都有)、`ui.Game3D`(Three.js 3D 游戏:`setup(context)` 拿到渲染器、场景、相机和 OrbitControls,往场景里放东西并返回每帧要做的事;同样懒加载、休眠、卸载时释放场景和 WebGL 上下文)、`ui.FullScreen`(盖住整个页面:外壳、它的顶栏和侧栏都在下面,铺到刘海和底部横条下,在桌面版标题栏之下、键盘之上;触摸全归它,屏幕边缘也不会拉出 Ta 的面板;给横屏游戏、能走进去的世界用,旧版 App 没有它时用 `??` 退回原处显示)、`data-own-gestures`(元素上的属性:从它开始的触摸归它,Ta 的滑动只从屏幕边缘开始,长按不出菜单;游戏自动带上)、`ui.Game`(Phaser 4 游戏:页面自带的游戏引擎,第一次开始游戏时才加载;填满父元素,看不见时休眠,卸载时销毁,键盘只在游戏获得焦点时归它,主题颜色放在游戏的 registry 里,见 docs/design/ta-games.md)、`ui.QrCode`(文字的二维码,任何主题下都是白底黑码)、`ui.ImageViewer`(看图:先完整显示且不超过原始像素,双指或触控板捏合、Ctrl/⌘ 加滚轮、双击或双点缩放,放大后拖动或滚动,底部是 − / 比例 / + / 适应窗口 / 实际大小;给了 `onPrevious` / `onNext` 时两侧有上一张、下一张按钮,未放大时 ← → 也能切换;工作台的图片预览和对话里的大图用的都是它)、`on`(当前对话的事件)、`sendUserMessage`(发到当前对话;`/命令` 会执行 pi 扩展的命令。扩展以用户身份发的消息,经 `sendUserMessage`、`server.prompt`、代码块的 `send` 或宿主的 `prompt`,都在 `<context>` 末行带上来源 `[ta:from 包名]`(`TaMessageSource`),对话里在气泡上方显示包的名字和图标)、`switchSession`(把 ta serve 里另一个打开的会话显示为当前对话;传会话 id 的 Promise 时立即切过去显示"正在打开",`opening` 给出占位的标题)、`openChat`(按会话文件打开对话,和对话列表一样:先显示页面或设备上已有的内容,已关闭的一次往返重新打开;没有这个对话时返回 false)、`openLink`(像点回复里的链接一样打开:先问扩展的打开方式,比如分享和智能体卡片的链接,没有就在工作台的浏览器里打开)、`callHost`(调用本包 `pi.host` 的方法,经 `callPackageHost`)、`reloadExtensions`(扩展自己安装、导入或移除了包之后,像回复结束时一样重新加载 Web 扩展和当前对话的 pi 扩展)、`ui.showView` / `ui.useView`(显示、查看任意扩展的视图)、`ui.showChats`(打开对话列表,手机上是"对话"标签;`busy` 时只列进行中的对话,顶部一个可清除的"进行中"标签)、`ui.Composer` / `ui.Markdown`(和对话一样的输入框与 Markdown,麦克风和按住说话也一样;输入框的 `commands` 让 `/` 列出在 `cwd` 新开对话时会有的命令,`voiceSends`、`onTalkSent`、`onListening`、`working` / `onStop`、`after` 和分身的输入框一样:听到的话直接发出、知道哪句是说的以便朗读回答、正在听、正在回答时发送键变成停止、右侧放自己的按钮)、`ui.HoldToTalk`(按住说话的按钮,和输入框的“按住 说话”条一样:页面变暗、用页面的识别器听,可滑到“取消”“编辑”,松手交出文字;页面不能识别语音时不显示)、`ui.voice`(`canListen` / `canSpeak` / `speak` / `hush`:用设置里的声音朗读)、视图的 `send`(对话式页面接收别的扩展发来的一条消息,就像在它的输入框里输入;分身页面有它,回答经 `preview` 读到)、`ui.useChatScroll`(和对话一样的滚动:停在底部时跟随新消息,往上翻看时不会被拉回、正在看的内容不跳,点开的部分留在原处;`sent` 是用户发出的消息数,多一条就回到底部)、`ui.Empty`(列表或视图为空时的提示:一行标题加至多一行说明,在所在区域居中;菜单、选择器和弹窗里用 `compact`;`picture` 在上方放一张插图)、`ui.Picture` / `ui.PictureCards`(和 Ta 一样的小插图:SVG 里的图形用 `ta-pic-*` 类名,跟随主题;一排可点的插图卡片,带标签和一行说明)、`ui.Dialog`(盖住整页的弹窗)、`ui.openEditor` 的 `preview`(单击打开的预览标签,标题斜体,下一个预览会替换它,双击或 `ui.pinEditor` 固定)、`ui.setEditorDirty`(标签显示未保存圆点,关闭前确认)、`ui.useActiveEditor`(工作台当前标签)、`ui.DiffEditor`(Monaco 差异编辑器,并排或内联,可编辑右侧)、`ui.confirm` 的 `confirmLabel` / `danger`、视图的 `head`(自己的顶栏)、`ui.input` / `ui.editor`(向用户要一行或多行文字,取消时为 `undefined`)、页面的 `menu`(侧栏列出该页面时悬浮显示的 … 菜单)与 `pages`(侧栏列出的页面,导航栏不再单列)、`discover`(不常用的页面默认收在"发现",用户固定后才进导航栏)、`ui.notify`(页面右下角的通知)、`ui.notifySession`(像聊天软件那样告诉用户某个对话说了什么:用户正在看它时不提醒,分身跟进的任务交给分身,除非它在提问;手机和平板上不弹窗,由列表和“对话”标签上的未读黄点告诉;电脑上页面在前台时是带对话头像和名字的横幅,点一下打开对话,`options` 是可点的回答,同一个回答从各个页面只发一次;页面不在前台时是系统通知,回复是静音的;没有系统通知时,提问和失败留一条横幅等用户回来)、`ui.confirm`(继续前先确认,返回用户是否同意)、`ui.theme`、`ui.language`、`ui.supportsWebview`(能否用 `<webview>` 显示网站,Ta 桌面版里可以,其他地方用 iframe)、`ui.debugWebview`(Ta 桌面版:向这种 webview 里的网页发 Chrome DevTools Protocol 命令,只限网页本身)、`ui.desktop.browserData`(Ta 桌面版,macOS 和 Windows:用户在应用的原生对话框里同意后,把其浏览器某个个人资料的 Cookie 导入内置浏览器;也可清除内置浏览器数据)、`registerChatIcon`(扩展自己的、不是智能体的对话(如它写的简报、它问的问题)在列表和通知里的图标,代替目录的字母;给了 `folder` 时,同一个 `folder` 的对话在对话列表里收成一行,点开是它们自己的列表,扩展分组里已关闭的对话也列在那里,如定时任务的运行)、`registerHomeItems` / `ui.useHomeItems`(分身主页里分身下方的行,放用户每天要看的东西,如每日简报)、`registerInitiative`(页面自己替用户做事(如分身开始一项任务)时走多远,由管用户信任的扩展回答,只问第一个注册的;ta-initiative 用它)、`ui.pinChat`(按会话文件把对话置顶或取消,和用户点置顶一样)、`registerSessionMenu`(列表里对话的菜单(右键或长按一行)中扩展自己的一组条目)、`ui.custom`(像 pi 的 `ctx.ui.custom` 那样,不论用户在哪,把扩展的组件盖在页面上,扩展停止时一并关闭)、`ui.useSessions` / `ui.useSavedSessions`(ta serve 打开的会话和最近保存的对话,和页面的列表是同一份,不必自己轮询)、`ui.useAsks`(等用户决定的对话,和对话列表顶部“待你决定”是同一份:上一轮在问(`TaSessionInfo.asking`)而用户还没回答也没点“不用决定了”,或有对话框在等;最新的在前)、`ui.Face` / `ui.GroupFace`(不是 Ta 的成员的脸,和频道里的智能体一样,同一个 `seed` 在各设备上相同;群组的叠放头像)、`ui.Stack`(像列表推入点开的内容那样压在页面上的一层,手机上从左边缘滑动和系统返回也能关闭)、`ui.useBusy`(等待 ta serve 的操作显示忙碌,点了就知道生效了)、`ui.Switch`(设置里的开关,`onChange` 返回 Promise 时先显示新状态,失败再退回),以及页面的 `React` 和 ta serve 的服务:`server`(会话,pi 的 RPC 命令)、`workspace`(目录里的文件与命令)、`terminals`(终端)、`packages`(包),以及经中继与其他 Ta 共享的房间 `rooms`(发生的事经 `onRoomEvent` 收到,扩展停止时不再收到)(类型见 `WebExtensionAPI`)。
26
+ - **Web 扩展**是一个不带 import 的 ES 模块,默认导出一个函数,页面用 `pi` 调用它;返回的函数在卸载时调用。`pi` 的接口照 pi 的 ExtensionAPI 命名:`ui.setWidget`(默认在输入框上方,和 pi 一样;`placement: 'panel'` 放进右侧工作台的卡片标签)、`registerView`(页面,默认在“发现”里、用户可放进导航栏,或导航栏上方的一个侧栏列表;`location: 'panel'` 是右侧工作台的工具)、`registerMessageRenderer`(显示 pi 扩展用 `sendMessage` 发出的自定义消息)、`registerCodeRenderer`(把回复和 `ui.Markdown` 里某种语言的代码块画成扩展自己的卡片,组件拿到 `{ code, language, closed, send, answer }`,流式时 `closed` 为假,`send` 把文字作为用户消息发到代码块所在的对话(分身首页的回复也有,它也是普通对话;页面的 `ui.Markdown` 里没有;旧版 App 不传,用 `sendUserMessage`),`answer` 是用户在这条回复之后说的话(点选或打字回答后才有,各设备一致,代码块给的选择就算做了;旧版 App 没有这个键);抛错时显示为代码,如 `@celljs/ta-glance` 的 `ta-glance` 卡片)、`registerTool`(页面打开的对话里由浏览器执行的工具)、`registerToolRenderer`(照 pi 的同名接口传一个 resolver `(toolName, next) => renderer`,决定任意工具的调用在对话里怎么读:`renderCall(args)` 给出页面语言的动词、对象和可选的小图标,代替工具名;`next()` 是后面的 resolver 的结果)、`registerSettings`(设置里的一个分区,排在 Ta 自己的分区之后:每行是标签、说明和扩展自己画的控件,值用 `storage` 保存;标签为空的行是自带说明的整块面板,靠 `search` 被搜到)、`registerTasks` / `ui.useTasks`(替用户做的事,由分身和其他扩展的任务一起列出,见 docs/design/ta-double.md;任务带 `remove` 和 `removeHint` 时,列表里可以左滑删除、多选后批量删除,询问统一由 `ui.removeTasks` 做;带 `gathered` 的一行代表多件用户自己在做的事,如分身任务里的"进行中的对话",列表按 `gathered` 里各状态的个数计数,不把这一行当成一个任务)、`ui.SelectCheck` / `ui.SelectBar`(列表多选时行首的圆形勾选和列表底部的操作栏,样式与页面一致)、`registerOpener`(打开回复里的链接:文件及其行、目录、网页,按注册顺序询问,返回 true 表示已打开)、`registerComposerAddon`(给所有对话的输入框加东西:`actions(conversation)` 是 + 菜单里的条目,每个都是一个图标方块(每页 4×2,多了左右滑动翻页):`setting: true` 在名字下显示当前值(`detail`),`toggle: true` 是开关(`checked` 表示开着,图标点亮,点了不关菜单),条目可以带 `items` 二级列表;`above` 画在输入框上方;`subscribe` 通知条目变了。`conversation` 说明是哪个对话:`sessionId`、`sessionFile`、`cwd`、`kind` 为 `double` 或 `chat`、`group`、`title`;分身、智能体和普通对话都有)、`ui.Game3D`(Three.js 3D 游戏:`setup(context)` 拿到渲染器、场景、相机和 OrbitControls,往场景里放东西并返回每帧要做的事;同样懒加载、休眠、卸载时释放场景和 WebGL 上下文)、`ui.FullScreen`(盖住整个页面:外壳、它的顶栏和侧栏都在下面,铺到刘海和底部横条下,在桌面版标题栏之下、键盘之上;触摸全归它,屏幕边缘也不会拉出 Ta 的面板;给横屏游戏、能走进去的世界用,旧版 App 没有它时用 `??` 退回原处显示)、`data-own-gestures`(元素上的属性:从它开始的触摸归它,Ta 的滑动只从屏幕边缘开始,长按不出菜单;游戏自动带上)、`ui.Game`(Phaser 4 游戏:页面自带的游戏引擎,第一次开始游戏时才加载;填满父元素,看不见时休眠,卸载时销毁,键盘只在游戏获得焦点时归它,主题颜色放在游戏的 registry 里,见 docs/design/ta-games.md。每个游戏都是屏幕上的一个部分(`game-<n>`),Ta 能替用户玩:`app_do` 在画布上点一下、移动指针、按键或按住;名字是 `title`,没有时用包的标题;游戏在 registry 里设了 `score` 和 `over`(`ui.Game3D` 由循环的 `state()` 返回)时,Ta 看得到分数和是否结束)、`ui.QrCode`(文字的二维码,任何主题下都是白底黑码)、`ui.ImageViewer`(看图:先完整显示且不超过原始像素,双指或触控板捏合、Ctrl/⌘ 加滚轮、双击或双点缩放,放大后拖动或滚动,底部是 − / 比例 / + / 适应窗口 / 实际大小;给了 `onPrevious` / `onNext` 时两侧有上一张、下一张按钮,未放大时 ← → 也能切换;工作台的图片预览和对话里的大图用的都是它)、`on`(当前对话的事件)、`sendUserMessage`(发到当前对话;`/命令` 会执行 pi 扩展的命令。扩展以用户身份发的消息,经 `sendUserMessage`、`server.prompt`、代码块的 `send` 或宿主的 `prompt`,都在 `<context>` 末行带上来源 `[ta:from 包名]`(`TaMessageSource`),对话里在气泡上方显示包的名字和图标)、`switchSession`(把 ta serve 里另一个打开的会话显示为当前对话;传会话 id 的 Promise 时立即切过去显示"正在打开",`opening` 给出占位的标题)、`openChat`(按会话文件打开对话,和对话列表一样:先显示页面或设备上已有的内容,已关闭的一次往返重新打开;没有这个对话时返回 false)、`openLink`(像点回复里的链接一样打开:先问扩展的打开方式,比如分享和智能体卡片的链接,没有就在工作台的浏览器里打开)、`callHost`(调用本包 `pi.host` 的方法,经 `callPackageHost`)、`reloadExtensions`(扩展自己安装、导入或移除了包之后,像回复结束时一样重新加载 Web 扩展和当前对话的 pi 扩展)、`ui.showView` / `ui.useView`(显示、查看任意扩展的视图)、`ui.showChats`(打开对话列表,手机上是"对话"标签;`busy` 时只列进行中的对话,顶部一个可清除的"进行中"标签)、`ui.Composer` / `ui.Markdown`(和对话一样的输入框与 Markdown,麦克风和按住说话也一样;输入框的 `commands` 让 `/` 列出在 `cwd` 新开对话时会有的命令,`voiceSends`、`onTalkSent`、`onListening`、`working` / `onStop`、`after` 和分身的输入框一样:听到的话直接发出、知道哪句是说的以便朗读回答、正在听、正在回答时发送键变成停止、右侧放自己的按钮)、`ui.HoldToTalk`(按住说话的按钮,和输入框的“按住 说话”条一样:页面变暗、用页面的识别器听,可滑到“取消”“编辑”,松手交出文字;页面不能识别语音时不显示)、`ui.voice`(`canListen` / `canSpeak` / `speak` / `hush`:用设置里的声音朗读)、视图的 `send`(对话式页面接收别的扩展发来的一条消息,就像在它的输入框里输入;分身页面有它,回答经 `preview` 读到)、`ui.useChatScroll`(和对话一样的滚动:停在底部时跟随新消息,往上翻看时不会被拉回、正在看的内容不跳,点开的部分留在原处;`sent` 是用户发出的消息数,多一条就回到底部)、`ui.Empty`(列表或视图为空时的提示:一行标题加至多一行说明,在所在区域居中;菜单、选择器和弹窗里用 `compact`;`picture` 在上方放一张插图)、`ui.Picture` / `ui.PictureCards`(和 Ta 一样的小插图:SVG 里的图形用 `ta-pic-*` 类名,跟随主题;一排可点的插图卡片,带标签和一行说明)、`ui.Dialog`(盖住整页的弹窗)、`ui.openEditor` 的 `preview`(单击打开的预览标签,标题斜体,下一个预览会替换它,双击或 `ui.pinEditor` 固定)、`ui.setEditorDirty`(标签显示未保存圆点,关闭前确认)、`ui.useActiveEditor`(工作台当前标签)、`ui.DiffEditor`(Monaco 差异编辑器,并排或内联,可编辑右侧)、`ui.confirm` 的 `confirmLabel` / `danger`、视图的 `head`(自己的顶栏)、`ui.input` / `ui.editor`(向用户要一行或多行文字,取消时为 `undefined`)、页面的 `menu`(侧栏列出该页面时悬浮显示的 … 菜单)与 `pages`(侧栏列出的页面,导航栏不再单列)、`discover`(不常用的页面默认收在"发现",用户固定后才进导航栏)、`ui.notify`(页面右下角的通知)、`ui.notifySession`(像聊天软件那样告诉用户某个对话说了什么:用户正在看它时不提醒,分身跟进的任务交给分身,除非它在提问;手机和平板上不弹窗,由列表和“对话”标签上的未读黄点告诉;电脑上页面在前台时是带对话头像和名字的横幅,点一下打开对话,`options` 是可点的回答,同一个回答从各个页面只发一次;页面不在前台时是系统通知,回复是静音的;没有系统通知时,提问和失败留一条横幅等用户回来)、`ui.confirm`(继续前先确认,返回用户是否同意)、`ui.theme`、`ui.language`、`ui.supportsWebview`(能否用 `<webview>` 显示网站,Ta 桌面版里可以,其他地方用 iframe)、`ui.debugWebview`(Ta 桌面版:向这种 webview 里的网页发 Chrome DevTools Protocol 命令,只限网页本身)、`ui.desktop.browserData`(Ta 桌面版,macOS 和 Windows:用户在应用的原生对话框里同意后,把其浏览器某个个人资料的 Cookie 导入内置浏览器;也可清除内置浏览器数据)、`registerChatIcon`(扩展自己的、不是智能体的对话(如它写的简报、它问的问题)在列表和通知里的图标,代替目录的字母;给了 `folder` 时,同一个 `folder` 的对话在对话列表里收成一行,点开是它们自己的列表,扩展分组里已关闭的对话也列在那里,如定时任务的运行;第一次出现时默认置顶)、`registerHomeItems` / `ui.useHomeItems`(分身对话列表里的行,放用户每天要看的东西,如每日简报;第一次出现时默认置顶,用户可取消;带 `sessionFile` 时它代表的对话不再单独列出)、`registerInitiative`(页面自己替用户做事(如分身开始一项任务)时走多远,由管用户信任的扩展回答,只问第一个注册的;ta-initiative 用它)、`ui.pinChat`(按会话文件把对话置顶或取消,和用户点置顶一样)、`registerSessionMenu`(列表里对话的菜单(右键或长按一行)中扩展自己的一组条目)、`ui.custom`(像 pi 的 `ctx.ui.custom` 那样,不论用户在哪,把扩展的组件盖在页面上,扩展停止时一并关闭)、`ui.useSessions` / `ui.useSavedSessions`(ta serve 打开的会话和最近保存的对话,和页面的列表是同一份,不必自己轮询)、`ui.useAsks`(等用户决定的对话,和对话列表顶部“待你决定”是同一份:上一轮在问(`TaSessionInfo.asking`)而用户还没回答也没点“不用决定了”,或有对话框在等;最新的在前)、`ui.Face` / `ui.GroupFace`(不是 Ta 的成员的脸,和频道里的智能体一样,同一个 `seed` 在各设备上相同;群组的叠放头像)、`ui.Stack`(像列表推入点开的内容那样压在页面上的一层,手机上从左边缘滑动和系统返回也能关闭)、`ui.useBusy`(等待 ta serve 的操作显示忙碌,点了就知道生效了)、`ui.Switch`(设置里的开关,`onChange` 返回 Promise 时先显示新状态,失败再退回),以及页面的 `React` 和 ta serve 的服务:`server`(会话,pi 的 RPC 命令)、`workspace`(目录里的文件与命令)、`terminals`(终端)、`packages`(包),以及经中继与其他 Ta 共享的房间 `rooms`(发生的事经 `onRoomEvent` 收到,扩展停止时不再收到)(类型见 `WebExtensionAPI`)。
27
27
  - **文件的字节**:`pi.files` 给出工作区的文件字节。页面由 ta serve 自己提供时 `byUrl` 为真,直接用 `workspace.fileUrl` 的地址加载就行;手机应用里、或页面经中继打开时,那个地址在页面里加载不到,`byUrl` 为假,`pi.files.read(url)` 经 WebSocket 取回 `{ type, size, data }`(端到端加密,中继读不到)。`@celljs/ta-workspace` 的预览就靠它:图片、视频、声音、PDF 做成 `blob:`,HTML 报告按文件文本放进沙框。
28
28
  - **用自然语言做包**:内置扩展 [@celljs/ta-extensions](../ta-extensions/README.md) 带技能 `ta-package`(终端里的 Ta 也有),并在导航栏加了"扩展"页(一句话做扩展、导出导入),写明了包的格式、Web 扩展接口和验证步骤。当前对话每次回复结束,页面重新读取 Web 扩展:新的加载、改过的重新加载、删掉的卸载;工具有变化时,用同一个会话文件重新打开这段对话(只限本页打开的对话),包有改动时让会话重新加载 pi 扩展。页面重新显示时也会检查一次(包也可能在终端里改)。
29
+ - **让 Ta 替你操作扩展页**:`ui.useScreenPart({ id, title, state?, items?, actions?, scroll?, floats? })` 说明页面的一块是什么、有哪些行、能做什么,Ta 的 `app_look` / `app_do` 照用户的方式读它、操作它;元素标上 `data-ta-part`、`data-ta-item`、`data-ta-action`。浮在所有页面之上的一块(比如 Ta 自己的通话条,通话中在哪一页都在)写 `floats: true`:它排在最前面,也不会被当成页面的滚动区。标了 `data-ta-part` 的那块里能滚动的区域,Ta 也能滚(`app_do` 的 `scroll`:向下、向上一屏,到顶、到底,或滚到某一行),`app_look` 只列看得见的行并说明位置(不在滚动区里的条目,如盖在上面的对话框,标 `fixed: true`,总会列出);边滚边加载的列表用 `scroll.more()` 说明更多内容在哪一头、`scroll.loading()` 说明正在加载。`ui.screen.scroll(part, to)` / `ui.screen.pageScroll()` 是同一套能力。
29
30
  - **稳定**:每个扩展注册的东西归它自己,卸载时一并撤掉;一个扩展加载失败或渲染出错,只在它自己的位置显示错误,不影响页面和其他扩展。
30
31
 
31
32
  **设置 → 更多 → 扩展**(齿轮菜单的"扩展")列出安装的扩展(每个是一个带 Web 扩展的包,可移除、重新加载);**内置扩展**列出随 Ta 提供的包和 Web 扩展,可以在这里开关:
@@ -0,0 +1,13 @@
1
+ import type { TaAccountInfo } from '@celljs/ta-protocol';
2
+ import { type AccountSide } from './device-account.js';
3
+ /**
4
+ * The account a page shows (docs/design/ta-account.md): in the app, the phone's own; elsewhere, that of the computer
5
+ * whose page it is, once connected to it.
6
+ */
7
+ export declare function useAccountSide(): AccountSide | undefined;
8
+ /** The account as it is now, read again every few seconds while shown; `act` runs a change and shows what it made. */
9
+ export declare function useAccountInfo(side: AccountSide | undefined, every?: number): {
10
+ info: TaAccountInfo | undefined;
11
+ failed: unknown;
12
+ act: (run: (side: AccountSide) => Promise<TaAccountInfo>) => Promise<void>;
13
+ };
@@ -0,0 +1,74 @@
1
+ import { relayDefaultUrl } from '@celljs/ta-relay';
2
+ import * as React from 'react';
3
+ import { CloudSignInUtil } from '../cloud/cloud-sign-in.js';
4
+ import { useWorkbench } from '../hooks.js';
5
+ import { WorkbenchUtil } from '../workbench-util.js';
6
+ import { DeviceAccount } from './device-account.js';
7
+ /** The account of the computer of the page, through its ta serve (TaAccountServer). */
8
+ function serveSide(account) {
9
+ return {
10
+ read: () => account.getAccount(),
11
+ signIn: (provider, service) => account.signIn(provider, service),
12
+ cancelSignIn: () => account.cancelSignIn(),
13
+ approve: id => account.approve(id),
14
+ remove: id => account.remove(id),
15
+ signOut: () => account.signOut(),
16
+ };
17
+ }
18
+ /**
19
+ * The relay the app's account is on: that of the computers it is paired with, as theirs is; else the relay of the
20
+ * deployment this build is for, else the default one.
21
+ */
22
+ async function appService(hosts, current) {
23
+ var _a;
24
+ var _b, _c, _d;
25
+ const paired = (one) => (one && 'pairing' in one.credential ? one.credential.pairing.relay : undefined);
26
+ return ((_d = (_c = (_b = paired(hosts.find(one => one.id === current))) !== null && _b !== void 0 ? _b : hosts.map(paired).find(Boolean)) !== null && _c !== void 0 ? _c : (_a = (await CloudSignInUtil.distribution())) === null || _a === void 0 ? void 0 : _a.relay) !== null && _d !== void 0 ? _d : relayDefaultUrl());
27
+ }
28
+ /**
29
+ * The account a page shows (docs/design/ta-account.md): in the app, the phone's own; elsewhere, that of the computer
30
+ * whose page it is, once connected to it.
31
+ */
32
+ export function useAccountSide() {
33
+ const [{ status, hosts, host }, bench] = useWorkbench();
34
+ const app = WorkbenchUtil.isApp();
35
+ const where = React.useRef({ hosts, host });
36
+ where.current = { hosts, host };
37
+ const online = status === 'online';
38
+ return React.useMemo(() => {
39
+ if (app) {
40
+ return DeviceAccount.of(bench, () => appService(where.current.hosts, where.current.host), async () => {
41
+ var _a;
42
+ const chosen = CloudSignInUtil.chosen();
43
+ const built = (_a = (await CloudSignInUtil.distribution())) === null || _a === void 0 ? void 0 : _a.gateway;
44
+ return [chosen, built].filter((one) => !!one);
45
+ });
46
+ }
47
+ return online ? serveSide(bench.account) : undefined;
48
+ }, [app, online, bench]);
49
+ }
50
+ /** The account as it is now, read again every few seconds while shown; `act` runs a change and shows what it made. */
51
+ export function useAccountInfo(side, every = 3000) {
52
+ const [info, setInfo] = React.useState();
53
+ const [failed, setFailed] = React.useState();
54
+ React.useEffect(() => {
55
+ if (!side) {
56
+ return;
57
+ }
58
+ let live = true;
59
+ const read = () => side.read().then(next => live && setInfo(next), (error) => live && setFailed(error));
60
+ void read();
61
+ const timer = setInterval(() => document.visibilityState !== 'hidden' && void read(), every);
62
+ return () => {
63
+ live = false;
64
+ clearInterval(timer);
65
+ };
66
+ }, [side, every]);
67
+ const act = React.useCallback(async (run) => {
68
+ if (side) {
69
+ setInfo(await run(side));
70
+ }
71
+ }, [side]);
72
+ return { info, failed, act };
73
+ }
74
+ //# sourceMappingURL=account-side.js.map
@@ -0,0 +1,69 @@
1
+ import type { TaAccountInfo } from '@celljs/ta-protocol';
2
+ import { AccountAgent, type AccountKept, type AccountView, type AccountWay } from '@celljs/ta-relay';
3
+ import type { SavedHost } from '../workbench-protocol.js';
4
+ /** What a page does about the account: of its ta serve (a computer), or of the device itself (the app). */
5
+ export interface AccountSide {
6
+ read(): Promise<TaAccountInfo>;
7
+ signIn(provider: string, service?: string): Promise<TaAccountInfo>;
8
+ cancelSignIn(): Promise<TaAccountInfo>;
9
+ approve(id: string): Promise<TaAccountInfo>;
10
+ remove(id: string): Promise<TaAccountInfo>;
11
+ signOut(): Promise<TaAccountInfo>;
12
+ }
13
+ /** The computers a device's account brings, kept with the device's computers (TaWorkbench). */
14
+ export interface AccountHosts {
15
+ readonly state: {
16
+ hosts: SavedHost[];
17
+ };
18
+ addAccountHost(link: string, account: string): Promise<void>;
19
+ forgetAccountHosts(account?: string): void;
20
+ }
21
+ /**
22
+ * The app as a device of the user's account (docs/design/ta-account.md): its own keys in localStorage; the computers
23
+ * of the account come into its list of computers as they let it in, and go as they are removed. The same agent as a
24
+ * computer's (AccountAgent), with the hooks of a device that pairs with computers rather than letting devices in.
25
+ */
26
+ export declare class DeviceAccount implements AccountSide {
27
+ protected readonly hosts: AccountHosts;
28
+ protected readonly service: () => Promise<string>;
29
+ protected readonly gateways: () => Promise<string[]>;
30
+ protected static instance?: DeviceAccount;
31
+ protected agent?: AccountAgent;
32
+ protected view?: AccountView;
33
+ protected signingIn?: {
34
+ way: AccountWay;
35
+ handle: string;
36
+ code: string;
37
+ url: string;
38
+ interval: number;
39
+ expiresAt: number;
40
+ };
41
+ protected error?: string;
42
+ protected timer?: ReturnType<typeof setTimeout>;
43
+ protected running?: Promise<void>;
44
+ protected constructor(hosts: AccountHosts, service: () => Promise<string>, gateways: () => Promise<string[]>);
45
+ /** The one of the page. */
46
+ static of(hosts: AccountHosts, service: () => Promise<string>, gateways: () => Promise<string[]>): DeviceAccount;
47
+ /** What the device calls itself in the account. */
48
+ static deviceName(agent?: string): string;
49
+ protected static read(): AccountKept | undefined;
50
+ protected agentOf(kept: AccountKept): AccountAgent;
51
+ /** A Ta in the cloud signed in to: its token is the account of its gateway, which this device joins by itself. */
52
+ protected cloudToken(): {
53
+ service: string;
54
+ token: string;
55
+ } | undefined;
56
+ /** Joins the account of the gateway of a Ta in the cloud of this device, unless the user left the account. */
57
+ protected adopt(): Promise<boolean>;
58
+ protected forget(): void;
59
+ protected schedule(after: number): void;
60
+ protected round(): Promise<void>;
61
+ protected pollSignIn(): Promise<number>;
62
+ read(): Promise<TaAccountInfo>;
63
+ signIn(provider: string, service?: string): Promise<TaAccountInfo>;
64
+ cancelSignIn(): Promise<TaAccountInfo>;
65
+ protected act(run: (agent: AccountAgent) => Promise<AccountView>): Promise<TaAccountInfo>;
66
+ approve(id: string): Promise<TaAccountInfo>;
67
+ remove(id: string): Promise<TaAccountInfo>;
68
+ signOut(): Promise<TaAccountInfo>;
69
+ }
@@ -0,0 +1,215 @@
1
+ import { AccountAgent, AccountCallError, AccountService } from '@celljs/ta-relay';
2
+ import { storage } from '../workbench-util.js';
3
+ const KEY = 'ta.account';
4
+ /** Signed out of the account by the user: not signed in again by itself with the token of a Ta in the cloud. */
5
+ const OFF_KEY = 'ta.account.off';
6
+ const SYNC_MS = 15000;
7
+ const WAITING_SYNC_MS = 3000;
8
+ /**
9
+ * The app as a device of the user's account (docs/design/ta-account.md): its own keys in localStorage; the computers
10
+ * of the account come into its list of computers as they let it in, and go as they are removed. The same agent as a
11
+ * computer's (AccountAgent), with the hooks of a device that pairs with computers rather than letting devices in.
12
+ */
13
+ export class DeviceAccount {
14
+ constructor(hosts, service, gateways) {
15
+ this.hosts = hosts;
16
+ this.service = service;
17
+ this.gateways = gateways;
18
+ const kept = DeviceAccount.read();
19
+ if (kept) {
20
+ this.agent = this.agentOf(kept);
21
+ }
22
+ this.schedule(0);
23
+ document.addEventListener('visibilitychange', () => document.visibilityState === 'visible' && this.schedule(0));
24
+ }
25
+ /** The one of the page. */
26
+ static of(hosts, service, gateways) {
27
+ var _a;
28
+ (_a = DeviceAccount.instance) !== null && _a !== void 0 ? _a : (DeviceAccount.instance = new DeviceAccount(hosts, service, gateways));
29
+ return DeviceAccount.instance;
30
+ }
31
+ /** What the device calls itself in the account. */
32
+ static deviceName(agent = navigator.userAgent) {
33
+ return /iPad/.test(agent) ? 'iPad' : /iPhone/.test(agent) ? 'iPhone' : /Android/.test(agent) ? 'Android' : 'Phone';
34
+ }
35
+ static read() {
36
+ var _a, _b;
37
+ var _c;
38
+ try {
39
+ const kept = JSON.parse((_c = (_a = storage()) === null || _a === void 0 ? void 0 : _a.getItem(KEY)) !== null && _c !== void 0 ? _c : 'null');
40
+ return (kept === null || kept === void 0 ? void 0 : kept.token) && ((_b = kept.self) === null || _b === void 0 ? void 0 : _b.signKey) ? kept : undefined;
41
+ }
42
+ catch (_d) {
43
+ return undefined;
44
+ }
45
+ }
46
+ agentOf(kept) {
47
+ return new AccountAgent(kept, {
48
+ save: next => { var _a; return (_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(KEY, JSON.stringify(next)); },
49
+ name: () => DeviceAccount.deviceName(),
50
+ pairing: (from, link) => this.hosts.addAccountHost(link, from.id),
51
+ unpaired: from => this.hosts.forgetAccountHosts(from),
52
+ signedOut: () => {
53
+ var _a;
54
+ this.forget();
55
+ // A token no longer good, or this device removed: not joined again by itself.
56
+ (_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(OFF_KEY, '1');
57
+ },
58
+ });
59
+ }
60
+ /** A Ta in the cloud signed in to: its token is the account of its gateway, which this device joins by itself. */
61
+ cloudToken() {
62
+ for (const host of this.hosts.state.hosts) {
63
+ if ('token' in host.credential && host.credential.url) {
64
+ return { service: host.credential.url.replace(/\/+$/, ''), token: host.credential.token };
65
+ }
66
+ }
67
+ return undefined;
68
+ }
69
+ /** Joins the account of the gateway of a Ta in the cloud of this device, unless the user left the account. */
70
+ async adopt() {
71
+ var _a, _b;
72
+ const cloud = ((_a = storage()) === null || _a === void 0 ? void 0 : _a.getItem(OFF_KEY)) ? undefined : this.cloudToken();
73
+ if (!cloud || !(await AccountService.ways(cloud.service, [cloud.service])).some(one => one.gateway)) {
74
+ return false;
75
+ }
76
+ const kept = await AccountAgent.create(cloud.service, cloud.token, { id: '', name: '' }, 'phone', DeviceAccount.deviceName());
77
+ (_b = storage()) === null || _b === void 0 ? void 0 : _b.setItem(KEY, JSON.stringify(kept));
78
+ this.agent = this.agentOf(kept);
79
+ return true;
80
+ }
81
+ forget() {
82
+ var _a;
83
+ (_a = storage()) === null || _a === void 0 ? void 0 : _a.removeItem(KEY);
84
+ this.agent = undefined;
85
+ this.view = undefined;
86
+ this.hosts.forgetAccountHosts();
87
+ }
88
+ schedule(after) {
89
+ clearTimeout(this.timer);
90
+ if (!this.agent && !this.signingIn && !this.cloudToken()) {
91
+ return;
92
+ }
93
+ this.timer = setTimeout(() => void this.round(), after);
94
+ }
95
+ round() {
96
+ var _a;
97
+ (_a = this.running) !== null && _a !== void 0 ? _a : (this.running = (async () => {
98
+ let next = SYNC_MS;
99
+ try {
100
+ if (this.signingIn) {
101
+ next = await this.pollSignIn();
102
+ }
103
+ else if (this.agent || (await this.adopt())) {
104
+ const agent = this.agent;
105
+ this.view = await agent.sync();
106
+ this.error = undefined;
107
+ if (this.view.waiting || this.view.devices.some(one => one.waiting)) {
108
+ next = WAITING_SYNC_MS;
109
+ }
110
+ }
111
+ }
112
+ catch (error) {
113
+ this.error = error instanceof Error ? error.message : String(error);
114
+ }
115
+ finally {
116
+ this.running = undefined;
117
+ }
118
+ if (document.visibilityState !== 'hidden') {
119
+ this.schedule(next);
120
+ }
121
+ })());
122
+ return this.running;
123
+ }
124
+ async pollSignIn() {
125
+ var _a, _b;
126
+ const signing = this.signingIn;
127
+ if (Date.now() > signing.expiresAt) {
128
+ this.signingIn = undefined;
129
+ return SYNC_MS;
130
+ }
131
+ const answer = await AccountService.check(signing.way, signing.handle);
132
+ if (answer.status === 'pending') {
133
+ return signing.interval * 1000;
134
+ }
135
+ this.signingIn = undefined;
136
+ if (answer.status === 'failed') {
137
+ this.error = answer.error;
138
+ return SYNC_MS;
139
+ }
140
+ const kept = await AccountAgent.create(signing.way.service, answer.token, answer.account, 'phone', DeviceAccount.deviceName());
141
+ (_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(KEY, JSON.stringify(kept));
142
+ (_b = storage()) === null || _b === void 0 ? void 0 : _b.removeItem(OFF_KEY);
143
+ this.agent = this.agentOf(kept);
144
+ this.view = await this.agent.sync();
145
+ return WAITING_SYNC_MS;
146
+ }
147
+ async read() {
148
+ var _a, _b;
149
+ var _c, _d;
150
+ const service = (_d = (_c = (_a = this.agent) === null || _a === void 0 ? void 0 : _a.state.service) !== null && _c !== void 0 ? _c : (_b = this.signingIn) === null || _b === void 0 ? void 0 : _b.way.service) !== null && _d !== void 0 ? _d : (await this.service());
151
+ const error = this.error ? { error: this.error } : {};
152
+ if (!this.agent) {
153
+ const signing = this.signingIn;
154
+ return {
155
+ service,
156
+ providers: await AccountService.ways(service, await this.gateways().catch(() => [])).catch(() => []),
157
+ devices: [],
158
+ ...(signing ? { signingIn: { provider: signing.way.id, code: signing.code, url: signing.url, expiresAt: signing.expiresAt } } : {}),
159
+ ...error,
160
+ };
161
+ }
162
+ if (!this.view) {
163
+ await this.round();
164
+ }
165
+ const view = this.view;
166
+ if (!view) {
167
+ return { service, providers: [], account: this.agent.state.account, devices: [], ...error };
168
+ }
169
+ const devices = view.devices.map(({ trusted: _trusted, ...device }) => device);
170
+ return { service, providers: [], account: view.account, waiting: view.waiting, code: view.code, devices, ...error };
171
+ }
172
+ async signIn(provider, service) {
173
+ if (!this.agent) {
174
+ const ways = await AccountService.ways(await this.service(), await this.gateways().catch(() => []));
175
+ const way = ways.find(one => one.id === provider && (service === undefined || one.service === service));
176
+ if (!way) {
177
+ throw new AccountCallError(404, `No way to sign in with ${provider} here.`);
178
+ }
179
+ const start = await AccountService.begin(way, DeviceAccount.deviceName());
180
+ this.signingIn = { way, ...start, expiresAt: Date.now() + start.expiresIn * 1000 };
181
+ this.error = undefined;
182
+ this.schedule(start.interval * 1000);
183
+ }
184
+ return this.read();
185
+ }
186
+ async cancelSignIn() {
187
+ this.signingIn = undefined;
188
+ return this.read();
189
+ }
190
+ async act(run) {
191
+ if (!this.agent) {
192
+ throw new AccountCallError(401, 'Sign in to an account first.');
193
+ }
194
+ this.view = await run(this.agent);
195
+ this.schedule(WAITING_SYNC_MS);
196
+ return this.read();
197
+ }
198
+ approve(id) {
199
+ return this.act(agent => agent.approve(id));
200
+ }
201
+ remove(id) {
202
+ return this.act(agent => agent.remove(id));
203
+ }
204
+ async signOut() {
205
+ var _a;
206
+ if (this.agent) {
207
+ await this.agent.signOut();
208
+ this.forget();
209
+ (_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(OFF_KEY, '1');
210
+ }
211
+ this.error = undefined;
212
+ return this.read();
213
+ }
214
+ }
215
+ //# sourceMappingURL=device-account.js.map
@@ -1,7 +1,7 @@
1
1
  import type { TaSessionInfo } from '@celljs/ta-protocol';
2
2
  import * as React from 'react';
3
- import { type ChatListProps } from '../components/chat-list.js';
4
- import type { ChatSeen } from '../components/chat-seen.js';
3
+ import type { ChatListProps } from '../components/chat-list-props.js';
4
+ import { type ChatSeen } from '../components/chat-seen.js';
5
5
  /**
6
6
  * Which conversations the user has seen (useSeenChats), and the one in front of them: the conversation `shown`,
7
7
  * else the double's own while its page is in front (`doubleShown`). The app keeps it, whichever list or tab is
@@ -11,5 +11,5 @@ export declare function useSeenConversations(sessions: readonly TaSessionInfo[],
11
11
  seen: ChatSeen;
12
12
  looking?: string;
13
13
  };
14
- /** The list of chats with what the double knows of them: its tasks marked, a conversation to hand it. */
15
- export declare function AssistantChatList(props: Omit<ChatListProps, 'double' | 'notice'>): React.JSX.Element;
14
+ /** The list of chats with what the double knows of them: its tasks marked, a conversation to hand it; its home over them. */
15
+ export declare function AssistantChatList(props: Omit<ChatListProps, 'double' | 'notice' | 'home'>): React.JSX.Element;
@@ -1,9 +1,15 @@
1
+ import { useInject } from '@celljs/react';
1
2
  import * as React from 'react';
2
3
  import { ChatList } from '../components/chat-list.js';
4
+ import { ChatSeenUtil, SEEN_CHATS } from '../components/chat-seen.js';
3
5
  import { ConnectionBanner } from '../components/connection-bar.js';
6
+ import { DOUBLE_PAGE, SideListUtil } from '../components/side-lists.js';
4
7
  import { useSeenChats } from '../components/use-seen-chats.js';
5
- import { useNotices } from '../hooks.js';
8
+ import { WebLabelUtil } from '../extension/web-extension-protocol.js';
9
+ import { WebTaskUtil } from '../extension/web-tasks.js';
10
+ import { useNotices, useWebExtensions } from '../hooks.js';
6
11
  import { useT } from '../i18n/use-t.js';
12
+ import { TaState } from '../state/state-protocol.js';
7
13
  import { useAssistant } from './assistant-hooks.js';
8
14
  /**
9
15
  * Which conversations the user has seen (useSeenChats), and the one in front of them: the conversation `shown`,
@@ -16,7 +22,67 @@ export function useSeenConversations(sessions, shown, doubleShown) {
16
22
  const looking = shown !== null && shown !== void 0 ? shown : (doubleShown && ready ? (_a = assistant.store()) === null || _a === void 0 ? void 0 : _a.sessionId : undefined);
17
23
  return { seen: useSeenChats(sessions, looking), looking };
18
24
  }
19
- /** The list of chats with what the double knows of them: its tasks marked, a conversation to hand it. */
25
+ /**
26
+ * The double's home over the chats, unless a sidebar view of before lists the double (docs/design/ta-partners.md):
27
+ * its card (its page's preview and menu), the rows extensions add under it, and every task.
28
+ */
29
+ function useChatHome(onPicked) {
30
+ const [extensions, host] = useWebExtensions();
31
+ const [, notices] = useNotices();
32
+ const t = useT();
33
+ const state = useInject(TaState);
34
+ const view = extensions.views.find(candidate => candidate.id === DOUBLE_PAGE);
35
+ const listed = SideListUtil.viewListsDouble(extensions.views);
36
+ const tasks = React.useSyncExternalStore(host.tasks.subscribe, host.tasks.tasks, host.tasks.tasks);
37
+ const items = React.useSyncExternalStore(host.home.subscribe, host.home.items, host.home.items);
38
+ // Its preview and whether it works, as one string: the same line stays the same value.
39
+ const watch = React.useCallback((listener) => { var _a; var _b; return (_b = (_a = view === null || view === void 0 ? void 0 : view.subscribePreview) === null || _a === void 0 ? void 0 : _a.call(view, listener)) !== null && _b !== void 0 ? _b : (() => undefined); }, [view]);
40
+ const read = () => {
41
+ var _a, _b;
42
+ const preview = (_a = view === null || view === void 0 ? void 0 : view.preview) === null || _a === void 0 ? void 0 : _a.call(view);
43
+ return `${((_b = view === null || view === void 0 ? void 0 : view.busy) === null || _b === void 0 ? void 0 : _b.call(view)) ? 1 : 0}\n${preview ? `${preview.at}\n${preview.text}` : ''}`;
44
+ };
45
+ const line = React.useSyncExternalStore(watch, read, read);
46
+ const latest = React.useRef(onPicked);
47
+ latest.current = onPicked;
48
+ const name = view ? WebLabelUtil.text(view.title) : t('ta.builtin.assistant');
49
+ const shown = extensions.page === DOUBLE_PAGE;
50
+ const shownItem = extensions.page && !extensions.pageHidden ? extensions.pageFrom : undefined;
51
+ return React.useMemo(() => {
52
+ if (listed) {
53
+ return undefined;
54
+ }
55
+ const [busy, at, ...text] = line.split('\n');
56
+ return {
57
+ double: {
58
+ name,
59
+ shown,
60
+ busy: busy === '1',
61
+ preview: at ? { at: Number(at), text: text.join('\n') } : undefined,
62
+ menu: view === null || view === void 0 ? void 0 : view.menu,
63
+ open: () => {
64
+ latest.current();
65
+ host.showPage(DOUBLE_PAGE);
66
+ },
67
+ },
68
+ items,
69
+ shownItem,
70
+ openItem: entry => {
71
+ latest.current();
72
+ return host.openHome(entry);
73
+ },
74
+ tasks,
75
+ look: (key, ended) => {
76
+ const next = ChatSeenUtil.look(state.get(SEEN_CHATS), key, ended, Date.now());
77
+ if (next) {
78
+ state.set(SEEN_CHATS, next);
79
+ }
80
+ },
81
+ remove: removed => void WebTaskUtil.remove(removed, notices, t),
82
+ };
83
+ }, [listed, line, name, shown, view, items, shownItem, tasks, host, state, notices, t]);
84
+ }
85
+ /** The list of chats with what the double knows of them: its tasks marked, a conversation to hand it; its home over them. */
20
86
  export function AssistantChatList(props) {
21
87
  var _a;
22
88
  const [{ tasks, ready }, assistant] = useAssistant();
@@ -26,12 +92,16 @@ export function AssistantChatList(props) {
26
92
  const session = ready ? (_a = assistant.store()) === null || _a === void 0 ? void 0 : _a.sessionId : undefined;
27
93
  const { sessionFile } = assistant;
28
94
  const double = React.useMemo(() => ({
29
- tasks: new Map(tasks.filter(task => !task.takenOver).map(task => [task.sessionId, task.status])),
95
+ // By the id of its session, and by its file: a task's conversation is marked once saved too.
96
+ tasks: new Map(tasks
97
+ .filter(task => !task.takenOver)
98
+ .flatMap(task => [[task.sessionId, task.status], ...(task.sessionFile ? [[task.sessionFile, task.status]] : [])])),
30
99
  session,
31
100
  sessionFile,
32
101
  name,
33
102
  hand: (info, title) => void assistant.adopt({ sessionId: info.sessionId, title, cwd: info.cwd }).catch(error => notices.error(error)),
34
103
  }), [tasks, session, sessionFile, name, assistant, notices]);
35
- return React.createElement(ChatList, { ...props, double: double, notice: React.createElement(ConnectionBanner, null) });
104
+ const home = useChatHome(props.onPicked);
105
+ return React.createElement(ChatList, { ...props, double: double, home: home, notice: React.createElement(ConnectionBanner, null) });
36
106
  }
37
107
  //# sourceMappingURL=assistant-chat-list.js.map