@celljs/ta-web 4.47.1 → 4.48.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 (247) hide show
  1. package/esm/browser/assistant/assistant-role.d.ts +1 -1
  2. package/esm/browser/assistant/assistant-role.js +1 -1
  3. package/esm/browser/assistant/assistant-task-source.js +6 -1
  4. package/esm/browser/assistant/assistant-task-util.d.ts +1 -0
  5. package/esm/browser/assistant/assistant-task-util.js +9 -3
  6. package/esm/browser/assistant/assistant-view.js +4 -2
  7. package/esm/browser/cloud/cloud-sign-in.d.ts +26 -4
  8. package/esm/browser/cloud/cloud-sign-in.js +88 -18
  9. package/esm/browser/components/app-nav.d.ts +3 -1
  10. package/esm/browser/components/app-nav.js +3 -3
  11. package/esm/browser/components/app-view.js +16 -6
  12. package/esm/browser/components/asks-badge.d.ts +12 -0
  13. package/esm/browser/components/asks-badge.js +17 -1
  14. package/esm/browser/components/chat-list-row.d.ts +4 -1
  15. package/esm/browser/components/chat-list-row.js +7 -1
  16. package/esm/browser/components/chats-dot.d.ts +4 -1
  17. package/esm/browser/components/chats-dot.js +6 -2
  18. package/esm/browser/components/cloud-sign-in-view.d.ts +2 -1
  19. package/esm/browser/components/cloud-sign-in-view.js +28 -5
  20. package/esm/browser/components/composer-box-protocol.d.ts +5 -3
  21. package/esm/browser/components/composer-box.js +11 -11
  22. package/esm/browser/components/composer.d.ts +8 -1
  23. package/esm/browser/components/composer.js +57 -34
  24. package/esm/browser/components/host-view.d.ts +1 -1
  25. package/esm/browser/components/lightbox.d.ts +15 -1
  26. package/esm/browser/components/lightbox.js +14 -2
  27. package/esm/browser/components/link.js +8 -3
  28. package/esm/browser/components/markdown.d.ts +4 -2
  29. package/esm/browser/components/markdown.js +13 -4
  30. package/esm/browser/components/media.d.ts +6 -0
  31. package/esm/browser/components/media.js +9 -1
  32. package/esm/browser/components/message-images.d.ts +5 -0
  33. package/esm/browser/components/message-images.js +40 -4
  34. package/esm/browser/components/message-user.js +4 -2
  35. package/esm/browser/components/partner-row.js +4 -4
  36. package/esm/browser/components/phone-shell.d.ts +2 -0
  37. package/esm/browser/components/phone-shell.js +2 -2
  38. package/esm/browser/components/sending.d.ts +19 -0
  39. package/esm/browser/components/sending.js +27 -0
  40. package/esm/browser/components/session-view.js +4 -3
  41. package/esm/browser/components/settings-choices.js +1 -0
  42. package/esm/browser/components/settings-parts.js +28 -17
  43. package/esm/browser/components/share-dialog.js +3 -2
  44. package/esm/browser/components/share-item-sheet.js +1 -1
  45. package/esm/browser/components/share-sheet.d.ts +4 -2
  46. package/esm/browser/components/share-sheet.js +16 -2
  47. package/esm/browser/components/sign-in-accounts.js +7 -1
  48. package/esm/browser/components/unseen-drop.d.ts +2 -2
  49. package/esm/browser/components/unseen-drop.js +1 -1
  50. package/esm/browser/device/app-badge.d.ts +8 -0
  51. package/esm/browser/device/app-badge.js +28 -0
  52. package/esm/browser/device/code-scan.js +1 -1
  53. package/esm/browser/extension/web-api-code.d.ts +26 -0
  54. package/esm/browser/extension/web-api-components.d.ts +31 -0
  55. package/esm/browser/extension/web-api-menus.d.ts +15 -0
  56. package/esm/browser/extension/web-api-messages.d.ts +15 -0
  57. package/esm/browser/extension/web-api-messages.js +2 -0
  58. package/esm/browser/extension/web-api-partners.d.ts +16 -0
  59. package/esm/browser/extension/web-api-spec.js +1 -0
  60. package/esm/browser/extension/web-extension-api.d.ts +7 -13
  61. package/esm/browser/extension/web-extension-context.js +2 -0
  62. package/esm/browser/extension/web-session-notices.js +11 -2
  63. package/esm/browser/extension/web-share-ui.js +1 -0
  64. package/esm/browser/extension/web-share.js +3 -3
  65. package/esm/browser/extension/web-sharing.js +1 -1
  66. package/esm/browser/i18n/en/assistant.d.ts +2 -0
  67. package/esm/browser/i18n/en/assistant.js +2 -0
  68. package/esm/browser/i18n/en/chat.d.ts +11 -0
  69. package/esm/browser/i18n/en/chat.js +13 -2
  70. package/esm/browser/i18n/en/common.d.ts +4 -0
  71. package/esm/browser/i18n/en/common.js +4 -0
  72. package/esm/browser/i18n/en/service.d.ts +5 -0
  73. package/esm/browser/i18n/en/service.js +5 -0
  74. package/esm/browser/i18n/en/settings.d.ts +6 -0
  75. package/esm/browser/i18n/en/settings.js +8 -2
  76. package/esm/browser/i18n/ja/assistant.js +2 -0
  77. package/esm/browser/i18n/ja/chat.js +13 -2
  78. package/esm/browser/i18n/ja/common.js +4 -0
  79. package/esm/browser/i18n/ja/service.js +5 -0
  80. package/esm/browser/i18n/ja/settings.js +10 -4
  81. package/esm/browser/i18n/locales.d.ts +29 -1
  82. package/esm/browser/i18n/messages.d.ts +28 -0
  83. package/esm/browser/i18n/zh/assistant.js +2 -0
  84. package/esm/browser/i18n/zh/chat.js +13 -2
  85. package/esm/browser/i18n/zh/common.js +4 -0
  86. package/esm/browser/i18n/zh/service.js +5 -0
  87. package/esm/browser/i18n/zh/settings.js +8 -2
  88. package/esm/browser/i18n/zh-tw/assistant.js +2 -0
  89. package/esm/browser/i18n/zh-tw/chat.js +13 -2
  90. package/esm/browser/i18n/zh-tw/common.js +4 -0
  91. package/esm/browser/i18n/zh-tw/service.js +5 -0
  92. package/esm/browser/i18n/zh-tw/settings.js +8 -2
  93. package/esm/browser/links/links.js +1 -1
  94. package/esm/browser/notices/session-notices.d.ts +4 -4
  95. package/esm/browser/notices/session-notices.js +3 -6
  96. package/esm/browser/partners/partners-util.d.ts +6 -0
  97. package/esm/browser/partners/partners-util.js +22 -0
  98. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  99. package/esm/browser/settings/agent-settings.d.ts +2 -0
  100. package/esm/browser/settings/agent-settings.js +2 -0
  101. package/esm/browser/settings/settings-protocol.d.ts +8 -0
  102. package/esm/browser/settings/settings-protocol.js +5 -0
  103. package/esm/browser/style/base.d.ts +1 -1
  104. package/esm/browser/style/base.js +3 -0
  105. package/esm/browser/style/chat-list.d.ts +1 -1
  106. package/esm/browser/style/chat-list.js +8 -3
  107. package/esm/browser/style/conversation-column.d.ts +1 -1
  108. package/esm/browser/style/conversation-column.js +6 -1
  109. package/esm/browser/style/conversation.d.ts +1 -1
  110. package/esm/browser/style/conversation.js +18 -0
  111. package/esm/browser/style/phone.d.ts +1 -1
  112. package/esm/browser/style/phone.js +2 -0
  113. package/esm/browser/util/composer.d.ts +18 -3
  114. package/esm/browser/util/composer.js +31 -5
  115. package/esm/browser/util/desktop.d.ts +8 -1
  116. package/esm/browser/util/desktop.js +10 -0
  117. package/esm/browser/util/image-shrink.d.ts +5 -1
  118. package/esm/browser/util/image-shrink.js +1 -1
  119. package/esm/browser/util/markdown.d.ts +3 -5
  120. package/esm/browser/util/markdown.js +5 -29
  121. package/esm/browser/util/process.js +2 -2
  122. package/lib/browser/assistant/assistant-role.d.ts +1 -1
  123. package/lib/browser/assistant/assistant-role.js +1 -1
  124. package/lib/browser/assistant/assistant-task-source.js +5 -0
  125. package/lib/browser/assistant/assistant-task-util.d.ts +1 -0
  126. package/lib/browser/assistant/assistant-task-util.js +8 -2
  127. package/lib/browser/assistant/assistant-view.js +4 -2
  128. package/lib/browser/cloud/cloud-sign-in.d.ts +26 -4
  129. package/lib/browser/cloud/cloud-sign-in.js +89 -19
  130. package/lib/browser/components/app-nav.d.ts +3 -1
  131. package/lib/browser/components/app-nav.js +2 -2
  132. package/lib/browser/components/app-view.js +16 -6
  133. package/lib/browser/components/asks-badge.d.ts +12 -0
  134. package/lib/browser/components/asks-badge.js +19 -1
  135. package/lib/browser/components/chat-list-row.d.ts +4 -1
  136. package/lib/browser/components/chat-list-row.js +7 -1
  137. package/lib/browser/components/chats-dot.d.ts +4 -1
  138. package/lib/browser/components/chats-dot.js +6 -2
  139. package/lib/browser/components/cloud-sign-in-view.d.ts +2 -1
  140. package/lib/browser/components/cloud-sign-in-view.js +28 -5
  141. package/lib/browser/components/composer-box-protocol.d.ts +5 -3
  142. package/lib/browser/components/composer-box.js +11 -11
  143. package/lib/browser/components/composer.d.ts +8 -1
  144. package/lib/browser/components/composer.js +56 -33
  145. package/lib/browser/components/host-view.d.ts +1 -1
  146. package/lib/browser/components/lightbox.d.ts +15 -1
  147. package/lib/browser/components/lightbox.js +15 -2
  148. package/lib/browser/components/link.js +8 -3
  149. package/lib/browser/components/markdown.d.ts +4 -2
  150. package/lib/browser/components/markdown.js +11 -2
  151. package/lib/browser/components/media.d.ts +6 -0
  152. package/lib/browser/components/media.js +10 -2
  153. package/lib/browser/components/message-images.d.ts +5 -0
  154. package/lib/browser/components/message-images.js +40 -4
  155. package/lib/browser/components/message-user.js +4 -2
  156. package/lib/browser/components/partner-row.js +4 -4
  157. package/lib/browser/components/phone-shell.d.ts +2 -0
  158. package/lib/browser/components/phone-shell.js +1 -1
  159. package/lib/browser/components/sending.d.ts +20 -0
  160. package/lib/browser/components/sending.js +63 -0
  161. package/lib/browser/components/session-view.js +4 -3
  162. package/lib/browser/components/settings-choices.js +1 -0
  163. package/lib/browser/components/settings-parts.js +26 -15
  164. package/lib/browser/components/share-dialog.js +3 -2
  165. package/lib/browser/components/share-item-sheet.js +1 -1
  166. package/lib/browser/components/share-sheet.d.ts +4 -2
  167. package/lib/browser/components/share-sheet.js +16 -2
  168. package/lib/browser/components/sign-in-accounts.js +7 -1
  169. package/lib/browser/components/unseen-drop.d.ts +2 -2
  170. package/lib/browser/components/unseen-drop.js +1 -1
  171. package/lib/browser/device/app-badge.d.ts +9 -0
  172. package/lib/browser/device/app-badge.js +31 -0
  173. package/lib/browser/device/code-scan.js +1 -1
  174. package/lib/browser/extension/web-api-code.d.ts +26 -0
  175. package/lib/browser/extension/web-api-components.d.ts +31 -0
  176. package/lib/browser/extension/web-api-menus.d.ts +15 -0
  177. package/lib/browser/extension/web-api-messages.d.ts +16 -0
  178. package/lib/browser/extension/web-api-messages.js +3 -0
  179. package/lib/browser/extension/web-api-partners.d.ts +16 -0
  180. package/lib/browser/extension/web-api-spec.js +1 -0
  181. package/lib/browser/extension/web-extension-api.d.ts +7 -13
  182. package/lib/browser/extension/web-extension-context.js +2 -0
  183. package/lib/browser/extension/web-session-notices.js +10 -1
  184. package/lib/browser/extension/web-share-ui.js +1 -0
  185. package/lib/browser/extension/web-share.js +3 -3
  186. package/lib/browser/extension/web-sharing.js +1 -1
  187. package/lib/browser/i18n/en/assistant.d.ts +2 -0
  188. package/lib/browser/i18n/en/assistant.js +2 -0
  189. package/lib/browser/i18n/en/chat.d.ts +11 -0
  190. package/lib/browser/i18n/en/chat.js +13 -2
  191. package/lib/browser/i18n/en/common.d.ts +4 -0
  192. package/lib/browser/i18n/en/common.js +4 -0
  193. package/lib/browser/i18n/en/service.d.ts +5 -0
  194. package/lib/browser/i18n/en/service.js +5 -0
  195. package/lib/browser/i18n/en/settings.d.ts +6 -0
  196. package/lib/browser/i18n/en/settings.js +8 -2
  197. package/lib/browser/i18n/ja/assistant.js +2 -0
  198. package/lib/browser/i18n/ja/chat.js +13 -2
  199. package/lib/browser/i18n/ja/common.js +4 -0
  200. package/lib/browser/i18n/ja/service.js +5 -0
  201. package/lib/browser/i18n/ja/settings.js +10 -4
  202. package/lib/browser/i18n/locales.d.ts +29 -1
  203. package/lib/browser/i18n/messages.d.ts +28 -0
  204. package/lib/browser/i18n/zh/assistant.js +2 -0
  205. package/lib/browser/i18n/zh/chat.js +13 -2
  206. package/lib/browser/i18n/zh/common.js +4 -0
  207. package/lib/browser/i18n/zh/service.js +5 -0
  208. package/lib/browser/i18n/zh/settings.js +8 -2
  209. package/lib/browser/i18n/zh-tw/assistant.js +2 -0
  210. package/lib/browser/i18n/zh-tw/chat.js +13 -2
  211. package/lib/browser/i18n/zh-tw/common.js +4 -0
  212. package/lib/browser/i18n/zh-tw/service.js +5 -0
  213. package/lib/browser/i18n/zh-tw/settings.js +8 -2
  214. package/lib/browser/links/links.js +1 -1
  215. package/lib/browser/notices/session-notices.d.ts +4 -4
  216. package/lib/browser/notices/session-notices.js +3 -6
  217. package/lib/browser/partners/partners-util.d.ts +6 -0
  218. package/lib/browser/partners/partners-util.js +22 -0
  219. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  220. package/lib/browser/settings/agent-settings.d.ts +2 -0
  221. package/lib/browser/settings/agent-settings.js +3 -1
  222. package/lib/browser/settings/settings-protocol.d.ts +8 -0
  223. package/lib/browser/settings/settings-protocol.js +6 -1
  224. package/lib/browser/style/base.d.ts +1 -1
  225. package/lib/browser/style/base.js +3 -0
  226. package/lib/browser/style/chat-list.d.ts +1 -1
  227. package/lib/browser/style/chat-list.js +8 -3
  228. package/lib/browser/style/conversation-column.d.ts +1 -1
  229. package/lib/browser/style/conversation-column.js +6 -1
  230. package/lib/browser/style/conversation.d.ts +1 -1
  231. package/lib/browser/style/conversation.js +18 -0
  232. package/lib/browser/style/phone.d.ts +1 -1
  233. package/lib/browser/style/phone.js +2 -0
  234. package/lib/browser/util/composer.d.ts +18 -3
  235. package/lib/browser/util/composer.js +31 -5
  236. package/lib/browser/util/desktop.d.ts +8 -1
  237. package/lib/browser/util/desktop.js +10 -0
  238. package/lib/browser/util/image-shrink.d.ts +5 -1
  239. package/lib/browser/util/image-shrink.js +1 -1
  240. package/lib/browser/util/markdown.d.ts +3 -5
  241. package/lib/browser/util/markdown.js +5 -29
  242. package/lib/browser/util/process.js +1 -1
  243. package/package.json +7 -7
  244. package/esm/browser/util/share-link.d.ts +0 -21
  245. package/esm/browser/util/share-link.js +0 -61
  246. package/lib/browser/util/share-link.d.ts +0 -22
  247. package/lib/browser/util/share-link.js +0 -64
