@celljs/ta-web 4.12.0 → 4.13.1

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 (229) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/assistant/assistant-extension.js +14 -0
  4. package/esm/browser/assistant/assistant-initiative.d.ts +27 -0
  5. package/esm/browser/assistant/assistant-initiative.js +76 -0
  6. package/esm/browser/assistant/assistant-task-source.d.ts +7 -0
  7. package/esm/browser/assistant/assistant-task-source.js +12 -2
  8. package/esm/browser/assistant/assistant-view.js +5 -4
  9. package/esm/browser/assistant/assistant.d.ts +5 -0
  10. package/esm/browser/assistant/assistant.js +25 -6
  11. package/esm/browser/components/app-nav.d.ts +3 -1
  12. package/esm/browser/components/app-nav.js +5 -2
  13. package/esm/browser/components/app-view.js +18 -9
  14. package/esm/browser/components/asks-badge.d.ts +5 -0
  15. package/esm/browser/components/asks-badge.js +8 -0
  16. package/esm/browser/components/chat-asks.d.ts +46 -0
  17. package/esm/browser/components/chat-asks.js +101 -0
  18. package/esm/browser/components/chat-list.d.ts +7 -1
  19. package/esm/browser/components/chat-list.js +46 -17
  20. package/esm/browser/components/composer-addon-util.d.ts +11 -0
  21. package/esm/browser/components/composer-addon-util.js +40 -0
  22. package/esm/browser/components/composer-addons.d.ts +1 -7
  23. package/esm/browser/components/composer-addons.js +1 -27
  24. package/esm/browser/components/composer.d.ts +7 -1
  25. package/esm/browser/components/composer.js +33 -20
  26. package/esm/browser/components/connection-bar.js +31 -12
  27. package/esm/browser/components/conversation-scroll-util.d.ts +5 -0
  28. package/esm/browser/components/conversation-scroll-util.js +18 -0
  29. package/esm/browser/components/conversation-scroll.d.ts +12 -2
  30. package/esm/browser/components/conversation-scroll.js +68 -5
  31. package/esm/browser/components/discover-view.js +5 -1
  32. package/esm/browser/components/earlier-messages.d.ts +10 -3
  33. package/esm/browser/components/earlier-messages.js +14 -8
  34. package/esm/browser/components/folder-picker.d.ts +2 -0
  35. package/esm/browser/components/folder-picker.js +7 -0
  36. package/esm/browser/components/host-view.d.ts +1 -1
  37. package/esm/browser/components/markdown.js +4 -2
  38. package/esm/browser/components/media.js +4 -39
  39. package/esm/browser/components/mermaid-view.js +45 -3
  40. package/esm/browser/components/message-footer.d.ts +2 -0
  41. package/esm/browser/components/message-footer.js +8 -1
  42. package/esm/browser/components/message-list.d.ts +12 -0
  43. package/esm/browser/components/message-list.js +156 -25
  44. package/esm/browser/components/phone-shell.d.ts +7 -2
  45. package/esm/browser/components/phone-shell.js +7 -3
  46. package/esm/browser/components/relay-services.d.ts +24 -0
  47. package/esm/browser/components/relay-services.js +249 -0
  48. package/esm/browser/components/relay-view.js +17 -1
  49. package/esm/browser/components/remote-hosts.js +1 -1
  50. package/esm/browser/components/session-view.js +16 -4
  51. package/esm/browser/components/settings-controls.js +3 -3
  52. package/esm/browser/components/settings-parts.js +13 -1
  53. package/esm/browser/components/ta-avatar.js +6 -0
  54. package/esm/browser/components/tool-result.d.ts +13 -0
  55. package/esm/browser/components/tool-result.js +138 -0
  56. package/esm/browser/components/tool-view.js +5 -15
  57. package/esm/browser/components/web-composer.js +2 -1
  58. package/esm/browser/extension/extension-view.d.ts +3 -1
  59. package/esm/browser/extension/extension-view.js +7 -0
  60. package/esm/browser/extension/icons.js +9 -1
  61. package/esm/browser/extension/web-api-components.d.ts +3 -3
  62. package/esm/browser/extension/web-api-contributions.d.ts +119 -0
  63. package/esm/browser/extension/web-extension-api.d.ts +23 -46
  64. package/esm/browser/extension/web-extension-context.d.ts +6 -1
  65. package/esm/browser/extension/web-extension-context.js +63 -6
  66. package/esm/browser/extension/web-extension-protocol.d.ts +5 -1
  67. package/esm/browser/extension/web-extension-protocol.js +1 -0
  68. package/esm/browser/extension/web-extension-run.d.ts +3 -2
  69. package/esm/browser/extension/web-extension-run.js +3 -0
  70. package/esm/browser/extension/web-extensions.d.ts +2 -8
  71. package/esm/browser/extension/web-extensions.js +9 -35
  72. package/esm/browser/extension/web-page-list.d.ts +25 -0
  73. package/esm/browser/extension/web-page-list.js +35 -0
  74. package/esm/browser/extension/web-session-notices.d.ts +6 -1
  75. package/esm/browser/extension/web-session-notices.js +30 -4
  76. package/esm/browser/extension/web-sharing.d.ts +5 -2
  77. package/esm/browser/extension/web-sharing.js +10 -1
  78. package/esm/browser/i18n/locales.d.ts +69 -3
  79. package/esm/browser/i18n/messages.d.ts +68 -2
  80. package/esm/browser/i18n/messages.js +138 -6
  81. package/esm/browser/markdown/code-renderers.d.ts +4 -0
  82. package/esm/browser/markdown/code-renderers.js +4 -0
  83. package/esm/browser/markdown/lazy.d.ts +8 -0
  84. package/esm/browser/markdown/lazy.js +35 -0
  85. package/esm/browser/markdown/mermaid.d.ts +15 -3
  86. package/esm/browser/markdown/mermaid.js +45 -6
  87. package/esm/browser/notices/notices-protocol.d.ts +5 -0
  88. package/esm/browser/notices/notices.d.ts +19 -0
  89. package/esm/browser/notices/notices.js +85 -2
  90. package/esm/browser/notices/session-notices.d.ts +5 -2
  91. package/esm/browser/notices/session-notices.js +10 -1
  92. package/esm/browser/style/base.d.ts +1 -1
  93. package/esm/browser/style/base.js +2 -1
  94. package/esm/browser/style/conversation.d.ts +1 -1
  95. package/esm/browser/style/conversation.js +51 -0
  96. package/esm/browser/style/device.js +3 -0
  97. package/esm/browser/style/layout.d.ts +1 -1
  98. package/esm/browser/style/layout.js +24 -9
  99. package/esm/browser/style/pages.d.ts +1 -1
  100. package/esm/browser/style/pages.js +2 -0
  101. package/esm/browser/style/phone.d.ts +1 -1
  102. package/esm/browser/style/phone.js +2 -0
  103. package/esm/browser/style/shell.d.ts +1 -1
  104. package/esm/browser/style/shell.js +14 -3
  105. package/esm/browser/util/desktop.d.ts +18 -1
  106. package/esm/browser/util/desktop.js +13 -0
  107. package/esm/browser/util/process.d.ts +26 -1
  108. package/esm/browser/util/process.js +79 -5
  109. package/esm/browser/util/progress.d.ts +6 -1
  110. package/esm/browser/util/progress.js +11 -2
  111. package/esm/browser/util/scroll-rest.d.ts +10 -0
  112. package/esm/browser/util/scroll-rest.js +44 -0
  113. package/esm/browser/util/tool-result.d.ts +32 -0
  114. package/esm/browser/util/tool-result.js +85 -0
  115. package/esm/browser/util/tool.js +7 -0
  116. package/lib/browser/assistant/assistant-extension.js +14 -0
  117. package/lib/browser/assistant/assistant-initiative.d.ts +28 -0
  118. package/lib/browser/assistant/assistant-initiative.js +80 -0
  119. package/lib/browser/assistant/assistant-task-source.d.ts +7 -0
  120. package/lib/browser/assistant/assistant-task-source.js +12 -2
  121. package/lib/browser/assistant/assistant-view.js +3 -2
  122. package/lib/browser/assistant/assistant.d.ts +5 -0
  123. package/lib/browser/assistant/assistant.js +24 -5
  124. package/lib/browser/components/app-nav.d.ts +3 -1
  125. package/lib/browser/components/app-nav.js +5 -2
  126. package/lib/browser/components/app-view.js +17 -8
  127. package/lib/browser/components/asks-badge.d.ts +6 -0
  128. package/lib/browser/components/asks-badge.js +44 -0
  129. package/lib/browser/components/chat-asks.d.ts +47 -0
  130. package/lib/browser/components/chat-asks.js +104 -0
  131. package/lib/browser/components/chat-list.d.ts +7 -1
  132. package/lib/browser/components/chat-list.js +46 -17
  133. package/lib/browser/components/composer-addon-util.d.ts +12 -0
  134. package/lib/browser/components/composer-addon-util.js +76 -0
  135. package/lib/browser/components/composer-addons.d.ts +1 -7
  136. package/lib/browser/components/composer-addons.js +2 -29
  137. package/lib/browser/components/composer.d.ts +7 -1
  138. package/lib/browser/components/composer.js +33 -19
  139. package/lib/browser/components/connection-bar.js +30 -11
  140. package/lib/browser/components/conversation-scroll-util.d.ts +5 -0
  141. package/lib/browser/components/conversation-scroll-util.js +18 -0
  142. package/lib/browser/components/conversation-scroll.d.ts +12 -2
  143. package/lib/browser/components/conversation-scroll.js +68 -5
  144. package/lib/browser/components/discover-view.js +5 -1
  145. package/lib/browser/components/earlier-messages.d.ts +10 -3
  146. package/lib/browser/components/earlier-messages.js +16 -9
  147. package/lib/browser/components/folder-picker.d.ts +2 -0
  148. package/lib/browser/components/folder-picker.js +7 -0
  149. package/lib/browser/components/host-view.d.ts +1 -1
  150. package/lib/browser/components/markdown.js +3 -1
  151. package/lib/browser/components/media.js +3 -38
  152. package/lib/browser/components/mermaid-view.js +45 -3
  153. package/lib/browser/components/message-footer.d.ts +2 -0
  154. package/lib/browser/components/message-footer.js +8 -0
  155. package/lib/browser/components/message-list.d.ts +12 -0
  156. package/lib/browser/components/message-list.js +153 -20
  157. package/lib/browser/components/phone-shell.d.ts +7 -2
  158. package/lib/browser/components/phone-shell.js +7 -3
  159. package/lib/browser/components/relay-services.d.ts +25 -0
  160. package/lib/browser/components/relay-services.js +286 -0
  161. package/lib/browser/components/relay-view.js +17 -1
  162. package/lib/browser/components/remote-hosts.js +1 -1
  163. package/lib/browser/components/session-view.js +15 -3
  164. package/lib/browser/components/settings-controls.js +3 -3
  165. package/lib/browser/components/settings-parts.js +13 -1
  166. package/lib/browser/components/ta-avatar.js +6 -0
  167. package/lib/browser/components/tool-result.d.ts +14 -0
  168. package/lib/browser/components/tool-result.js +175 -0
  169. package/lib/browser/components/tool-view.js +10 -20
  170. package/lib/browser/components/web-composer.js +2 -1
  171. package/lib/browser/extension/extension-view.d.ts +3 -1
  172. package/lib/browser/extension/extension-view.js +8 -1
  173. package/lib/browser/extension/icons.js +8 -0
  174. package/lib/browser/extension/web-api-components.d.ts +3 -3
  175. package/lib/browser/extension/web-api-contributions.d.ts +119 -0
  176. package/lib/browser/extension/web-extension-api.d.ts +23 -46
  177. package/lib/browser/extension/web-extension-context.d.ts +6 -1
  178. package/lib/browser/extension/web-extension-context.js +63 -6
  179. package/lib/browser/extension/web-extension-protocol.d.ts +5 -1
  180. package/lib/browser/extension/web-extension-protocol.js +1 -0
  181. package/lib/browser/extension/web-extension-run.d.ts +3 -2
  182. package/lib/browser/extension/web-extension-run.js +3 -0
  183. package/lib/browser/extension/web-extensions.d.ts +2 -8
  184. package/lib/browser/extension/web-extensions.js +9 -35
  185. package/lib/browser/extension/web-page-list.d.ts +26 -0
  186. package/lib/browser/extension/web-page-list.js +39 -0
  187. package/lib/browser/extension/web-session-notices.d.ts +6 -1
  188. package/lib/browser/extension/web-session-notices.js +30 -4
  189. package/lib/browser/extension/web-sharing.d.ts +5 -2
  190. package/lib/browser/extension/web-sharing.js +10 -1
  191. package/lib/browser/i18n/locales.d.ts +69 -3
  192. package/lib/browser/i18n/messages.d.ts +68 -2
  193. package/lib/browser/i18n/messages.js +138 -6
  194. package/lib/browser/markdown/code-renderers.d.ts +4 -0
  195. package/lib/browser/markdown/code-renderers.js +5 -1
  196. package/lib/browser/markdown/lazy.d.ts +8 -0
  197. package/lib/browser/markdown/lazy.js +37 -1
  198. package/lib/browser/markdown/mermaid.d.ts +15 -3
  199. package/lib/browser/markdown/mermaid.js +44 -5
  200. package/lib/browser/notices/notices-protocol.d.ts +5 -0
  201. package/lib/browser/notices/notices.d.ts +19 -0
  202. package/lib/browser/notices/notices.js +84 -1
  203. package/lib/browser/notices/session-notices.d.ts +5 -2
  204. package/lib/browser/notices/session-notices.js +10 -1
  205. package/lib/browser/style/base.d.ts +1 -1
  206. package/lib/browser/style/base.js +2 -1
  207. package/lib/browser/style/conversation.d.ts +1 -1
  208. package/lib/browser/style/conversation.js +51 -0
  209. package/lib/browser/style/device.js +3 -0
  210. package/lib/browser/style/layout.d.ts +1 -1
  211. package/lib/browser/style/layout.js +24 -9
  212. package/lib/browser/style/pages.d.ts +1 -1
  213. package/lib/browser/style/pages.js +2 -0
  214. package/lib/browser/style/phone.d.ts +1 -1
  215. package/lib/browser/style/phone.js +2 -0
  216. package/lib/browser/style/shell.d.ts +1 -1
  217. package/lib/browser/style/shell.js +14 -3
  218. package/lib/browser/util/desktop.d.ts +18 -1
  219. package/lib/browser/util/desktop.js +13 -0
  220. package/lib/browser/util/process.d.ts +26 -1
  221. package/lib/browser/util/process.js +79 -5
  222. package/lib/browser/util/progress.d.ts +6 -1
  223. package/lib/browser/util/progress.js +11 -2
  224. package/lib/browser/util/scroll-rest.d.ts +11 -0
  225. package/lib/browser/util/scroll-rest.js +47 -0
  226. package/lib/browser/util/tool-result.d.ts +33 -0
  227. package/lib/browser/util/tool-result.js +88 -0
  228. package/lib/browser/util/tool.js +7 -0
  229. package/package.json +7 -7
