@celljs/ta-web 4.12.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 (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
package/README.en.md CHANGED
@@ -23,7 +23,7 @@ Initially, the interface shows only conversations. You tell Ta what you want thi
23
23
  Everything new in the interface comes from **web extensions** within packages, using the same mechanism and terminology as pi extensions:
24
24
 
25
25
  - **Packages** are pi packages. In the `pi` field of `package.json`, `extensions` are extensions for Ta (terminal and server), and `web` are extensions for this page; when not declared, modules in the `web/` directory are used. Packages can be placed in `~/.ta/agent/extensions/<name>/` or the project's `.ta/extensions/` to take effect, or installed with `ta install`.
26
- - **Web extensions** are ES modules without import statements, with a default export of a function that the page calls with `pi`; the returned function is called on unload. The `pi` interface follows pi's ExtensionAPI naming: `ui.setWidget` (default above the input box, same as pi; `placement: 'panel'` puts it in the right workbench's card tabs), `registerView` (pages in the navigation bar, or a list of the sidebar at the top of the navigation bar; `location: 'panel'` is a tool in the right workbench; `discover: true` keeps a page not used every day under Discover until the user pins it), `registerMessageRenderer` (displays custom messages sent by pi extensions with `sendMessage`), `registerCodeRenderer` (draws the fenced blocks of a language in replies and in `ui.Markdown` as a card of the extension's own; the component gets `{ code, language, closed }`, `closed` false while the block streams, and a renderer that throws shows the block as code, as the `ta-glance` cards of `@celljs/ta-glance`), `registerTool` (tools executed by the browser in conversations opened on the page), `registerToolRenderer` (as pi's, a resolver `(toolName, next) => renderer` that chooses how calls of any tool read in conversations: `renderCall(args)` gives a verb, a target and a small icon in the language of the page, in place of the tool's name; `next()` is what the resolvers after it would use), `registerSettings` (a section of the settings, after those of Ta: rows of a label, a description and a control the extension draws, the values kept with `storage`), `registerTasks` / `ui.useTasks` (work done for the user, listed by the double with its own tasks and those of other extensions; see docs/design/ta-double.md. A task with `remove` and `removeHint` can be swiped away in the lists, or selected with others and deleted at once; `ui.removeTasks` asks the user), `ui.SelectCheck` / `ui.SelectBar` (the round mark at the start of a row and the bar under a list while it selects several, as the lists of the page), `registerOpener` (opens links in replies: files and their lines, directories, web pages, asked in registration order, returns true if opened), `registerComposerAddon` (adds to the message box of every conversation: `actions(conversation)` are entries of the + menu, each a tile of its grid (four by two a page, more a page to swipe to): `setting: true` shows its value (`detail`) under its label, `toggle: true` is a switch (`checked` is on, its icon lit; turning it leaves the menu open), and entries may have `items`, a list in its place; `above` is drawn above the box; `subscribe` says the entries changed. `conversation` says which: `sessionId`, `sessionFile`, `cwd`, `kind` `double` or `chat`, `group`, `title`; the double, agents and plain conversations all have it), `ui.Game3D` (a 3D game on Three.js: `setup(context)` gets a renderer, a scene, a camera and OrbitControls, fills the scene and returns what to do each frame; loaded, asleep and ended as `ui.Game`, its scene and WebGL context given back at the end), `ui.FullScreen` (covers all of the page: the shell, its head and side columns under it, under the notch and the home bar, below the title bar of the desktop app and above the keyboard; its touches are all its own, an edge brings out no panel of Ta; for a game held sideways or a world to walk in, `??` back to its place in an app older than it), `data-own-gestures` (an attribute of an element whose touches are its own: the slides of Ta start there only from an edge of the screen, a held finger opens no menu; games carry it), `ui.Game` (a game on Phaser 4, the game engine of the page, loaded when the first game starts; it fills its parent, sleeps while out of sight and ends when it unmounts, takes the keyboard only while it has the focus, and finds the colors of the theme in its registry; see docs/design/ta-games.md), `ui.QrCode` (a QR code of a text, black on white whatever the theme), `ui.ImageViewer` (a picture to look at closely: all of it at first and never larger than its own pixels, pinched with two fingers or a trackpad, zoomed with Ctrl/⌘ and the wheel or a double click or tap, dragged or scrolled once zoomed, with − / the scale / + / fit to window / actual size below it, and given `onPrevious` / `onNext` the pictures beside it by buttons at its sides and, unless zoomed, ← →; the previews of pictures in the workbench and the large pictures of a conversation are this), `on` (events of the current conversation), `sendUserMessage` (sends to the current conversation; a `/command` runs a command of a pi extension), `switchSession` (shows another session open in ta serve as the current conversation; given a Promise of the session id it switches at once and shows "Opening", `opening` giving the title meanwhile), `openChat` (opens the conversation of a session file as the lists do: at once from what the page or the device has, opened again in one round trip when it closed; false when no conversation has it), `callHost` (calls a method of the package's `pi.host`, through `callPackageHost`), `reloadExtensions` (after an extension installed, imported or removed packages itself, reloads the web extensions and the pi extensions of the current conversation as at the end of a reply), `ui.showView` / `ui.useView` (shows and reads any extension's view), `ui.Composer` / `ui.Markdown` (the message box and the Markdown of the conversations, the microphone and the hold to talk too; with `commands`, `/` lists the commands a new conversation in `cwd` will have; `voiceSends`, `onTalkSent`, `onListening`, `working` / `onStop` and `after` are those of the double's box: what is heard is sent at once, the page knows what was said by voice to read its answer aloud, that the user talks now, the send button stops what answers, buttons of its own on the right), `ui.HoldToTalk` (a button held to talk, as the bar of the message box: the page dims and listens with its recognizer, 取消 and 编辑 to slide onto, the words given as the finger lets go; nothing where the page cannot listen), `ui.voice` (`canListen` / `canSpeak` / `speak` / `hush`: read aloud in the voice of the settings), the `send` of a view (a page that is a conversation takes a message from another extension as if typed in its box; the double's page has it, its answer comes as its `preview`), `ui.useChatScroll` (scrolls as the conversations: at the bottom it follows new messages, scrolled up it is never pulled back and what is read does not jump, a part opened by a click stays where it was; `sent` is how many messages the user sent, one more of which goes to the bottom), `ui.Empty` (what a list or a view shows while empty: a title and at most one line of hint, centred in its space; `compact` in menus, pickers and dialogs; `picture` puts a picture above), `ui.Picture` / `ui.PictureCards` (small pictures as those of Ta: the shapes of an SVG take the classes `ta-pic-*` and follow the theme; a row of picture cards to click, with a label and a line of description), `ui.Dialog` (a dialog over the page), `preview` of `ui.openEditor` (a preview tab opened by a click, its title in italics, replaced by the next preview, kept by a double click or `ui.pinEditor`), `ui.setEditorDirty` (the tab shows an unsaved dot and asks before closing), `ui.useActiveEditor` (the current tab of the workbench), `ui.DiffEditor` (Monaco's diff editor, side by side or inline, the right side editable), `confirmLabel` / `danger` of `ui.confirm`, `head` of a view (a top bar of its own), `ui.input` / `ui.editor` (asks the user for a line or lines of text, `undefined` when cancelled), the page's `menu` (floating … menu when the page is listed in sidebar) and `pages` (pages listed in sidebar, navigation bar no longer lists them separately), `ui.notify` (notifications in bottom right of page), `ui.notifySession` (tells the user what a conversation said, as a messenger does: nothing while they look at it, nothing of a task the double follows unless it asks; nothing that pops up on a phone or a tablet, the unread dots of the list and of the Chats tab telling; on a computer in front, a banner with the face and name of the conversation, a tap opening it, its `options` buttons that send that answer once from whichever page; a notice of the system while it is not, silent for an answer; without those, a banner that waits for the user when it asks or failed), `ui.confirm` (confirm before continuing, returns whether user agreed), `ui.theme`, `ui.language`, `ui.supportsWebview` (whether a view can show a site in a `<webview>`, as in Ta Desktop, rather than an iframe), `ui.debugWebview` (Ta Desktop: a command of the Chrome DevTools Protocol to the page of such a webview, limited to the page itself), `ui.desktop.browserData` (Ta Desktop on macOS and Windows: the cookies of a profile of the user's browser taken into the browser of Ta once the user says yes in a dialog of the app, and clearing that browser's data), and page services: `server` (session, pi's RPC commands), `workspace` (files and commands in directory), `terminals` (terminals), `packages` (packages) (types see `WebExtensionAPI`).
26
+ - **Web extensions** are ES modules without import statements, with a default export of a function that the page calls with `pi`; the returned function is called on unload. The `pi` interface follows pi's ExtensionAPI naming: `ui.setWidget` (default above the input box, same as pi; `placement: 'panel'` puts it in the right workbench's card tabs), `registerView` (pages in the navigation bar, or a list of the sidebar at the top of the navigation bar; `location: 'panel'` is a tool in the right workbench; `discover: true` keeps a page not used every day under Discover until the user pins it), `registerMessageRenderer` (displays custom messages sent by pi extensions with `sendMessage`), `registerCodeRenderer` (draws the fenced blocks of a language in replies and in `ui.Markdown` as a card of the extension's own; the component gets `{ code, language, closed, send, answer }`, `closed` false while the block streams, `send` sending words as the user to the conversation the block is in (none in a page's `ui.Markdown`; older Ta apps pass none, use `sendUserMessage` there), `answer` what the user said after the reply, once they did (a choice the block offers is made, tapped or typed, on every device; older Ta apps pass no such key), and a renderer that throws shows the block as code, as the `ta-glance` cards of `@celljs/ta-glance`), `registerTool` (tools executed by the browser in conversations opened on the page), `registerToolRenderer` (as pi's, a resolver `(toolName, next) => renderer` that chooses how calls of any tool read in conversations: `renderCall(args)` gives a verb, a target and a small icon in the language of the page, in place of the tool's name; `next()` is what the resolvers after it would use), `registerSettings` (a section of the settings, after those of Ta: rows of a label, a description and a control the extension draws, the values kept with `storage`; a row with an empty label is a panel that says what it is itself, found by `search`), `registerTasks` / `ui.useTasks` (work done for the user, listed by the double with its own tasks and those of other extensions; see docs/design/ta-double.md. A task with `remove` and `removeHint` can be swiped away in the lists, or selected with others and deleted at once; `ui.removeTasks` asks the user), `ui.SelectCheck` / `ui.SelectBar` (the round mark at the start of a row and the bar under a list while it selects several, as the lists of the page), `registerOpener` (opens links in replies: files and their lines, directories, web pages, asked in registration order, returns true if opened), `registerComposerAddon` (adds to the message box of every conversation: `actions(conversation)` are entries of the + menu, each a tile of its grid (four by two a page, more a page to swipe to): `setting: true` shows its value (`detail`) under its label, `toggle: true` is a switch (`checked` is on, its icon lit; turning it leaves the menu open), and entries may have `items`, a list in its place; `above` is drawn above the box; `subscribe` says the entries changed. `conversation` says which: `sessionId`, `sessionFile`, `cwd`, `kind` `double` or `chat`, `group`, `title`; the double, agents and plain conversations all have it), `ui.Game3D` (a 3D game on Three.js: `setup(context)` gets a renderer, a scene, a camera and OrbitControls, fills the scene and returns what to do each frame; loaded, asleep and ended as `ui.Game`, its scene and WebGL context given back at the end), `ui.FullScreen` (covers all of the page: the shell, its head and side columns under it, under the notch and the home bar, below the title bar of the desktop app and above the keyboard; its touches are all its own, an edge brings out no panel of Ta; for a game held sideways or a world to walk in, `??` back to its place in an app older than it), `data-own-gestures` (an attribute of an element whose touches are its own: the slides of Ta start there only from an edge of the screen, a held finger opens no menu; games carry it), `ui.Game` (a game on Phaser 4, the game engine of the page, loaded when the first game starts; it fills its parent, sleeps while out of sight and ends when it unmounts, takes the keyboard only while it has the focus, and finds the colors of the theme in its registry; see docs/design/ta-games.md), `ui.QrCode` (a QR code of a text, black on white whatever the theme), `ui.ImageViewer` (a picture to look at closely: all of it at first and never larger than its own pixels, pinched with two fingers or a trackpad, zoomed with Ctrl/⌘ and the wheel or a double click or tap, dragged or scrolled once zoomed, with − / the scale / + / fit to window / actual size below it, and given `onPrevious` / `onNext` the pictures beside it by buttons at its sides and, unless zoomed, ← →; the previews of pictures in the workbench and the large pictures of a conversation are this), `on` (events of the current conversation), `sendUserMessage` (sends to the current conversation; a `/command` runs a command of a pi extension. What an extension sends as the user, by `sendUserMessage`, `server.prompt`, the `send` of a block or `prompt` of its host, says where it came from in the last line of its `<context>`, `[ta:from <package>]` (`TaMessageSource`), and the conversation shows the name and icon of the package above the bubble), `switchSession` (shows another session open in ta serve as the current conversation; given a Promise of the session id it switches at once and shows "Opening", `opening` giving the title meanwhile), `openChat` (opens the conversation of a session file as the lists do: at once from what the page or the device has, opened again in one round trip when it closed; false when no conversation has it), `callHost` (calls a method of the package's `pi.host`, through `callPackageHost`), `reloadExtensions` (after an extension installed, imported or removed packages itself, reloads the web extensions and the pi extensions of the current conversation as at the end of a reply), `ui.showView` / `ui.useView` (shows and reads any extension's view), `ui.Composer` / `ui.Markdown` (the message box and the Markdown of the conversations, the microphone and the hold to talk too; with `commands`, `/` lists the commands a new conversation in `cwd` will have; `voiceSends`, `onTalkSent`, `onListening`, `working` / `onStop` and `after` are those of the double's box: what is heard is sent at once, the page knows what was said by voice to read its answer aloud, that the user talks now, the send button stops what answers, buttons of its own on the right), `ui.HoldToTalk` (a button held to talk, as the bar of the message box: the page dims and listens with its recognizer, 取消 and 编辑 to slide onto, the words given as the finger lets go; nothing where the page cannot listen), `ui.voice` (`canListen` / `canSpeak` / `speak` / `hush`: read aloud in the voice of the settings), the `send` of a view (a page that is a conversation takes a message from another extension as if typed in its box; the double's page has it, its answer comes as its `preview`), `ui.useChatScroll` (scrolls as the conversations: at the bottom it follows new messages, scrolled up it is never pulled back and what is read does not jump, a part opened by a click stays where it was; `sent` is how many messages the user sent, one more of which goes to the bottom), `ui.Empty` (what a list or a view shows while empty: a title and at most one line of hint, centred in its space; `compact` in menus, pickers and dialogs; `picture` puts a picture above), `ui.Picture` / `ui.PictureCards` (small pictures as those of Ta: the shapes of an SVG take the classes `ta-pic-*` and follow the theme; a row of picture cards to click, with a label and a line of description), `ui.Dialog` (a dialog over the page), `preview` of `ui.openEditor` (a preview tab opened by a click, its title in italics, replaced by the next preview, kept by a double click or `ui.pinEditor`), `ui.setEditorDirty` (the tab shows an unsaved dot and asks before closing), `ui.useActiveEditor` (the current tab of the workbench), `ui.DiffEditor` (Monaco's diff editor, side by side or inline, the right side editable), `confirmLabel` / `danger` of `ui.confirm`, `head` of a view (a top bar of its own), `ui.input` / `ui.editor` (asks the user for a line or lines of text, `undefined` when cancelled), the page's `menu` (floating … menu when the page is listed in sidebar) and `pages` (pages listed in sidebar, navigation bar no longer lists them separately), `ui.notify` (notifications in bottom right of page), `ui.notifySession` (tells the user what a conversation said, as a messenger does: nothing while they look at it, nothing of a task the double follows unless it asks; nothing that pops up on a phone or a tablet, the unread dots of the list and of the Chats tab telling; on a computer in front, a banner with the face and name of the conversation, a tap opening it, its `options` buttons that send that answer once from whichever page; a notice of the system while it is not, silent for an answer; without those, a banner that waits for the user when it asks or failed), `ui.confirm` (confirm before continuing, returns whether user agreed), `ui.theme`, `ui.language`, `ui.supportsWebview` (whether a view can show a site in a `<webview>`, as in Ta Desktop, rather than an iframe), `ui.debugWebview` (Ta Desktop: a command of the Chrome DevTools Protocol to the page of such a webview, limited to the page itself), `ui.desktop.browserData` (Ta Desktop on macOS and Windows: the cookies of a profile of the user's browser taken into the browser of Ta once the user says yes in a dialog of the app, and clearing that browser's data), `registerChatIcon` (an icon for conversations of the extension that are no agent, such as a brief it writes or a question it asks, in the lists and on their notices in place of the letter of their directory), `registerHomeItems` / `ui.useHomeItems` (rows of the double's home under the double, for what the user looks at each day, such as a daily brief), `ui.pinChat` (pins a conversation by its session file, or unpins it, as the user does with Pin), `registerSessionMenu` (a section of entries of its own in the menu of a conversation of a list, a right click or a held finger on its row), `ui.custom` (a component of the extension over the page wherever the user is, as pi's `ctx.ui.custom`, closed when the extension stops), `ui.useSessions` / `ui.useSavedSessions` (the open sessions of ta serve and the conversations saved lately, as the lists of the page have them, without a poll of its own), `ui.useAsks` (the conversations that wait for the user to decide, as the top of the list of chats shows them: their last turn asked (`TaSessionInfo.asking`) and the user neither answered nor let it go, or a dialog waits; the latest first), `ui.Face` / `ui.GroupFace` (the face of one who is not Ta, as the agents of channels have, the same for the same `seed` on every device; a group of them), `ui.Stack` (a level pushed over the page as a list pushes what was tapped in it, closed on a phone by the swipe from the left edge and the back of the system too), `ui.useBusy` (what waits on ta serve shows it is busy, so that the user sees the click took), `ui.Switch` (the switch of the settings: an `onChange` that returns a promise shows the new state at once, and the old one again if it fails), and page services: `server` (session, pi's RPC commands), `workspace` (files and commands in directory), `terminals` (terminals), `packages` (packages), and `rooms`, rooms shared with other Ta through the relay (what happens in them comes by `onRoomEvent`, no more once the extension stops) (types see `WebExtensionAPI`).
27
27
  - **The bytes of files**: `pi.files` gives the bytes of a file of the workspace. When the page is served by ta serve itself, `byUrl` is true and the URL of `workspace.fileUrl` loads as it is; in the app on a phone, or when the page is opened through a relay, that URL is not there to load, `byUrl` is false, and `pi.files.read(url)` gives `{ type, size, data }` over the WebSocket (sealed end to end: the relay reads none of it). The previews of @celljs/ta-workspace are built on it: pictures, videos, sounds and PDFs as `blob:` URLs, an HTML report from the text of the file in a sandboxed frame.
28
28
  - **Make packages with natural language**: the built-in extension [@celljs/ta-extensions](../ta-extensions/README.md) includes the skill `ta-package` (also available in the Ta terminal) and adds an "Extensions" page in the navigation bar (create an extension in one sentence, export or import). It documents package format, the web extension interface, and validation steps. At the end of each reply in the current conversation, the page reloads web extensions: new ones load, changed ones reload, and deleted ones unload; when tools change, the conversation reopens that part in the same session file (only for conversations opened on this page); when packages change, the session reloads pi extensions. The page checks again when redisplayed (packages might change in the terminal too).
29
29
  - **Stable**: each extension owns what it registers and removes it all on unload; if one extension fails to load or render, only that extension's area shows an error, without affecting the page or other extensions.
package/README.md CHANGED
@@ -23,7 +23,7 @@ Web 客户端可以装成桌面或手机上的应用:Chrome / Edge 地址栏
23
23
  界面上新增的一切都来自包里的 **Web 扩展**,和 pi 的扩展同一套机制、同一套叫法:
24
24
 
25
25
  - **包**就是 pi 的包。`package.json` 的 `pi` 里,`extensions` 是给 Ta(终端和服务端)的扩展,`web` 是给这个页面的扩展;没有声明时取 `web/` 目录下的模块。包放在 `~/.ta/agent/extensions/<名字>/`(项目的 `.ta/extensions/`)即可生效,也可以用 `ta install` 安装。
26
- - **Web 扩展**是一个不带 import 的 ES 模块,默认导出一个函数,页面用 `pi` 调用它;返回的函数在卸载时调用。`pi` 的接口照 pi 的 ExtensionAPI 命名:`ui.setWidget`(默认在输入框上方,和 pi 一样;`placement: 'panel'` 放进右侧工作台的卡片标签)、`registerView`(导航栏里的页面,或导航栏上方的一个侧栏列表;`location: 'panel'` 是右侧工作台的工具)、`registerMessageRenderer`(显示 pi 扩展用 `sendMessage` 发出的自定义消息)、`registerCodeRenderer`(把回复和 `ui.Markdown` 里某种语言的代码块画成扩展自己的卡片,组件拿到 `{ code, language, closed }`,流式时 `closed` 为假;抛错时显示为代码,如 `@celljs/ta-glance` 的 `ta-glance` 卡片)、`registerTool`(页面打开的对话里由浏览器执行的工具)、`registerToolRenderer`(照 pi 的同名接口传一个 resolver `(toolName, next) => renderer`,决定任意工具的调用在对话里怎么读:`renderCall(args)` 给出页面语言的动词、对象和可选的小图标,代替工具名;`next()` 是后面的 resolver 的结果)、`registerSettings`(设置里的一个分区,排在 Ta 自己的分区之后:每行是标签、说明和扩展自己画的控件,值用 `storage` 保存)、`registerTasks` / `ui.useTasks`(替用户做的事,由分身和其他扩展的任务一起列出,见 docs/design/ta-double.md;任务带 `remove` 和 `removeHint` 时,列表里可以左滑删除、多选后批量删除,询问统一由 `ui.removeTasks` 做)、`ui.SelectCheck` / `ui.SelectBar`(列表多选时行首的圆形勾选和列表底部的操作栏,样式与页面一致)、`registerOpener`(打开回复里的链接:文件及其行、目录、网页,按注册顺序询问,返回 true 表示已打开)、`registerComposerAddon`(给所有对话的输入框加东西:`actions(conversation)` 是 + 菜单里的条目,每个都是一个图标方块(每页 4×2,多了左右滑动翻页):`setting: true` 在名字下显示当前值(`detail`),`toggle: true` 是开关(`checked` 表示开着,图标点亮,点了不关菜单),条目可以带 `items` 二级列表;`above` 画在输入框上方;`subscribe` 通知条目变了。`conversation` 说明是哪个对话:`sessionId`、`sessionFile`、`cwd`、`kind` 为 `double` 或 `chat`、`group`、`title`;分身、智能体和普通对话都有)、`ui.Game3D`(Three.js 3D 游戏:`setup(context)` 拿到渲染器、场景、相机和 OrbitControls,往场景里放东西并返回每帧要做的事;同样懒加载、休眠、卸载时释放场景和 WebGL 上下文)、`ui.FullScreen`(盖住整个页面:外壳、它的顶栏和侧栏都在下面,铺到刘海和底部横条下,在桌面版标题栏之下、键盘之上;触摸全归它,屏幕边缘也不会拉出 Ta 的面板;给横屏游戏、能走进去的世界用,旧版 App 没有它时用 `??` 退回原处显示)、`data-own-gestures`(元素上的属性:从它开始的触摸归它,Ta 的滑动只从屏幕边缘开始,长按不出菜单;游戏自动带上)、`ui.Game`(Phaser 4 游戏:页面自带的游戏引擎,第一次开始游戏时才加载;填满父元素,看不见时休眠,卸载时销毁,键盘只在游戏获得焦点时归它,主题颜色放在游戏的 registry 里,见 docs/design/ta-games.md)、`ui.QrCode`(文字的二维码,任何主题下都是白底黑码)、`ui.ImageViewer`(看图:先完整显示且不超过原始像素,双指或触控板捏合、Ctrl/⌘ 加滚轮、双击或双点缩放,放大后拖动或滚动,底部是 − / 比例 / + / 适应窗口 / 实际大小;给了 `onPrevious` / `onNext` 时两侧有上一张、下一张按钮,未放大时 ← → 也能切换;工作台的图片预览和对话里的大图用的都是它)、`on`(当前对话的事件)、`sendUserMessage`(发到当前对话;`/命令` 会执行 pi 扩展的命令)、`switchSession`(把 ta serve 里另一个打开的会话显示为当前对话;传会话 id 的 Promise 时立即切过去显示"正在打开",`opening` 给出占位的标题)、`openChat`(按会话文件打开对话,和对话列表一样:先显示页面或设备上已有的内容,已关闭的一次往返重新打开;没有这个对话时返回 false)、`callHost`(调用本包 `pi.host` 的方法,经 `callPackageHost`)、`reloadExtensions`(扩展自己安装、导入或移除了包之后,像回复结束时一样重新加载 Web 扩展和当前对话的 pi 扩展)、`ui.showView` / `ui.useView`(显示、查看任意扩展的视图)、`ui.Composer` / `ui.Markdown`(和对话一样的输入框与 Markdown,麦克风和按住说话也一样;输入框的 `commands` 让 `/` 列出在 `cwd` 新开对话时会有的命令,`voiceSends`、`onTalkSent`、`onListening`、`working` / `onStop`、`after` 和分身的输入框一样:听到的话直接发出、知道哪句是说的以便朗读回答、正在听、正在回答时发送键变成停止、右侧放自己的按钮)、`ui.HoldToTalk`(按住说话的按钮,和输入框的“按住 说话”条一样:页面变暗、用页面的识别器听,可滑到“取消”“编辑”,松手交出文字;页面不能识别语音时不显示)、`ui.voice`(`canListen` / `canSpeak` / `speak` / `hush`:用设置里的声音朗读)、视图的 `send`(对话式页面接收别的扩展发来的一条消息,就像在它的输入框里输入;分身页面有它,回答经 `preview` 读到)、`ui.useChatScroll`(和对话一样的滚动:停在底部时跟随新消息,往上翻看时不会被拉回、正在看的内容不跳,点开的部分留在原处;`sent` 是用户发出的消息数,多一条就回到底部)、`ui.Empty`(列表或视图为空时的提示:一行标题加至多一行说明,在所在区域居中;菜单、选择器和弹窗里用 `compact`;`picture` 在上方放一张插图)、`ui.Picture` / `ui.PictureCards`(和 Ta 一样的小插图:SVG 里的图形用 `ta-pic-*` 类名,跟随主题;一排可点的插图卡片,带标签和一行说明)、`ui.Dialog`(盖住整页的弹窗)、`ui.openEditor` 的 `preview`(单击打开的预览标签,标题斜体,下一个预览会替换它,双击或 `ui.pinEditor` 固定)、`ui.setEditorDirty`(标签显示未保存圆点,关闭前确认)、`ui.useActiveEditor`(工作台当前标签)、`ui.DiffEditor`(Monaco 差异编辑器,并排或内联,可编辑右侧)、`ui.confirm` 的 `confirmLabel` / `danger`、视图的 `head`(自己的顶栏)、`ui.input` / `ui.editor`(向用户要一行或多行文字,取消时为 `undefined`)、页面的 `menu`(侧栏列出该页面时悬浮显示的 … 菜单)与 `pages`(侧栏列出的页面,导航栏不再单列)、`discover`(不常用的页面默认收在"发现",用户固定后才进导航栏)、`ui.notify`(页面右下角的通知)、`ui.notifySession`(像聊天软件那样告诉用户某个对话说了什么:用户正在看它时不提醒,分身跟进的任务交给分身,除非它在提问;手机和平板上不弹窗,由列表和“对话”标签上的未读黄点告诉;电脑上页面在前台时是带对话头像和名字的横幅,点一下打开对话,`options` 是可点的回答,同一个回答从各个页面只发一次;页面不在前台时是系统通知,回复是静音的;没有系统通知时,提问和失败留一条横幅等用户回来)、`ui.confirm`(继续前先确认,返回用户是否同意)、`ui.theme`、`ui.language`、`ui.supportsWebview`(能否用 `<webview>` 显示网站,Ta 桌面版里可以,其他地方用 iframe)、`ui.debugWebview`(Ta 桌面版:向这种 webview 里的网页发 Chrome DevTools Protocol 命令,只限网页本身)、`ui.desktop.browserData`(Ta 桌面版,macOS 和 Windows:用户在应用的原生对话框里同意后,把其浏览器某个个人资料的 Cookie 导入内置浏览器;也可清除内置浏览器数据),以及页面的 `React` 和 ta serve 的服务:`server`(会话,pi 的 RPC 命令)、`workspace`(目录里的文件与命令)、`terminals`(终端)、`packages`(包)(类型见 `WebExtensionAPI`)。
26
+ - **Web 扩展**是一个不带 import 的 ES 模块,默认导出一个函数,页面用 `pi` 调用它;返回的函数在卸载时调用。`pi` 的接口照 pi 的 ExtensionAPI 命名:`ui.setWidget`(默认在输入框上方,和 pi 一样;`placement: 'panel'` 放进右侧工作台的卡片标签)、`registerView`(导航栏里的页面,或导航栏上方的一个侧栏列表;`location: 'panel'` 是右侧工作台的工具)、`registerMessageRenderer`(显示 pi 扩展用 `sendMessage` 发出的自定义消息)、`registerCodeRenderer`(把回复和 `ui.Markdown` 里某种语言的代码块画成扩展自己的卡片,组件拿到 `{ code, language, closed, send, answer }`,流式时 `closed` 为假,`send` 把文字作为用户消息发到代码块所在的对话(页面的 `ui.Markdown` 里没有;旧版 App 不传,用 `sendUserMessage`),`answer` 是用户在这条回复之后说的话(点选或打字回答后才有,各设备一致,代码块给的选择就算做了;旧版 App 没有这个键);抛错时显示为代码,如 `@celljs/ta-glance` 的 `ta-glance` 卡片)、`registerTool`(页面打开的对话里由浏览器执行的工具)、`registerToolRenderer`(照 pi 的同名接口传一个 resolver `(toolName, next) => renderer`,决定任意工具的调用在对话里怎么读:`renderCall(args)` 给出页面语言的动词、对象和可选的小图标,代替工具名;`next()` 是后面的 resolver 的结果)、`registerSettings`(设置里的一个分区,排在 Ta 自己的分区之后:每行是标签、说明和扩展自己画的控件,值用 `storage` 保存;标签为空的行是自带说明的整块面板,靠 `search` 被搜到)、`registerTasks` / `ui.useTasks`(替用户做的事,由分身和其他扩展的任务一起列出,见 docs/design/ta-double.md;任务带 `remove` 和 `removeHint` 时,列表里可以左滑删除、多选后批量删除,询问统一由 `ui.removeTasks` 做)、`ui.SelectCheck` / `ui.SelectBar`(列表多选时行首的圆形勾选和列表底部的操作栏,样式与页面一致)、`registerOpener`(打开回复里的链接:文件及其行、目录、网页,按注册顺序询问,返回 true 表示已打开)、`registerComposerAddon`(给所有对话的输入框加东西:`actions(conversation)` 是 + 菜单里的条目,每个都是一个图标方块(每页 4×2,多了左右滑动翻页):`setting: true` 在名字下显示当前值(`detail`),`toggle: true` 是开关(`checked` 表示开着,图标点亮,点了不关菜单),条目可以带 `items` 二级列表;`above` 画在输入框上方;`subscribe` 通知条目变了。`conversation` 说明是哪个对话:`sessionId`、`sessionFile`、`cwd`、`kind` 为 `double` 或 `chat`、`group`、`title`;分身、智能体和普通对话都有)、`ui.Game3D`(Three.js 3D 游戏:`setup(context)` 拿到渲染器、场景、相机和 OrbitControls,往场景里放东西并返回每帧要做的事;同样懒加载、休眠、卸载时释放场景和 WebGL 上下文)、`ui.FullScreen`(盖住整个页面:外壳、它的顶栏和侧栏都在下面,铺到刘海和底部横条下,在桌面版标题栏之下、键盘之上;触摸全归它,屏幕边缘也不会拉出 Ta 的面板;给横屏游戏、能走进去的世界用,旧版 App 没有它时用 `??` 退回原处显示)、`data-own-gestures`(元素上的属性:从它开始的触摸归它,Ta 的滑动只从屏幕边缘开始,长按不出菜单;游戏自动带上)、`ui.Game`(Phaser 4 游戏:页面自带的游戏引擎,第一次开始游戏时才加载;填满父元素,看不见时休眠,卸载时销毁,键盘只在游戏获得焦点时归它,主题颜色放在游戏的 registry 里,见 docs/design/ta-games.md)、`ui.QrCode`(文字的二维码,任何主题下都是白底黑码)、`ui.ImageViewer`(看图:先完整显示且不超过原始像素,双指或触控板捏合、Ctrl/⌘ 加滚轮、双击或双点缩放,放大后拖动或滚动,底部是 − / 比例 / + / 适应窗口 / 实际大小;给了 `onPrevious` / `onNext` 时两侧有上一张、下一张按钮,未放大时 ← → 也能切换;工作台的图片预览和对话里的大图用的都是它)、`on`(当前对话的事件)、`sendUserMessage`(发到当前对话;`/命令` 会执行 pi 扩展的命令。扩展以用户身份发的消息,经 `sendUserMessage`、`server.prompt`、代码块的 `send` 或宿主的 `prompt`,都在 `<context>` 末行带上来源 `[ta:from 包名]`(`TaMessageSource`),对话里在气泡上方显示包的名字和图标)、`switchSession`(把 ta serve 里另一个打开的会话显示为当前对话;传会话 id 的 Promise 时立即切过去显示"正在打开",`opening` 给出占位的标题)、`openChat`(按会话文件打开对话,和对话列表一样:先显示页面或设备上已有的内容,已关闭的一次往返重新打开;没有这个对话时返回 false)、`callHost`(调用本包 `pi.host` 的方法,经 `callPackageHost`)、`reloadExtensions`(扩展自己安装、导入或移除了包之后,像回复结束时一样重新加载 Web 扩展和当前对话的 pi 扩展)、`ui.showView` / `ui.useView`(显示、查看任意扩展的视图)、`ui.Composer` / `ui.Markdown`(和对话一样的输入框与 Markdown,麦克风和按住说话也一样;输入框的 `commands` 让 `/` 列出在 `cwd` 新开对话时会有的命令,`voiceSends`、`onTalkSent`、`onListening`、`working` / `onStop`、`after` 和分身的输入框一样:听到的话直接发出、知道哪句是说的以便朗读回答、正在听、正在回答时发送键变成停止、右侧放自己的按钮)、`ui.HoldToTalk`(按住说话的按钮,和输入框的“按住 说话”条一样:页面变暗、用页面的识别器听,可滑到“取消”“编辑”,松手交出文字;页面不能识别语音时不显示)、`ui.voice`(`canListen` / `canSpeak` / `speak` / `hush`:用设置里的声音朗读)、视图的 `send`(对话式页面接收别的扩展发来的一条消息,就像在它的输入框里输入;分身页面有它,回答经 `preview` 读到)、`ui.useChatScroll`(和对话一样的滚动:停在底部时跟随新消息,往上翻看时不会被拉回、正在看的内容不跳,点开的部分留在原处;`sent` 是用户发出的消息数,多一条就回到底部)、`ui.Empty`(列表或视图为空时的提示:一行标题加至多一行说明,在所在区域居中;菜单、选择器和弹窗里用 `compact`;`picture` 在上方放一张插图)、`ui.Picture` / `ui.PictureCards`(和 Ta 一样的小插图:SVG 里的图形用 `ta-pic-*` 类名,跟随主题;一排可点的插图卡片,带标签和一行说明)、`ui.Dialog`(盖住整页的弹窗)、`ui.openEditor` 的 `preview`(单击打开的预览标签,标题斜体,下一个预览会替换它,双击或 `ui.pinEditor` 固定)、`ui.setEditorDirty`(标签显示未保存圆点,关闭前确认)、`ui.useActiveEditor`(工作台当前标签)、`ui.DiffEditor`(Monaco 差异编辑器,并排或内联,可编辑右侧)、`ui.confirm` 的 `confirmLabel` / `danger`、视图的 `head`(自己的顶栏)、`ui.input` / `ui.editor`(向用户要一行或多行文字,取消时为 `undefined`)、页面的 `menu`(侧栏列出该页面时悬浮显示的 … 菜单)与 `pages`(侧栏列出的页面,导航栏不再单列)、`discover`(不常用的页面默认收在"发现",用户固定后才进导航栏)、`ui.notify`(页面右下角的通知)、`ui.notifySession`(像聊天软件那样告诉用户某个对话说了什么:用户正在看它时不提醒,分身跟进的任务交给分身,除非它在提问;手机和平板上不弹窗,由列表和“对话”标签上的未读黄点告诉;电脑上页面在前台时是带对话头像和名字的横幅,点一下打开对话,`options` 是可点的回答,同一个回答从各个页面只发一次;页面不在前台时是系统通知,回复是静音的;没有系统通知时,提问和失败留一条横幅等用户回来)、`ui.confirm`(继续前先确认,返回用户是否同意)、`ui.theme`、`ui.language`、`ui.supportsWebview`(能否用 `<webview>` 显示网站,Ta 桌面版里可以,其他地方用 iframe)、`ui.debugWebview`(Ta 桌面版:向这种 webview 里的网页发 Chrome DevTools Protocol 命令,只限网页本身)、`ui.desktop.browserData`(Ta 桌面版,macOS 和 Windows:用户在应用的原生对话框里同意后,把其浏览器某个个人资料的 Cookie 导入内置浏览器;也可清除内置浏览器数据)、`registerChatIcon`(扩展自己的、不是智能体的对话(如它写的简报、它问的问题)在列表和通知里的图标,代替目录的字母)、`registerHomeItems` / `ui.useHomeItems`(分身主页里分身下方的行,放用户每天要看的东西,如每日简报)、`ui.pinChat`(按会话文件把对话置顶或取消,和用户点置顶一样)、`registerSessionMenu`(列表里对话的菜单(右键或长按一行)中扩展自己的一组条目)、`ui.custom`(像 pi 的 `ctx.ui.custom` 那样,不论用户在哪,把扩展的组件盖在页面上,扩展停止时一并关闭)、`ui.useSessions` / `ui.useSavedSessions`(ta serve 打开的会话和最近保存的对话,和页面的列表是同一份,不必自己轮询)、`ui.useAsks`(等用户决定的对话,和对话列表顶部“待你决定”是同一份:上一轮在问(`TaSessionInfo.asking`)而用户还没回答也没点“不用决定了”,或有对话框在等;最新的在前)、`ui.Face` / `ui.GroupFace`(不是 Ta 的成员的脸,和频道里的智能体一样,同一个 `seed` 在各设备上相同;群组的叠放头像)、`ui.Stack`(像列表推入点开的内容那样压在页面上的一层,手机上从左边缘滑动和系统返回也能关闭)、`ui.useBusy`(等待 ta serve 的操作显示忙碌,点了就知道生效了)、`ui.Switch`(设置里的开关,`onChange` 返回 Promise 时先显示新状态,失败再退回),以及页面的 `React` 和 ta serve 的服务:`server`(会话,pi 的 RPC 命令)、`workspace`(目录里的文件与命令)、`terminals`(终端)、`packages`(包),以及经中继与其他 Ta 共享的房间 `rooms`(发生的事经 `onRoomEvent` 收到,扩展停止时不再收到)(类型见 `WebExtensionAPI`)。
27
27
  - **文件的字节**:`pi.files` 给出工作区的文件字节。页面由 ta serve 自己提供时 `byUrl` 为真,直接用 `workspace.fileUrl` 的地址加载就行;手机应用里、或页面经中继打开时,那个地址在页面里加载不到,`byUrl` 为假,`pi.files.read(url)` 经 WebSocket 取回 `{ type, size, data }`(端到端加密,中继读不到)。`@celljs/ta-workspace` 的预览就靠它:图片、视频、声音、PDF 做成 `blob:`,HTML 报告按文件文本放进沙框。
28
28
  - **用自然语言做包**:内置扩展 [@celljs/ta-extensions](../ta-extensions/README.md) 带技能 `ta-package`(终端里的 Ta 也有),并在导航栏加了"扩展"页(一句话做扩展、导出导入),写明了包的格式、Web 扩展接口和验证步骤。当前对话每次回复结束,页面重新读取 Web 扩展:新的加载、改过的重新加载、删掉的卸载;工具有变化时,用同一个会话文件重新打开这段对话(只限本页打开的对话),包有改动时让会话重新加载 pi 扩展。页面重新显示时也会检查一次(包也可能在终端里改)。
29
29
  - **稳定**:每个扩展注册的东西归它自己,卸载时一并撤掉;一个扩展加载失败或渲染出错,只在它自己的位置显示错误,不影响页面和其他扩展。
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { Autowired, Component } from '@celljs/core';
11
11
  import { Bot, Copy, Download, Hand, ListTodo, Pencil, RotateCcw, ScrollText, Sparkles, Square, Trash2 } from 'lucide-react';
12
12
  import * as React from 'react';
13
+ import { ChatAskUtil, LET_GO_ASKS } from '../components/chat-asks.js';
13
14
  import { DinoLookPicker } from '../components/dino-look-picker.js';
14
15
  import { BuiltinWebExtension } from '../extension/web-extension-protocol.js';
15
16
  import { message } from '../i18n/messages.js';
@@ -96,6 +97,19 @@ let AssistantWebExtension = class AssistantWebExtension {
96
97
  openDouble: () => pi.ui.showView(`${ASSISTANT_NAME}/assistant`),
97
98
  menu: taskMenu,
98
99
  remove,
100
+ asking: task => {
101
+ var _a;
102
+ const info = this.workbench.state.sessions.find(each => each.sessionId === task.sessionId);
103
+ return info && ((_a = ChatAskUtil.asking(info, this.persisted.get(LET_GO_ASKS))) === null || _a === void 0 ? void 0 : _a.question);
104
+ },
105
+ watchAsking: listener => {
106
+ const stops = [this.workbench.subscribe(() => listener()), this.persisted.subscribe(() => listener())];
107
+ return () => {
108
+ for (const stop of stops) {
109
+ stop();
110
+ }
111
+ };
112
+ },
99
113
  });
100
114
  pi.registerTasks(tasks);
101
115
  const registerPage = () => pi.registerView('assistant', {
@@ -0,0 +1,27 @@
1
+ import type { WebInitiative, WebInitiativeKind } from '../extension/web-api-contributions.js';
2
+ import type { TaWebExtensions } from '../extension/web-extension-protocol.js';
3
+ import type { Settings, TaSettings } from '../settings/settings-protocol.js';
4
+ /** The double starting a task it hands out: by default without asking, as pi asks nothing (Settings.confirmTasks). */
5
+ export declare const START_TASK: WebInitiativeKind;
6
+ /**
7
+ * Whether the double asks before it starts a task, kept with the extension that keeps the user's trust when there is
8
+ * one (WebExtensionAPI.registerInitiative): its level drives Settings.confirmTasks (`act` does not ask), what the user
9
+ * answers moves it, and the user's own switch (the + of the box, the settings) is kept there as their choice. Without
10
+ * one, Settings.confirmTasks alone, as before.
11
+ */
12
+ export declare class AssistantInitiative {
13
+ protected readonly extensions: () => TaWebExtensions | undefined;
14
+ protected readonly settings: () => TaSettings;
15
+ /** Settings.confirmTasks as the level last made it: a change to another value is the user's. */
16
+ protected synced?: boolean;
17
+ protected current?: WebInitiative;
18
+ protected unwatch?: () => void;
19
+ protected unwatchProvider?: () => void;
20
+ constructor(extensions: () => TaWebExtensions | undefined, settings: () => TaSettings);
21
+ start(): void;
22
+ /** The settings changed: a new value of Settings.confirmTasks not of the level is the user's, kept as their choice. */
23
+ settingsChanged(settings: Settings): void;
24
+ /** What the user answered when the double asked. */
25
+ record(outcome: 'accepted' | 'declined', title: string): void;
26
+ protected sync(): Promise<void>;
27
+ }
@@ -0,0 +1,76 @@
1
+ /** The double starting a task it hands out: by default without asking, as pi asks nothing (Settings.confirmTasks). */
2
+ export const START_TASK = {
3
+ id: 'double.start-task',
4
+ title: { en: 'The double starts the tasks it hands out', zh: '分身开始它交出的任务' },
5
+ reversible: true,
6
+ level: 'act',
7
+ };
8
+ /**
9
+ * Whether the double asks before it starts a task, kept with the extension that keeps the user's trust when there is
10
+ * one (WebExtensionAPI.registerInitiative): its level drives Settings.confirmTasks (`act` does not ask), what the user
11
+ * answers moves it, and the user's own switch (the + of the box, the settings) is kept there as their choice. Without
12
+ * one, Settings.confirmTasks alone, as before.
13
+ */
14
+ export class AssistantInitiative {
15
+ constructor(extensions, settings) {
16
+ this.extensions = extensions;
17
+ this.settings = settings;
18
+ }
19
+ start() {
20
+ const extensions = this.extensions();
21
+ if (this.unwatch || !extensions) {
22
+ return;
23
+ }
24
+ const pick = () => {
25
+ var _a, _b, _c;
26
+ const next = (_a = extensions.state.initiatives) === null || _a === void 0 ? void 0 : _a[0];
27
+ if (next === this.current) {
28
+ return;
29
+ }
30
+ (_b = this.unwatchProvider) === null || _b === void 0 ? void 0 : _b.call(this);
31
+ this.current = next;
32
+ this.synced = undefined;
33
+ this.unwatchProvider = (_c = next === null || next === void 0 ? void 0 : next.subscribe) === null || _c === void 0 ? void 0 : _c.call(next, () => void this.sync());
34
+ void this.sync();
35
+ };
36
+ this.unwatch = extensions.subscribe(pick);
37
+ pick();
38
+ }
39
+ /** The settings changed: a new value of Settings.confirmTasks not of the level is the user's, kept as their choice. */
40
+ settingsChanged(settings) {
41
+ const provider = this.current;
42
+ if (!provider || this.synced === undefined || settings.confirmTasks === this.synced) {
43
+ return;
44
+ }
45
+ this.synced = settings.confirmTasks;
46
+ void provider.setLevel(START_TASK, settings.confirmTasks ? 'ask' : 'act').catch(() => undefined);
47
+ }
48
+ /** What the user answered when the double asked. */
49
+ record(outcome, title) {
50
+ var _a;
51
+ void ((_a = this.current) === null || _a === void 0 ? void 0 : _a.record(START_TASK, outcome, title).catch(() => undefined));
52
+ }
53
+ async sync() {
54
+ const provider = this.current;
55
+ if (!provider) {
56
+ return;
57
+ }
58
+ const asking = (await provider.level(START_TASK).catch(() => undefined)) !== 'act';
59
+ if (provider !== this.current) {
60
+ return;
61
+ }
62
+ const settings = this.settings();
63
+ const now = settings.state.settings.confirmTasks;
64
+ // The first time: the user turned asking on before a level was kept, which is their choice.
65
+ if (this.synced === undefined && now && !asking) {
66
+ this.synced = true;
67
+ await provider.setLevel(START_TASK, 'ask').catch(() => undefined);
68
+ return;
69
+ }
70
+ this.synced = asking;
71
+ if (now !== asking) {
72
+ settings.update({ confirmTasks: asking });
73
+ }
74
+ }
75
+ }
76
+ //# sourceMappingURL=assistant-initiative.js.map
@@ -13,6 +13,12 @@ export interface AssistantTaskActions {
13
13
  menu(task: AssistantTask): WebMenuItem[][];
14
14
  /** Deletes it without asking (WebTask.remove). */
15
15
  remove(task: AssistantTask): Promise<void>;
16
+ /**
17
+ * What the conversation of a task asks the user to decide, its turn over (TaSessionInfo.asking, unless let go):
18
+ * the task waits for them. `watchAsking` tells when that may have changed (the list of sessions, what was let go).
19
+ */
20
+ asking?(task: AssistantTask): string | undefined;
21
+ watchAsking?(listener: () => void): () => void;
16
22
  }
17
23
  /** What of a task's session the list shows: a new task object only when it changes. */
18
24
  interface Shown {
@@ -39,6 +45,7 @@ export declare class AssistantTaskSource implements WebTaskSource {
39
45
  }>;
40
46
  protected readonly listeners: Set<() => void>;
41
47
  protected stopAssistant?: () => void;
48
+ protected stopAsking?: () => void;
42
49
  constructor(assistant: TaAssistant, actions: AssistantTaskActions);
43
50
  tasks(): readonly WebTask[];
44
51
  subscribe(listener: () => void): () => void;
@@ -28,8 +28,10 @@ export class AssistantTaskSource {
28
28
  return this.list;
29
29
  }
30
30
  subscribe(listener) {
31
+ var _a, _b;
31
32
  if (this.listeners.size === 0) {
32
33
  this.stopAssistant = this.assistant.subscribe(state => this.sync(state));
34
+ this.stopAsking = (_b = (_a = this.actions).watchAsking) === null || _b === void 0 ? void 0 : _b.call(_a, () => this.build());
33
35
  this.sync(this.assistant.state);
34
36
  // The lists show them before the double is opened.
35
37
  void this.assistant.loadTasks().catch(() => undefined);
@@ -48,9 +50,11 @@ export class AssistantTaskSource {
48
50
  this.sync(this.assistant.state);
49
51
  }
50
52
  dispose() {
51
- var _a;
53
+ var _a, _b;
52
54
  (_a = this.stopAssistant) === null || _a === void 0 ? void 0 : _a.call(this);
53
55
  this.stopAssistant = undefined;
56
+ (_b = this.stopAsking) === null || _b === void 0 ? void 0 : _b.call(this);
57
+ this.stopAsking = undefined;
54
58
  for (const { stop } of this.stores.values()) {
55
59
  stop();
56
60
  }
@@ -109,18 +113,24 @@ export class AssistantTaskSource {
109
113
  }
110
114
  }
111
115
  status(task, state) {
116
+ var _a, _b;
112
117
  if (task.status === 'running' && state && state.pendingUi.length > 0) {
113
118
  return 'waiting';
114
119
  }
120
+ if (task.status !== 'running' && !task.takenOver && ((_b = (_a = this.actions).asking) === null || _b === void 0 ? void 0 : _b.call(_a, task))) {
121
+ return 'waiting';
122
+ }
115
123
  return task.status;
116
124
  }
117
125
  detail(task, status, state) {
126
+ var _a, _b;
118
127
  const { t } = this.actions;
119
128
  if (task.takenOver) {
120
129
  return t('ta.task.takenOver');
121
130
  }
122
131
  if (status === 'waiting') {
123
- return t('ta.task.waiting');
132
+ const asking = task.status === 'running' ? undefined : (_b = (_a = this.actions).asking) === null || _b === void 0 ? void 0 : _b.call(_a, task);
133
+ return asking ? t('ta.chat.toAsk', { question: asking }) : t('ta.task.waiting');
124
134
  }
125
135
  return activity(task, state, t);
126
136
  }
@@ -7,13 +7,13 @@ import { ConnectionBanner } from '../components/connection-bar.js';
7
7
  import { ASK_CLASS } from '../components/conversation-scroll.js';
8
8
  import { useConversationScroll } from '../components/conversation-scroll-hooks.js';
9
9
  import { DialogView } from '../components/dialog-view.js';
10
- import { useAsked, useEarlierMessages } from '../components/earlier-messages.js';
10
+ import { isAsk, useAsked, useEarlierMessages } from '../components/earlier-messages.js';
11
11
  import { HeroCards, HeroSteps } from '../components/hero-cards.js';
12
12
  import { Icon } from '../components/icon.js';
13
13
  import { Markdown } from '../components/markdown.js';
14
14
  import { useMessageActions } from '../components/message-actions.js';
15
15
  import { MessageActions, TimeBreak, TurnFooter, UserFooter } from '../components/message-footer.js';
16
- import { endsInSteps, MessageImages, Process, quiet, SkillUse, TurnAvatar, UserSaid, userWords } from '../components/message-list.js';
16
+ import { endsInSteps, MessageImages, Process, quiet, SkillUse, TurnAvatar, UserMarks, UserSaid, userWords } from '../components/message-list.js';
17
17
  import { useMessageMenu } from '../components/message-menu.js';
18
18
  import { RunStatus } from '../components/run-status.js';
19
19
  import { useSessionSettings } from '../components/session-settings.js';
@@ -74,9 +74,9 @@ export function moodOf({ working, attention, listening, speaking, running, recen
74
74
  }
75
75
  /** `index`: in the whole conversation, of which `messages` start at `start`. */
76
76
  /** What the user said; a task that reports back stays where it comes in. */
77
- const saidByUser = (message) => {
77
+ const saidByUser = (message, index, messages) => {
78
78
  const text = MessageUtil.text(MessageUtil.blocks(message)).trim();
79
- return message.role === 'user' && !TASK_UPDATE.test(text) && !AssistantTaskUtil.isRenamedNote(text);
79
+ return isAsk(message, index, messages) && !TASK_UPDATE.test(text) && !AssistantTaskUtil.isRenamedNote(text);
80
80
  };
81
81
  function lastReply(messages, start) {
82
82
  for (let index = messages.length - 1; index >= 0; index--) {
@@ -109,6 +109,7 @@ function DoubleUserMessage({ message, blocks }) {
109
109
  const { text, copied, skill } = userWords(blocks);
110
110
  const [menu, onContextMenu] = useMessageMenu({ kind: 'user', message, text: copied });
111
111
  return (React.createElement("div", { className: `ta-msg-user ${ASK_CLASS}`, onContextMenu: onContextMenu },
112
+ React.createElement(UserMarks, { blocks: blocks }),
112
113
  skill && React.createElement(SkillUse, { skill: skill }),
113
114
  React.createElement(UserSaid, { blocks: blocks, text: text, bubble: "ta-msg-bubble", timestamp: message.timestamp }),
114
115
  React.createElement(UserFooter, { message: message, text: copied }),
@@ -1,10 +1,12 @@
1
1
  import { type ClientTool, type SessionState, type SessionStore } from '@celljs/ta-client';
2
2
  import { type TaPromptInput, type TaServer, type TaSessionInfo } from '@celljs/ta-protocol';
3
+ import { TaWebExtensions } from '../extension/web-extension-protocol.js';
3
4
  import { TaKeptChats } from '../offline/kept-chats-protocol.js';
4
5
  import { type Settings, TaSettings } from '../settings/settings-protocol.js';
5
6
  import { TaState } from '../state/state-protocol.js';
6
7
  import type { ComposerImage } from '../util/composer.js';
7
8
  import { TaWorkbench } from '../workbench-protocol.js';
9
+ import { AssistantInitiative } from './assistant-initiative.js';
8
10
  import { type AssistantAsk, type AssistantState, type AssistantTask, TaAssistant } from './assistant-protocol.js';
9
11
  import { AssistantTaskBook } from './assistant-task-book.js';
10
12
  /** What the double is to hear of a task that ended (finished), and when it ended. */
@@ -18,6 +20,9 @@ export declare class TaAssistantImpl implements TaAssistant {
18
20
  protected readonly persisted: TaState;
19
21
  protected readonly settings: TaSettings;
20
22
  protected readonly kept: TaKeptChats;
23
+ protected readonly extensions: TaWebExtensions;
24
+ /** Whether it asks before starting a task, kept with the extension of the user's trust. */
25
+ protected readonly initiative: AssistantInitiative;
21
26
  protected current: AssistantState;
22
27
  protected assistant?: SessionStore;
23
28
  /** Until the conversation is open (and while the computer cannot be reached): it as this device kept it. */
@@ -9,11 +9,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { Autowired, Component } from '@celljs/core';
11
11
  import { TaRemoteError } from '@celljs/ta-client';
12
- import { TaErrorCode, TaErrorUtil } from '@celljs/ta-protocol';
12
+ import { TaErrorCode, TaErrorUtil, TaMessageSource, } from '@celljs/ta-protocol';
13
+ import { TaWebExtensions } from '../extension/web-extension-protocol.js';
14
+ import { message } from '../i18n/messages.js';
13
15
  import { TaKeptChats } from '../offline/kept-chats-protocol.js';
14
16
  import { SettingsUtil, TaSettings } from '../settings/settings-protocol.js';
15
17
  import { TaState } from '../state/state-protocol.js';
16
18
  import { TaWorkbench } from '../workbench-protocol.js';
19
+ import { AssistantInitiative } from './assistant-initiative.js';
17
20
  import { TaAssistant } from './assistant-protocol.js';
18
21
  import { ASSISTANT_TOOLS, assistantRole } from './assistant-role.js';
19
22
  import { ASSISTANT_NAME_STATE, AssistantStates } from './assistant-state.js';
@@ -24,6 +27,8 @@ const { FILE, TASKS, PROMPT, ASKING } = AssistantStates;
24
27
  const NOTE_SETTLE_MS = 5000;
25
28
  let TaAssistantImpl = class TaAssistantImpl {
26
29
  constructor() {
30
+ /** Whether it asks before starting a task, kept with the extension of the user's trust. */
31
+ this.initiative = new AssistantInitiative(() => this.extensions, () => this.settings);
27
32
  this.current = { ready: false, tasks: [], asks: [] };
28
33
  this.taskStores = new Map();
29
34
  this.followAgain = false;
@@ -59,6 +64,7 @@ let TaAssistantImpl = class TaAssistantImpl {
59
64
  start() {
60
65
  var _a, _b;
61
66
  (_a = this.unwatchSettings) !== null && _a !== void 0 ? _a : (this.unwatchSettings = this.settings.subscribe(state => this.settingsChanged(state.settings)));
67
+ this.initiative.start();
62
68
  (_b = this.starting) !== null && _b !== void 0 ? _b : (this.starting = this.open().catch(error => {
63
69
  this.starting = undefined;
64
70
  if (TaRemoteError.isConnectionLost(error)) {
@@ -66,7 +72,11 @@ let TaAssistantImpl = class TaAssistantImpl {
66
72
  setTimeout(() => void this.workbench.connected().then(() => (this.starting || this.assistant ? undefined : this.start()), () => undefined), 1000);
67
73
  return;
68
74
  }
69
- this.update({ error: error instanceof Error ? error.message : String(error) });
75
+ // One let into another's Ta without starting conversations there: what they may use is said, not an error of the server.
76
+ const forbidden = TaErrorUtil.code(error) === TaErrorCode.FORBIDDEN;
77
+ this.update({
78
+ error: forbidden ? message(this.settings.state.language, 'ta.assistant.forbidden') : error instanceof Error ? error.message : String(error),
79
+ });
70
80
  }));
71
81
  return this.starting;
72
82
  }
@@ -355,6 +365,7 @@ let TaAssistantImpl = class TaAssistantImpl {
355
365
  }
356
366
  /** Asking first or not is in the role: the conversation opens again with it, once the double is not at work. */
357
367
  settingsChanged(settings) {
368
+ this.initiative.settingsChanged(settings);
358
369
  const store = this.assistant;
359
370
  if (store && settings.assistantModel && settings.assistantModel !== this.model) {
360
371
  void this.applyModel(store.sessionId);
@@ -510,7 +521,7 @@ let TaAssistantImpl = class TaAssistantImpl {
510
521
  }
511
522
  // Its session closed since (idle, or the service restarted): opened again from its file.
512
523
  const store = await this.openTask(id);
513
- await store.prompt(message, { streamingBehavior: 'steer' });
524
+ await store.prompt(TaMessageSource.mark(message, TaMessageSource.DOUBLE), { streamingBehavior: 'steer' });
514
525
  return `Sent to task ${id}.`;
515
526
  },
516
527
  stop_task: async ({ id }) => {
@@ -531,8 +542,12 @@ let TaAssistantImpl = class TaAssistantImpl {
531
542
  throw new Error(`${running} tasks run already, as many as the user lets run at once: wait for one to end (a <task_update> comes), or stop one.`);
532
543
  }
533
544
  const where = cwd || ((_a = this.workbench.state.server) === null || _a === void 0 ? void 0 : _a.cwd) || '.';
534
- if (confirmTasks && !(await this.ask({ id: `a${++this.asked}`, title, instructions, cwd: where, at: Date.now() }))) {
535
- return `The user did not let task "${title}" start. Ask them what they want instead; do not start it again unasked.`;
545
+ if (confirmTasks) {
546
+ const started = await this.ask({ id: `a${++this.asked}`, title, instructions, cwd: where, at: Date.now() });
547
+ this.initiative.record(started ? 'accepted' : 'declined', title);
548
+ if (!started) {
549
+ return `The user did not let task "${title}" start. Ask them what they want instead; do not start it again unasked.`;
550
+ }
536
551
  }
537
552
  const info = await this.server.openSession({ cwd: where });
538
553
  await this.server.setSessionName(info.sessionId, title);
@@ -543,7 +558,7 @@ let TaAssistantImpl = class TaAssistantImpl {
543
558
  const task = { id, title, sessionId: info.sessionId, cwd: info.cwd, status: 'running', startedAt: Date.now(), origin: this.sessionFile };
544
559
  this.book.add(task);
545
560
  const store = await this.follow(task);
546
- await store.prompt(instructions);
561
+ await store.prompt(TaMessageSource.mark(instructions, TaMessageSource.DOUBLE));
547
562
  const { sessionFile } = await this.server.getState(info.sessionId);
548
563
  this.book.change(task, { sessionFile });
549
564
  return `Started task ${this.book.idOf(task)} "${title}" in ${info.cwd}. A <task_update> comes when it ends.`;
@@ -671,6 +686,10 @@ __decorate([
671
686
  Autowired(TaKeptChats),
672
687
  __metadata("design:type", Object)
673
688
  ], TaAssistantImpl.prototype, "kept", void 0);
689
+ __decorate([
690
+ Autowired({ id: TaWebExtensions, detached: true }),
691
+ __metadata("design:type", Object)
692
+ ], TaAssistantImpl.prototype, "extensions", void 0);
674
693
  TaAssistantImpl = __decorate([
675
694
  Component(TaAssistant)
676
695
  ], TaAssistantImpl);
@@ -29,13 +29,15 @@ export interface RailProps {
29
29
  onSurface(surface: PhoneSurface | undefined): void;
30
30
  /** What a held entry does: the double listens, the chats open a new one (entryHold). */
31
31
  holds: EntryHolds;
32
+ /** The conversations that wait for the user to decide (ChatAskUtil.count): a count on the entry of the chats. */
33
+ asks?: number;
32
34
  }
33
35
  /**
34
36
  * The navigation on the left, as the tabs of a phone: the logo; the lists of the sidebar; the pages, and Discover
35
37
  * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
36
38
  * Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
37
39
  */
38
- export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, }: RailProps): React.JSX.Element;
40
+ export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, }: RailProps): React.JSX.Element;
39
41
  /** A sidebar view of a web extension, under its title or its own top bar. */
40
42
  export declare function SidebarView({ view }: {
41
43
  view: WebViewEntry;
@@ -9,6 +9,7 @@ import { useT } from '../i18n/use-t.js';
9
9
  import { ShortcutUtil } from '../settings/agent-settings.js';
10
10
  import { NavigationUtil } from '../settings/navigation.js';
11
11
  import { AccountMenu } from './account-menu.js';
12
+ import { AsksBadge } from './asks-badge.js';
12
13
  import { ConnectionBanner } from './connection-bar.js';
13
14
  import { useContextMenu } from './context-menu.js';
14
15
  import { Dino } from './dino.js';
@@ -47,7 +48,7 @@ function RailItem({ label, active, onClick, onContextMenu, onPointerDown, 'data-
47
48
  * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
48
49
  * Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
49
50
  */
50
- export function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, }) {
51
+ export function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, }) {
51
52
  const t = useT();
52
53
  const [{ server }] = useWorkbench();
53
54
  const [menu, openMenu] = useContextMenu();
@@ -67,7 +68,9 @@ export function Rail({ lists, list, onList, navigation, current, onPage, onDisco
67
68
  React.createElement(Dino, { size: 26 })),
68
69
  React.createElement("div", { className: "ta-rail-items" },
69
70
  navigation.home && item(navigation.home, false, true),
70
- lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, active: list === entry.id, onClick: () => onList(entry.id), ...held(entryHold(entry.id, entry.double, holds)) }, entry.double ? React.createElement(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 })))),
71
+ lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, active: list === entry.id, onClick: () => onList(entry.id), ...held(entryHold(entry.id, entry.double, holds)) },
72
+ entry.double ? React.createElement(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 }),
73
+ entry.id === '' && !!asks && React.createElement(AsksBadge, { count: asks })))),
71
74
  (navigation.nav.length > 0 || discover) && React.createElement("hr", { className: "ta-rail-divider" }),
72
75
  navigation.nav.map(view => item(view)),
73
76
  discover && (React.createElement(RailItem, { label: t('ta.discover'), active: !settingsShown && current === DISCOVER, onClick: onDiscover, onContextMenu: event => openMenu(event, [settingsItem]) },
@@ -6,7 +6,7 @@ import { REMOVED_CHATS } from '../chat/chat-protocol.js';
6
6
  import { ChatView, useChat } from '../chat/chat-view.js';
7
7
  import { useDevice } from '../device/device.js';
8
8
  import { LaunchScreenUtil } from '../device/launch-screen.js';
9
- import { MessageRenderers, SessionAvatars, SessionMenus, ToolRenderers } from '../extension/extension-view.js';
9
+ import { LoadedExtensions, MessageRenderers, SessionAvatars, SessionMenus, ToolRenderers } from '../extension/extension-view.js';
10
10
  import { WebCwdUtil } from '../extension/web-extension-protocol.js';
11
11
  import { TaFiles } from '../files/files-protocol.js';
12
12
  import { useCodeScan, useNotices, useOpenLink, usePersisted, useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
@@ -20,6 +20,7 @@ import { PageView, Rail, SidebarView, useNavigation } from './app-nav.js';
20
20
  import { CARDS_ID, EDITOR, FIRST_SIDE, LOGIN_LATER, RAIL, SIDE, SIDEBAR, useDrawerSwipe, useKeys, useRefresh, useRight, useTitlebarColor, useWorkbenchCards, } from './app-shell-hooks.js';
21
21
  import { AuthUtil, LoginPage, useAuthProviders } from './auth-view.js';
22
22
  import { BoardSurface, useSurfaces } from './board.js';
23
+ import { ChatAskUtil, LET_GO_ASKS } from './chat-asks.js';
23
24
  import { ChatIconsProvider, ChatIconUtil } from './chat-icon.js';
24
25
  import { BY_DIRECTORY, ChatListUtil, FOLDED, PINNED } from './chat-list.js';
25
26
  import { ChatSeenUtil, SEEN_CHATS } from './chat-seen.js';
@@ -70,6 +71,7 @@ function AppShell() {
70
71
  const [chatsByDirectory, setChatsByDirectory] = usePersisted(BY_DIRECTORY);
71
72
  const [foldedChats, setFoldedChats] = usePersisted(FOLDED);
72
73
  const [pinnedChats, setPinnedChats] = usePersisted(PINNED);
74
+ const [letGoAsks, setLetGoAsks] = usePersisted(LET_GO_ASKS);
73
75
  const [navOpen, setNavOpen] = React.useState(false);
74
76
  const layout = useDevice(device => device.layout);
75
77
  const touch = useDevice(device => device.touch);
@@ -394,7 +396,13 @@ function AppShell() {
394
396
  showPage('');
395
397
  }
396
398
  };
397
- const chats = (React.createElement(AssistantChatList, { sessions: workbench.sessions, saved: workbench.saved, removed: removedChats, archived: workbench.archived, onArchive: readArchived, foldDays: chatSettings.chatFoldDays, archiveDays: chatSettings.chatArchiveDays, selected: view || phone ? undefined : (pending !== null && pending !== void 0 ? pending : store === null || store === void 0 ? void 0 : store.sessionId), chat: chat, byDirectory: chatsByDirectory, onByDirectory: setChatsByDirectory, folded: foldedChats, onFolded: setFoldedChats, pinned: pinnedChats, onPinned: setPinnedChats, looking: looking, seen: seenChats, onPicked: picked }));
399
+ const chats = (React.createElement(AssistantChatList, { sessions: workbench.sessions, saved: workbench.saved, removed: removedChats, archived: workbench.archived, onArchive: readArchived, foldDays: chatSettings.chatFoldDays, archiveDays: chatSettings.chatArchiveDays, selected: view || phone ? undefined : (pending !== null && pending !== void 0 ? pending : store === null || store === void 0 ? void 0 : store.sessionId), chat: chat, byDirectory: chatsByDirectory, onByDirectory: setChatsByDirectory, folded: foldedChats, onFolded: setFoldedChats, pinned: pinnedChats, onPinned: setPinnedChats, looking: looking, seen: seenChats, letGo: letGoAsks, onLetGo: entry => {
400
+ var _a;
401
+ const at = (_a = entry.asking) === null || _a === void 0 ? void 0 : _a.at;
402
+ if (at !== undefined) {
403
+ setLetGoAsks(before => ChatAskUtil.letGo(before, ChatListUtil.file(entry), at));
404
+ }
405
+ }, onPicked: picked }));
398
406
  const sideList = sideView ? React.createElement(SidebarView, { view: sideView }) : sideComing ? React.createElement(ListSkeleton, null) : chats;
399
407
  const editorArea = (React.createElement(EditorArea, { editors: extensions.editors, active: activeEditor, views: tools, onShow: id => host.showEditor(id), onClose: ids => void host.closeEditors(ids), onPin: id => host.pinEditor(id), onOpenView: openTool, onHide: editor.toggle, cwd: (_f = WebCwdUtil.shown(extensions)) !== null && _f !== void 0 ? _f : (_c = workbench.server) === null || _c === void 0 ? void 0 : _c.cwd, maximized: maximized, onMaximize: () => setMaximized(!maximized) }));
400
408
  // A photo of the scan screen to the double: its conversation shows, the photo goes with what to do with it.
@@ -476,10 +484,10 @@ function AppShell() {
476
484
  }
477
485
  : {};
478
486
  // The chats' tab has the amber dot of their rows while one of them said something unseen, as a messenger's: of
479
- // those the list shows, so that each dot of the tab has a row to find. Dragged away, all are seen.
480
- const listedChats = phone
481
- ? ChatListUtil.entries(workbench.sessions, workbench.saved, removedChats, undefined, WorkbenchUtil.daysAgo(Date.now(), chatSettings.chatArchiveDays), pinnedChats, ChatIconUtil.archiveSince(extensions.chatIcons, Date.now())).listed
482
- : [];
487
+ // those the list shows, so that each dot of the tab has a row to find. Dragged away, all are seen. Those that
488
+ // wait for the user to decide are counted on it, on the rail too, until answered.
489
+ const listedChats = ChatListUtil.entries(workbench.sessions, workbench.saved, removedChats, undefined, WorkbenchUtil.daysAgo(Date.now(), chatSettings.chatArchiveDays), ChatListUtil.keptFiles(workbench.saved, pinnedChats, letGoAsks), ChatIconUtil.archiveSince(extensions.chatIcons, Date.now())).listed;
490
+ const chatsAsking = ChatAskUtil.count(listedChats, letGoAsks);
483
491
  const inFront = looking ? workbench.sessions.find(session => session.sessionId === looking) : undefined;
484
492
  const chatsUnseen = ChatSeenUtil.anyUnseen(listedChats, seenChats, inFront && ChatListUtil.file(inFront));
485
493
  const seeAllChats = () => state.set(SEEN_CHATS, ChatSeenUtil.seeAll(state.get(SEEN_CHATS), listedChats, Date.now()));
@@ -490,7 +498,7 @@ function AppShell() {
490
498
  fold: t('ta.nav.fold'),
491
499
  settings: { label: t('ta.nav.settings'), run: () => openSettings('navigation') },
492
500
  holds,
493
- }).map(item => (item.id === '' && chatsUnseen ? { ...item, unseen: true, onSeeAll: seeAllChats } : item))
501
+ }).map(item => (item.id === '' && (chatsUnseen || chatsAsking) ? { ...item, unseen: chatsUnseen, onSeeAll: seeAllChats, asks: chatsAsking } : item))
494
502
  : [];
495
503
  const tab = tabPage === 'me' ? ME_TAB : tabPage === 'discover' ? DISCOVER : ((_g = tabView === null || tabView === void 0 ? void 0 : tabView.id) !== null && _g !== void 0 ? _g : side);
496
504
  // The launcher and the board are over the first tab only, as WeChat's over its chats.
@@ -520,7 +528,7 @@ function AppShell() {
520
528
  setSettings(undefined);
521
529
  setNavOpen(false);
522
530
  setTabPage('discover');
523
- }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds }),
531
+ }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds, asks: chatsAsking }),
524
532
  sideShown && (React.createElement("div", { className: "ta-sidebar", style: paneStyle(sidebar) },
525
533
  sideList,
526
534
  React.createElement(Sash, { pane: sidebar, side: "start", label: t('ta.layout.sidebar') })))),
@@ -541,7 +549,8 @@ function AppShell() {
541
549
  React.createElement(SessionAvatars.Provider, { value: extensions.avatars },
542
550
  React.createElement(ChatIconsProvider, { entries: extensions.chatIcons },
543
551
  React.createElement(SessionMenus.Provider, { value: extensions.sessionMenus },
544
- React.createElement(WorkbenchToggleContext.Provider, { value: toggle }, content))))))))));
552
+ React.createElement(LoadedExtensions.Provider, { value: extensions.extensions },
553
+ React.createElement(WorkbenchToggleContext.Provider, { value: toggle }, content)))))))))));
545
554
  }
546
555
  /** The app, with the look the user picked for the double (every ta below draws it) and the picker of that look. */
547
556
  export function AppView() {
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ /** How many conversations wait for the user to decide, on the entry of the chats (a tab, the rail): blue, as their ? on the rows. */
3
+ export declare function AsksBadge({ count }: {
4
+ count: number;
5
+ }): React.JSX.Element;