@celljs/ta-web 4.11.0 → 4.13.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 (281) 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 +10 -6
  9. package/esm/browser/assistant/assistant.d.ts +5 -0
  10. package/esm/browser/assistant/assistant.js +25 -6
  11. package/esm/browser/chat/chat-view.js +6 -5
  12. package/esm/browser/components/app-nav.d.ts +3 -1
  13. package/esm/browser/components/app-nav.js +5 -2
  14. package/esm/browser/components/app-view.js +26 -13
  15. package/esm/browser/components/asks-badge.d.ts +5 -0
  16. package/esm/browser/components/asks-badge.js +8 -0
  17. package/esm/browser/components/chat-asks.d.ts +46 -0
  18. package/esm/browser/components/chat-asks.js +101 -0
  19. package/esm/browser/components/chat-list.d.ts +7 -1
  20. package/esm/browser/components/chat-list.js +46 -17
  21. package/esm/browser/components/composer-addon-util.d.ts +11 -0
  22. package/esm/browser/components/composer-addon-util.js +40 -0
  23. package/esm/browser/components/composer-addons.d.ts +1 -7
  24. package/esm/browser/components/composer-addons.js +1 -27
  25. package/esm/browser/components/composer-box.d.ts +1 -0
  26. package/esm/browser/components/composer-box.js +50 -28
  27. package/esm/browser/components/composer.d.ts +10 -1
  28. package/esm/browser/components/composer.js +61 -22
  29. package/esm/browser/components/connection-bar.js +31 -12
  30. package/esm/browser/components/conversation-scroll-hooks.d.ts +16 -0
  31. package/esm/browser/components/conversation-scroll-hooks.js +98 -0
  32. package/esm/browser/components/conversation-scroll-util.d.ts +35 -0
  33. package/esm/browser/components/conversation-scroll-util.js +74 -0
  34. package/esm/browser/components/conversation-scroll.d.ts +57 -33
  35. package/esm/browser/components/conversation-scroll.js +188 -123
  36. package/esm/browser/components/discover-view.js +5 -1
  37. package/esm/browser/components/earlier-messages.d.ts +10 -3
  38. package/esm/browser/components/earlier-messages.js +14 -8
  39. package/esm/browser/components/face.d.ts +24 -0
  40. package/esm/browser/components/face.js +42 -0
  41. package/esm/browser/components/folder-picker.d.ts +2 -0
  42. package/esm/browser/components/folder-picker.js +7 -0
  43. package/esm/browser/components/host-view.d.ts +1 -1
  44. package/esm/browser/components/markdown.js +4 -2
  45. package/esm/browser/components/media.js +25 -11
  46. package/esm/browser/components/mermaid-view.js +45 -3
  47. package/esm/browser/components/message-actions.js +1 -0
  48. package/esm/browser/components/message-footer.d.ts +4 -0
  49. package/esm/browser/components/message-footer.js +8 -1
  50. package/esm/browser/components/message-list.d.ts +15 -1
  51. package/esm/browser/components/message-list.js +204 -41
  52. package/esm/browser/components/phone-shell.d.ts +7 -2
  53. package/esm/browser/components/phone-shell.js +9 -3
  54. package/esm/browser/components/relay-services.d.ts +24 -0
  55. package/esm/browser/components/relay-services.js +249 -0
  56. package/esm/browser/components/relay-view.js +17 -1
  57. package/esm/browser/components/remote-hosts.js +1 -1
  58. package/esm/browser/components/session-view.d.ts +3 -1
  59. package/esm/browser/components/session-view.js +23 -7
  60. package/esm/browser/components/settings-controls.js +3 -3
  61. package/esm/browser/components/settings-parts.js +13 -1
  62. package/esm/browser/components/stop-times.d.ts +47 -0
  63. package/esm/browser/components/stop-times.js +81 -0
  64. package/esm/browser/components/ta-avatar.js +6 -0
  65. package/esm/browser/components/tool-result.d.ts +13 -0
  66. package/esm/browser/components/tool-result.js +138 -0
  67. package/esm/browser/components/tool-view.js +5 -15
  68. package/esm/browser/components/use-stop-times.d.ts +3 -0
  69. package/esm/browser/components/use-stop-times.js +17 -0
  70. package/esm/browser/components/web-composer.js +2 -1
  71. package/esm/browser/device/photo-picker.d.ts +14 -0
  72. package/esm/browser/device/photo-picker.js +48 -0
  73. package/esm/browser/device/row-swipe.d.ts +2 -0
  74. package/esm/browser/device/row-swipe.js +8 -2
  75. package/esm/browser/device/sheet-swipe.d.ts +1 -1
  76. package/esm/browser/device/sheet-swipe.js +17 -3
  77. package/esm/browser/extension/extension-view.d.ts +3 -1
  78. package/esm/browser/extension/extension-view.js +7 -0
  79. package/esm/browser/extension/icons.js +10 -1
  80. package/esm/browser/extension/web-api-components.d.ts +21 -3
  81. package/esm/browser/extension/web-api-contributions.d.ts +128 -0
  82. package/esm/browser/extension/web-extension-api.d.ts +45 -48
  83. package/esm/browser/extension/web-extension-context.d.ts +6 -1
  84. package/esm/browser/extension/web-extension-context.js +72 -7
  85. package/esm/browser/extension/web-extension-protocol.d.ts +18 -2
  86. package/esm/browser/extension/web-extension-protocol.js +2 -0
  87. package/esm/browser/extension/web-extension-run.d.ts +3 -2
  88. package/esm/browser/extension/web-extension-run.js +3 -0
  89. package/esm/browser/extension/web-extensions.d.ts +2 -8
  90. package/esm/browser/extension/web-extensions.js +12 -35
  91. package/esm/browser/extension/web-page-list.d.ts +25 -0
  92. package/esm/browser/extension/web-page-list.js +35 -0
  93. package/esm/browser/extension/web-session-notices.d.ts +6 -1
  94. package/esm/browser/extension/web-session-notices.js +30 -4
  95. package/esm/browser/extension/web-sharing.d.ts +5 -2
  96. package/esm/browser/extension/web-sharing.js +10 -1
  97. package/esm/browser/i18n/locales.d.ts +77 -1
  98. package/esm/browser/i18n/messages.d.ts +76 -0
  99. package/esm/browser/i18n/messages.js +154 -2
  100. package/esm/browser/links/links-protocol.d.ts +2 -0
  101. package/esm/browser/links/links.d.ts +7 -2
  102. package/esm/browser/links/links.js +16 -9
  103. package/esm/browser/markdown/code-renderers.d.ts +4 -0
  104. package/esm/browser/markdown/code-renderers.js +4 -0
  105. package/esm/browser/markdown/lazy.d.ts +8 -0
  106. package/esm/browser/markdown/lazy.js +35 -0
  107. package/esm/browser/markdown/mermaid.d.ts +15 -3
  108. package/esm/browser/markdown/mermaid.js +45 -6
  109. package/esm/browser/notices/notices-protocol.d.ts +5 -0
  110. package/esm/browser/notices/notices.d.ts +19 -0
  111. package/esm/browser/notices/notices.js +85 -2
  112. package/esm/browser/notices/session-notices.d.ts +5 -2
  113. package/esm/browser/notices/session-notices.js +10 -1
  114. package/esm/browser/style/base.d.ts +1 -1
  115. package/esm/browser/style/base.js +2 -1
  116. package/esm/browser/style/conversation.d.ts +1 -1
  117. package/esm/browser/style/conversation.js +53 -0
  118. package/esm/browser/style/device.js +3 -0
  119. package/esm/browser/style/layout.d.ts +1 -1
  120. package/esm/browser/style/layout.js +27 -9
  121. package/esm/browser/style/pages.d.ts +1 -1
  122. package/esm/browser/style/pages.js +5 -0
  123. package/esm/browser/style/phone.d.ts +1 -1
  124. package/esm/browser/style/phone.js +2 -0
  125. package/esm/browser/style/shell.d.ts +1 -1
  126. package/esm/browser/style/shell.js +16 -3
  127. package/esm/browser/style/surfaces.d.ts +1 -1
  128. package/esm/browser/style/surfaces.js +19 -0
  129. package/esm/browser/util/desktop.d.ts +18 -1
  130. package/esm/browser/util/desktop.js +13 -0
  131. package/esm/browser/util/frame.d.ts +2 -0
  132. package/esm/browser/util/frame.js +2 -0
  133. package/esm/browser/util/process.d.ts +69 -2
  134. package/esm/browser/util/process.js +163 -8
  135. package/esm/browser/util/progress.d.ts +6 -1
  136. package/esm/browser/util/progress.js +11 -2
  137. package/esm/browser/util/scroll-rest.d.ts +10 -0
  138. package/esm/browser/util/scroll-rest.js +44 -0
  139. package/esm/browser/util/tool-result.d.ts +32 -0
  140. package/esm/browser/util/tool-result.js +85 -0
  141. package/esm/browser/util/tool.js +7 -0
  142. package/lib/browser/assistant/assistant-extension.js +14 -0
  143. package/lib/browser/assistant/assistant-initiative.d.ts +28 -0
  144. package/lib/browser/assistant/assistant-initiative.js +80 -0
  145. package/lib/browser/assistant/assistant-task-source.d.ts +7 -0
  146. package/lib/browser/assistant/assistant-task-source.js +12 -2
  147. package/lib/browser/assistant/assistant-view.js +8 -4
  148. package/lib/browser/assistant/assistant.d.ts +5 -0
  149. package/lib/browser/assistant/assistant.js +24 -5
  150. package/lib/browser/chat/chat-view.js +6 -5
  151. package/lib/browser/components/app-nav.d.ts +3 -1
  152. package/lib/browser/components/app-nav.js +5 -2
  153. package/lib/browser/components/app-view.js +25 -12
  154. package/lib/browser/components/asks-badge.d.ts +6 -0
  155. package/lib/browser/components/asks-badge.js +44 -0
  156. package/lib/browser/components/chat-asks.d.ts +47 -0
  157. package/lib/browser/components/chat-asks.js +104 -0
  158. package/lib/browser/components/chat-list.d.ts +7 -1
  159. package/lib/browser/components/chat-list.js +46 -17
  160. package/lib/browser/components/composer-addon-util.d.ts +12 -0
  161. package/lib/browser/components/composer-addon-util.js +76 -0
  162. package/lib/browser/components/composer-addons.d.ts +1 -7
  163. package/lib/browser/components/composer-addons.js +2 -29
  164. package/lib/browser/components/composer-box.d.ts +1 -0
  165. package/lib/browser/components/composer-box.js +48 -26
  166. package/lib/browser/components/composer.d.ts +10 -1
  167. package/lib/browser/components/composer.js +61 -21
  168. package/lib/browser/components/connection-bar.js +30 -11
  169. package/lib/browser/components/conversation-scroll-hooks.d.ts +17 -0
  170. package/lib/browser/components/conversation-scroll-hooks.js +135 -0
  171. package/lib/browser/components/conversation-scroll-util.d.ts +36 -0
  172. package/lib/browser/components/conversation-scroll-util.js +78 -0
  173. package/lib/browser/components/conversation-scroll.d.ts +57 -33
  174. package/lib/browser/components/conversation-scroll.js +189 -158
  175. package/lib/browser/components/discover-view.js +5 -1
  176. package/lib/browser/components/earlier-messages.d.ts +10 -3
  177. package/lib/browser/components/earlier-messages.js +16 -9
  178. package/lib/browser/components/face.d.ts +25 -0
  179. package/lib/browser/components/face.js +79 -0
  180. package/lib/browser/components/folder-picker.d.ts +2 -0
  181. package/lib/browser/components/folder-picker.js +7 -0
  182. package/lib/browser/components/host-view.d.ts +1 -1
  183. package/lib/browser/components/markdown.js +3 -1
  184. package/lib/browser/components/media.js +24 -10
  185. package/lib/browser/components/mermaid-view.js +45 -3
  186. package/lib/browser/components/message-actions.js +1 -0
  187. package/lib/browser/components/message-footer.d.ts +4 -0
  188. package/lib/browser/components/message-footer.js +8 -0
  189. package/lib/browser/components/message-list.d.ts +15 -1
  190. package/lib/browser/components/message-list.js +200 -35
  191. package/lib/browser/components/phone-shell.d.ts +7 -2
  192. package/lib/browser/components/phone-shell.js +9 -3
  193. package/lib/browser/components/relay-services.d.ts +25 -0
  194. package/lib/browser/components/relay-services.js +286 -0
  195. package/lib/browser/components/relay-view.js +17 -1
  196. package/lib/browser/components/remote-hosts.js +1 -1
  197. package/lib/browser/components/session-view.d.ts +3 -1
  198. package/lib/browser/components/session-view.js +23 -7
  199. package/lib/browser/components/settings-controls.js +3 -3
  200. package/lib/browser/components/settings-parts.js +13 -1
  201. package/lib/browser/components/stop-times.d.ts +48 -0
  202. package/lib/browser/components/stop-times.js +85 -0
  203. package/lib/browser/components/ta-avatar.js +6 -0
  204. package/lib/browser/components/tool-result.d.ts +14 -0
  205. package/lib/browser/components/tool-result.js +175 -0
  206. package/lib/browser/components/tool-view.js +10 -20
  207. package/lib/browser/components/use-stop-times.d.ts +4 -0
  208. package/lib/browser/components/use-stop-times.js +53 -0
  209. package/lib/browser/components/web-composer.js +2 -1
  210. package/lib/browser/device/photo-picker.d.ts +15 -0
  211. package/lib/browser/device/photo-picker.js +51 -0
  212. package/lib/browser/device/row-swipe.d.ts +2 -0
  213. package/lib/browser/device/row-swipe.js +8 -2
  214. package/lib/browser/device/sheet-swipe.d.ts +1 -1
  215. package/lib/browser/device/sheet-swipe.js +17 -3
  216. package/lib/browser/extension/extension-view.d.ts +3 -1
  217. package/lib/browser/extension/extension-view.js +8 -1
  218. package/lib/browser/extension/icons.js +9 -0
  219. package/lib/browser/extension/web-api-components.d.ts +21 -3
  220. package/lib/browser/extension/web-api-contributions.d.ts +128 -0
  221. package/lib/browser/extension/web-extension-api.d.ts +45 -48
  222. package/lib/browser/extension/web-extension-context.d.ts +6 -1
  223. package/lib/browser/extension/web-extension-context.js +73 -8
  224. package/lib/browser/extension/web-extension-protocol.d.ts +18 -2
  225. package/lib/browser/extension/web-extension-protocol.js +2 -0
  226. package/lib/browser/extension/web-extension-run.d.ts +3 -2
  227. package/lib/browser/extension/web-extension-run.js +3 -0
  228. package/lib/browser/extension/web-extensions.d.ts +2 -8
  229. package/lib/browser/extension/web-extensions.js +12 -35
  230. package/lib/browser/extension/web-page-list.d.ts +26 -0
  231. package/lib/browser/extension/web-page-list.js +39 -0
  232. package/lib/browser/extension/web-session-notices.d.ts +6 -1
  233. package/lib/browser/extension/web-session-notices.js +30 -4
  234. package/lib/browser/extension/web-sharing.d.ts +5 -2
  235. package/lib/browser/extension/web-sharing.js +10 -1
  236. package/lib/browser/i18n/locales.d.ts +77 -1
  237. package/lib/browser/i18n/messages.d.ts +76 -0
  238. package/lib/browser/i18n/messages.js +154 -2
  239. package/lib/browser/links/links-protocol.d.ts +2 -0
  240. package/lib/browser/links/links.d.ts +7 -2
  241. package/lib/browser/links/links.js +16 -9
  242. package/lib/browser/markdown/code-renderers.d.ts +4 -0
  243. package/lib/browser/markdown/code-renderers.js +5 -1
  244. package/lib/browser/markdown/lazy.d.ts +8 -0
  245. package/lib/browser/markdown/lazy.js +37 -1
  246. package/lib/browser/markdown/mermaid.d.ts +15 -3
  247. package/lib/browser/markdown/mermaid.js +44 -5
  248. package/lib/browser/notices/notices-protocol.d.ts +5 -0
  249. package/lib/browser/notices/notices.d.ts +19 -0
  250. package/lib/browser/notices/notices.js +84 -1
  251. package/lib/browser/notices/session-notices.d.ts +5 -2
  252. package/lib/browser/notices/session-notices.js +10 -1
  253. package/lib/browser/style/base.d.ts +1 -1
  254. package/lib/browser/style/base.js +2 -1
  255. package/lib/browser/style/conversation.d.ts +1 -1
  256. package/lib/browser/style/conversation.js +53 -0
  257. package/lib/browser/style/device.js +3 -0
  258. package/lib/browser/style/layout.d.ts +1 -1
  259. package/lib/browser/style/layout.js +27 -9
  260. package/lib/browser/style/pages.d.ts +1 -1
  261. package/lib/browser/style/pages.js +5 -0
  262. package/lib/browser/style/phone.d.ts +1 -1
  263. package/lib/browser/style/phone.js +2 -0
  264. package/lib/browser/style/shell.d.ts +1 -1
  265. package/lib/browser/style/shell.js +16 -3
  266. package/lib/browser/style/surfaces.d.ts +1 -1
  267. package/lib/browser/style/surfaces.js +19 -0
  268. package/lib/browser/util/desktop.d.ts +18 -1
  269. package/lib/browser/util/desktop.js +13 -0
  270. package/lib/browser/util/frame.d.ts +2 -0
  271. package/lib/browser/util/frame.js +2 -0
  272. package/lib/browser/util/process.d.ts +69 -2
  273. package/lib/browser/util/process.js +165 -9
  274. package/lib/browser/util/progress.d.ts +6 -1
  275. package/lib/browser/util/progress.js +11 -2
  276. package/lib/browser/util/scroll-rest.d.ts +11 -0
  277. package/lib/browser/util/scroll-rest.js +47 -0
  278. package/lib/browser/util/tool-result.d.ts +33 -0
  279. package/lib/browser/util/tool-result.js +88 -0
  280. package/lib/browser/util/tool.js +7 -0
  281. package/package.json +7 -7