@@ -37,8 +37,10 @@ exports.UserImageUtil = exports.MessageImages = exports.ConversationSession = vo
37
37
  exports.TurnAvatar = TurnAvatar;
38
38
  exports.UserImages = UserImages;
39
39
  exports.UserSaid = UserSaid;
40
+ exports.MessageOrigin = MessageOrigin;
40
41
  exports.userWords = userWords;
41
42
  exports.SkillUse = SkillUse;
43
+ exports.UserMarks = UserMarks;
42
44
  exports.Process = Process;
43
45
  exports.quiet = quiet;
44
46
  exports.endsInSteps = endsInSteps;
@@ -47,11 +49,13 @@ const ta_protocol_1 = require("@celljs/ta-protocol");
47
49
  const lucide_react_1 = require("lucide-react");
48
50
  const React = __importStar(require("react"));
49
51
  const extension_view_1 = require("../extension/extension-view");
52
+ const icons_1 = require("../extension/icons");
50
53
  const use_t_1 = require("../i18n/use-t");
51
54
  const code_renderers_1 = require("../markdown/code-renderers");
52
55
  const lazy_1 = require("../markdown/lazy");
53
56
  const message_1 = require("../util/message");
54
57
  const process_1 = require("../util/process");
58
+ const progress_1 = require("../util/progress");
55
59
  const tool_1 = require("../util/tool");
