@celljs/ta-web 4.9.1 → 4.10.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.
- package/README.en.md +4 -3
- package/README.md +4 -3
- package/esm/browser/assistant/assistant-chat-list.js +8 -2
- package/esm/browser/assistant/assistant-extension.d.ts +8 -1
- package/esm/browser/assistant/assistant-extension.js +20 -0
- package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
- package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-util.js +5 -3
- package/esm/browser/assistant/assistant-view.js +81 -56
- package/esm/browser/assistant/assistant.d.ts +10 -1
- package/esm/browser/assistant/assistant.js +44 -5
- package/esm/browser/chat/chat-packages.d.ts +39 -0
- package/esm/browser/chat/chat-packages.js +70 -0
- package/esm/browser/chat/chat-protocol.d.ts +23 -1
- package/esm/browser/chat/chat-stores.d.ts +59 -0
- package/esm/browser/chat/chat-stores.js +121 -0
- package/esm/browser/chat/chat-util.d.ts +17 -0
- package/esm/browser/chat/chat-util.js +61 -0
- package/esm/browser/chat/chat-view.js +33 -12
- package/esm/browser/chat/chat.d.ts +31 -39
- package/esm/browser/chat/chat.js +226 -175
- package/esm/browser/components/app-nav.d.ts +6 -3
- package/esm/browser/components/app-nav.js +19 -10
- package/esm/browser/components/app-shell-hooks.d.ts +2 -2
- package/esm/browser/components/app-shell-hooks.js +7 -3
- package/esm/browser/components/app-view.js +75 -21
- package/esm/browser/components/chat-list.d.ts +20 -2
- package/esm/browser/components/chat-list.js +138 -22
- package/esm/browser/components/composer-box.d.ts +5 -5
- package/esm/browser/components/composer-box.js +111 -4
- package/esm/browser/components/composer.d.ts +7 -0
- package/esm/browser/components/composer.js +5 -4
- package/esm/browser/components/connection-bar.js +50 -17
- package/esm/browser/components/context-menu.d.ts +30 -4
- package/esm/browser/components/context-menu.js +199 -37
- package/esm/browser/components/conversation-scroll.d.ts +129 -6
- package/esm/browser/components/conversation-scroll.js +429 -109
- package/esm/browser/components/earlier-messages.d.ts +2 -1
- package/esm/browser/components/earlier-messages.js +2 -17
- package/esm/browser/components/editor-area.d.ts +3 -1
- package/esm/browser/components/editor-area.js +6 -5
- package/esm/browser/components/empty-pictures.d.ts +0 -2
- package/esm/browser/components/empty-pictures.js +0 -16
- package/esm/browser/components/folder-picker.d.ts +5 -2
- package/esm/browser/components/folder-picker.js +26 -8
- package/esm/browser/components/held-talk.d.ts +28 -0
- package/esm/browser/components/held-talk.js +76 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/icon.d.ts +2 -2
- package/esm/browser/components/icon.js +5 -6
- package/esm/browser/components/image-viewer.d.ts +124 -0
- package/esm/browser/components/image-viewer.js +397 -0
- package/esm/browser/components/lightbox.d.ts +11 -0
- package/esm/browser/components/lightbox.js +24 -0
- package/esm/browser/components/markdown.d.ts +6 -2
- package/esm/browser/components/markdown.js +24 -10
- package/esm/browser/components/media.js +1 -10
- package/esm/browser/components/message-footer.d.ts +16 -2
- package/esm/browser/components/message-footer.js +29 -12
- package/esm/browser/components/message-list.d.ts +24 -3
- package/esm/browser/components/message-list.js +149 -20
- package/esm/browser/components/message-menu.d.ts +3 -1
- package/esm/browser/components/message-menu.js +18 -3
- package/esm/browser/components/nav-places.d.ts +16 -1
- package/esm/browser/components/nav-places.js +12 -3
- package/esm/browser/components/phone-shell.d.ts +4 -1
- package/esm/browser/components/phone-shell.js +3 -1
- package/esm/browser/components/run-status.js +3 -3
- package/esm/browser/components/session-settings.d.ts +6 -0
- package/esm/browser/components/session-settings.js +14 -1
- package/esm/browser/components/session-view.js +8 -4
- package/esm/browser/components/settings-parts.d.ts +2 -2
- package/esm/browser/components/settings-parts.js +24 -1
- package/esm/browser/components/swipe-row.d.ts +2 -2
- package/esm/browser/components/swipe-row.js +7 -3
- package/esm/browser/components/tool-view.js +14 -12
- package/esm/browser/components/voice-button.d.ts +1 -1
- package/esm/browser/components/voice-button.js +1 -1
- package/esm/browser/components/voice-talk.d.ts +43 -0
- package/esm/browser/components/voice-talk.js +222 -0
- package/esm/browser/device/device.d.ts +3 -0
- package/esm/browser/device/device.js +11 -1
- package/esm/browser/device/hold.d.ts +42 -0
- package/esm/browser/device/hold.js +136 -0
- package/esm/browser/device/launch-screen.d.ts +1 -1
- package/esm/browser/device/launch-screen.js +1 -1
- package/esm/browser/device/long-press.d.ts +2 -0
- package/esm/browser/device/long-press.js +16 -1
- package/esm/browser/device/pull-down.d.ts +4 -2
- package/esm/browser/device/pull-down.js +64 -76
- package/esm/browser/device/row-swipe.d.ts +35 -10
- package/esm/browser/device/row-swipe.js +149 -71
- package/esm/browser/device/shake-undo.d.ts +16 -0
- package/esm/browser/device/shake-undo.js +59 -0
- package/esm/browser/device/sheet-swipe.d.ts +118 -18
- package/esm/browser/device/sheet-swipe.js +406 -107
- package/esm/browser/extension/web-extension-api.d.ts +97 -1
- package/esm/browser/extension/web-extension-code.d.ts +6 -0
- package/esm/browser/extension/web-extension-code.js +24 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
- package/esm/browser/extension/web-extension-protocol.js +8 -0
- package/esm/browser/extension/web-extensions.d.ts +14 -1
- package/esm/browser/extension/web-extensions.js +122 -23
- package/esm/browser/files/files-protocol.d.ts +25 -0
- package/esm/browser/files/files-protocol.js +2 -0
- package/esm/browser/files/files.d.ts +35 -0
- package/esm/browser/files/files.js +119 -0
- package/esm/browser/i18n/locales.d.ts +24 -2
- package/esm/browser/i18n/messages.d.ts +23 -1
- package/esm/browser/i18n/messages.js +48 -4
- package/esm/browser/index.d.ts +6 -0
- package/esm/browser/index.js +6 -0
- package/esm/browser/notices/notices-protocol.d.ts +9 -1
- package/esm/browser/notices/notices.d.ts +2 -0
- package/esm/browser/notices/notices.js +20 -10
- package/esm/browser/offline/device-values.d.ts +55 -0
- package/esm/browser/offline/device-values.js +142 -0
- package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
- package/esm/browser/offline/kept-chats-protocol.js +2 -0
- package/esm/browser/offline/kept-chats.d.ts +47 -0
- package/esm/browser/offline/kept-chats.js +146 -0
- package/esm/browser/offline/offline-reads.d.ts +44 -0
- package/esm/browser/offline/offline-reads.js +107 -0
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +57 -17
- package/esm/browser/style/device.js +27 -4
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +67 -15
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -1
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +46 -3
- package/esm/browser/util/frame.d.ts +5 -4
- package/esm/browser/util/frame.js +5 -4
- package/esm/browser/util/markdown.d.ts +18 -1
- package/esm/browser/util/markdown.js +119 -5
- package/esm/browser/util/process.d.ts +21 -0
- package/esm/browser/util/process.js +45 -1
- package/esm/browser/util/voice.d.ts +5 -2
- package/esm/browser/util/voice.js +6 -3
- package/esm/browser/util/zoom.d.ts +46 -0
- package/esm/browser/util/zoom.js +96 -0
- package/esm/browser/workbench-calls.d.ts +59 -0
- package/esm/browser/workbench-calls.js +141 -0
- package/esm/browser/workbench-protocol.d.ts +5 -1
- package/esm/browser/workbench-util.d.ts +7 -0
- package/esm/browser/workbench-util.js +9 -2
- package/esm/browser/workbench.d.ts +14 -5
- package/esm/browser/workbench.js +51 -31
- package/lib/browser/assistant/assistant-chat-list.js +8 -2
- package/lib/browser/assistant/assistant-extension.d.ts +8 -1
- package/lib/browser/assistant/assistant-extension.js +20 -0
- package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
- package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-util.js +5 -3
- package/lib/browser/assistant/assistant-view.js +78 -53
- package/lib/browser/assistant/assistant.d.ts +10 -1
- package/lib/browser/assistant/assistant.js +44 -5
- package/lib/browser/chat/chat-packages.d.ts +40 -0
- package/lib/browser/chat/chat-packages.js +74 -0
- package/lib/browser/chat/chat-protocol.d.ts +23 -1
- package/lib/browser/chat/chat-stores.d.ts +60 -0
- package/lib/browser/chat/chat-stores.js +125 -0
- package/lib/browser/chat/chat-util.d.ts +18 -0
- package/lib/browser/chat/chat-util.js +64 -0
- package/lib/browser/chat/chat-view.js +33 -12
- package/lib/browser/chat/chat.d.ts +31 -39
- package/lib/browser/chat/chat.js +227 -176
- package/lib/browser/components/app-nav.d.ts +6 -3
- package/lib/browser/components/app-nav.js +17 -8
- package/lib/browser/components/app-shell-hooks.d.ts +2 -2
- package/lib/browser/components/app-shell-hooks.js +7 -3
- package/lib/browser/components/app-view.js +74 -20
- package/lib/browser/components/chat-list.d.ts +20 -2
- package/lib/browser/components/chat-list.js +137 -21
- package/lib/browser/components/composer-box.d.ts +5 -5
- package/lib/browser/components/composer-box.js +111 -4
- package/lib/browser/components/composer.d.ts +7 -0
- package/lib/browser/components/composer.js +5 -4
- package/lib/browser/components/connection-bar.js +48 -15
- package/lib/browser/components/context-menu.d.ts +30 -4
- package/lib/browser/components/context-menu.js +198 -36
- package/lib/browser/components/conversation-scroll.d.ts +129 -6
- package/lib/browser/components/conversation-scroll.js +431 -110
- package/lib/browser/components/earlier-messages.d.ts +2 -1
- package/lib/browser/components/earlier-messages.js +2 -17
- package/lib/browser/components/editor-area.d.ts +3 -1
- package/lib/browser/components/editor-area.js +5 -4
- package/lib/browser/components/empty-pictures.d.ts +0 -2
- package/lib/browser/components/empty-pictures.js +0 -17
- package/lib/browser/components/folder-picker.d.ts +5 -2
- package/lib/browser/components/folder-picker.js +26 -8
- package/lib/browser/components/held-talk.d.ts +29 -0
- package/lib/browser/components/held-talk.js +79 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/icon.d.ts +2 -2
- package/lib/browser/components/icon.js +7 -6
- package/lib/browser/components/image-viewer.d.ts +125 -0
- package/lib/browser/components/image-viewer.js +435 -0
- package/lib/browser/components/lightbox.d.ts +12 -0
- package/lib/browser/components/lightbox.js +60 -0
- package/lib/browser/components/markdown.d.ts +6 -2
- package/lib/browser/components/markdown.js +24 -10
- package/lib/browser/components/media.js +2 -11
- package/lib/browser/components/message-footer.d.ts +16 -2
- package/lib/browser/components/message-footer.js +31 -12
- package/lib/browser/components/message-list.d.ts +24 -3
- package/lib/browser/components/message-list.js +146 -16
- package/lib/browser/components/message-menu.d.ts +3 -1
- package/lib/browser/components/message-menu.js +17 -2
- package/lib/browser/components/nav-places.d.ts +16 -1
- package/lib/browser/components/nav-places.js +13 -3
- package/lib/browser/components/phone-shell.d.ts +4 -1
- package/lib/browser/components/phone-shell.js +3 -1
- package/lib/browser/components/run-status.js +3 -3
- package/lib/browser/components/session-settings.d.ts +6 -0
- package/lib/browser/components/session-settings.js +14 -1
- package/lib/browser/components/session-view.js +7 -3
- package/lib/browser/components/settings-parts.d.ts +2 -2
- package/lib/browser/components/settings-parts.js +24 -1
- package/lib/browser/components/swipe-row.d.ts +2 -2
- package/lib/browser/components/swipe-row.js +7 -3
- package/lib/browser/components/tool-view.js +14 -12
- package/lib/browser/components/voice-button.d.ts +1 -1
- package/lib/browser/components/voice-button.js +1 -1
- package/lib/browser/components/voice-talk.d.ts +44 -0
- package/lib/browser/components/voice-talk.js +260 -0
- package/lib/browser/device/device.d.ts +3 -0
- package/lib/browser/device/device.js +11 -1
- package/lib/browser/device/hold.d.ts +43 -0
- package/lib/browser/device/hold.js +173 -0
- package/lib/browser/device/launch-screen.d.ts +1 -1
- package/lib/browser/device/launch-screen.js +1 -1
- package/lib/browser/device/long-press.d.ts +2 -0
- package/lib/browser/device/long-press.js +16 -1
- package/lib/browser/device/pull-down.d.ts +4 -2
- package/lib/browser/device/pull-down.js +63 -75
- package/lib/browser/device/row-swipe.d.ts +35 -10
- package/lib/browser/device/row-swipe.js +148 -70
- package/lib/browser/device/shake-undo.d.ts +17 -0
- package/lib/browser/device/shake-undo.js +63 -0
- package/lib/browser/device/sheet-swipe.d.ts +118 -18
- package/lib/browser/device/sheet-swipe.js +410 -108
- package/lib/browser/extension/web-extension-api.d.ts +97 -1
- package/lib/browser/extension/web-extension-code.d.ts +6 -0
- package/lib/browser/extension/web-extension-code.js +24 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
- package/lib/browser/extension/web-extension-protocol.js +9 -1
- package/lib/browser/extension/web-extensions.d.ts +14 -1
- package/lib/browser/extension/web-extensions.js +120 -21
- package/lib/browser/files/files-protocol.d.ts +26 -0
- package/lib/browser/files/files-protocol.js +5 -0
- package/lib/browser/files/files.d.ts +36 -0
- package/lib/browser/files/files.js +122 -0
- package/lib/browser/i18n/locales.d.ts +24 -2
- package/lib/browser/i18n/messages.d.ts +23 -1
- package/lib/browser/i18n/messages.js +48 -4
- package/lib/browser/index.d.ts +6 -0
- package/lib/browser/index.js +6 -0
- package/lib/browser/notices/notices-protocol.d.ts +9 -1
- package/lib/browser/notices/notices.d.ts +2 -0
- package/lib/browser/notices/notices.js +20 -10
- package/lib/browser/offline/device-values.d.ts +56 -0
- package/lib/browser/offline/device-values.js +148 -0
- package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
- package/lib/browser/offline/kept-chats-protocol.js +5 -0
- package/lib/browser/offline/kept-chats.d.ts +48 -0
- package/lib/browser/offline/kept-chats.js +149 -0
- package/lib/browser/offline/offline-reads.d.ts +45 -0
- package/lib/browser/offline/offline-reads.js +111 -0
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +57 -17
- package/lib/browser/style/device.js +27 -4
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +67 -15
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -1
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +46 -3
- package/lib/browser/util/frame.d.ts +5 -4
- package/lib/browser/util/frame.js +5 -4
- package/lib/browser/util/markdown.d.ts +18 -1
- package/lib/browser/util/markdown.js +119 -5
- package/lib/browser/util/process.d.ts +21 -0
- package/lib/browser/util/process.js +46 -2
- package/lib/browser/util/voice.d.ts +5 -2
- package/lib/browser/util/voice.js +6 -3
- package/lib/browser/util/zoom.d.ts +47 -0
- package/lib/browser/util/zoom.js +99 -0
- package/lib/browser/workbench-calls.d.ts +60 -0
- package/lib/browser/workbench-calls.js +145 -0
- package/lib/browser/workbench-protocol.d.ts +5 -1
- package/lib/browser/workbench-util.d.ts +7 -0
- package/lib/browser/workbench-util.js +10 -3
- package/lib/browser/workbench.d.ts +14 -5
- package/lib/browser/workbench.js +51 -31
- package/package.json +10 -10
- package/public/launch.svg +46 -42
package/README.en.md
CHANGED
|
@@ -16,14 +16,15 @@ The Web client can be installed as an application on desktop or mobile: use the
|
|
|
16
16
|
|
|
17
17
|
## Interface
|
|
18
18
|
|
|
19
|
-
The main layout is IDE-style: the navigation bar on the far left, in the order of a phone's bottom tabs: under the logo the lists of the sidebar (web extension sidebar views such as the agents, then the conversations), a divider, then pages for web extensions and Discover, and the account menu at the bottom; picking a list shows it in the sidebar, picking it again hides the sidebar (Mod+B also toggles it). The sidebar next to it (resizable and collapsible; the current list's search box and + button at the top) containing all open sessions on the server (which can be created, created in a specified directory, or closed; grouped by directory by default, each group folding with a + of its own for a new chat there, a button in the search box switching to a list by time, which a search always shows), the current conversation in the middle, and a collapsible panel on the right for web extension cards. On narrow screens, the navigation bar and conversation list become drawers, and the panel floats above the conversation.
|
|
19
|
+
The main layout is IDE-style: the navigation bar on the far left, in the order of a phone's bottom tabs: under the logo the lists of the sidebar (web extension sidebar views such as the agents, then the conversations), a divider, then pages for web extensions and Discover, and the account menu at the bottom; picking a list shows it in the sidebar, picking it again hides the sidebar (Mod+B also toggles it; the Workbench button at the bottom of the rail and Mod+J show or hide the workbench on the right from any page, its head saying the directory its tools are in). The sidebar next to it (resizable and collapsible; the current list's search box and + button at the top) containing all open sessions on the server (which can be created, created in a specified directory, or closed; grouped by directory by default, each group folding with a + of its own for a new chat there, a button in the search box switching to a list by time, which a search always shows), the current conversation in the middle, and a collapsible panel on the right for web extension cards. On narrow screens, the navigation bar and conversation list become drawers, and the panel floats above the conversation. Holding the double or the conversations in the navigation (their tabs on a phone) opens no menu: it talks, as a held message box does (below). Held, the double opens and its box listens, and what was said goes to it as the finger lets go (its answer only shows, unless "Read the answer to what I say by voice" is on, in the Voice settings or the + of the double's box); held, the conversations open a new conversation whose box listens, and letting go starts it with what was said (`HeldTalk`, `components/held-talk.ts`). Where the browser cannot recognize speech, both are a plain tap.
|
|
20
20
|
|
|
21
21
|
Initially, the interface shows only conversations. You tell Ta what you want this page to do and display, and Ta builds it as a pi package—cards beside the conversation, a standalone page, or a new Ta command—which appears on the page immediately.
|
|
22
22
|
|
|
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`), `registerTool` (tools executed by the browser in conversations opened on the page), `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)` is a section of its own in the + menu, 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.QrCode` (a QR code of a text, black on white
|
|
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`), `registerTool` (tools executed by the browser in conversations opened on the page), `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)` is a section of its own in the + menu, 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.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 / + / 1:1 below it; 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), `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), `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.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`).
|
|
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.
|
|
27
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).
|
|
28
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.
|
|
29
30
|
|
|
@@ -34,7 +35,7 @@ Everything new in the interface comes from **web extensions** within packages, u
|
|
|
34
35
|
### Conversation and Input Box
|
|
35
36
|
|
|
36
37
|
- **Conversation flow**: continuous thinking, tool calls, and interim explanations in a turn are folded into a single line "Executed N steps": this expands while in progress, shows only recent steps, and collapses after completion (remaining expanded and marking failed steps if any); the final text is the reply. Layout is a pure function `ProcessUtil` (`util/process.ts`); each message uses a stable key and memos per message, so streaming output only redraws changed messages.
|
|
37
|
-
- **Input box**: Enter sends, Shift+Enter inserts a newline; during IME composition, Enter does not send. While Ta works, Enter suggests, Alt+Enter queues, Esc stops, and send and stop use the same button. `/` lists commands, `@` finds and inserts `@path` by filename (using the server's `findFiles`; the menu explains if unsupported); images can be pasted, dragged, or selected (PNG, JPEG, GIF, WebP; max 5 MB per image, max 8 per message); queued messages show above the input box and can be undone back to the box (`clearQueue`). Where the browser recognizes speech (`Voice`, `util/voice.ts`), every input box has a microphone on its right: a conversation puts what is heard at the caret to be read over before sending; the double sends it as soon as it is heard. Logic is in `ComposerUtil` (`util/composer.ts`).
|
|
38
|
+
- **Input box**: Enter sends, Shift+Enter inserts a newline; during IME composition, Enter does not send. While Ta works, Enter suggests, Alt+Enter queues, Esc stops, and send and stop use the same button. `/` lists commands, `@` finds and inserts `@path` by filename (using the server's `findFiles`; the menu explains if unsupported); images can be pasted, dragged, or selected (PNG, JPEG, GIF, WebP; max 5 MB per image, max 8 per message); queued messages show above the input box and can be undone back to the box (`clearQueue`). Where the browser recognizes speech (`Voice`, `util/voice.ts`), every input box has a microphone on its right: a conversation puts what is heard at the caret to be read over before sending; the double sends it as soon as it is heard. Logic is in `ComposerUtil` (`util/composer.ts`). On a touch screen a finger held on the message box talks, as in WeChat (the whole box while the keyboard is down, its field and microphone included; with the keyboard up the field is the system's, to select and paste): the page dims and blurs, a green bubble shows the words as they come, a 取消 (cancel) and a 编辑 (edit) circle wait left and right, and the arc at the bottom says "release to send". Let go where the finger is and what was said is sent, with what the box already held; slid onto 取消 it is dropped, onto 编辑 it stays in the box to read over; a talk under 600 ms is no input at all (the bubble says it was too short, then goes), nor is one where nothing was heard, which a wrong touch is; the overlay fades out as the finger lets go (`VoiceTalkUtil`, `components/voice-talk.tsx`; the gesture is `device/hold.ts`).
|
|
38
39
|
- **Avatar**: `TaAvatar` is the dinosaur the double is (the Cell logo by default), and `mark` is a 1–2 character badge to distinguish agents (in web extensions it's `pi.ui.Avatar`); each reply starts with a small avatar (once per turn): during work, eye expression shows thinking, execution, or output; on the last turn when done, eyes squint with a checkmark; on error, it shows an alert badge; an empty conversation page displays a large avatar that blinks and occasionally looks at the input box. With reduced motion, everything is static. The figure of the account (the bottom of the rail, Me on a phone) is a close-up of the same dinosaur's head, `DinoFace`: round eyes and blushing cheeks; it tilts its head, blinks, follows the pointer with its eyes and laughs when tapped. Still SVG files of every kind are in `assets/dinos/` (made by `bun ta-packages/ta-web/scripts/dino-art.ts`).
|
|
39
40
|
- **Status and hints**: four levels (info, success, warning, and error), each with a fixed icon and color, with the body always in body color. By ownership, there are three types: global **connection status bar** (a capsule at the top of the main area that appears after 1 second of disconnect, showing reason, countdown, and "Retry now"; shows "Reconnected" for 2 seconds after recovery); **notices** (`TaNotices`, bottom right, top on phone; success 3s, info 4s, warning 6s, error 8s; add 4s for buttons; pause on hover or focus; merge same messages with count; max 4 notices); **inline hints** (`Callout`, staying at the place of issue, such as when a turn reply fails, an extension view errors, or a token is rejected). Operation failures (send, switch model, open conversation, etc.) uniformly use `notices.error`: server errors with `hint` put the suggestion on the second line; failures from disconnect merge into one "Did not complete: ta serve not connected" message. Operations needing user confirmation use `notices.confirm`; irreversible operations have red buttons with default focus on "Cancel".
|
|
40
41
|
- **Links**: all links in replies are clickable (`TaLinks`, parsed in `LinkUtil`). Web links, bare URLs in text, and `<URL>` open by default in the browser on the right workbench; Cmd/Ctrl+click (or middle button) opens in the system browser. File paths (`[text](src/a.ts#L10-L20)`, `src/a.ts:10:5`, `file://` address, and inline code like `src/a.ts:12` and `package.json`) are parsed relative to the conversation directory, open and locate in the workbench, and select corresponding lines and columns (syntax like VS Code: `#L10`, `#L10C5-L12C3`, `:10:5`, `:10-20`); directories (`docs/`) open in the explorer at that directory. Open actions are provided by web extensions (`registerOpener`; the built-in @celljs/ta-workspace handles files, directories, and the built-in browser). For security, following VS Code: only http(s), mailto, and paths are recognized; `javascript:`, `data:`, `command:`, etc. are plain text; rendering results are React elements, not HTML; paths are confirmed to exist on the server first, though read/write are still subject to execution environment constraints. Before opening in the system browser, a popup shows the full address with the domain highlighted (domains with similar appearance are shown in browser's punycode format); you can copy, open, or trust the domain. Localhost addresses (localhost, 127.0.0.1, and the host where ta serve runs) and **Settings → Links → Trusted Domains** (`github.com`, `*.github.com`, `localhost:3000`, `*`) skip confirmation; new windows always have `noopener,noreferrer`. In the built-in browser, URLs same-origin with the Ta page do not get `allow-same-origin` and cannot reach the page or token.
|
package/README.md
CHANGED
|
@@ -16,14 +16,15 @@ Web 客户端可以装成桌面或手机上的应用:Chrome / Edge 地址栏
|
|
|
16
16
|
|
|
17
17
|
## 界面
|
|
18
18
|
|
|
19
|
-
主框架是 IDE 式布局:最左侧是导航栏,和手机的底部标签同一顺序:logo 下面先是侧栏的列表(Web 扩展的侧栏视图,如智能体,然后是对话),一条分隔线后是 Web 扩展的页面和"发现",底部是头像菜单;点一个列表,侧栏换成它,再点一次收起侧栏(Mod+B
|
|
19
|
+
主框架是 IDE 式布局:最左侧是导航栏,和手机的底部标签同一顺序:logo 下面先是侧栏的列表(Web 扩展的侧栏视图,如智能体,然后是对话),一条分隔线后是 Web 扩展的页面和"发现",底部是头像菜单;点一个列表,侧栏换成它,再点一次收起侧栏(Mod+B 同样开关侧栏;导轨底部的"工作台"按钮和 Mod+J 在任何页面上开关右侧工作台,工作台顶栏显示它的工具所在的目录)。旁边是侧栏(可拖宽、可收起;顶部是当前列表的搜索框和 +)(服务器上所有打开的会话,可新建、在指定目录新建、关闭;默认按目录分组,每组可折叠、组头的 + 在该目录新建,搜索框里的按钮切回按时间排列,搜索时总是按时间排列),中间是当前对话,右侧是可收起的面板,放 Web 扩展的卡片。窄屏时导航栏和对话列表变成抽屉,面板浮在对话上方。按住导航栏上的"分身"和"对话"(手机上是底部对应的标签)不弹菜单,而是按住说话(见下面的输入框):按住分身,打开它并在它的输入框上开始听,松手发给分身(回复默认只显示文字;设置的"声音"里打开"语音说话后朗读回复",或分身输入框 + 菜单里的同名开关,它的回复才会读出来);按住对话,新建一个对话并在它的输入框上听,松手就用这句话开始这个对话(`HeldTalk`,`components/held-talk.ts`)。浏览器不能识别语音时,这两项只是普通点按。
|
|
20
20
|
|
|
21
21
|
一开始,界面上只有对话。你告诉 Ta 想让这个页面做什么、显示什么,Ta 就把它做成一个 pi 包——对话旁的卡片、单独的页面,或者 Ta 的新命令——做完立刻出现在页面上。
|
|
22
22
|
|
|
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` 发出的自定义消息)、`registerTool`(页面打开的对话里由浏览器执行的工具)、`registerTasks` / `ui.useTasks`(替用户做的事,由分身和其他扩展的任务一起列出,见 docs/design/ta-double.md;任务带 `remove` 和 `removeHint` 时,列表里可以左滑删除、多选后批量删除,询问统一由 `ui.removeTasks` 做)、`ui.SelectCheck` / `ui.SelectBar`(列表多选时行首的圆形勾选和列表底部的操作栏,样式与页面一致)、`registerOpener`(打开回复里的链接:文件及其行、目录、网页,按注册顺序询问,返回 true 表示已打开)、`registerComposerAddon`(给所有对话的输入框加东西:`actions(conversation)` 是 + 菜单里自己的一组,条目可以带 `items` 二级列表;`above` 画在输入框上方;`subscribe` 通知条目变了。`conversation` 说明是哪个对话:`sessionId`、`sessionFile`、`cwd`、`kind` 为 `double` 或 `chat`、`group`、`title`;分身、智能体和普通对话都有)、`ui.QrCode`(文字的二维码,任何主题下都是白底黑码)、`on`(当前对话的事件)、`sendUserMessage`(发到当前对话;`/命令` 会执行 pi 扩展的命令)、`switchSession`(把 ta serve 里另一个打开的会话显示为当前对话;传会话 id 的 Promise 时立即切过去显示"正在打开",`opening` 给出占位的标题)、`callHost`(调用本包 `pi.host` 的方法,经 `callPackageHost`)、`reloadExtensions`(扩展自己安装、导入或移除了包之后,像回复结束时一样重新加载 Web 扩展和当前对话的 pi 扩展)、`ui.showView` / `ui.useView`(显示、查看任意扩展的视图)、`ui.Composer` / `ui.Markdown`(和对话一样的输入框与 Markdown)、`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.confirm`(继续前先确认,返回用户是否同意)、`ui.theme`、`ui.language`、`ui.supportsWebview`(能否用 `<webview>` 显示网站,Ta 桌面版里可以,其他地方用 iframe)、`ui.debugWebview`(Ta 桌面版:向这种 webview 里的网页发 Chrome DevTools Protocol 命令,只限网页本身)、`ui.desktop.browserData`(Ta 桌面版,macOS 和 Windows
|
|
26
|
+
- **Web 扩展**是一个不带 import 的 ES 模块,默认导出一个函数,页面用 `pi` 调用它;返回的函数在卸载时调用。`pi` 的接口照 pi 的 ExtensionAPI 命名:`ui.setWidget`(默认在输入框上方,和 pi 一样;`placement: 'panel'` 放进右侧工作台的卡片标签)、`registerView`(导航栏里的页面,或导航栏上方的一个侧栏列表;`location: 'panel'` 是右侧工作台的工具)、`registerMessageRenderer`(显示 pi 扩展用 `sendMessage` 发出的自定义消息)、`registerTool`(页面打开的对话里由浏览器执行的工具)、`registerSettings`(设置里的一个分区,排在 Ta 自己的分区之后:每行是标签、说明和扩展自己画的控件,值用 `storage` 保存)、`registerTasks` / `ui.useTasks`(替用户做的事,由分身和其他扩展的任务一起列出,见 docs/design/ta-double.md;任务带 `remove` 和 `removeHint` 时,列表里可以左滑删除、多选后批量删除,询问统一由 `ui.removeTasks` 做)、`ui.SelectCheck` / `ui.SelectBar`(列表多选时行首的圆形勾选和列表底部的操作栏,样式与页面一致)、`registerOpener`(打开回复里的链接:文件及其行、目录、网页,按注册顺序询问,返回 true 表示已打开)、`registerComposerAddon`(给所有对话的输入框加东西:`actions(conversation)` 是 + 菜单里自己的一组,条目可以带 `items` 二级列表;`above` 画在输入框上方;`subscribe` 通知条目变了。`conversation` 说明是哪个对话:`sessionId`、`sessionFile`、`cwd`、`kind` 为 `double` 或 `chat`、`group`、`title`;分身、智能体和普通对话都有)、`ui.QrCode`(文字的二维码,任何主题下都是白底黑码)、`ui.ImageViewer`(看图:先完整显示且不超过原始像素,双指或触控板捏合、Ctrl/⌘ 加滚轮、双击或双点缩放,放大后拖动或滚动,底部是 − / 比例 / + / 1:1;工作台的图片预览和对话里的大图用的都是它)、`on`(当前对话的事件)、`sendUserMessage`(发到当前对话;`/命令` 会执行 pi 扩展的命令)、`switchSession`(把 ta serve 里另一个打开的会话显示为当前对话;传会话 id 的 Promise 时立即切过去显示"正在打开",`opening` 给出占位的标题)、`callHost`(调用本包 `pi.host` 的方法,经 `callPackageHost`)、`reloadExtensions`(扩展自己安装、导入或移除了包之后,像回复结束时一样重新加载 Web 扩展和当前对话的 pi 扩展)、`ui.showView` / `ui.useView`(显示、查看任意扩展的视图)、`ui.Composer` / `ui.Markdown`(和对话一样的输入框与 Markdown)、`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.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`)。
|
|
27
|
+
- **文件的字节**:`pi.files` 给出工作区的文件字节。页面由 ta serve 自己提供时 `byUrl` 为真,直接用 `workspace.fileUrl` 的地址加载就行;手机应用里、或页面经中继打开时,那个地址在页面里加载不到,`byUrl` 为假,`pi.files.read(url)` 经 WebSocket 取回 `{ type, size, data }`(端到端加密,中继读不到)。`@celljs/ta-workspace` 的预览就靠它:图片、视频、声音、PDF 做成 `blob:`,HTML 报告按文件文本放进沙框。
|
|
27
28
|
- **用自然语言做包**:内置扩展 [@celljs/ta-extensions](../ta-extensions/README.md) 带技能 `ta-package`(终端里的 Ta 也有),并在导航栏加了"扩展"页(一句话做扩展、导出导入),写明了包的格式、Web 扩展接口和验证步骤。当前对话每次回复结束,页面重新读取 Web 扩展:新的加载、改过的重新加载、删掉的卸载;工具有变化时,用同一个会话文件重新打开这段对话(只限本页打开的对话),包有改动时让会话重新加载 pi 扩展。页面重新显示时也会检查一次(包也可能在终端里改)。
|
|
28
29
|
- **稳定**:每个扩展注册的东西归它自己,卸载时一并撤掉;一个扩展加载失败或渲染出错,只在它自己的位置显示错误,不影响页面和其他扩展。
|
|
29
30
|
|
|
@@ -34,7 +35,7 @@ Web 客户端可以装成桌面或手机上的应用:Chrome / Edge 地址栏
|
|
|
34
35
|
### 对话与输入框
|
|
35
36
|
|
|
36
37
|
- **对话流**:一轮里连续的思考、工具调用和中途说明折成一行“已执行 N 步”:进行中展开、只显示最近几步,结束后收起(有失败的步骤时保持展开并标出),最后的正文是回复。布局是纯函数 `ProcessUtil`(`util/process.ts`);每条用稳定的 key 并按条 memo,流式输出时只重绘变化的那条。
|
|
37
|
-
- **输入框**:Enter 发送、Shift+Enter 换行,输入法合成期间的回车不发送;Ta 工作时 Enter 引导、Alt+Enter 排队追加、Esc 停止,发送与停止是同一个按钮。`/` 列出命令,`@` 按文件名查找并插入 `@路径`(服务端 `findFiles`,不支持时菜单里说明);图片可粘贴、拖入或选择(PNG/JPEG/GIF/WebP,单张 5 MB、每条 8 张以内);排队的消息显示在输入框上方,可撤回到输入框(`clearQueue`)。浏览器能识别语音时(`Voice`,`util/voice.ts`),每个输入框右侧都有麦克风:普通对话把听到的话填进光标处,改完再发;分身听完直接发出。逻辑在 `ComposerUtil`(`util/composer.ts`)。
|
|
38
|
+
- **输入框**:Enter 发送、Shift+Enter 换行,输入法合成期间的回车不发送;Ta 工作时 Enter 引导、Alt+Enter 排队追加、Esc 停止,发送与停止是同一个按钮。`/` 列出命令,`@` 按文件名查找并插入 `@路径`(服务端 `findFiles`,不支持时菜单里说明);图片可粘贴、拖入或选择(PNG/JPEG/GIF/WebP,单张 5 MB、每条 8 张以内);排队的消息显示在输入框上方,可撤回到输入框(`clearQueue`)。浏览器能识别语音时(`Voice`,`util/voice.ts`),每个输入框右侧都有麦克风:普通对话把听到的话填进光标处,改完再发;分身听完直接发出。逻辑在 `ComposerUtil`(`util/composer.ts`)。触屏上还可以照微信那样按住输入框说话(键盘收起时的整个输入框,含文字区和话筒;键盘弹出后文字区留给系统选字、粘贴):页面变暗模糊,绿色气泡边听边显示文字,下方左右是"取消""编辑"两个圆,底部弧形提示"松开 发送"。原地松手就把这句话(连同输入框里已有的内容)发出;手指滑到"取消"上松手则丢掉,滑到"编辑"上松手则留在输入框里改;说话不到 600ms 不算这次输入(气泡里提示"说话时间太短"后消失),什么都没听到也不算,防止误触;松手后浮层淡出,首次使用浏览器会先询问麦克风权限(`VoiceTalkUtil`,`components/voice-talk.tsx`;手势在 `device/hold.ts`)。
|
|
38
39
|
- **头像**:`TaAvatar` 是分身选的那种恐龙(默认就是 Cell logo),`mark` 是 1~2 个字符的角标,用来区分智能体(Web 扩展里是 `pi.ui.Avatar`);每轮回复开头放一个小头像(一轮一次):工作中用眼神表示思考、执行或输出,最后一轮完成时眯眼带勾,出错时带提醒角标;空对话页是大号头像,会眨眼、不时看向输入框。减少动效时全部静止。账号头像(导轨左下角、手机"我")是同一只恐龙的头部特写 `DinoFace`:圆眼、腮红,会歪头、眨眼、眼睛跟着指针,点一下会笑。各品种的静态 SVG 在 `assets/dinos/`(`bun ta-packages/ta-web/scripts/dino-art.ts` 生成)。
|
|
39
40
|
- **状态与提示**:分四级(info / success / warning / error),每级有固定的图标和颜色,正文始终用正文色。按归属分三种:全局的**连接状态条**(主区顶部的胶囊,断线超过 1 秒才出现,显示原因、倒计时和“立即重试”,恢复后显示“已重新连接”2 秒);**通知**(`TaNotices`,右下角、手机在顶部,success 3 秒、info 4 秒、warning 6 秒、error 8 秒,有按钮的多留 4 秒,悬停或聚焦时暂停计时,同一条重复出现时合并计数,最多 4 条);**就地提示**(`Callout`,留在出事的位置,如一轮回复失败、扩展视图出错、token 被拒绝)。操作失败(发送、切换模型、打开对话等)统一用 `notices.error`:服务端带 `hint` 的错误把建议放第二行,断线导致的失败合并成一条“没有完成:ta serve 未连接”。需要用户确认的操作用 `notices.confirm`,不可撤销的操作按钮为红色、默认焦点在“取消”。
|
|
40
41
|
- **链接**:回复里的链接都可以点(`TaLinks`,解析在 `LinkUtil`)。网页链接、正文里的裸 URL 和 `<URL>` 默认在右侧工作台的浏览器里打开,Cmd/Ctrl + 点击(或中键)在系统浏览器里打开;文件路径(`[说明](src/a.ts#L10-L20)`、`src/a.ts:10:5`、`file://` 地址,以及写成行内代码的 `src/a.ts:12`、`package.json`)按对话目录解析,在工作台打开并定位、选中对应行列(写法同 VS Code:`#L10`、`#L10C5-L12C3`、`:10:5`、`:10-20`);目录(`docs/`)在资源管理器里切到该目录。打开动作由 Web 扩展提供(`registerOpener`,内置的 @celljs/ta-workspace 负责文件、目录和内置浏览器)。安全上照 VS Code 的做法:只认 http(s)、mailto 和路径,`javascript:`、`data:`、`command:` 等其他协议一律当普通文本;渲染结果是 React 元素而不是 HTML;路径先经服务端确认存在,读写仍受执行环境约束;在系统浏览器打开前会弹窗显示完整地址并突出域名(外观相近的域名按浏览器的 punycode 显示),可复制、打开或信任该域名,本机地址(localhost、127.0.0.1、ta serve 所在主机)和 **设置 → 链接 → 受信任的域名**(`github.com`、`*.github.com`、`localhost:3000`、`*`)里的不再询问;新窗口一律 `noopener,noreferrer`。内置浏览器里,与 Ta 页面同源的地址不给 `allow-same-origin`,碰不到页面和 token。
|
|
@@ -2,18 +2,24 @@ import * as React from 'react';
|
|
|
2
2
|
import { ChatList } from '../components/chat-list.js';
|
|
3
3
|
import { ConnectionBanner } from '../components/connection-bar.js';
|
|
4
4
|
import { useNotices } from '../hooks.js';
|
|
5
|
+
import { useT } from '../i18n/use-t.js';
|
|
5
6
|
import { useAssistant } from './assistant-hooks.js';
|
|
6
7
|
/** The list of chats with what the double knows of them: its tasks marked, a conversation to hand it. */
|
|
7
8
|
export function AssistantChatList(props) {
|
|
8
9
|
var _a;
|
|
9
10
|
const [{ tasks, ready }, assistant] = useAssistant();
|
|
10
11
|
const [, notices] = useNotices();
|
|
12
|
+
const t = useT();
|
|
13
|
+
const name = assistant.name || t('ta.builtin.assistant');
|
|
11
14
|
const session = ready ? (_a = assistant.store()) === null || _a === void 0 ? void 0 : _a.sessionId : undefined;
|
|
15
|
+
const { sessionFile } = assistant;
|
|
12
16
|
const double = React.useMemo(() => ({
|
|
13
|
-
tasks: new
|
|
17
|
+
tasks: new Map(tasks.filter(task => !task.takenOver).map(task => [task.sessionId, task.status])),
|
|
14
18
|
session,
|
|
19
|
+
sessionFile,
|
|
20
|
+
name,
|
|
15
21
|
hand: (info, title) => void assistant.adopt({ sessionId: info.sessionId, title, cwd: info.cwd }).catch(error => notices.error(error)),
|
|
16
|
-
}), [tasks, session, assistant, notices]);
|
|
22
|
+
}), [tasks, session, sessionFile, name, assistant, notices]);
|
|
17
23
|
return React.createElement(ChatList, { ...props, double: double, notice: React.createElement(ConnectionBanner, null) });
|
|
18
24
|
}
|
|
19
25
|
//# sourceMappingURL=assistant-chat-list.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebExtensionAPI, WebExtensionFactory, WebMenuItem } from '../extension/web-extension-api.js';
|
|
1
|
+
import type { WebExtensionAPI, WebExtensionFactory, WebMenuItem, WebViewPreview } from '../extension/web-extension-api.js';
|
|
2
2
|
import { BuiltinWebExtension } from '../extension/web-extension-protocol.js';
|
|
3
3
|
import { TaSettings } from '../settings/settings-protocol.js';
|
|
4
4
|
import { TaState } from '../state/state-protocol.js';
|
|
@@ -17,6 +17,13 @@ export declare class AssistantWebExtension implements BuiltinWebExtension {
|
|
|
17
17
|
protected readonly persisted: TaState;
|
|
18
18
|
protected readonly workbench: TaWorkbench;
|
|
19
19
|
protected readonly settings: TaSettings;
|
|
20
|
+
/**
|
|
21
|
+
* What the double said last, as the list of chats shows a conversation: from the open sessions, else the
|
|
22
|
+
* saved ones. A note of a task the double reads is not something said to the user: none then.
|
|
23
|
+
*/
|
|
24
|
+
protected preview(): WebViewPreview | undefined;
|
|
25
|
+
/** The double answers in its own conversation now. */
|
|
26
|
+
protected busy(): boolean;
|
|
20
27
|
readonly activate: WebExtensionFactory;
|
|
21
28
|
/** The … of the page: stop, start over; its name, its look, its system prompt, the default directory its tasks open in; the conversation as a file. */
|
|
22
29
|
protected menu(pi: WebExtensionAPI): WebMenuItem[][];
|
|
@@ -103,6 +103,9 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
103
103
|
icon: Bot,
|
|
104
104
|
render: () => React.createElement(AssistantPanel, { onTask: openTask }),
|
|
105
105
|
menu: () => this.menu(pi),
|
|
106
|
+
preview: () => this.preview(),
|
|
107
|
+
busy: () => this.busy(),
|
|
108
|
+
subscribe: listener => this.workbench.subscribe(() => listener()),
|
|
106
109
|
});
|
|
107
110
|
registerPage();
|
|
108
111
|
pi.registerView('tasks-card', {
|
|
@@ -150,6 +153,23 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
150
153
|
};
|
|
151
154
|
};
|
|
152
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* What the double said last, as the list of chats shows a conversation: from the open sessions, else the
|
|
158
|
+
* saved ones. A note of a task the double reads is not something said to the user: none then.
|
|
159
|
+
*/
|
|
160
|
+
preview() {
|
|
161
|
+
var _a;
|
|
162
|
+
const file = this.assistant.sessionFile;
|
|
163
|
+
const { sessions, saved } = this.workbench.state;
|
|
164
|
+
const session = file ? ((_a = sessions.find(each => each.sessionFile === file)) !== null && _a !== void 0 ? _a : saved.find(each => each.sessionFile === file)) : undefined;
|
|
165
|
+
const text = session === null || session === void 0 ? void 0 : session.lastMessage;
|
|
166
|
+
return text && !text.startsWith('<task_') ? { text, at: session.updatedAt } : undefined;
|
|
167
|
+
}
|
|
168
|
+
/** The double answers in its own conversation now. */
|
|
169
|
+
busy() {
|
|
170
|
+
const file = this.assistant.sessionFile;
|
|
171
|
+
return !!file && this.workbench.state.sessions.some(each => each.sessionFile === file && each.isStreaming);
|
|
172
|
+
}
|
|
153
173
|
/** The … of the page: stop, start over; its name, its look, its system prompt, the default directory its tasks open in; the conversation as a file. */
|
|
154
174
|
menu(pi) {
|
|
155
175
|
var _a;
|
|
@@ -58,8 +58,10 @@ export interface TaAssistant {
|
|
|
58
58
|
warm(): Promise<void>;
|
|
59
59
|
/** Reads the tasks kept, for the lists, without opening the conversation. */
|
|
60
60
|
loadTasks(): Promise<void>;
|
|
61
|
-
/** The conversation with ta. */
|
|
61
|
+
/** The conversation with ta; before it opens, it as this device kept it (`showKept`), if it did. */
|
|
62
62
|
store(): SessionStore | undefined;
|
|
63
|
+
/** Before the conversation opens, and without the computer: shows it as this device last saw it. */
|
|
64
|
+
showKept(): Promise<void>;
|
|
63
65
|
taskStore(taskId: string): SessionStore | undefined;
|
|
64
66
|
/**
|
|
65
67
|
* The session of a task to show: the one followed, else its conversation opened again from its file (a
|
|
@@ -13,6 +13,8 @@ export declare namespace AssistantTaskUtil {
|
|
|
13
13
|
/**
|
|
14
14
|
* The tasks of both lists, each in its newer copy (the higher `rev`; the server's, `theirs`, when
|
|
15
15
|
* both are as new, so that the pages end with the same), in the order they started; the last MAX_TASKS.
|
|
16
|
+
* A task taken off the list in either stays off: a page that changed it meanwhile, as often, does not
|
|
17
|
+
* bring it back.
|
|
16
18
|
*/
|
|
17
19
|
function merge(ours: readonly AssistantTask[], theirs: readonly AssistantTask[]): AssistantTask[];
|
|
18
20
|
/** The tasks the lists show. */
|
|
@@ -17,6 +17,8 @@ export var AssistantTaskUtil;
|
|
|
17
17
|
/**
|
|
18
18
|
* The tasks of both lists, each in its newer copy (the higher `rev`; the server's, `theirs`, when
|
|
19
19
|
* both are as new, so that the pages end with the same), in the order they started; the last MAX_TASKS.
|
|
20
|
+
* A task taken off the list in either stays off: a page that changed it meanwhile, as often, does not
|
|
21
|
+
* bring it back.
|
|
20
22
|
*/
|
|
21
23
|
function merge(ours, theirs) {
|
|
22
24
|
var _a, _b;
|
|
@@ -26,9 +28,9 @@ export var AssistantTaskUtil;
|
|
|
26
28
|
}
|
|
27
29
|
for (const task of theirs) {
|
|
28
30
|
const mine = byId.get(task.id);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
31
|
+
const newer = !mine || ((_a = task.rev) !== null && _a !== void 0 ? _a : 0) >= ((_b = mine.rev) !== null && _b !== void 0 ? _b : 0) ? task : mine;
|
|
32
|
+
const removed = !!(task.removed || (mine === null || mine === void 0 ? void 0 : mine.removed));
|
|
33
|
+
byId.set(task.id, removed && !newer.removed ? { ...newer, removed } : newer);
|
|
32
34
|
}
|
|
33
35
|
return [...byId.values()].sort((a, b) => number(a.id) - number(b.id) || a.startedAt - b.startedAt).slice(-MAX_TASKS);
|
|
34
36
|
}
|
|
@@ -3,6 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { Callout } from '../components/callout.js';
|
|
4
4
|
import { Composer } from '../components/composer.js';
|
|
5
5
|
import { useComposerAddons } from '../components/composer-addons.js';
|
|
6
|
+
import { ConnectionBanner } from '../components/connection-bar.js';
|
|
6
7
|
import { ASK_CLASS, useConversationScroll } from '../components/conversation-scroll.js';
|
|
7
8
|
import { DialogView } from '../components/dialog-view.js';
|
|
8
9
|
import { useAsked, useEarlierMessages } from '../components/earlier-messages.js';
|
|
@@ -10,14 +11,14 @@ import { HeroCards, HeroSteps } from '../components/hero-cards.js';
|
|
|
10
11
|
import { Icon } from '../components/icon.js';
|
|
11
12
|
import { Markdown } from '../components/markdown.js';
|
|
12
13
|
import { useMessageActions } from '../components/message-actions.js';
|
|
13
|
-
import { MessageActions, TurnFooter, UserFooter } from '../components/message-footer.js';
|
|
14
|
-
import { Process, quiet, TurnAvatar,
|
|
14
|
+
import { MessageActions, TimeBreak, TurnFooter, UserFooter } from '../components/message-footer.js';
|
|
15
|
+
import { Process, quiet, TurnAvatar, UserSaid } from '../components/message-list.js';
|
|
15
16
|
import { useMessageMenu } from '../components/message-menu.js';
|
|
16
17
|
import { RunStatus } from '../components/run-status.js';
|
|
17
18
|
import { useSessionSettings } from '../components/session-settings.js';
|
|
18
19
|
import { TaAvatar } from '../components/ta-avatar.js';
|
|
19
20
|
import { WorkbenchToggle } from '../components/workbench-toggle.js';
|
|
20
|
-
import { CustomMessage } from '../extension/extension-view.js';
|
|
21
|
+
import { CustomMessage, MessageRenderers } from '../extension/extension-view.js';
|
|
21
22
|
import { WebTaskUtil } from '../extension/web-tasks.js';
|
|
22
23
|
import { useNotices, usePersisted, useSessionState, useSettings, useTasks, useWebExtensions, useWorkbench } from '../hooks.js';
|
|
23
24
|
import { useT } from '../i18n/use-t.js';
|
|
@@ -82,37 +83,33 @@ function lastReply(messages, start) {
|
|
|
82
83
|
}
|
|
83
84
|
return undefined;
|
|
84
85
|
}
|
|
85
|
-
/** When an item of the conversation began: its first message; one still empty (a turn about to come), when the one before did. */
|
|
86
|
-
function startsOf(items) {
|
|
87
|
-
let last = Number.NEGATIVE_INFINITY;
|
|
88
|
-
return items.map(item => {
|
|
89
|
-
const first = item.kind === 'turn' ? item.messages[0] : item.message;
|
|
90
|
-
const at = first === null || first === void 0 ? void 0 : first.timestamp;
|
|
91
|
-
last = typeof at === 'number' ? at : last;
|
|
92
|
-
return last;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
86
|
/** A turn of the double: held, it opens the same menu as a turn of a conversation (message-menu.tsx). */
|
|
96
|
-
function DoubleTurn({ item, children }) {
|
|
87
|
+
function DoubleTurn({ item, latest, children }) {
|
|
97
88
|
const reply = item.reply.join('\n\n').trim();
|
|
98
|
-
const [menu, onContextMenu] = useMessageMenu({
|
|
89
|
+
const [menu, onContextMenu] = useMessageMenu({
|
|
90
|
+
kind: 'turn',
|
|
91
|
+
last: item.active ? undefined : item.last,
|
|
92
|
+
reply: item.active ? '' : reply,
|
|
93
|
+
messages: item.messages,
|
|
94
|
+
});
|
|
99
95
|
return (React.createElement("div", { className: `ta-msg-ta ${item.active ? 'ta-turn-live' : ''}`, onContextMenu: onContextMenu },
|
|
100
96
|
children,
|
|
101
|
-
!item.active && React.createElement(TurnFooter, { messages: item.messages, last: item.last, reply: reply }),
|
|
97
|
+
!item.active && React.createElement(TurnFooter, { messages: item.messages, last: item.last, reply: reply, latest: latest }),
|
|
102
98
|
menu));
|
|
103
99
|
}
|
|
104
100
|
/** What the user said to the double: held, the same menu as a message of a conversation. */
|
|
105
101
|
function DoubleUserMessage({ message, blocks, text }) {
|
|
106
102
|
const [menu, onContextMenu] = useMessageMenu({ kind: 'user', message, text });
|
|
107
103
|
return (React.createElement("div", { className: `ta-msg-user ${ASK_CLASS}`, onContextMenu: onContextMenu },
|
|
108
|
-
React.createElement(
|
|
109
|
-
text && React.createElement("div", { className: "ta-msg-bubble" }, text),
|
|
104
|
+
React.createElement(UserSaid, { blocks: blocks, text: text, bubble: "ta-msg-bubble" }),
|
|
110
105
|
React.createElement(UserFooter, { message: message, text: text }),
|
|
111
106
|
menu));
|
|
112
107
|
}
|
|
113
108
|
function Conversation({ state, tasks, origin, onTask, t }) {
|
|
114
109
|
const items = React.useMemo(() => ProcessUtil.items(state.messages, state.working, state.start), [state.messages, state.working, state.start]);
|
|
115
|
-
const starts = React.useMemo(() =>
|
|
110
|
+
const starts = React.useMemo(() => ProcessUtil.starts(items), [items]);
|
|
111
|
+
const renderers = React.useContext(MessageRenderers);
|
|
112
|
+
const breaks = React.useMemo(() => ProcessUtil.timeBreaks(starts, index => ProcessUtil.shown(items[index], renderers)), [starts, items, renderers]);
|
|
116
113
|
const own = React.useMemo(() => tasks.filter(task => task.origin && task.origin === origin), [tasks, origin]);
|
|
117
114
|
let lastTurn = items.length - 1;
|
|
118
115
|
while (lastTurn >= 0 && items[lastTurn].kind !== 'turn') {
|
|
@@ -122,40 +119,43 @@ function Conversation({ state, tasks, origin, onTask, t }) {
|
|
|
122
119
|
const last = items[items.length - 1];
|
|
123
120
|
const status = state.working || state.compacting ? React.createElement(RunStatus, { state: state }) : undefined;
|
|
124
121
|
const onHead = status && quiet(last);
|
|
122
|
+
const row = (item, index) => {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
if (item.kind === 'turn') {
|
|
125
|
+
const results = MessageUtil.results(item.messages);
|
|
126
|
+
const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
|
|
127
|
+
const stopReason = MessageUtil.stopReason(item.last);
|
|
128
|
+
const mood = ProcessUtil.mood(item, index === lastTurn, waiting);
|
|
129
|
+
const started = WebTaskUtil.startedIn(own, origin, starts[index], (_b = starts[index + 1]) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY);
|
|
130
|
+
return (React.createElement(DoubleTurn, { key: item.key, item: item, latest: index === lastTurn },
|
|
131
|
+
React.createElement(Process, { steps: item.steps, active: item.active, results: results, tools: state.tools, leading: React.createElement(TurnAvatar, { mood: mood }), status: onHead && item === last ? status : undefined }),
|
|
132
|
+
React.createElement(TaskCards, { tasks: started }),
|
|
133
|
+
item.reply.map((text, index) => (React.createElement(Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
|
|
134
|
+
!item.active && stopReason === 'error' && errorMessage && React.createElement(Callout, { level: "error" }, errorMessage)));
|
|
135
|
+
}
|
|
136
|
+
const { role } = item.message;
|
|
137
|
+
if (role === 'custom') {
|
|
138
|
+
return React.createElement(CustomMessage, { key: item.key, message: item.message });
|
|
139
|
+
}
|
|
140
|
+
if (role !== 'user') {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const blocks = MessageUtil.blocks(item.message);
|
|
144
|
+
const text = MessageUtil.text(blocks).trim();
|
|
145
|
+
const update = TASK_UPDATE.exec(text);
|
|
146
|
+
if (update) {
|
|
147
|
+
const status = update[3];
|
|
148
|
+
return (React.createElement("button", { key: item.key, type: "button", className: "ta-task-update", onClick: () => onTask(update[1]) },
|
|
149
|
+
React.createElement("span", { className: `ta-status ta-status-${TASK_DOTS[status]}` }),
|
|
150
|
+
React.createElement("span", { className: "ta-task-update-text" }, t('ta.task.ended', { title: update[2], status: t(`ta.task.${status}`) })),
|
|
151
|
+
React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-task-update-chevron" })));
|
|
152
|
+
}
|
|
153
|
+
return React.createElement(DoubleUserMessage, { key: item.key, message: item.message, blocks: blocks, text: text });
|
|
154
|
+
};
|
|
125
155
|
return (React.createElement(React.Fragment, null,
|
|
126
|
-
items.map((item, index) => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const results = MessageUtil.results(item.messages);
|
|
130
|
-
const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
|
|
131
|
-
const stopReason = MessageUtil.stopReason(item.last);
|
|
132
|
-
const mood = ProcessUtil.mood(item, index === lastTurn, waiting);
|
|
133
|
-
const started = WebTaskUtil.startedIn(own, origin, starts[index], (_b = starts[index + 1]) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY);
|
|
134
|
-
return (React.createElement(DoubleTurn, { key: item.key, item: item },
|
|
135
|
-
React.createElement(Process, { steps: item.steps, active: item.active, results: results, tools: state.tools, leading: React.createElement(TurnAvatar, { mood: mood }), status: onHead && item === last ? status : undefined }),
|
|
136
|
-
React.createElement(TaskCards, { tasks: started }),
|
|
137
|
-
item.reply.map((text, index) => (React.createElement(Markdown, { key: index, text: text }))),
|
|
138
|
-
!item.active && stopReason === 'error' && errorMessage && React.createElement(Callout, { level: "error" }, errorMessage)));
|
|
139
|
-
}
|
|
140
|
-
const { role } = item.message;
|
|
141
|
-
if (role === 'custom') {
|
|
142
|
-
return React.createElement(CustomMessage, { key: item.key, message: item.message });
|
|
143
|
-
}
|
|
144
|
-
if (role !== 'user') {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
const blocks = MessageUtil.blocks(item.message);
|
|
148
|
-
const text = MessageUtil.text(blocks).trim();
|
|
149
|
-
const update = TASK_UPDATE.exec(text);
|
|
150
|
-
if (update) {
|
|
151
|
-
const status = update[3];
|
|
152
|
-
return (React.createElement("button", { key: item.key, type: "button", className: "ta-task-update", onClick: () => onTask(update[1]) },
|
|
153
|
-
React.createElement("span", { className: `ta-status ta-status-${TASK_DOTS[status]}` }),
|
|
154
|
-
React.createElement("span", { className: "ta-task-update-text" }, t('ta.task.ended', { title: update[2], status: t(`ta.task.${status}`) })),
|
|
155
|
-
React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-task-update-chevron" })));
|
|
156
|
-
}
|
|
157
|
-
return React.createElement(DoubleUserMessage, { key: item.key, message: item.message, blocks: blocks, text: text });
|
|
158
|
-
}),
|
|
156
|
+
items.map((item, index) => (React.createElement(React.Fragment, { key: item.key },
|
|
157
|
+
breaks[index] !== undefined && React.createElement(TimeBreak, { timestamp: breaks[index] }),
|
|
158
|
+
row(item, index)))),
|
|
159
159
|
status && !onHead && React.createElement("div", { className: "ta-run-line" }, status)));
|
|
160
160
|
}
|
|
161
161
|
function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
@@ -174,7 +174,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
174
174
|
const [, notices] = useNotices();
|
|
175
175
|
const spoken = React.useRef(undefined);
|
|
176
176
|
const box = React.useRef(null);
|
|
177
|
-
const { speak, confirmTasks } = settingsState.settings;
|
|
177
|
+
const { speak, speakTalk, confirmTasks } = settingsState.settings;
|
|
178
178
|
const [name] = usePersisted(ASSISTANT_NAME_STATE);
|
|
179
179
|
const attentions = [
|
|
180
180
|
...state.pendingUi.map(request => ({ source: 'ta', store, request })),
|
|
@@ -197,6 +197,10 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
197
197
|
});
|
|
198
198
|
React.useEffect(() => onMood(mood), [mood, onMood]);
|
|
199
199
|
const reply = lastReply(state.messages, state.start);
|
|
200
|
+
// Said to it by voice, held (its box, or its entry of the navigation): what it answers is heard once, as a
|
|
201
|
+
// conversation by voice, where the user asked for it (Settings.speakTalk, off at first: a reply read out loud
|
|
202
|
+
// where the user only wanted to type by voice is awkward).
|
|
203
|
+
const aloud = React.useRef(false);
|
|
200
204
|
// Reads a new reply out once the run has settled; what was said before the page opened stays quiet.
|
|
201
205
|
React.useEffect(() => {
|
|
202
206
|
if (state.working || !reply || spoken.current === reply.index) {
|
|
@@ -204,7 +208,11 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
204
208
|
}
|
|
205
209
|
const first = spoken.current === undefined;
|
|
206
210
|
spoken.current = reply.index;
|
|
207
|
-
|
|
211
|
+
const audible = Voice.canSpeak();
|
|
212
|
+
// A conversation by voice is heard even as the first reply the page shows.
|
|
213
|
+
const answerAloud = aloud.current && audible;
|
|
214
|
+
aloud.current = false;
|
|
215
|
+
if (answerAloud || (!first && speak && audible)) {
|
|
208
216
|
setSpeaking(true);
|
|
209
217
|
Voice.speak(reply.text, settingsState.language, () => setSpeaking(false));
|
|
210
218
|
}
|
|
@@ -273,6 +281,17 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
273
281
|
},
|
|
274
282
|
]
|
|
275
283
|
: []),
|
|
284
|
+
...(Voice.canSpeak() && Voice.canListen()
|
|
285
|
+
? [
|
|
286
|
+
{
|
|
287
|
+
key: 'speakTalk',
|
|
288
|
+
label: t('ta.settings.speakTalk'),
|
|
289
|
+
icon: React.createElement(Icon, { icon: Mic, size: 16 }),
|
|
290
|
+
detail: t(speakTalk ? 'ta.on' : 'ta.off'),
|
|
291
|
+
run: () => settings.update({ speakTalk: !speakTalk }),
|
|
292
|
+
},
|
|
293
|
+
]
|
|
294
|
+
: []),
|
|
276
295
|
{
|
|
277
296
|
key: 'confirm',
|
|
278
297
|
label: t('ta.assistant.confirmOn'),
|
|
@@ -309,8 +328,11 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
309
328
|
attentions.map(({ source, store: from, request }) => (React.createElement("div", { key: request.id, className: "ta-attention" },
|
|
310
329
|
React.createElement("div", { className: "ta-attention-source" }, source),
|
|
311
330
|
React.createElement(DialogView, { request: request, respond: response => from.respondUi(response).catch(() => undefined) })))),
|
|
331
|
+
React.createElement(ConnectionBanner, null),
|
|
312
332
|
addons.above,
|
|
313
|
-
React.createElement(Composer, { ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onError: fail, voiceSends: true,
|
|
333
|
+
React.createElement(Composer, { ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onError: fail, voiceSends: true, talkPlace: "double", onTalkSent: () => {
|
|
334
|
+
aloud.current = speakTalk;
|
|
335
|
+
}, onListening: on => {
|
|
314
336
|
setListening(on);
|
|
315
337
|
if (on) {
|
|
316
338
|
hush();
|
|
@@ -328,6 +350,9 @@ export function AssistantPanel({ onTask }) {
|
|
|
328
350
|
const [mood, setMood] = React.useState('idle');
|
|
329
351
|
const [name] = usePersisted(ASSISTANT_NAME_STATE);
|
|
330
352
|
const taskStates = useTaskStates(assistant, state.tasks);
|
|
353
|
+
React.useEffect(() => {
|
|
354
|
+
void assistant.showKept();
|
|
355
|
+
}, [assistant]);
|
|
331
356
|
React.useEffect(() => {
|
|
332
357
|
if (workbench.status === 'online') {
|
|
333
358
|
void assistant.start();
|
|
@@ -355,7 +380,7 @@ export function AssistantPanel({ onTask }) {
|
|
|
355
380
|
React.createElement(TasksChip, { tasks: allTasks, onOpen: openTasks }),
|
|
356
381
|
React.createElement(WorkbenchToggle, null)),
|
|
357
382
|
React.createElement("div", { className: "ta-assistant-body" },
|
|
358
|
-
React.createElement("div", { className: "ta-assistant-chat" }, store ? (React.createElement(Chat, { store: store, tasks: state.tasks, taskStates: taskStates, onTask: openTask, onMood: setMood, onTasks: openTasks })) : (React.createElement("div", { className: "ta-empty" }, state.error ? (React.createElement(Callout, { level: "error" }, state.error)) : (React.createElement(React.Fragment, null,
|
|
383
|
+
React.createElement("div", { className: "ta-assistant-chat" }, store ? (React.createElement(Chat, { store: store, tasks: state.tasks, taskStates: taskStates, onTask: openTask, onMood: setMood, onTasks: openTasks })) : (React.createElement("div", { className: "ta-empty" }, state.error ? (React.createElement(Callout, { level: "error" }, state.error)) : workbench.offlineShown ? (React.createElement("span", { className: "ta-muted" }, t('ta.assistant.offline'))) : (React.createElement(React.Fragment, null,
|
|
359
384
|
React.createElement("span", { className: "ta-spinner" }),
|
|
360
385
|
" ",
|
|
361
386
|
t('ta.assistant.waking'))))))))));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
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 { TaKeptChats } from '../offline/kept-chats-protocol.js';
|
|
3
4
|
import { type Settings, TaSettings } from '../settings/settings-protocol.js';
|
|
4
5
|
import { TaState } from '../state/state-protocol.js';
|
|
5
6
|
import { TaWorkbench } from '../workbench-protocol.js';
|
|
@@ -15,8 +16,13 @@ export declare class TaAssistantImpl implements TaAssistant {
|
|
|
15
16
|
protected readonly workbench: TaWorkbench;
|
|
16
17
|
protected readonly persisted: TaState;
|
|
17
18
|
protected readonly settings: TaSettings;
|
|
19
|
+
protected readonly kept: TaKeptChats;
|
|
18
20
|
protected current: AssistantState;
|
|
19
21
|
protected assistant?: SessionStore;
|
|
22
|
+
/** Until the conversation is open (and while the computer cannot be reached): it as this device kept it. */
|
|
23
|
+
protected preview?: SessionStore;
|
|
24
|
+
/** Stops keeping the conversation on the device. */
|
|
25
|
+
protected unkeep?: () => void;
|
|
20
26
|
/** The directory of the conversation with ta, set when it opened: pi's `/new` keeps it. */
|
|
21
27
|
protected cwd?: string;
|
|
22
28
|
protected readonly taskStores: Map<string, SessionStore>;
|
|
@@ -53,6 +59,7 @@ export declare class TaAssistantImpl implements TaAssistant {
|
|
|
53
59
|
start(): Promise<void>;
|
|
54
60
|
warm(): Promise<void>;
|
|
55
61
|
store(): SessionStore | undefined;
|
|
62
|
+
showKept(): Promise<void>;
|
|
56
63
|
loadTasks(): Promise<void>;
|
|
57
64
|
/** The tasks other pages change, and the connection: back online (the service restarted, say), what runs is followed again. */
|
|
58
65
|
protected watchTasks(): void;
|
|
@@ -93,6 +100,8 @@ export declare class TaAssistantImpl implements TaAssistant {
|
|
|
93
100
|
protected reopen(store: SessionStore): Promise<void>;
|
|
94
101
|
stop(): Promise<void>;
|
|
95
102
|
restart(): Promise<void>;
|
|
103
|
+
/** Keeps the conversation on the device as it changes, under its file of the time (`restart` gives it another). */
|
|
104
|
+
protected keep(store: SessionStore): void;
|
|
96
105
|
/** The role of ta, whether it asks first, and what the user added to it. */
|
|
97
106
|
protected systemPrompt(): string;
|
|
98
107
|
/** Asking first or not is in the role: the conversation opens again with it, once the double is not at work. */
|