@@ -1,3 +1,4 @@
1
+ import { LocalRefs } from '@celljs/ta-protocol/lib/common/local-refs';
1
2
  import { LinkUtil } from './link.js';
2
3
  export const CALLOUT_KINDS = ['note', 'tip', 'important', 'warning', 'caution'];
3
4
  export const MARKDOWN_TINTS = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'gray'];
@@ -7,7 +8,6 @@ const RULE = /^\s*([-*_])(\s*\1){2,}\s*$/;
7
8
  const BULLET = /^\s*[-*+]\s+(.*)$/;
8
9
  const NUMBERED = /^\s*\d+[.)]\s+(.*)$/;
9
10
  const TABLE_SEPARATOR = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
10
- const SCHEME = /^[a-z][a-z\d+.-]*:/i;
11
11
  /** Data URLs of media, which show without a request; scripts in an SVG image do not run. */
12
12
  const DATA_MEDIA = /^data:(image|video|audio)\/[\w.+-]+[;,]/i;
13
13
  const EXTENSIONS = {
@@ -379,7 +379,7 @@ export var MarkdownUtil;
379
379
  if (link) {
380
380
  const href = (_d = link[2]) !== null && _d !== void 0 ? _d : link[3];
381
381
  const target = LinkUtil.parse(href);
382
- if ((target === null || target === void 0 ? void 0 : target.type) === 'path' && !target.selection && localPath(href) !== undefined && media(href, false)) {
382
+ if ((target === null || target === void 0 ? void 0 : target.type) === 'path' && !target.selection && MarkdownUtil.localPath(href) !== undefined && media(href, false)) {
383
383
  // A link to a picture or a video of the workspace shows it.
384
384
  push({ type: 'media', src: href, alt: link[1] });
385
385
  }
@@ -429,39 +429,15 @@ export var MarkdownUtil;
429
429
  if (data) {
430
430
  return data[1].toLowerCase();
431
431
  }
432
- if (!/^https?:/i.test(src) && localPath(src) === undefined) {
432
+ if (!/^https?:/i.test(src) && MarkdownUtil.localPath(src) === undefined) {
433
433
  return undefined;
434
434
  }
435
435
  const extension = (_a = /\.(\w+)$/.exec(src.split(/[?#]/)[0])) === null || _a === void 0 ? void 0 : _a[1].toLowerCase();
436
436
  return (extension && EXTENSIONS[extension]) || (guess ? 'image' : undefined);
437
437
  }
438
438
  MarkdownUtil.media = media;
439
- /**
440
- * The path of a file a target names: a relative or absolute path, or a `file:` URL of this machine;
441
- * undefined for URLs, which the page loads as they are.
442
- */
443
- function localPath(src) {
444
- let path = src;
445
- if (/^file:/i.test(src)) {
446
- const url = /^file:\/\/(?:localhost)?(\/[^?#]*)/i.exec(src);
447
- if (!url) {
448
- return undefined;
449
- }
450
- path = url[1];
451
- }
452
- else if (SCHEME.test(src) || src.startsWith('//')) {
453
- return undefined;
454
- }
455
- path = path.split(/[?#]/)[0];
456
- try {
457
- path = decodeURI(path);
458
- }
459
- catch (_a) {
460
- // Kept as written.
461
- }
462
- return path || undefined;
463
- }
464
- MarkdownUtil.localPath = localPath;
439
+ /** The path of a file a target names (LocalRefs.localPath); undefined for URLs, which the page loads as they are. */
440
+ MarkdownUtil.localPath = LocalRefs.localPath;
465
441
  /** `$$` or `\\[` starting at line `start`: its block and the line it ends on. */
466
442
  function mathBlock(lines, start) {
467
443
  const first = lines[start].trim();
@@ -1,4 +1,4 @@
1
- import { TA_RESUME_MESSAGE, TaAgentSummary, TaMessageSource, TaPictureNote, TaSaid } from '@celljs/ta-protocol';
1
+ import { TA_RESUME_MESSAGE, TaAgentSummary, TaMessageContext, TaMessageSource, TaPictureNote, TaSaid, TaToolLeak } from '@celljs/ta-protocol';
2
2
  import { MessageUtil } from './message.js';
3
3
  /** While the agent works, only the latest steps show; the earlier ones fold into one row. */
4
4
  export const VISIBLE_STEPS = 8;
@@ -195,7 +195,7 @@ export var ProcessUtil;
195
195
  steps.push({ kind: 'summary', key, text: summary });
196
196
  return;
197
197
  }
198
- const { said, told } = TaPictureNote.take(block.text);
198
+ const { said, told } = TaPictureNote.take(TaMessageContext.echoed(TaToolLeak.strip(block.text)));
199
199
  if (told.size) {
200
200
  steps.push({ kind: 'pictures', key: `${key}.p`, told: [...told] });
201
201
  }
@@ -1,6 +1,6 @@
1
1
  import { type TaDelegateLevel } from '@celljs/ta-protocol';
2
2
  /** The role of ta in its conversation with the user. */
3
- export declare const ASSISTANT_PROMPT = "You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.\n- To hand out work, call start_task with a short title and complete, self-contained instructions: a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.\n- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.\n- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.\n- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as \"bun test\", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.\n- When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.\n- When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.\n- What the user says is often spoken and transcribed, with wrong words and sentences cut off: read it for what they mean, with what was said before. A message from a call ([ta:from @celljs/ta-call \u2026]) is the user's own request, retold by the call: \"the user wants X\" means they ask you for X.\n- When they ask for something to be done (\"\u5E2E\u6211\u5F04\", \"\u5E2E\u6211\u6539\", \"\u6362\u4E00\u4E2A\", \"\u88C5\u4E0A\", \"\u6253\u5F00\u2026\"), that is their go: start it now, in this turn, then say in one sentence what you started, with asked: true. Do not ask first whether to start, nor offer to, nor stop at saying what you would do.\n- A short go (\"\u6765\", \"\u597D\", \"\u5F00\u59CB\", \"\u884C\", \"\u55EF\") answers what you said last: do what you proposed, or the most likely of what waits for them (the step they usually take next, as installing what was just changed, before what needs their taste), with asked: true, and say in one sentence which you took. Ask only when two are as likely, and then one yes-or-no question with your best guess (\"\u88C5\u5230\u624B\u673A\u4E0A\uFF0C\u5BF9\u5427\uFF1F\"), never a card of choices.\n- What a task can find out (which voices a service has, where a setting is, which file) is no question for the user: the task finds it, picks what fits, does it and tries it. A taste they did not say (a man's or a woman's voice) is yours to pick: say what you picked, so they can change it.\n- Instructions of a task say to get it done and checked: the result the user wants, how the task shows it works (it tries it, as the user would), and that it asks them only before what is risky or cannot be undone.\n- What the user asks of their screen (open a page, look at what is wrong, press something) is done on the page in front of them, on the device they use, a phone's on a phone: do it yourself, with app_look, app_go and app_do; a message from a call says which device. Never the computer's desktop (screenshots, tools that drive the computer) unless they name the computer.\n- When you cannot tell what they want at all (words that ask for nothing, a sentence cut off), say in one short sentence what you heard and ask them to say it again; never answer nothing.\n- Ask first only before what is risky or cannot be undone (deleting, publishing, sending or paying for them) that they did not clearly ask for.\n- Your replies are read aloud: short plain sentences, no tables, no code unless asked. Short is not vague: say what you started, picked or found. Reply in the user's language.";
3
+ export declare const ASSISTANT_PROMPT = "You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.\n- To hand out work, call start_task with a short title and complete, self-contained instructions (its two required fields, named title and instructions): a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.\n- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.\n- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.\n- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as \"bun test\", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.\n- When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.\n- When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.\n- What the user says is often spoken and transcribed, with wrong words and sentences cut off: read it for what they mean, with what was said before. A message from a call ([ta:from @celljs/ta-call \u2026]) is the user's own request, retold by the call: \"the user wants X\" means they ask you for X.\n- When they ask for something to be done (\"\u5E2E\u6211\u5F04\", \"\u5E2E\u6211\u6539\", \"\u6362\u4E00\u4E2A\", \"\u88C5\u4E0A\", \"\u6253\u5F00\u2026\"), that is their go: start it now, in this turn, then say in one sentence what you started, with asked: true. Do not ask first whether to start, nor offer to, nor stop at saying what you would do.\n- A short go (\"\u6765\", \"\u597D\", \"\u5F00\u59CB\", \"\u884C\", \"\u55EF\") answers what you said last: do what you proposed, or the most likely of what waits for them (the step they usually take next, as installing what was just changed, before what needs their taste), with asked: true, and say in one sentence which you took. Ask only when two are as likely, and then one yes-or-no question with your best guess (\"\u88C5\u5230\u624B\u673A\u4E0A\uFF0C\u5BF9\u5427\uFF1F\"), never a card of choices.\n- What a task can find out (which voices a service has, where a setting is, which file) is no question for the user: the task finds it, picks what fits, does it and tries it. A taste they did not say (a man's or a woman's voice) is yours to pick: say what you picked, so they can change it.\n- Instructions of a task say to get it done and checked: the result the user wants, how the task shows it works (it tries it, as the user would), and that it asks them only before what is risky or cannot be undone.\n- What the user asks of their screen (open a page, look at what is wrong, press something) is done on the page in front of them, on the device they use, a phone's on a phone: do it yourself, with app_look, app_go and app_do; a message from a call says which device. Never the computer's desktop (screenshots, tools that drive the computer) unless they name the computer.\n- When you cannot tell what they want at all (words that ask for nothing, a sentence cut off), say in one short sentence what you heard and ask them to say it again; never answer nothing.\n- Ask first only before what is risky or cannot be undone (deleting, publishing, sending or paying for them) that they did not clearly ask for.\n- Your replies are read aloud: short plain sentences, no tables, no code unless asked. Short is not vague: say what you started, picked or found. Reply in the user's language.";
4
4
  /**
5
5
  * In the role while the user wants to be asked first (Settings.confirmTasks): of what the double starts of its own
6
6
  * accord only, never twice (docs/design/ta-double.md, 听懂与派活). The team tools of ta-channels read the same words in the
@@ -5,7 +5,7 @@ exports.assistantRole = assistantRole;
5
5
  const ta_protocol_1 = require("@celljs/ta-protocol");
6
6
  /** The role of ta in its conversation with the user. */
7
7
  exports.ASSISTANT_PROMPT = `You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.
8
- - To hand out work, call start_task with a short title and complete, self-contained instructions: a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.
8
+ - To hand out work, call start_task with a short title and complete, self-contained instructions (its two required fields, named title and instructions): a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.
9
9
  - A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.
10
10
  - When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.
11
11
  - Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as "bun test", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.
@@ -18,6 +18,11 @@ function activity(task, state, t) {
18
18
  if (task.paused && task.status !== 'running') {
19
19
  return t('ta.task.paused');
20
20
  }
21
+ // Not done because its reply came to nothing (filtered, empty): why, in the user's language.
22
+ const deadEnd = task.status === 'failed' ? ta_protocol_1.TaDeadEnd.describedKind(task.result) : undefined;
23
+ if (deadEnd) {
24
+ return t(deadEnd === 'empty' ? 'ta.task.deadEndEmpty' : 'ta.task.deadEndFiltered');
25
+ }
21
26
  return task.status === 'running' ? t('ta.task.running') : ta_protocol_1.TaSaid.line(said !== null && said !== void 0 ? said : '', { chars: 80 }) || t(`ta.task.${task.status}`);
22
27
  }
23
28
  /** How a task came out of a check: its own verdict for a check that ended, else the verdict of the check of it. */
@@ -41,6 +41,7 @@ export declare namespace AssistantTaskUtil {
41
41
  timestamp?: number;
42
42
  stopReason?: string;
43
43
  errorMessage?: string;
44
+ content?: unknown;
44
45
  } | undefined;
45
46
  /** How the run of a task's session ended (ended), and the id of the message that tells the double, the same in every page. */
46
47
  function outcome(state: SessionState): {
@@ -106,9 +106,12 @@ var AssistantTaskUtil;
106
106
  var _a, _b, _c;
107
107
  const last = lastAnswer(state.messages);
108
108
  const reason = message_1.MessageUtil.stopReason(last);
109
+ // A reply that came to nothing (filtered, refused, empty) is no answer: not done, and its words are not the result.
110
+ const deadEnd = ta_protocol_1.TaDeadEnd.kind({ role: 'assistant', ...last });
109
111
  // Its last answer asked for a tool, whose result never came: the run was cut, not done.
110
- const status = state.closed || reason === 'aborted' || reason === 'toolUse' ? 'stopped' : reason === 'error' ? 'failed' : 'done';
111
- const result = (_b = (_a = (status === 'failed' ? last === null || last === void 0 ? void 0 : last.errorMessage : undefined)) !== null && _a !== void 0 ? _a : lastWords(state.messages)) !== null && _b !== void 0 ? _b : '';
112
+ const status = state.closed || reason === 'aborted' || reason === 'toolUse' ? 'stopped' : reason === 'error' || deadEnd ? 'failed' : 'done';
113
+ const failure = deadEnd ? ta_protocol_1.TaDeadEnd.describe(deadEnd, last === null || last === void 0 ? void 0 : last.errorMessage) : last === null || last === void 0 ? void 0 : last.errorMessage;
114
+ const result = (_b = (_a = (status === 'failed' ? failure : undefined)) !== null && _a !== void 0 ? _a : lastWords(state.messages)) !== null && _b !== void 0 ? _b : '';
112
115
  return { status, result, endedAt: state.closed ? undefined : last === null || last === void 0 ? void 0 : last.timestamp, key: `${status}:${(_c = last === null || last === void 0 ? void 0 : last.timestamp) !== null && _c !== void 0 ? _c : 0}` };
113
116
  }
114
117
  AssistantTaskUtil.outcome = outcome;
@@ -122,6 +125,9 @@ var AssistantTaskUtil;
122
125
  function updateNote(task) {
123
126
  var _a, _b;
124
127
  const lines = [((_a = task.result) !== null && _a !== void 0 ? _a : '').slice(0, RESULT_CHARS)];
128
+ if (task.status === 'failed' && ta_protocol_1.TaDeadEnd.described(task.result)) {
129
+ lines.push('Do not start it again on your own: tell the user it is not done and why, and let them decide.');
130
+ }
125
131
  if (task.paused) {
126
132
  lines.push('The user paused it, with the other tasks that ran: leave it until they resume it.');
127
133
  }
@@ -63,6 +63,7 @@ const workbench_toggle_1 = require("../components/workbench-toggle");
63
63
  const drafts_protocol_1 = require("../drafts/drafts-protocol");
64
64
  const hooks_1 = require("../hooks");
65
65
  const use_t_1 = require("../i18n/use-t");
66
+ const agent_settings_1 = require("../settings/agent-settings");
66
67
  const message_1 = require("../util/message");
67
68
  const assistant_hooks_1 = require("./assistant-hooks");
68
69
  const assistant_state_1 = require("./assistant-state");
@@ -137,7 +138,8 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
137
138
  const [, notices] = (0, hooks_1.useNotices)();
138
139
  const spoken = React.useRef(undefined);
139
140
  const box = React.useRef(null);
140
- const { speak, speakTalk, confirmTasks, delegate, voice } = settingsState.settings;
141
+ const { speak, speakTalk, confirmTasks, delegate, voice, sendWhileWorking } = settingsState.settings;
142
+ const [, extensions] = (0, hooks_1.useWebExtensions)();
141
143
  const [name] = (0, hooks_1.usePersisted)(assistant_state_1.ASSISTANT_NAME_STATE);
142
144
  const attentions = [
143
145
  ...state.pendingUi.map(request => ({ source: 'ta', store, request })),
@@ -362,7 +364,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
362
364
  React.createElement(connection_bar_1.ConnectionBanner, null),
363
365
  addons.above,
364
366
  React.createElement(voice_call_bar_1.CallBar, { state: callState, call: call }),
365
- React.createElement(composer_1.Composer, { above: React.createElement(phone_hint_1.PhoneHint, null), ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, compacting: !!state.compacting, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onStopTimed: stopTimed, onError: fail, after: speaking ? React.createElement(voice_button_1.SpeakingButton, { onStop: hush }) : undefined, voiceSends: true, recentShots: settingsState.settings.recentShots, talkPlace: "double", draft: drafts_protocol_1.DraftPlaces.DOUBLE, onTalkSent: () => {
367
+ React.createElement(composer_1.Composer, { above: React.createElement(phone_hint_1.PhoneHint, null), ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, compacting: !!state.compacting, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onStopTimed: stopTimed, onError: fail, after: speaking ? React.createElement(voice_button_1.SpeakingButton, { onStop: hush }) : undefined, voiceSends: true, recentShots: settingsState.settings.recentShots, sendWhileWorking: sendWhileWorking, onQueueSettings: () => extensions.openSettings(agent_settings_1.QUEUE_SETTINGS), talkPlace: "double", draft: drafts_protocol_1.DraftPlaces.DOUBLE, onTalkSent: () => {
366
368
  aloud.current = speakTalk;
367
369
  }, onTalkCall: voice_1.Voice.canSpeak() && voice_1.Voice.canListen() && !callState.active ? (0, voice_call_bar_1.talkCall)(call) : undefined, talkCalls: talkCalls, onListening: on => {
368
370
  setListening(on);
@@ -1,4 +1,4 @@
1
- import { TaDeploymentUtil, type TaDeviceSignIn, type TaDeviceSignInState, type TaDistribution, type TaSignInProvider } from '@celljs/ta-protocol';
1
+ import { TaDeploymentUtil, type TaDeviceSignIn, type TaDeviceSignInFailure, type TaDeviceSignInState, type TaDistribution, type TaSignInProvider } from '@celljs/ta-protocol';
2
2
  import type { Credential } from '../workbench-protocol';
3
3
  /** Why signing in to Ta in the cloud stopped: the address answers no gateway, does not answer, or the code ran out. */
4
4
  export declare class CloudSignInError extends Error {
@@ -12,7 +12,15 @@ export interface CloudSignInProgress {
12
12
  waiting?: string;
13
13
  /** The browser went straight to a way to sign in, no code to check there (CloudSignIn's `provider`). */
14
14
  direct?: true;
15
+ /** The sign-in there did not go through (TaDeviceSignInState `failed`): the user starts it again from here. */
16
+ failed?: TaDeviceSignInFailure;
17
+ /** The code ran out, or the gateway lost it, and a new one is ready: the browser to be opened again. */
18
+ renewed?: true;
19
+ /** The gateway has not answered for a while (restarting, the network gone): asked on, and said so. */
20
+ offline?: true;
15
21
  }
22
+ /** How long the gateway may not answer the polls before the sign-in says it is reconnecting. */
23
+ export declare const OFFLINE_MS = 6000;
16
24
  /**
17
25
  * Signing this device in to Ta in the cloud of a deployment, with an account (docs/design/ta-deploy.md 8.1): no code to
18
26
  * scan, no token to paste. The gateway of the address gives a code (TA_DEVICE_SIGN_IN_PATH), the user signs in in a
@@ -61,12 +69,14 @@ export declare namespace CloudSignInUtil {
61
69
  /** Where the browser signs in for the device of `code` with `provider` at once, as RFC 8628's verification_uri_complete. */
62
70
  function direct(gateway: string, provider: string, code: string): string;
63
71
  function start(gateway: string, name: string, fetcher?: typeof fetch): Promise<TaDeviceSignIn>;
64
- /** One poll: a network that drops for a moment is `pending`, as nothing changed. */
65
- function poll(gateway: string, device: string, fetcher?: typeof fetch): Promise<TaDeviceSignInState>;
72
+ /** One poll; undefined when the gateway did not answer (the network, a restart): nothing changed, asked again. */
73
+ function poll(gateway: string, device: string, fetcher?: typeof fetch): Promise<TaDeviceSignInState | undefined>;
66
74
  }
67
75
  /**
68
76
  * One sign-in to Ta in the cloud, from asking for the code until the token: it polls until then, or until stopped. What
69
- * it shows goes to `onProgress`; the browser is opened by `open`.
77
+ * it shows goes to `onProgress`; the browser is opened by `open`. It does not end on what the user can get past from
78
+ * here: a sign-in that failed at the provider, the gateway away for a while, a code that ran out (`renews`) each show,
79
+ * and the browser opened again (`reopen`) takes it on (docs/design/ta-deploy.md 8.5).
70
80
  */
71
81
  export declare class CloudSignIn {
72
82
  protected readonly options: {
@@ -77,11 +87,16 @@ export declare class CloudSignIn {
77
87
  onProgress(progress: CloudSignInProgress): void;
78
88
  /** A way to sign in of the gateway the browser goes to at once, rather than the page that shows the code. */
79
89
  provider?: string;
90
+ /** How many times a code that ran out is quietly replaced by a new one, rather than failing; none by default. */
91
+ renews?: number;
80
92
  fetcher?: typeof fetch;
81
93
  };
82
94
  protected stopped: boolean;
83
95
  protected timer?: ReturnType<typeof setTimeout>;
84
96
  protected wake?: () => void;
97
+ protected progress?: CloudSignInProgress;
98
+ /** Opened again after it failed: what the gateway said before is old until it says something else. */
99
+ protected reopened: boolean;
85
100
  constructor(options: {
86
101
  gateway: string;
87
102
  /** What the sign-ins of the account list this device as: its user agent, as a browser's. */
@@ -90,10 +105,17 @@ export declare class CloudSignIn {
90
105
  onProgress(progress: CloudSignInProgress): void;
91
106
  /** A way to sign in of the gateway the browser goes to at once, rather than the page that shows the code. */
92
107
  provider?: string;
108
+ /** How many times a code that ran out is quietly replaced by a new one, rather than failing; none by default. */
109
+ renews?: number;
93
110
  fetcher?: typeof fetch;
94
111
  });
95
112
  /** The credential of the gateway once signed in; undefined when stopped. */
96
113
  run(): Promise<Credential | undefined>;
114
+ protected wait(started: TaDeviceSignIn): Promise<Credential | undefined | 'expired'>;
115
+ /** Tells `onProgress` once of what changed, not at every poll. */
116
+ protected show(change: Partial<CloudSignInProgress>): void;
117
+ /** Opens the browser where the user signs in again, the sign-in there started anew; at a tap of the user. */
118
+ reopen(): void;
97
119
  /** Polls now rather than at the end of the wait: back from the browser. */
98
120
  poke(): void;
99
121
  stop(): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CloudSignIn = exports.CloudSignInUtil = exports.CloudSignInError = void 0;
3
+ exports.CloudSignIn = exports.CloudSignInUtil = exports.OFFLINE_MS = exports.CloudSignInError = void 0;
4
4
  const ta_protocol_1 = require("@celljs/ta-protocol");
5
5
  /** Why signing in to Ta in the cloud stopped: the address answers no gateway, does not answer, or the code ran out. */
6
6
  class CloudSignInError extends Error {
@@ -10,6 +10,8 @@ class CloudSignInError extends Error {
10
10
  }
11
11
  }
12
12
  exports.CloudSignInError = CloudSignInError;
13
+ /** How long the gateway may not answer the polls before the sign-in says it is reconnecting. */
14
+ exports.OFFLINE_MS = 6000;
13
15
  /**
14
16
  * Signing this device in to Ta in the cloud of a deployment, with an account (docs/design/ta-deploy.md 8.1): no code to
15
17
  * scan, no token to paste. The gateway of the address gives a code (TA_DEVICE_SIGN_IN_PATH), the user signs in in a
@@ -166,7 +168,7 @@ var CloudSignInUtil;
166
168
  return (await response.json());
167
169
  }
168
170
  CloudSignInUtil.start = start;
169
- /** One poll: a network that drops for a moment is `pending`, as nothing changed. */
171
+ /** One poll; undefined when the gateway did not answer (the network, a restart): nothing changed, asked again. */
170
172
  async function poll(gateway, device, fetcher = fetch) {
171
173
  try {
172
174
  const response = await fetcher(`${gateway}${ta_protocol_1.TA_DEVICE_SIGN_IN_PATH}/poll`, {
@@ -174,36 +176,60 @@ var CloudSignInUtil;
174
176
  body: JSON.stringify({ device }),
175
177
  signal: AbortSignal.timeout(CloudSignInUtil.GATEWAY_MS),
176
178
  });
177
- return response.ok ? (await response.json()) : { status: 'pending' };
179
+ return response.ok ? (await response.json()) : undefined;
178
180
  }
179
181
  catch (_a) {
180
- return { status: 'pending' };
182
+ return undefined;
181
183
  }
182
184
  }
183
185
  CloudSignInUtil.poll = poll;
184
186
  })(CloudSignInUtil || (exports.CloudSignInUtil = CloudSignInUtil = {}));
185
187
  /**
186
188
  * One sign-in to Ta in the cloud, from asking for the code until the token: it polls until then, or until stopped. What
187
- * it shows goes to `onProgress`; the browser is opened by `open`.
189
+ * it shows goes to `onProgress`; the browser is opened by `open`. It does not end on what the user can get past from
190
+ * here: a sign-in that failed at the provider, the gateway away for a while, a code that ran out (`renews`) each show,
191
+ * and the browser opened again (`reopen`) takes it on (docs/design/ta-deploy.md 8.5).
188
192
  */
189
193
  class CloudSignIn {
190
194
  constructor(options) {
191
195
  this.options = options;
192
196
  this.stopped = false;
197
+ /** Opened again after it failed: what the gateway said before is old until it says something else. */
198
+ this.reopened = false;
193
199
  }
194
200
  /** The credential of the gateway once signed in; undefined when stopped. */
195
201
  async run() {
196
- const { gateway, fetcher } = this.options;
197
- const started = await CloudSignInUtil.start(gateway, this.options.name, fetcher);
198
- if (this.stopped) {
199
- return undefined;
202
+ var _a;
203
+ const { gateway, fetcher, provider } = this.options;
204
+ for (let renewed = 0;; renewed++) {
205
+ if (renewed > ((_a = this.options.renews) !== null && _a !== void 0 ? _a : 0)) {
206
+ throw new CloudSignInError('expired');
207
+ }
208
+ const started = await CloudSignInUtil.start(gateway, this.options.name, fetcher);
209
+ if (this.stopped) {
210
+ return undefined;
211
+ }
212
+ this.progress = {
213
+ ...(provider
214
+ ? { code: started.code, url: CloudSignInUtil.direct(gateway, provider, started.code), direct: true }
215
+ : { code: started.code, url: started.url }),
216
+ ...(renewed > 0 ? { renewed: true } : {}),
217
+ };
218
+ this.reopened = false;
219
+ this.options.onProgress({ ...this.progress });
220
+ // A new code is not opened unasked: the user may be in the browser still, or away.
221
+ if (renewed === 0) {
222
+ this.options.open(this.progress.url);
223
+ }
224
+ const result = await this.wait(started);
225
+ if (result !== 'expired') {
226
+ return result;
227
+ }
200
228
  }
201
- const { provider } = this.options;
202
- const progress = provider
203
- ? { code: started.code, url: CloudSignInUtil.direct(gateway, provider, started.code), direct: true }
204
- : { code: started.code, url: started.url };
205
- this.options.onProgress({ ...progress });
206
- this.options.open(progress.url);
229
+ }
230
+ async wait(started) {
231
+ const { gateway, fetcher } = this.options;
232
+ let silentSince;
207
233
  while (!this.stopped) {
208
234
  await new Promise(resolve => {
209
235
  this.wake = resolve;
@@ -216,19 +242,63 @@ class CloudSignIn {
216
242
  if (this.stopped) {
217
243
  return undefined;
218
244
  }
245
+ if (!state) {
246
+ silentSince !== null && silentSince !== void 0 ? silentSince : (silentSince = Date.now());
247
+ if (Date.now() - silentSince >= exports.OFFLINE_MS) {
248
+ this.show({ offline: true });
249
+ }
250
+ continue;
251
+ }
252
+ silentSince = undefined;
253
+ this.show({ offline: undefined });
219
254
  if (state.status === 'done') {
220
255
  return { token: state.token, url: gateway };
221
256
  }
222
257
  if (state.status === 'expired') {
223
- throw new CloudSignInError('expired');
258
+ return 'expired';
224
259
  }
225
- if (state.status === 'waiting' && progress.waiting !== state.account) {
226
- progress.waiting = state.account;
227
- this.options.onProgress({ ...progress });
260
+ if (state.status === 'failed') {
261
+ if (!this.reopened) {
262
+ this.show({ failed: state.reason });
263
+ }
264
+ continue;
228
265
  }
266
+ this.reopened = false;
267
+ this.show({ failed: undefined, ...(state.status === 'waiting' ? { waiting: state.account } : {}) });
229
268
  }
230
269
  return undefined;
231
270
  }
271
+ /** Tells `onProgress` once of what changed, not at every poll. */
272
+ show(change) {
273
+ const progress = this.progress;
274
+ if (!progress) {
275
+ return;
276
+ }
277
+ let changed = false;
278
+ for (const [key, value] of Object.entries(change)) {
279
+ if (progress[key] !== value) {
280
+ changed = true;
281
+ if (value === undefined) {
282
+ delete progress[key];
283
+ }
284
+ else {
285
+ progress[key] = value;
286
+ }
287
+ }
288
+ }
289
+ if (changed) {
290
+ this.options.onProgress({ ...progress });
291
+ }
292
+ }
293
+ /** Opens the browser where the user signs in again, the sign-in there started anew; at a tap of the user. */
294
+ reopen() {
295
+ if (!this.progress) {
296
+ return;
297
+ }
298
+ this.reopened = Boolean(this.progress.failed);
299
+ this.show({ failed: undefined, renewed: undefined });
300
+ this.options.open(this.progress.url);
301
+ }
232
302
  /** Polls now rather than at the end of the wait: back from the browser. */
233
303
  poke() {
234
304
  var _a;
@@ -35,6 +35,8 @@ export interface RailProps {
35
35
  onDismissAsks?(): void;
36
36
  /** A chat said something unseen: the amber dot on the double's entry, as on a phone's first tab; dragged away, all seen. */
37
37
  onSeeAll?(): void;
38
+ /** How many messages people sent the user has not seen: a red number on the double's entry, before all else; dragged away, all seen (onSeeAll). */
39
+ count?: number;
38
40
  /** A double click where nothing is: the sidebar and the workbench both go, or both come back. */
39
41
  onToggleSides?(): void;
40
42
  }
@@ -43,7 +45,7 @@ export interface RailProps {
43
45
  * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
44
46
  * Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
45
47
  */
46
- export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, onToggleSides, }: RailProps): React.JSX.Element;
48
+ export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, count, onToggleSides, }: RailProps): React.JSX.Element;
47
49
  /** A sidebar view of a web extension, under its title or its own top bar. */
48
50
  export declare function SidebarView({ view }: {
49
51
  view: WebViewEntry;
@@ -90,7 +90,7 @@ function RailItem({ label, place, active, onClick, onContextMenu, onPointerDown,
90
90
  * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
91
91
  * Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
92
92
  */
93
- function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, onToggleSides, }) {
93
+ function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, count, onToggleSides, }) {
94
94
  const t = (0, use_t_1.useT)();
95
95
  const [{ server }] = (0, hooks_1.useWorkbench)();
96
96
  const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
@@ -116,7 +116,7 @@ function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, on
116
116
  lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, place: `list:${entry.id}`, active: list === entry.id, onClick: () => onList(entry.id), ...held((0, nav_places_1.entryHold)(entry.id, entry.double, holds)) },
117
117
  entry.double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 }),
118
118
  entry.double &&
119
- (asks ? (React.createElement(asks_badge_1.AsksBadge, { count: asks, onDismiss: onDismissAsks })) : (onSeeAll && React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: onSeeAll, className: "ta-tabbar-dot ta-rail-dot" })))))),
119
+ (count ? (React.createElement(asks_badge_1.PeopleBadge, { count: count, onDismiss: onSeeAll })) : asks ? (React.createElement(asks_badge_1.AsksBadge, { count: asks, onDismiss: onDismissAsks })) : (onSeeAll && React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: onSeeAll, className: "ta-tabbar-dot ta-rail-dot" })))))),
120
120
  (navigation.nav.length > 0 || discover) && React.createElement("hr", { className: "ta-rail-divider" }),
121
121
  navigation.nav.map(view => item(view)),
122
122
  discover && (React.createElement(RailItem, { label: t('ta.discover'), place: "discover", active: !settingsShown && current === nav_places_1.DISCOVER, onClick: onDiscover, onContextMenu: event => openMenu(event, [settingsItem]) },
@@ -38,6 +38,7 @@ const lucide_react_1 = require("lucide-react");
38
38
  const React = __importStar(require("react"));
39
39
  const assistant_chat_list_1 = require("../assistant/assistant-chat-list");
40
40
  const chat_view_1 = require("../chat/chat-view");
41
+ const app_badge_1 = require("../device/app-badge");
41
42
  const web_extension_protocol_1 = require("../extension/web-extension-protocol");
42
43
  const hooks_1 = require("../hooks");
43
44
  const notices_1 = require("../notices/notices");
@@ -46,6 +47,7 @@ const app_nav_1 = require("./app-nav");
46
47
  const app_shell_hooks_1 = require("./app-shell-hooks");
47
48
  const app_shell_state_1 = require("./app-shell-state");
48
49
  const app_update_view_1 = require("./app-update-view");
50
+ const asks_badge_1 = require("./asks-badge");
49
51
  const auth_view_1 = require("./auth-view");
50
52
  const board_1 = require("./board");
51
53
  const chat_asks_1 = require("./chat-asks");
@@ -125,7 +127,7 @@ function AppShell() {
125
127
  // The chats' tab, and the double's on the rail, have the amber dot while a row of the double's list has one, as a
126
128
  // messenger's; what waits for the user to decide is counted there until answered.
127
129
  (0, first_steps_1.useFirstSteps)(workbench.status === 'online', workbench.sessions, workbench.saved);
128
- const { listed: listedChats, unseen: chatsUnseen } = (0, chats_dot_1.useChatsDot)({
130
+ const { listed: listedChats, unseen: chatsUnseen, count: chatsCount, seePeople, } = (0, chats_dot_1.useChatsDot)({
129
131
  sessions: workbench.sessions,
130
132
  saved: workbench.saved,
131
133
  removed: removedChats,
@@ -137,6 +139,11 @@ function AppShell() {
137
139
  extensions,
138
140
  host,
139
141
  });
142
+ // As a messenger's: the messages of people unseen on the title of the tab and on the icon of Ta Desktop.
143
+ React.useEffect(() => {
144
+ document.title = chatsCount ? `(${asks_badge_1.CountUtil.text(chatsCount)}) Ta` : 'Ta';
145
+ app_badge_1.AppBadge.set(chatsCount);
146
+ }, [chatsCount]);
140
147
  if (workbench.status === 'signed-out') {
141
148
  return workbench.leaving ? React.createElement("div", { className: "ta-signin" }) : React.createElement(workbench_view_1.SignIn, { error: workbench.error });
142
149
  }
@@ -276,8 +283,11 @@ function AppShell() {
276
283
  picked();
277
284
  },
278
285
  });
279
- // Dragged away, the dot of the chats: all seen.
280
- const seeAllChats = () => state.set(chat_seen_1.SEEN_CHATS, chat_seen_1.ChatSeenUtil.seeAll(state.get(chat_seen_1.SEEN_CHATS), listedChats, Date.now()));
286
+ // Dragged away, the dot or the red number of the chats: all seen, what people said too, as WeChat's.
287
+ const seeAllChats = () => {
288
+ state.set(chat_seen_1.SEEN_CHATS, chat_seen_1.ChatSeenUtil.seeAll(state.get(chat_seen_1.SEEN_CHATS), listedChats, Date.now()));
289
+ seePeople();
290
+ };
281
291
  // Dragged away, the count of the double: what the conversations ask let go; the double's own tasks wait on.
282
292
  const letGoAllAsks = () => setLetGoAsks(before => chat_asks_1.ChatAskUtil.letGoAll(before, listedChats));
283
293
  const tabs = phone
@@ -287,8 +297,8 @@ function AppShell() {
287
297
  fold: t('ta.nav.fold'),
288
298
  settings: { label: t('ta.nav.settings'), run: () => openSettings('navigation') },
289
299
  holds,
290
- }).map(item => item.id === '' && chatsUnseen
291
- ? { ...item, unseen: true, onSeeAll: seeAllChats }
300
+ }).map(item => item.id === '' && (chatsUnseen || chatsCount)
301
+ ? { ...item, unseen: true, count: chatsCount, onSeeAll: seeAllChats }
292
302
  : item.double && deciding
293
303
  ? { ...item, asks: deciding, onSeeAll: letGoAllAsks }
294
304
  : item)
@@ -323,7 +333,7 @@ function AppShell() {
323
333
  setSettings(undefined);
324
334
  setNavOpen(false);
325
335
  setTabPage('discover');
326
- }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds, asks: deciding, onDismissAsks: letGoAllAsks, onSeeAll: chatsUnseen ? seeAllChats : undefined, onToggleSides: toggleSides }),
336
+ }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds, asks: deciding, onDismissAsks: letGoAllAsks, onSeeAll: chatsUnseen || chatsCount ? seeAllChats : undefined, count: chatsCount, onToggleSides: toggleSides }),
327
337
  sideShown && (React.createElement(workbench_toggle_1.SidebarPane, { style: (0, split_pane_1.paneStyle)(sidebar) },
328
338
  sideList,
329
339
  React.createElement(split_pane_1.Sash, { pane: sidebar, side: "start", label: t('ta.layout.sidebar') })))),
@@ -1,4 +1,8 @@
1
1
  import * as React from 'react';
2
+ export declare namespace CountUtil {
3
+ /** A count on a badge, as a messenger shows it: past 99, 99+. */
4
+ function text(count: number): string;
5
+ }
2
6
  /**
3
7
  * How many conversations wait for the user to decide, on the entry of the chats (a tab, the rail): blue, as their ? on
4
8
  * the rows. Dragged away as the amber dot (UnseenDrop), all of them are let go and seen (`onDismiss`).
@@ -7,4 +11,12 @@ export declare function AsksBadge({ count, onDismiss }: {
7
11
  count: number;
8
12
  onDismiss?: () => void;
9
13
  }): React.JSX.Element;
14
+ /**
15
+ * How many messages people sent the user has not seen (PartnersUtil.counted), on the entry of the chats: red, as the
16
+ * numbers of their rows and WeChat's tab. Dragged away as the amber dot (UnseenDrop), all is seen (`onDismiss`).
17
+ */
18
+ export declare function PeopleBadge({ count, onDismiss }: {
19
+ count: number;
20
+ onDismiss?: () => void;
21
+ }): React.JSX.Element;
10
22
  //# sourceMappingURL=asks-badge.d.ts.map
@@ -33,16 +33,34 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CountUtil = void 0;
36
37
  exports.AsksBadge = AsksBadge;
38
+ exports.PeopleBadge = PeopleBadge;
37
39
  const React = __importStar(require("react"));
38
40
  const use_t_1 = require("../i18n/use-t");
39
41
  const unseen_drop_1 = require("./unseen-drop");
42
+ var CountUtil;
43
+ (function (CountUtil) {
44
+ /** A count on a badge, as a messenger shows it: past 99, 99+. */
45
+ function text(count) {
46
+ return count > 99 ? '99+' : String(count);
47
+ }
48
+ CountUtil.text = text;
49
+ })(CountUtil || (exports.CountUtil = CountUtil = {}));
40
50
  /**
41
51
  * How many conversations wait for the user to decide, on the entry of the chats (a tab, the rail): blue, as their ? on
42
52
  * the rows. Dragged away as the amber dot (UnseenDrop), all of them are let go and seen (`onDismiss`).
43
53
  */
44
54
  function AsksBadge({ count, onDismiss }) {
45
55
  const t = (0, use_t_1.useT)();
46
- return (React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.asksCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge", tone: "asks" }, count > 99 ? '99+' : count));
56
+ return (React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.asksCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge", tone: "asks" }, CountUtil.text(count)));
57
+ }
58
+ /**
59
+ * How many messages people sent the user has not seen (PartnersUtil.counted), on the entry of the chats: red, as the
60
+ * numbers of their rows and WeChat's tab. Dragged away as the amber dot (UnseenDrop), all is seen (`onDismiss`).
61
+ */
62
+ function PeopleBadge({ count, onDismiss }) {
63
+ const t = (0, use_t_1.useT)();
64
+ return (React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.unseenCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge ta-people", tone: "people" }, CountUtil.text(count)));
47
65
  }
48
66
  //# sourceMappingURL=asks-badge.js.map
@@ -69,11 +69,14 @@ export declare function ChatAvatar({ session, source, who, size, mood }: {
69
69
  * Always there, so that it grows in and goes, the avatar never drawn again; told only while it is on. A conversation
70
70
  * that waits for the user to decide has a blue ? instead, over an amber dot: seeing it does not end it, answering does.
71
71
  * The amber dot drags away as a drop (UnseenDrop), as a messenger's unread: let go past its neck, it is seen (`onSee`).
72
+ * Messages of people (a friend, a group chat) have their `count` instead, a red number on the face, as WeChat's: what a
73
+ * person said reaches the user before what an agent answered.
72
74
  */
73
- export declare function ChatDot({ unseen, asks, onSee }: {
75
+ export declare function ChatDot({ unseen, asks, onSee, count }: {
74
76
  unseen: boolean;
75
77
  asks: boolean;
76
78
  onSee?: () => void;
79
+ count?: number;
77
80
  }): React.JSX.Element;
78
81
  /**
79
82
  * The row of a folder (WebChatIcon.folder), as a messenger folds its subscriptions: its icon, its title, and the latest