56
60
  const callout_1 = require("./callout");
57
61
  const conversation_scroll_1 = require("./conversation-scroll");
@@ -223,7 +227,37 @@ function UserSaid({ blocks, text, bubble = 'ta-bubble', timestamp }) {
223
227
  React.createElement(UserImages, { blocks: blocks, timestamp: timestamp }),
224
228
  text && React.createElement(said_text_1.SaidText, { text: text, className: "ta-bubble-text" })));
225
229
  }
226
- function UserMessage({ message }) {
230
+ /**
231
+ * Where a message of the user came from when not from what they typed (TaMessageSource): the package that sent it, as
232
+ * the user calls it, with what it says besides (the channel and who spoke); the double. None for what they typed.
233
+ */
234
+ function MessageOrigin({ blocks }) {
235
+ var _a;
236
+ var _b;
237
+ const t = (0, use_t_1.useT)();
238
+ const language = (0, use_t_1.useLanguage)();
239
+ const extensions = React.useContext(extension_view_1.LoadedExtensions);
240
+ const source = ta_protocol_1.TaMessageSource.of(message_1.MessageUtil.text(blocks));
241
+ if (!source) {
242
+ return null;
243
+ }
244
+ const info = (_a = extensions.find(extension => extension.name === source.from)) === null || _a === void 0 ? void 0 : _a.info;
245
+ const double = source.from === ta_protocol_1.TaMessageSource.DOUBLE;
246
+ const name = double ? t('ta.assistant.me') : ((_b = ta_protocol_1.TaPackageTextUtil.pick(info === null || info === void 0 ? void 0 : info.title, language)) !== null && _b !== void 0 ? _b : source.from.replace(/^@[^/]+\//, ''));
247
+ const glyph = double ? lucide_react_1.Bot : ((info === null || info === void 0 ? void 0 : info.icon) && icons_1.WEB_ICONS[info.icon]) || lucide_react_1.Puzzle;
248
+ return (React.createElement("span", { className: "ta-origin", title: source.from },
249
+ React.createElement(icon_1.Icon, { icon: glyph, size: 12 }),
250
+ React.createElement("span", { className: "ta-origin-name" }, name),
251
+ source.detail && React.createElement("span", { className: "ta-origin-detail" }, source.detail)));
252
+ }
253
+ /** Written while the agent was at its reply, sent once it answered (MessageItem.queued). */
254
+ function QueuedMark() {
255
+ const t = (0, use_t_1.useT)();
256
+ return (React.createElement("span", { className: "ta-origin ta-origin-queued", title: t('ta.message.queuedTitle') },
257
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.Clock3, size: 12 }),
258
+ React.createElement("span", { className: "ta-origin-name" }, t('ta.message.queued'))));
259
+ }
260
+ function UserMessage({ message, queued }) {
227
261
  const blocks = message_1.MessageUtil.blocks(message);
228
262
  const said = message_1.MessageUtil.text(blocks).trim();
229
263
  if (TASK_RENAMED.test(said)) {
@@ -235,7 +269,7 @@ function UserMessage({ message }) {
235
269
  return React.createElement(TaskUpdate, { title: update[1], status: update[2], result: update[3] });
236
270
  }
237
271
  const { text, copied, skill } = userWords(blocks);
238
- return React.createElement(UserBubble, { message: message, blocks: blocks, text: text, copied: copied, skill: skill });
272
+ return React.createElement(UserBubble, { message: message, blocks: blocks, text: text, copied: copied, skill: skill, queued: queued });
239
273
  }
240
274
  /**
241
275
  * What a message of the user's shows, in a conversation and the double alike: without the context and the notes of
@@ -262,17 +296,30 @@ function SkillUse({ skill }) {
262
296
  open && (React.createElement("div", { className: "ta-skill-body" },
263
297
  React.createElement(markdown_1.Markdown, { text: skill.content.replace(SKILL_BASE, '') })))));
264
298
  }
265
- function UserBubble({ message, blocks, text, copied, skill, }) {
299
+ /** Above a message of the user: where it came from, and that it waited for a reply; nothing for one typed and sent at once. */
300
+ function UserMarks({ blocks, queued }) {
301
+ const origin = React.createElement(MessageOrigin, { blocks: blocks });
302
+ if (!queued && !ta_protocol_1.TaMessageSource.of(message_1.MessageUtil.text(blocks))) {
303
+ return null;
304
+ }
305
+ return (React.createElement("div", { className: "ta-user-marks" },
306
+ origin,
307
+ queued && React.createElement(QueuedMark, null)));
308
+ }
309
+ function UserBubble({ message, blocks, text, copied, skill, queued, }) {
266
310
  const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({ kind: 'user', message, text: copied });
311
+ const marks = React.createElement(UserMarks, { blocks: blocks, queued: queued });
267
312
  const outbox = React.useContext(Outbox);
268
313
  const sent = outbox.of.get(message);
269
314
  if (sent) {
270
315
  // Not in the session yet: nothing to branch from or rewind to.
271
316
  return (React.createElement("div", { className: `ta-message ta-user ${sent.failed ? 'ta-user-failed' : 'ta-user-sending'}` },
317
+ marks,
272
318
  React.createElement(UserSaid, { blocks: blocks, text: text, timestamp: message.timestamp }),
273
319
  sent.failed ? React.createElement(SendFailed, { sent: sent, actions: outbox.actions }) : React.createElement("div", { className: "ta-footer" })));
274
320
  }
275
321
  return (React.createElement("div", { className: "ta-message ta-user", onContextMenu: onContextMenu },
322
+ marks,
276
323
  skill && React.createElement(SkillUse, { skill: skill }),
277
324
  React.createElement(UserSaid, { blocks: blocks, text: text, timestamp: message.timestamp }),
278
325
  React.createElement(message_footer_1.UserFooter, { message: message, text: copied }),
@@ -307,10 +354,26 @@ const ErrorStep = React.memo(function ErrorStep({ text }) {
307
354
  return (React.createElement("div", { className: "ta-step-thinking ta-step-error" },
308
355
  React.createElement("button", { type: "button", className: "ta-step-toggle", "aria-expanded": open, onClick: () => setOpen(!open) },
309
356
  React.createElement("span", { className: "ta-status ta-status-error" }),
310
- React.createElement("span", { className: "ta-step-tag" }, t('ta.process.retried')),
357
+ React.createElement("span", { className: "ta-step-tag" }, t('ta.process.requestFailed')),
311
358
  !open && text && React.createElement("span", { className: "ta-step-preview" }, process_1.ProcessUtil.preview(text))),
312
359
  open && text && React.createElement("div", { className: "ta-thinking-text" }, text)));
313
360
  });
361
+ /**
362
+ * What the user said while the agent worked (steering), where in its work it read it: a small bubble on the string of
363
+ * the steps, marked as said on the way, with where it came from when not typed. It stays in sight when the steps fold.
364
+ */
365
+ const SaidStep = React.memo(function SaidStep({ message }) {
366
+ const t = (0, use_t_1.useT)();
367
+ const blocks = message_1.MessageUtil.blocks(message);
368
+ const { text } = userWords(blocks);
369
+ return (React.createElement("div", { className: "ta-step-said" },
370
+ React.createElement("span", { className: "ta-status ta-status-said" }),
371
+ React.createElement("div", { className: "ta-said-head", title: t('ta.message.steeredTitle') },
372
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.CornerDownRight, size: 12 }),
373
+ React.createElement("span", null, t('ta.message.steered')),
374
+ React.createElement(MessageOrigin, { blocks: blocks })),
375
+ React.createElement(UserSaid, { blocks: blocks, text: text, bubble: "ta-said-bubble", timestamp: message.timestamp })));
376
+ });
314
377
  const TextStep = React.memo(function TextStep({ text, streaming }) {
315
378
  return (React.createElement("div", { className: "ta-step-text" },
316
379
  React.createElement("span", { className: "ta-status ta-status-thought" }),
@@ -327,6 +390,8 @@ function Step({ step, results, tools, tagged, streaming, }) {
327
390
  return React.createElement(SummaryStep, { text: step.text });
328
391
  case 'error':
329
392
  return React.createElement(ErrorStep, { text: step.text });
393
+ case 'said':
394
+ return React.createElement(SaidStep, { message: step.message });
330
395
  default: {
331
396
  const { id = '', name = '', arguments: args } = step.call;
332
397
  return (React.createElement(tool_view_1.ToolView, { id: id, name: name, args: (_a = args) !== null && _a !== void 0 ? _a : {}, run: id ? tools[id] : undefined, message: id ? results.get(id) : undefined, runs: tools }));
@@ -408,6 +473,8 @@ function Process({ steps, active, results, tools, leading, status, stopped, }) {
408
473
  const renderers = React.useContext(code_renderers_1.CodeRenderers);
409
474
  const pinned = open ? [] : steps.filter(step => process_1.ProcessUtil.pinned(step, renderers));
410
475
  const inline = pinned.length ? folded.steps.filter(step => !process_1.ProcessUtil.pinned(step, renderers)) : folded.steps;
476
+ // Folded, what the user said on the way stays too: their words do not go into the work.
477
+ const said = open ? [] : steps.filter(step => step.kind === 'said');
411
478
  // The earlier steps count as the head does: the calls among them, not the thoughts.
412
479
  const earlier = folded.hidden ? tool_1.ToolUtil.count(process_1.ProcessUtil.tools(steps.slice(0, folded.hidden)), results, tools).steps : 0;
413
480
  // Only thoughts: the head already says so, the steps need not say it again.
@@ -425,6 +492,7 @@ function Process({ steps, active, results, tools, leading, status, stopped, }) {
425
492
  shown && (React.createElement("div", { id: id, ref: stepsRef, className: "ta-process-steps" },
426
493
  folded.hidden > 0 && (React.createElement("button", { type: "button", className: "ta-link ta-more", onClick: () => setShowAll(true) }, earlier ? t('ta.process.earlier', { count: earlier }) : t('ta.process.showAll'))),
427
494
  inline.map((step, index) => (React.createElement(Step, { key: step.key, step: step, results: results, tools: tools, tagged: !thoughtOnly, streaming: active && index === inline.length - 1 }))))),
495
+ said.length > 0 && (React.createElement("div", { className: "ta-process-steps ta-said-folded" }, said.map(step => (React.createElement(SaidStep, { key: step.key, message: step.message }))))),
428
496
  pinned.map(step => (React.createElement(markdown_1.Markdown, { key: step.key, text: step.text })))));
429
497
  }
430
498
  /** A turn that has shown nothing yet: what ta does goes on its head. */
@@ -440,12 +508,20 @@ function endsInSteps(item) {
440
508
  return (item === null || item === void 0 ? void 0 : item.kind) === 'turn' && item.steps.length > 0 && !item.reply.length;
441
509
  }
442
510
  function Turn({ item, tools, mood, status, latest, }) {
511
+ const compacted = process_1.ProcessUtil.compaction(item);
512
+ if (compacted !== undefined) {
513
+ return React.createElement(CompactionBreak, { summary: compacted, tokens: message_1.MessageUtil.usage(item.messages).input });
514
+ }
515
+ return React.createElement(WorkTurn, { item: item, tools: tools, mood: mood, status: status, latest: latest });
516
+ }
517
+ function WorkTurn({ item, tools, mood, status, latest, }) {
443
518
  var _a;
444
519
  const t = (0, use_t_1.useT)();
445
520
  const session = React.useContext(exports.ConversationSession);
446
521
  const results = message_1.MessageUtil.results(item.messages);
447
522
  const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
448
523
  const ending = process_1.ProcessUtil.ending(item);
524
+ const held = useHeld(item.active, ending === 'silent' || ending === 'interrupted');
449
525
  const reply = item.reply.join('\n\n').trim();
450
526
  const actions = React.useContext(message_footer_1.MessageActions);
451
527
  const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({
@@ -458,20 +534,43 @@ function Turn({ item, tools, mood, status, latest, }) {
458
534
  return (React.createElement("div", { className: `ta-message ta-assistant ${item.active ? 'ta-turn-live' : ''}`, onContextMenu: onContextMenu },
459
535
  React.createElement(Process, { steps: item.steps, active: item.active, stopped: ending !== undefined && ending !== 'aborted', results: results, tools: tools, leading: React.createElement(TurnAvatar, { mood: mood }), status: status }),
460
536
  item.reply.map((text, index) => (React.createElement(markdown_1.Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
461
- ending && ending !== 'aborted' && (React.createElement(TurnEnd, { ending: ending, error: errorMessage, retries: item.steps.filter(step => step.kind === 'error').length, resume: latest && !(actions === null || actions === void 0 ? void 0 : actions.working) ? actions === null || actions === void 0 ? void 0 : actions.resume : undefined })),
537
+ ending && ending !== 'aborted' && !held && (React.createElement(TurnEnd, { ending: ending, error: errorMessage, resume: latest && !(actions === null || actions === void 0 ? void 0 : actions.working) ? actions === null || actions === void 0 ? void 0 : actions.resume : undefined })),
462
538
  ending === 'aborted' && React.createElement("div", { className: "ta-muted ta-small" }, t('ta.message.stopped')),
463
539
  !item.active && React.createElement(message_footer_1.TurnFooter, { messages: item.messages, last: item.last, reply: reply, session: session, latest: latest }),
464
540
  menu));
465
541
  }
542
+ /** How long a turn that just ended without a reply waits before it says so: an agent that goes on by itself does within it. */
543
+ const HOLD_MS = 8000;
544
+ /**
545
+ * Whether a turn seen to end without a reply (`quiet`) holds back what it says of it for a while: an external agent
546
+ * often ends a turn empty and goes on by itself seconds later, which made the warning come and go. A turn read
547
+ * already ended says it at once.
548
+ */
549
+ function useHeld(active, quiet) {
550
+ const [was, setWas] = React.useState(active);
551
+ const [held, setHeld] = React.useState(false);
552
+ if (was !== active) {
553
+ // Set while drawing, before what it draws is shown: the warning does not show for a frame first.
554
+ setWas(active);
555
+ setHeld(!active && quiet);
556
+ }
557
+ React.useEffect(() => {
558
+ if (held) {
559
+ const timer = setTimeout(() => setHeld(false), HOLD_MS);
560
+ return () => clearTimeout(timer);
561
+ }
562
+ }, [held]);
563
+ return held;
564
+ }
466
565
  /**
467
- * Why a turn stopped short, under it: the error (and that pi retried it, how many times), or that it was cut off,
468
- * or ended without a word; the last turn has a button to go on, which says so to the agent.
566
+ * Why a turn stopped short, under it: the error, or that it was cut off, or ended without a word; the last turn has
567
+ * a button to go on, which says so to the agent.
469
568
  */
470
- function TurnEnd({ ending, error, retries, resume }) {
569
+ function TurnEnd({ ending, error, resume }) {
471
570
  const t = (0, use_t_1.useT)();
472
571
  const action = resume && (React.createElement("button", { type: "button", className: "ta-button", onClick: resume }, t('ta.message.resume')));
473
572
  if (ending === 'error') {
474
- return (React.createElement(callout_1.Callout, { level: "error", detail: retries ? t('ta.message.retriedFailed', { count: retries }) : undefined, action: action }, (error === null || error === void 0 ? void 0 : error.trim()) || t('ta.message.failedUnknown')));
573
+ return (React.createElement(callout_1.Callout, { level: "error", action: action }, (error === null || error === void 0 ? void 0 : error.trim()) || t('ta.message.failedUnknown')));
475
574
  }
476
575
  return (React.createElement(callout_1.Callout, { level: "warning", action: action }, t(ending === 'interrupted' ? 'ta.message.interrupted' : 'ta.message.silent')));
477
576
  }
@@ -487,6 +586,25 @@ function BashMessage({ message }) {
487
586
  output && (React.createElement("div", { className: "ta-tool-body" },
488
587
  React.createElement("pre", { className: "ta-output" }, output))))));
489
588
  }
589
+ /**
590
+ * Where the context was compacted, by pi (`compactionSummary`) or by an external agent (ProcessUtil.compaction):
591
+ * a quiet mark across the conversation, as where it switched models, with how much was compacted; it opens to
592
+ * the summary the agent goes on from.
593
+ */
594
+ function CompactionBreak({ summary, tokens }) {
595
+ const t = (0, use_t_1.useT)();
596
+ const [open, setOpen] = React.useState(false);
597
+ return (React.createElement("div", { className: "ta-compaction" },
598
+ React.createElement("button", { type: "button", className: "ta-compaction-mark", "aria-expanded": open, onClick: () => setOpen(!open) },
599
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.FoldVertical, size: 12 }),
600
+ React.createElement("span", null, t('ta.message.compacted')),
601
+ !!tokens && React.createElement("span", { className: "ta-compaction-tokens" },
602
+ "\u00B7 ",
603
+ t('ta.message.compactedFrom', { tokens: progress_1.ProgressUtil.format(tokens) })),
604
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 12, className: "ta-compaction-chevron" })),
605
+ open && summary.trim() && (React.createElement("div", { className: "ta-compaction-summary" },
606
+ React.createElement(markdown_1.Markdown, { text: summary })))));
607
+ }
490
608
  function SummaryMessage({ title, text }) {
491
609
  const t = (0, use_t_1.useT)();
492
610
  return (React.createElement("details", { className: "ta-summary" },
@@ -498,13 +616,13 @@ function Message({ item }) {
498
616
  const { message } = item;
499
617
  switch (message.role) {
500
618
  case 'user':
501
- return React.createElement(UserMessage, { message: message });
619
+ return React.createElement(UserMessage, { message: message, queued: item.queued });
502
620
  case 'bashExecution':
503
621
  return React.createElement(BashMessage, { message: message });
504
622
  case 'custom':
505
623
  return React.createElement(extension_view_1.CustomMessage, { message: message });
506
624
  case 'compactionSummary':
507
- return React.createElement(SummaryMessage, { title: "ta.message.compacted", text: (_a = message.summary) !== null && _a !== void 0 ? _a : '' });
625
+ return React.createElement(CompactionBreak, { summary: (_a = message.summary) !== null && _a !== void 0 ? _a : '', tokens: message.tokensBefore });
508
626
  case 'branchSummary':
509
627
  return React.createElement(SummaryMessage, { title: "ta.message.branch", text: (_b = message.summary) !== null && _b !== void 0 ? _b : '' });
510
628
  default:
@@ -522,6 +640,21 @@ const ThreadRow = React.memo(function ThreadRow({ item, tools, mood, status, lat
522
640
  previous.latest === next.latest &&
523
641
  process_1.ProcessUtil.same(previous.item, next.item) &&
524
642
  (next.item.kind === 'message' || !next.item.active || previous.tools === next.tools));
643
+ /** `key`, once a frame was painted with it: until then, the one before. */
644
+ function useLaidOut(key) {
645
+ const [painted, setPainted] = React.useState(key);
646
+ React.useEffect(() => {
647
+ if (key === painted) {
648
+ return;
649
+ }
650
+ // The first frame lays it out, the next comes after it was painted.
651
+ let frame = requestAnimationFrame(() => {
652
+ frame = requestAnimationFrame(() => setPainted(key));
653
+ });
654
+ return () => cancelAnimationFrame(frame);
655
+ }, [key, painted]);
656
+ return painted;
657
+ }
525
658
  /** The last rows, which change and are in view, are always laid out. */
526
659
  const SETTLED_AFTER = 4;
527
660
  /** The conversation; tool results show with the calls they answer. `rows`: only its latest rows are drawn, more as asked. */
@@ -532,20 +665,19 @@ function MessageList({ state, outbox, rows }) {
532
665
  const items = React.useMemo(() => process_1.ProcessUtil.items(state.messages, state.working, state.start, renderers), [state.messages, state.working, state.start, renderers]);
533
666
  const breaks = React.useMemo(() => process_1.ProcessUtil.timeBreaks(process_1.ProcessUtil.starts(items), index => process_1.ProcessUtil.shown(items[index], renderers)), [items, renderers]);
534
667
  const models = React.useMemo(() => process_1.ProcessUtil.modelBreaks(items), [items]);
668
+ // A turn's cards know what the user said after it: a choice they asked for is made.
669
+ const answers = React.useMemo(() => process_1.ProcessUtil.answers(items, message => userWords(message_1.MessageUtil.blocks(message)).copied), [items]);
535
670
  const sent = React.useMemo(() => { var _a; return ({ of: new Map(((_a = state.outbox) !== null && _a !== void 0 ? _a : []).map(message => [message.message, message])), actions: outbox }); }, [state.outbox, outbox]);
536
671
  // The rows held back: those before the latest `rows.rows`.
537
672
  const from = rows ? Math.max(0, items.length - rows.rows) : 0;
538
673
  if (rows) {
539
674
  rows.hidden.current = from;
540
675
  }
541
- // Rows of earlier messages put in front are laid out once before they may skip it (content-visibility):
542
- // their height is then known, and the view does not move as they come near it.
543
- const firstKey = React.useRef((_a = items[from]) === null || _a === void 0 ? void 0 : _a.key);
544
- const front = Math.max(from, items.findIndex(item => item.key === firstKey.current));
545
- React.useLayoutEffect(() => {
546
- var _a;
547
- firstKey.current = (_a = items[from]) === null || _a === void 0 ? void 0 : _a.key;
548
- });
676
+ // Rows of earlier messages put in front are laid out in a frame before they may skip it (content-visibility):
677
+ // the browser keeps the height it laid out only as it paints, and a row that skips before has a height made
678
+ // up, which turns into its own as it comes into view, under the user's finger.
679
+ const laidOut = useLaidOut((_a = items[from]) === null || _a === void 0 ? void 0 : _a.key);
680
+ const front = Math.max(from, items.findIndex(item => item.key === laidOut));
549
681
  // Rows that come after the list is drawn come in with a motion; those of a conversation opened or loaded again,
550
682
  // and those already there when earlier messages come in front of them, still: by key, not by index.
551
683
  const freshRows = React.useRef(undefined);
@@ -572,7 +704,8 @@ function MessageList({ state, outbox, rows }) {
572
704
  .join(' ') },
573
705
  breaks[index] !== undefined && React.createElement(message_footer_1.TimeBreak, { timestamp: breaks[index] }),
574
706
  models[index] && React.createElement(message_footer_1.ModelBreak, { model: models[index] }),
575
- React.createElement(ThreadRow, { item: item, tools: state.tools, mood: item.kind === 'turn' ? process_1.ProcessUtil.mood(item, index === lastTurn, waiting) : 'idle', status: onHead && item === last ? status : undefined, latest: index === lastTurn })))),
707
+ React.createElement(code_renderers_1.CodeAnswer.Provider, { value: answers[index] },
708
+ React.createElement(ThreadRow, { item: item, tools: state.tools, mood: item.kind === 'turn' ? process_1.ProcessUtil.mood(item, index === lastTurn, waiting) : 'idle', status: onHead && item === last ? status : undefined, latest: index === lastTurn }))))),
576
709
  status && !onHead && React.createElement("div", { className: `ta-run-line ${endsInSteps(last) ? 'ta-run-steps' : ''}` }, status)));
577
710
  }
578
711
  //# sourceMappingURL=message-list.js.map
@@ -17,6 +17,8 @@ export interface PhoneTab {
17
17
  unseen?: boolean;
18
18
  /** Sees all of it, as the user drags its dot away (UnseenDrop); the dot stays put without. */
19
19
  onSeeAll?(): void;
20
+ /** How many of it wait for the user to decide: a blue count, in place of the amber dot. */
21
+ asks?: number;
20
22
  }
21
23
  export interface PhoneShellProps {
22
24
  tabs: PhoneTab[];
@@ -83,8 +85,11 @@ export declare function PhoneStack({ base, top, open, onClose }: PhoneStackProps
83
85
  export declare namespace PhoneUtil {
84
86
  /** Two taps of a tab within this are one double tap. */
85
87
  const DOUBLE_TAP_MS = 350;
86
- /** What marks a row with a dot of something unseen, in any list of the tabs (an extension's too). */
87
- const UNSEEN = "[data-unseen]";
88
+ /**
89
+ * What marks a row with a dot of something unseen, in any list of the tabs (an extension's too), or with the ? of
90
+ * a conversation that waits for the user to decide, at the top of the chats: those are found first.
91
+ */
92
+ const UNSEEN = "[data-unseen], [data-asks]";
88
93
  /**
89
94
  * Scrolls the list of the tab to its next row with a dot, below the top of what shows, else from the first
90
95
  * again: each tap one further, as WeChat's. Those all on the screen already are not scrolled to, only lit up.
@@ -45,6 +45,7 @@ const hold_1 = require("../device/hold");
45
45
  const pull_down_1 = require("../device/pull-down");
46
46
  const sheet_swipe_1 = require("../device/sheet-swipe");
47
47
  const use_t_1 = require("../i18n/use-t");
48
+ const asks_badge_1 = require("./asks-badge");
48
49
  const context_menu_1 = require("./context-menu");
49
50
  const ta_avatar_1 = require("./ta-avatar");
50
51
  const unseen_drop_1 = require("./unseen-drop");
@@ -267,7 +268,7 @@ function TabBar({ tabs, tab, onTab }) {
267
268
  return (React.createElement("button", { key: item.id, type: "button", className: `ta-tabbar-item${active ? ' ta-active' : ''}`, "aria-current": active ? 'page' : undefined, onClick: event => (active ? again(item.id, event.currentTarget.closest('.ta-phone-home')) : onTab(item.id)), onContextMenu: item.menu ? event => { var _a; return openMenu(event, (_a = item.menu) !== null && _a !== void 0 ? _a : []); } : undefined, ...held(item.hold) },
268
269
  React.createElement("span", { className: "ta-tabbar-icon" },
269
270
  item.double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(Glyph, { size: 22, strokeWidth: active ? 2 : 1.6 }),
270
- item.unseen && React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: item.onSeeAll })),
271
+ item.asks ? React.createElement(asks_badge_1.AsksBadge, { count: item.asks }) : item.unseen && React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: item.onSeeAll })),
271
272
  React.createElement("span", null, item.label)));
272
273
  }),
273
274
  menu));
@@ -276,8 +277,11 @@ var PhoneUtil;
276
277
  (function (PhoneUtil) {
277
278
  /** Two taps of a tab within this are one double tap. */
278
279
  PhoneUtil.DOUBLE_TAP_MS = 350;
279
- /** What marks a row with a dot of something unseen, in any list of the tabs (an extension's too). */
280
- PhoneUtil.UNSEEN = '[data-unseen]';
280
+ /**
281
+ * What marks a row with a dot of something unseen, in any list of the tabs (an extension's too), or with the ? of
282
+ * a conversation that waits for the user to decide, at the top of the chats: those are found first.
283
+ */
284
+ PhoneUtil.UNSEEN = '[data-unseen], [data-asks]';
281
285
  /** Over the row scrolled to, the room left above it. */
282
286
  const GAP = 8;
283
287
  const FLASH_MS = 1000;
@@ -0,0 +1,25 @@
1
+ import { type TaRelayFeature, type TaRelayProbe, type TaRelayService, type TaRelayTypeInfo } from '@celljs/ta-protocol';
2
+ import { type LucideIcon } from 'lucide-react';
3
+ import * as React from 'react';
4
+ import { useT } from '../i18n/use-t';
5
+ export declare namespace RelayServicesUtil {
6
+ /** What a service is called: the official relay, its name, else its host or its folder. */
7
+ function label(service: TaRelayService, t: ReturnType<typeof useT>): string;
8
+ /** Where a service is: a relay's host, a folder's path, where a store of a package is (a host, a bucket). */
9
+ function where(service: TaRelayService): string;
10
+ /** Whether a service can carry a feature: all can but a folder and a store, which only sync uses. */
11
+ function serves(service: TaRelayService, feature: TaRelayFeature): boolean;
12
+ /** The icon of a service: the official relay, a relay, a folder, a store by the icon its package gave its type. */
13
+ function icon(service: TaRelayService, types?: readonly TaRelayTypeInfo[]): LucideIcon;
14
+ function iconNamed(name: string | undefined): LucideIcon;
15
+ /** What a relay shows under its name: where it is, whether it answers, what it keeps. */
16
+ function line(service: TaRelayService, probe: TaRelayProbe | undefined, t: ReturnType<typeof useT>): string;
17
+ }
18
+ /**
19
+ * The relays of relays.json (docs/design/ta-relays.md) and which one each feature uses: phones that reach this
20
+ * computer, links that share, rooms and playing together, sync of the user's computers. A relay is the official one,
21
+ * one on the user's own Cloudflare or `ta relay` behind HTTPS; it reads none of what goes through it. What a feature
22
+ * made before (a device, a room, a link) stays on its relay when the choice changes.
23
+ */
24
+ export declare function RelayServices(): React.JSX.Element | null;
25
+ //# sourceMappingURL=relay-services.d.ts.map