@@ -54,6 +54,19 @@ var DesktopUtil;
54
54
  return has('debugWebview', scope) && typeof debug === 'function' ? (webContentsId, method, params) => debug(webContentsId, method, params) : undefined;
55
55
  }
56
56
  DesktopUtil.debugWebview = debugWebview;
57
+ /**
58
+ * Ta Desktop tells of what conversations say while its window is closed, hidden or minimized, with notices of the
59
+ * system of its own: the page leaves those times to it. `onOpen` hears one tapped; undefined elsewhere.
60
+ */
61
+ function notices(scope = globalThis) {
62
+ var _a, _b;
63
+ const onOpen = (_b = (_a = scope.taDesktop) === null || _a === void 0 ? void 0 : _a.notices) === null || _b === void 0 ? void 0 : _b.onOpen;
64
+ if (!has('notices', scope) || typeof onOpen !== 'function') {
65
+ return undefined;
66
+ }
67
+ return Object.freeze({ onOpen: (listener) => onOpen(listener) });
68
+ }
69
+ DesktopUtil.notices = notices;
57
70
  /** The screenshots of this computer, where Ta Desktop finds them. */
58
71
  function recentShots(scope = globalThis) {
59
72
  var _a;
@@ -4,6 +4,8 @@ export interface FrameScheduler {
4
4
  cancel(handle: number): void;
5
5
  }
6
6
  export declare namespace FrameUtil {
7
+ /** requestAnimationFrame, or a timer of one frame where there is none. */
8
+ const animation: FrameScheduler;
7
9
  /**
8
10
  * The listener, called at most once a frame however often the returned function is: a store that
9
11
  * changes many times between two frames costs one render. `cancel` drops a call not made yet.
@@ -7,6 +7,8 @@ const ANIMATION_FRAME = typeof requestAnimationFrame === 'function'
7
7
  : { request: callback => setTimeout(callback, 16), cancel: handle => clearTimeout(handle) };
8
8
  var FrameUtil;
9
9
  (function (FrameUtil) {
10
+ /** requestAnimationFrame, or a timer of one frame where there is none. */
11
+ FrameUtil.animation = ANIMATION_FRAME;
10
12
  /**
11
13
  * The listener, called at most once a frame however often the returned function is: a store that
12
14
  * changes many times between two frames costs one render. `cancel` drops a call not made yet.
@@ -20,12 +20,31 @@ export type ProcessStep = {
20
20
  kind: 'tool';
21
21
  key: string;
22
22
  call: ContentBlock;
23
+ }
24
+ /** A request that failed on the way, which the work went on after (pi retried it, or the user said to go on). */
25
+ | {
26
+ kind: 'error';
27
+ key: string;
28
+ text: string;
29
+ }
30
+ /** What the user said while it worked, which pi gave it after the results of its tools (steering): it went on with it. */
31
+ | {
32
+ kind: 'said';
33
+ key: string;
34
+ message: SessionMessage;
23
35
  };
36
+ /**
37
+ * How a turn that is over ended, when not with a reply: an error, stopped by the user, cut off in the middle of
38
+ * its work (the service stopped, the agent ended its turn with calls not done), or without a word after its work.
39
+ */
40
+ export type TurnEnding = 'error' | 'aborted' | 'interrupted' | 'silent';
24
41
  /** A message shown as it is: from the user, a `!command`, a message of an extension, a summary. */
25
42
  export interface MessageItem {
26
43
  kind: 'message';
27
44
  key: string;
28
45
  message: SessionMessage;
46
+ /** A message of the user written while the agent was at its reply: it waited for the reply to end (a follow-up). */
47
+ queued?: boolean;
29
48
  }
30
49
  /**
31
50
  * The assistant and tool result messages in a row: the work (thinking, tool calls, what ta said on
@@ -37,7 +56,7 @@ export interface TurnItem {
37
56
  /** The messages it is made of; the same objects while they do not change. */
38
57
  messages: SessionMessage[];
39
58
  steps: ProcessStep[];
40
- /** The text at the end, after the last tool call. */
59
+ /** The text at the end, after the last tool call; while active and after steps, it is still among them. */
41
60
  reply: string[];
42
61
  /** The last assistant message: its stop reason and error. */
43
62
  last?: SessionMessage;
@@ -60,9 +79,31 @@ export declare namespace ProcessUtil {
60
79
  * fills, not another put in its place. `offset`: where `messages` start in the conversation, so that
61
80
  * the keys stay as earlier messages come in front. A message not shown (see `hidden`) in the middle of
62
81
  * the work stays in its turn: an external agent that goes on on its own, with the files it changed
63
- * noted between, reads as one turn, not as a turn for each time it went on.
82
+ * noted between, reads as one turn, not as a turn for each time it went on. So does a message of the user it was
83
+ * given on the way (`steered`): a step of the turn, not the start of another.
64
84
  */
65
85
  function items(messages: SessionMessage[], working: boolean, offset?: number, renderers?: Readonly<Record<string, unknown>>): ThreadItem[];
86
+ /**
87
+ * The message at `index`, of the user, steered a turn: it came after the result of a tool and was written before
88
+ * it, while the agent worked; pi gave it to the agent with the results, and the work went on. One after another
89
+ * that did (written at once) did too. A message of the user that steered is a step of its turn, not an ask.
90
+ */
91
+ function steered(messages: readonly SessionMessage[], index: number): boolean;
92
+ /**
93
+ * Words on the way with a fenced block a web extension draws (WebExtensionAPI.registerCodeRenderer,
94
+ * `renderers` by language in lower case): a card for the user, as a choice to make, stays in sight when
95
+ * the steps fold.
96
+ */
97
+ function pinned(step: ProcessStep, renderers: Readonly<Record<string, unknown>>): step is Extract<ProcessStep, {
98
+ kind: 'text';
99
+ }>;
100
+ /** How `item` ended, when it is over and did not end with a reply. */
101
+ function ending(item: TurnItem): TurnEnding | undefined;
102
+ /**
103
+ * The summary of a turn that only compacted the context of an external agent (`/compact`): over, no tool
104
+ * called, no reply, its summary last; else undefined. It shows as pi's own compaction does, not as a turn.
105
+ */
106
+ function compaction(item: TurnItem): string | undefined;
66
107
  /** The tool calls: what "N steps" counts. */
67
108
  function tools(steps: ProcessStep[]): ContentBlock[];
68
109
  /** The steps shown: all of them, or while it works the latest few when more than two would fold. */
@@ -88,6 +129,11 @@ export declare namespace ProcessUtil {
88
129
  function shown(item: ThreadItem, renderers: Readonly<Record<string, unknown>>): boolean;
89
130
  /** A custom message the page draws nothing for: `display` false and no renderer of a web extension for its type. */
90
131
  function hidden(message: SessionMessage, renderers: Readonly<Record<string, unknown>>): boolean;
132
+ /**
133
+ * What the user said next after each turn (`said` reads a message of theirs), undefined for one they did not answer
134
+ * yet and for every other item: a card of the turn that asked them to pick knows it was answered, typed or tapped.
135
+ */
136
+ function answers(items: readonly ThreadItem[], said: (message: SessionMessage) => string): (string | undefined)[];
91
137
  /**
92
138
  * The time to show above each item, as WeChat does between messages: above the first item with a time,
93
139
  * and above one that began `TIME_BREAK_MS` or more after the one shown before it; else undefined. An
@@ -105,4 +151,25 @@ export declare namespace ProcessUtil {
105
151
  /** The two items show the same: their messages are the same objects, and so is whether it works. */
106
152
  function same(a: ThreadItem, b: ThreadItem): boolean;
107
153
  }
154
+ /**
155
+ * Which rows of a conversation came in after it was drawn (they come in with a motion): those after the row that was
156
+ * last when it was drawn, by key. Rows put in front (earlier messages, more of the row window) move the indexes of all
157
+ * rows, not which are new; more than MAX at the end at once, or the row they count from gone (a rewind), start again
158
+ * from the end.
159
+ */
160
+ export declare class FreshRows {
161
+ /** More rows than this at the end at once: the conversation loaded again, not messages that came in. */
162
+ static readonly MAX = 2;
163
+ private still;
164
+ private last;
165
+ constructor(items: readonly {
166
+ key: string;
167
+ }[]);
168
+ /** From which index `items` (as drawn now) came in after the list was drawn. */
169
+ from(items: readonly {
170
+ key: string;
171
+ }[]): number;
172
+ /** Searched from the end, where new rows are. */
173
+ private static lastIndexOf;
174
+ }
108
175
  //# sourceMappingURL=process.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProcessUtil = exports.TIME_BREAK_MS = exports.VISIBLE_STEPS = void 0;
3
+ exports.FreshRows = exports.ProcessUtil = exports.TIME_BREAK_MS = exports.VISIBLE_STEPS = void 0;
4
4
  const ta_protocol_1 = require("@celljs/ta-protocol");
5
5
  const message_1 = require("./message");
6
6
  /** While the agent works, only the latest steps show; the earlier ones fold into one row. */
@@ -20,7 +20,8 @@ var ProcessUtil;
20
20
  * fills, not another put in its place. `offset`: where `messages` start in the conversation, so that
21
21
  * the keys stay as earlier messages come in front. A message not shown (see `hidden`) in the middle of
22
22
  * the work stays in its turn: an external agent that goes on on its own, with the files it changed
23
- * noted between, reads as one turn, not as a turn for each time it went on.
23
+ * noted between, reads as one turn, not as a turn for each time it went on. So does a message of the user it was
24
+ * given on the way (`steered`): a step of the turn, not the start of another.
24
25
  */
25
26
  function items(messages, working, offset = 0, renderers = {}) {
26
27
  var _a;
@@ -29,12 +30,17 @@ var ProcessUtil;
29
30
  while (index < messages.length) {
30
31
  const role = messages[index].role;
31
32
  if (!TURN_ROLES.has(role)) {
32
- items.push({ kind: 'message', key: `m${offset + index}`, message: messages[index] });
33
+ const item = { kind: 'message', key: `m${offset + index}`, message: messages[index] };
34
+ if (index > 0 && writtenBefore(messages[index], messages[index - 1])) {
35
+ item.queued = true;
36
+ }
37
+ items.push(item);
33
38
  index++;
34
39
  continue;
35
40
  }
36
41
  const start = index;
37
- while (index < messages.length && (TURN_ROLES.has(messages[index].role) || hidden(messages[index], renderers))) {
42
+ while (index < messages.length &&
43
+ (TURN_ROLES.has(messages[index].role) || hidden(messages[index], renderers) || steered(messages, index))) {
38
44
  index++;
39
45
  }
40
46
  items.push(turn(messages.slice(start, index), offset + start, working && index === messages.length));
@@ -45,14 +51,55 @@ var ProcessUtil;
45
51
  return items;
46
52
  }
47
53
  ProcessUtil.items = items;
54
+ /**
55
+ * The message at `index`, of the user, steered a turn: it came after the result of a tool and was written before
56
+ * it, while the agent worked; pi gave it to the agent with the results, and the work went on. One after another
57
+ * that did (written at once) did too. A message of the user that steered is a step of its turn, not an ask.
58
+ */
59
+ function steered(messages, index) {
60
+ var _a;
61
+ if (((_a = messages[index]) === null || _a === void 0 ? void 0 : _a.role) !== 'user') {
62
+ return false;
63
+ }
64
+ for (let before = index - 1; before >= 0; before--) {
65
+ const { role } = messages[before];
66
+ if (role === 'user') {
67
+ return steered(messages, before);
68
+ }
69
+ if (TURN_ROLES.has(role)) {
70
+ return role === 'toolResult' && writtenBefore(messages[index], messages[before]);
71
+ }
72
+ }
73
+ return false;
74
+ }
75
+ ProcessUtil.steered = steered;
76
+ /** `message`, of the user, was written before `previous`, of the agent, came: while the agent worked. */
77
+ function writtenBefore(message, previous) {
78
+ const { role, timestamp } = message;
79
+ const { role: was, timestamp: at } = previous;
80
+ return role === 'user' && !!was && TURN_ROLES.has(was) && typeof timestamp === 'number' && typeof at === 'number' && timestamp < at;
81
+ }
48
82
  function turn(messages, start, active) {
49
83
  const steps = [];
50
84
  let last;
85
+ let final = messages.length - 1;
86
+ while (final >= 0 && messages[final].role !== 'assistant') {
87
+ final--;
88
+ }
51
89
  messages.forEach((message, offset) => {
52
- if (message.role !== 'assistant') {
90
+ var _a;
91
+ const { role } = message;
92
+ if (role === 'user') {
93
+ steps.push({ kind: 'said', key: `${start + offset}.u`, message });
94
+ }
95
+ if (role !== 'assistant') {
53
96
  return;
54
97
  }
55
98
  last = message;
99
+ const { errorMessage } = message;
100
+ if (offset !== final && message_1.MessageUtil.stopReason(message) === 'error') {
101
+ steps.push({ kind: 'error', key: `${start + offset}.e`, text: (_a = errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.trim()) !== null && _a !== void 0 ? _a : '' });
102
+ }
56
103
  message_1.MessageUtil.blocks(message).forEach((block, position) => {
57
104
  var _a, _b;
58
105
  const key = `${start + offset}.${position}`;
@@ -72,9 +119,63 @@ var ProcessUtil;
72
119
  while (end > 0 && steps[end - 1].kind === 'text') {
73
120
  end--;
74
121
  }
122
+ // While ta works after steps, what it says is one more step: a tool may follow it. The reply is what it ends with.
123
+ if (active && end > 0) {
124
+ end = steps.length;
125
+ }
75
126
  const reply = steps.slice(end).map(step => (step.kind === 'text' ? step.text : ''));
76
127
  return { kind: 'turn', key: `t${start}`, messages, steps: steps.slice(0, end), reply, last, active };
77
128
  }
129
+ /**
130
+ * Words on the way with a fenced block a web extension draws (WebExtensionAPI.registerCodeRenderer,
131
+ * `renderers` by language in lower case): a card for the user, as a choice to make, stays in sight when
132
+ * the steps fold.
133
+ */
134
+ function pinned(step, renderers) {
135
+ if (step.kind !== 'text') {
136
+ return false;
137
+ }
138
+ for (const [, language] of step.text.matchAll(/^ {0,3}(?:`{3,}|~{3,})[ \t]*([^\s`{]+)/gm)) {
139
+ if (renderers[language.toLowerCase()] !== undefined) {
140
+ return true;
141
+ }
142
+ }
143
+ return false;
144
+ }
145
+ ProcessUtil.pinned = pinned;
146
+ /** How `item` ended, when it is over and did not end with a reply. */
147
+ function ending(item) {
148
+ var _a;
149
+ if (item.active) {
150
+ return undefined;
151
+ }
152
+ const stopReason = message_1.MessageUtil.stopReason(item.last);
153
+ if (stopReason === 'error' || stopReason === 'aborted') {
154
+ return stopReason;
155
+ }
156
+ const roles = item.messages.map(message => message.role).filter(role => TURN_ROLES.has(role));
157
+ if (roles[roles.length - 1] === 'toolResult' || stopReason === 'toolUse') {
158
+ return 'interrupted';
159
+ }
160
+ // An external agent that compacted its context (/compact) ends its turn with the summary, not a reply.
161
+ if (((_a = item.steps[item.steps.length - 1]) === null || _a === void 0 ? void 0 : _a.kind) === 'summary') {
162
+ return undefined;
163
+ }
164
+ return item.last && !item.reply.some(text => text.trim()) ? 'silent' : undefined;
165
+ }
166
+ ProcessUtil.ending = ending;
167
+ /**
168
+ * The summary of a turn that only compacted the context of an external agent (`/compact`): over, no tool
169
+ * called, no reply, its summary last; else undefined. It shows as pi's own compaction does, not as a turn.
170
+ */
171
+ function compaction(item) {
172
+ const last = item.steps[item.steps.length - 1];
173
+ if (item.active || (last === null || last === void 0 ? void 0 : last.kind) !== 'summary' || item.reply.some(text => text.trim()) || item.steps.some(step => step.kind === 'tool')) {
174
+ return undefined;
175
+ }
176
+ return last.text;
177
+ }
178
+ ProcessUtil.compaction = compaction;
78
179
  /** The tool calls: what "N steps" counts. */
79
180
  function tools(steps) {
80
181
  return steps.flatMap(step => (step.kind === 'tool' ? [step.call] : []));
@@ -125,11 +226,11 @@ var ProcessUtil;
125
226
  const phase = ProcessUtil.phase(item.messages);
126
227
  return phase === 'thinking' ? 'thinking' : phase === 'writing' ? 'speaking' : 'working';
127
228
  }
128
- const stopReason = message_1.MessageUtil.stopReason(item.last);
129
- if (stopReason === 'error') {
229
+ const ended = ending(item);
230
+ if (ended === 'error' || ended === 'interrupted' || ended === 'silent') {
130
231
  return 'attention';
131
232
  }
132
- return last && stopReason !== 'aborted' ? 'done' : 'idle';
233
+ return last && ended !== 'aborted' ? 'done' : 'idle';
133
234
  }
134
235
  ProcessUtil.mood = mood;
135
236
  /** When each item began: its first message; one still empty (a turn about to come), when the one before did. */
@@ -157,6 +258,25 @@ var ProcessUtil;
157
258
  return role === 'custom' && !display && (customType === undefined || renderers[customType] === undefined);
158
259
  }
159
260
  ProcessUtil.hidden = hidden;
261
+ /**
262
+ * What the user said next after each turn (`said` reads a message of theirs), undefined for one they did not answer
263
+ * yet and for every other item: a card of the turn that asked them to pick knows it was answered, typed or tapped.
264
+ */
265
+ function answers(items, said) {
266
+ const out = new Array(items.length).fill(undefined);
267
+ let next;
268
+ for (let index = items.length - 1; index >= 0; index--) {
269
+ const item = items[index];
270
+ if (item.kind === 'message' && item.message.role === 'user') {
271
+ next = said(item.message);
272
+ }
273
+ else if (item.kind === 'turn') {
274
+ out[index] = next;
275
+ }
276
+ }
277
+ return out;
278
+ }
279
+ ProcessUtil.answers = answers;
160
280
  /**
161
281
  * The time to show above each item, as WeChat does between messages: above the first item with a time,
162
282
  * and above one that began `TIME_BREAK_MS` or more after the one shown before it; else undefined. An
@@ -204,10 +324,46 @@ var ProcessUtil;
204
324
  /** The two items show the same: their messages are the same objects, and so is whether it works. */
205
325
  function same(a, b) {
206
326
  if (a.kind === 'message' || b.kind === 'message') {
207
- return a.kind === b.kind && a.message === b.message;
327
+ return a.kind === b.kind && a.message === b.message && a.queued === b.queued;
208
328
  }
209
329
  return a.active === b.active && a.messages.length === b.messages.length && a.messages.every((message, index) => message === b.messages[index]);
210
330
  }
211
331
  ProcessUtil.same = same;
212
332
  })(ProcessUtil || (exports.ProcessUtil = ProcessUtil = {}));
333
+ /**
334
+ * Which rows of a conversation came in after it was drawn (they come in with a motion): those after the row that was
335
+ * last when it was drawn, by key. Rows put in front (earlier messages, more of the row window) move the indexes of all
336
+ * rows, not which are new; more than MAX at the end at once, or the row they count from gone (a rewind), start again
337
+ * from the end.
338
+ */
339
+ class FreshRows {
340
+ constructor(items) {
341
+ var _a;
342
+ this.still = this.last = (_a = items.at(-1)) === null || _a === void 0 ? void 0 : _a.key;
343
+ }
344
+ /** From which index `items` (as drawn now) came in after the list was drawn. */
345
+ from(items) {
346
+ var _a;
347
+ const previous = FreshRows.lastIndexOf(items, this.last);
348
+ this.last = (_a = items.at(-1)) === null || _a === void 0 ? void 0 : _a.key;
349
+ let from = FreshRows.lastIndexOf(items, this.still);
350
+ if (previous < 0 || from < 0 || items.length - 1 - previous > FreshRows.MAX) {
351
+ this.still = this.last;
352
+ from = items.length - 1;
353
+ }
354
+ return from + 1;
355
+ }
356
+ /** Searched from the end, where new rows are. */
357
+ static lastIndexOf(items, key) {
358
+ for (let index = items.length - 1; index >= 0; index--) {
359
+ if (items[index].key === key) {
360
+ return index;
361
+ }
362
+ }
363
+ return -1;
364
+ }
365
+ }
366
+ exports.FreshRows = FreshRows;
367
+ /** More rows than this at the end at once: the conversation loaded again, not messages that came in. */
368
+ FreshRows.MAX = 2;
213
369
  //# sourceMappingURL=process.js.map
@@ -24,12 +24,15 @@ export type Phase = {
24
24
  kind: 'attention';
25
25
  } | {
26
26
  kind: 'compacting';
27
- } | {
27
+ }
28
+ /** `error`: what the provider said, for a reason without a word of its own. */
29
+ | {
28
30
  kind: 'retrying';
29
31
  attempt: number;
30
32
  maxAttempts: number;
31
33
  seconds: number;
32
34
  reason: RetryReason;
35
+ error?: string;
33
36
  };
34
37
  /** Why pi retries, read from the error of the provider: what the loading line says before its countdown. */
35
38
  export type RetryReason = 'rateLimit' | 'overloaded' | 'network' | 'error';
@@ -50,6 +53,8 @@ export declare namespace ProgressUtil {
50
53
  }): string;
51
54
  /** What ta does now, the most pressing first: a question for the user, then pi's own work, then the model's. */
52
55
  function phase(state: SessionState, renderers?: readonly WebToolRendererResolver[]): Phase;
56
+ /** The first line of an error, short enough for the loading line. */
57
+ function brief(error: string | undefined, length?: number): string;
53
58
  /** Why a request failed, as the provider said it: a rate limit, a model too busy, the network, or another error. */
54
59
  function retryReason(errorMessage: string | undefined): RetryReason;
55
60
  /** The seconds left of a wait of `delayMs` that began at `since`, rounded up: 0 once it is over. */
@@ -41,7 +41,8 @@ var ProgressUtil;
41
41
  case 'compacting':
42
42
  return t('ta.progress.compacting');
43
43
  case 'retrying': {
44
- const reason = t(`ta.progress.retry.${phase.reason}`);
44
+ const error = phase.reason === 'error' ? ProgressUtil.brief(phase.error) : '';
45
+ const reason = error || t(`ta.progress.retry.${phase.reason}`);
45
46
  const seconds = (_b = options.secondsLeft) !== null && _b !== void 0 ? _b : phase.seconds;
46
47
  return seconds > 0
47
48
  ? t('ta.progress.retrying', { reason, seconds, attempt: phase.attempt, max: phase.maxAttempts })
@@ -61,7 +62,9 @@ var ProgressUtil;
61
62
  }
62
63
  if (state.retry) {
63
64
  const { attempt, maxAttempts, delayMs, errorMessage } = state.retry;
64
- return { kind: 'retrying', attempt, maxAttempts, seconds: Math.max(1, Math.round(delayMs / 1000)), reason: retryReason(errorMessage) };
65
+ const reason = retryReason(errorMessage);
66
+ const seconds = Math.max(1, Math.round(delayMs / 1000));
67
+ return { kind: 'retrying', attempt, maxAttempts, seconds, reason, ...(reason === 'error' && errorMessage ? { error: errorMessage } : {}) };
65
68
  }
66
69
  const [request] = state.pendingClientTools;
67
70
  if (request) {
@@ -90,6 +93,12 @@ var ProgressUtil;
90
93
  }
91
94
  }
92
95
  ProgressUtil.phase = phase;
96
+ /** The first line of an error, short enough for the loading line. */
97
+ function brief(error, length = 60) {
98
+ const line = (error !== null && error !== void 0 ? error : '').trim().split('\n')[0].trim();
99
+ return line.length > length ? `${line.slice(0, length - 1)}…` : line;
100
+ }
101
+ ProgressUtil.brief = brief;
93
102
  /** Why a request failed, as the provider said it: a rate limit, a model too busy, the network, or another error. */
94
103
  function retryReason(errorMessage) {
95
104
  const message = errorMessage !== null && errorMessage !== void 0 ? errorMessage : '';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Whether the user scrolls the page, anywhere in it: what costs a frame and need not happen now (a diagram drawn,
3
+ * the avatars moving) waits for it to rest, QUIET_MS without a scroll and no finger on it, for a fling not to stutter.
4
+ */
5
+ export declare namespace ScrollRest {
6
+ /** Whether the page scrolls now (or a finger holds it). */
7
+ function moving(now?: number): boolean;
8
+ /** Once the page rests, or WAIT_MS at most. */
9
+ function wait(): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=scroll-rest.d.ts.map
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScrollRest = void 0;
4
+ /**
5
+ * Whether the user scrolls the page, anywhere in it: what costs a frame and need not happen now (a diagram drawn,
6
+ * the avatars moving) waits for it to rest, QUIET_MS without a scroll and no finger on it, for a fling not to stutter.
7
+ */
8
+ var ScrollRest;
9
+ (function (ScrollRest) {
10
+ const QUIET_MS = 150;
11
+ /** At most this long: what follows a reply streaming scrolls on and on. */
12
+ const WAIT_MS = 1000;
13
+ let last = Number.NEGATIVE_INFINITY;
14
+ let touching = false;
15
+ let listening = false;
16
+ function listen() {
17
+ if (listening || typeof document === 'undefined') {
18
+ return;
19
+ }
20
+ listening = true;
21
+ const passive = { capture: true, passive: true };
22
+ document.addEventListener('scroll', () => (last = performance.now()), passive);
23
+ document.addEventListener('touchstart', () => (touching = true), passive);
24
+ const lifted = (event) => {
25
+ touching = event.touches.length > 0;
26
+ last = performance.now();
27
+ };
28
+ document.addEventListener('touchend', lifted, passive);
29
+ document.addEventListener('touchcancel', lifted, passive);
30
+ }
31
+ /** Whether the page scrolls now (or a finger holds it). */
32
+ function moving(now = performance.now()) {
33
+ listen();
34
+ return touching || now - last < QUIET_MS;
35
+ }
36
+ ScrollRest.moving = moving;
37
+ /** Once the page rests, or WAIT_MS at most. */
38
+ async function wait() {
39
+ listen();
40
+ const until = performance.now() + WAIT_MS;
41
+ for (let now = performance.now(); now < until && moving(now); now = performance.now()) {
42
+ await new Promise(resolve => setTimeout(resolve, Math.max(16, QUIET_MS - (now - last))));
43
+ }
44
+ }
45
+ ScrollRest.wait = wait;
46
+ })(ScrollRest || (exports.ScrollRest = ScrollRest = {}));
47
+ //# sourceMappingURL=scroll-rest.js.map
@@ -0,0 +1,33 @@
1
+ /** What an external agent's tool wrote when it returned nothing (`AgentTool` of @celljs/ta-agents). */
2
+ export declare const NO_OUTPUT = "(no output)";
3
+ /** What a script returned, the shape code mode scripts of agents answer with. */
4
+ export interface ScriptResult {
5
+ result: unknown;
6
+ stdout: string;
7
+ stderr: string;
8
+ failures: {
9
+ tool: string;
10
+ error: string;
11
+ }[];
12
+ }
13
+ /** What a command printed. */
14
+ export interface ShellResult {
15
+ stdout: string;
16
+ stderr: string;
17
+ exitCode?: number;
18
+ }
19
+ /** The output of a tool as a person reads it: JSON opened, the colors of a terminal left out. */
20
+ export declare namespace ResultUtil {
21
+ function clean(text: string): string;
22
+ /** The object or array a text holds, when the whole text is JSON of one. */
23
+ function json(text: string): object | undefined;
24
+ /** A script's answer: `{ result, stdout, stderr, toolFailures }`, the result being what it returned. */
25
+ function script(value: unknown): ScriptResult | undefined;
26
+ /** What a command printed: `{ stdout, stderr, exitCode }`. */
27
+ function shell(value: unknown): ShellResult | undefined;
28
+ /** Whether a value shows in the line of its key: a number, a word, a short line. */
29
+ function inline(value: unknown): boolean;
30
+ /** How a value that shows in a line reads. */
31
+ function atom(value: unknown): string;
32
+ }
33
+ //# sourceMappingURL=tool-result.d.ts.map
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResultUtil = exports.NO_OUTPUT = void 0;
4
+ /** What an external agent's tool wrote when it returned nothing (`AgentTool` of @celljs/ta-agents). */
5
+ exports.NO_OUTPUT = '(no output)';
6
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: the escape that starts a color of a terminal
7
+ const ANSI = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
8
+ const SCRIPT_KEYS = new Set(['result', 'stdout', 'stderr', 'toolFailures', 'toolFailureNotice']);
9
+ const SHELL_KEYS = new Set(['stdout', 'stderr', 'exitCode', 'signal', 'interrupted', 'denied', 'sandboxHint']);
10
+ /** The longest string shown in a line beside its key. */
11
+ const INLINE_CHARS = 72;
12
+ function str(value) {
13
+ return typeof value === 'string' ? value : '';
14
+ }
15
+ function record(value) {
16
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
17
+ }
18
+ /** The output of a tool as a person reads it: JSON opened, the colors of a terminal left out. */
19
+ var ResultUtil;
20
+ (function (ResultUtil) {
21
+ function clean(text) {
22
+ return text.replace(ANSI, '').replace(/\n+$/, '');
23
+ }
24
+ ResultUtil.clean = clean;
25
+ /** The object or array a text holds, when the whole text is JSON of one. */
26
+ function json(text) {
27
+ const trimmed = text.trim();
28
+ if (!/^[[{]/.test(trimmed)) {
29
+ return undefined;
30
+ }
31
+ try {
32
+ const value = JSON.parse(trimmed);
33
+ return value && typeof value === 'object' ? value : undefined;
34
+ }
35
+ catch (_a) {
36
+ return undefined;
37
+ }
38
+ }
39
+ ResultUtil.json = json;
40
+ /** A script's answer: `{ result, stdout, stderr, toolFailures }`, the result being what it returned. */
41
+ function script(value) {
42
+ var _a;
43
+ const object = record(value);
44
+ if (!object || !('result' in object) || !Object.keys(object).every(key => SCRIPT_KEYS.has(key))) {
45
+ return undefined;
46
+ }
47
+ const calls = (_a = record(object.toolFailures)) === null || _a === void 0 ? void 0 : _a.calls;
48
+ const failures = (Array.isArray(calls) ? calls : []).map(call => { var _a, _b; return ({
49
+ tool: str((_a = record(call)) === null || _a === void 0 ? void 0 : _a.tool),
50
+ error: clean(str((_b = record(call)) === null || _b === void 0 ? void 0 : _b.error)),
51
+ }); });
52
+ return { result: object.result, stdout: clean(str(object.stdout)), stderr: clean(str(object.stderr)), failures };
53
+ }
54
+ ResultUtil.script = script;
55
+ /** What a command printed: `{ stdout, stderr, exitCode }`. */
56
+ function shell(value) {
57
+ const object = record(value);
58
+ if (!object || typeof object.stdout !== 'string' || !('stderr' in object || 'exitCode' in object)) {
59
+ return undefined;
60
+ }
61
+ if (!Object.keys(object).every(key => SHELL_KEYS.has(key))) {
62
+ return undefined;
63
+ }
64
+ const exitCode = typeof object.exitCode === 'number' ? object.exitCode : undefined;
65
+ return { stdout: clean(object.stdout), stderr: clean(str(object.stderr)), exitCode };
66
+ }
67
+ ResultUtil.shell = shell;
68
+ /** Whether a value shows in the line of its key: a number, a word, a short line. */
69
+ function inline(value) {
70
+ if (typeof value === 'string') {
71
+ return value.length <= INLINE_CHARS && !value.includes('\n') && !json(value);
72
+ }
73
+ return value === null || typeof value !== 'object' || (Array.isArray(value) ? value.length === 0 : Object.keys(value).length === 0);
74
+ }
75
+ ResultUtil.inline = inline;
76
+ /** How a value that shows in a line reads. */
77
+ function atom(value) {
78
+ if (Array.isArray(value)) {
79
+ return '[]';
80
+ }
81
+ if (value && typeof value === 'object') {
82
+ return '{}';
83
+ }
84
+ return typeof value === 'string' ? value || '""' : String(value);
85
+ }
86
+ ResultUtil.atom = atom;
87
+ })(ResultUtil || (exports.ResultUtil = ResultUtil = {}));
88
+ //# sourceMappingURL=tool-result.js.map
@@ -52,6 +52,13 @@ const AGENT_TOOL_VERBS = {
52
52
  TaskOutput: 'ta.tool.verb.getTask',
53
53
  TaskStop: 'ta.tool.verb.stopTask',
54
54
  Skill: 'ta.tool.verb.skill',
55
+ SendMessage: 'ta.tool.verb.sendMessage',
56
+ TeamDelete: 'ta.tool.verb.deleteTeam',
57
+ CronCreate: 'ta.tool.verb.scheduleTask',
58
+ CronList: 'ta.tool.verb.listScheduled',
59
+ CronDelete: 'ta.tool.verb.deleteScheduled',
60
+ Artifact: 'ta.tool.verb.publish',
61
+ ImageEdit: 'ta.tool.verb.editImage',
55
62
  };
56
63
  const TARGET_CHARS = 160;
57
64
  function str(value) {