@celljs/ta-web 4.13.0 → 4.14.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 +2 -2
- package/README.md +2 -2
- package/esm/browser/assistant/assistant-extension.js +3 -2
- package/esm/browser/assistant/assistant-state.js +2 -2
- package/esm/browser/components/app-view.js +4 -0
- package/esm/browser/components/chat-asks.d.ts +8 -0
- package/esm/browser/components/chat-asks.js +10 -0
- package/esm/browser/components/chat-list.js +11 -1
- package/esm/browser/components/composer-box.d.ts +2 -0
- package/esm/browser/components/composer-box.js +2 -1
- package/esm/browser/components/composer.d.ts +3 -1
- package/esm/browser/components/composer.js +16 -4
- package/esm/browser/components/face.d.ts +13 -1
- package/esm/browser/components/face.js +16 -1
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/message-list.js +20 -1
- package/esm/browser/components/people.d.ts +32 -0
- package/esm/browser/components/people.js +71 -0
- package/esm/browser/components/session-view.d.ts +1 -1
- package/esm/browser/components/session-view.js +56 -36
- package/esm/browser/components/settings-parts.js +14 -3
- package/esm/browser/components/sign-in-setup.d.ts +16 -0
- package/esm/browser/components/sign-in-setup.js +116 -0
- package/esm/browser/components/use-seen-chats.d.ts +2 -0
- package/esm/browser/components/use-seen-chats.js +2 -2
- package/esm/browser/extension/web-api-components.d.ts +12 -0
- package/esm/browser/extension/web-extension-api.d.ts +2 -2
- package/esm/browser/i18n/locales.d.ts +35 -1
- package/esm/browser/i18n/messages.d.ts +34 -0
- package/esm/browser/i18n/messages.js +69 -0
- package/esm/browser/presence/presence-reporter.d.ts +32 -0
- package/esm/browser/presence/presence-reporter.js +71 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +24 -0
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +8 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +8 -0
- package/esm/browser/workbench-protocol.d.ts +9 -0
- package/esm/browser/workbench-util.d.ts +2 -0
- package/esm/browser/workbench-util.js +18 -0
- package/esm/browser/workbench.d.ts +3 -0
- package/esm/browser/workbench.js +14 -4
- package/lib/browser/assistant/assistant-extension.js +3 -2
- package/lib/browser/assistant/assistant-state.js +1 -1
- package/lib/browser/components/app-view.js +4 -0
- package/lib/browser/components/chat-asks.d.ts +8 -0
- package/lib/browser/components/chat-asks.js +10 -0
- package/lib/browser/components/chat-list.js +11 -1
- package/lib/browser/components/composer-box.d.ts +2 -0
- package/lib/browser/components/composer-box.js +2 -1
- package/lib/browser/components/composer.d.ts +3 -1
- package/lib/browser/components/composer.js +16 -4
- package/lib/browser/components/face.d.ts +13 -1
- package/lib/browser/components/face.js +16 -1
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/message-list.js +19 -0
- package/lib/browser/components/people.d.ts +33 -0
- package/lib/browser/components/people.js +109 -0
- package/lib/browser/components/session-view.d.ts +1 -1
- package/lib/browser/components/session-view.js +56 -36
- package/lib/browser/components/settings-parts.js +14 -3
- package/lib/browser/components/sign-in-setup.d.ts +17 -0
- package/lib/browser/components/sign-in-setup.js +153 -0
- package/lib/browser/components/use-seen-chats.d.ts +2 -0
- package/lib/browser/components/use-seen-chats.js +3 -2
- package/lib/browser/extension/web-api-components.d.ts +12 -0
- package/lib/browser/extension/web-extension-api.d.ts +2 -2
- package/lib/browser/i18n/locales.d.ts +35 -1
- package/lib/browser/i18n/messages.d.ts +34 -0
- package/lib/browser/i18n/messages.js +69 -0
- package/lib/browser/presence/presence-reporter.d.ts +33 -0
- package/lib/browser/presence/presence-reporter.js +75 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +24 -0
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +8 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +8 -0
- package/lib/browser/workbench-protocol.d.ts +9 -0
- package/lib/browser/workbench-util.d.ts +2 -0
- package/lib/browser/workbench-util.js +18 -0
- package/lib/browser/workbench.d.ts +3 -0
- package/lib/browser/workbench.js +14 -4
- package/package.json +10 -10
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, 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`).
|
|
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), `openLink` (opens a link as a click on a link of a reply does: the openers of extensions first, as of a share or an agent's card, else the browser of the workbench), `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), `registerInitiative` (how far the page goes on its own with what it does for the user, as the double starting a task: the extension that keeps the user's trust answers, the first registered; ta-initiative does), `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.
|
|
@@ -65,7 +65,7 @@ As WeChat pulls its mini programs down over its chats (design record docs/design
|
|
|
65
65
|
- **Widgets** (views at `location: 'board'`): on a phone, a swipe to the right over the first tab brings the board in from the left (from the left edge over a row swiped open); elsewhere a button of the rail. Edit takes cards off, puts them back and orders them by their handles, kept for the user (`board`). Built in: the double's tasks, Quick open, and Next up of the scheduled tasks.
|
|
66
66
|
- **Started on open**: a package with `pi.webActivation: 'open'`, or one opened without installing (`origin: 'temporary'`), loads when one of its pages opens; left, it keeps running in the background with its page as it was (`KeptPages`), shown again at once; it stops after the time of Settings, Extensions (5 minutes by default) in the background, or when more than three are there. Its pages are not in the navigation: Quick open lists them.
|
|
67
67
|
- **Sharing**: `ui.shareExtension` opens the dialog that hands an extension on (QR code, copy, the share of the system): the source of a published one, else end to end through the relay and kept nowhere (`TaRelayServer.sharePackage`); `ui.openShared` opens a link of an extension, asked first.
|
|
68
|
-
- For web extensions: `ui.usePages()` (every page, with its state, place, last use and temporary package), `ui.showView` (starts one started on open first; its name opens its first page), `ui.stopExtension`, `ui.forgetPage`, `pi.openTemporary(source, from)`, `ui.useContextMenu()` (the menu of the page, right click or long press), `ui.QrCode`, `ui.scanCode` and `ui.scan` (in the Ta app only; `ui.scan` is the Scan of the page, which opens what the code carries).
|
|
68
|
+
- For web extensions: `ui.usePages()` (every page, with its state, place, last use and temporary package), `ui.showView` (starts one started on open first; its name opens its first page), `ui.stopExtension`, `ui.forgetPage`, `pi.openTemporary(source, from)`, `ui.useContextMenu()` (the menu of the page, right click or long press), `ui.QrCode`, `ui.scanCode` and `ui.scan` (in the Ta app only; `ui.scan` is the Scan of the page, which opens what the code carries), `ui.connect(link)` (connects to another Ta by a pairing link, of `ta pair` or the device a Ta that let the user in gave them, and switches to it once it answered, the page loading again; false, said in a notice, when it did not answer or refused).
|
|
69
69
|
|
|
70
70
|
## Phones and tablets
|
|
71
71
|
|
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, 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`)。
|
|
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)、`openLink`(像点回复里的链接一样打开:先问扩展的打开方式,比如分享和智能体卡片的链接,没有就在工作台的浏览器里打开)、`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`(分身主页里分身下方的行,放用户每天要看的东西,如每日简报)、`registerInitiative`(页面自己替用户做事(如分身开始一项任务)时走多远,由管用户信任的扩展回答,只问第一个注册的;ta-initiative 用它)、`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
|
- **稳定**:每个扩展注册的东西归它自己,卸载时一并撤掉;一个扩展加载失败或渲染出错,只在它自己的位置显示错误,不影响页面和其他扩展。
|
|
@@ -65,7 +65,7 @@ Web 客户端可以装成桌面或手机上的应用:Chrome / Edge 地址栏
|
|
|
65
65
|
- **小组件**(`location: 'board'` 的视图):手机上在第一个标签上从左往右划,小组件面板从左侧滑入(已经划开的列表行上从左边缘开始);电脑和平板上是导轨底部的按钮。"编辑"里可以移除、加回卡片,拖动右侧把手排序,排列存在用户数据里(`board`)。内置的卡片有分身的任务、快捷打开和定时任务的"接下来"。
|
|
66
66
|
- **按需启动**:包的 `pi.webActivation: 'open'`,或免安装打开的临时扩展(`origin: 'temporary'`),在打开它的页面时才加载;离开后在后台继续运行、页面原样保留(`KeptPages`),再次打开没有等待;在后台超过保留时间(设置 → 扩展,默认 5 分钟)或后台超过 3 个时停止。这类扩展的页面不进导航栏,在快捷打开里找到。
|
|
67
67
|
- **分享**:`ui.shareExtension` 打开分享弹窗(二维码、复制、系统分享),已发布的扩展给来源,本机的经中继端到端发送、不存储(`TaRelayServer.sharePackage`);`ui.openShared` 打开扩展链接,先确认。
|
|
68
|
-
- 扩展接口:`ui.usePages()`(所有页面及其状态、位置、最近使用时间、临时扩展信息)、`ui.showView`(按需启动的先启动,扩展名打开它的第一个页面)、`ui.stopExtension`、`ui.forgetPage`、`pi.openTemporary(source, from)`、`ui.useContextMenu()`(和页面一样的右键/长按菜单)、`ui.QrCode`、`ui.scanCode` 和 `ui.scan`(只在 Ta 手机应用里;`ui.scan`
|
|
68
|
+
- 扩展接口:`ui.usePages()`(所有页面及其状态、位置、最近使用时间、临时扩展信息)、`ui.showView`(按需启动的先启动,扩展名打开它的第一个页面)、`ui.stopExtension`、`ui.forgetPage`、`pi.openTemporary(source, from)`、`ui.useContextMenu()`(和页面一样的右键/长按菜单)、`ui.QrCode`、`ui.scanCode` 和 `ui.scan`(只在 Ta 手机应用里;`ui.scan` 就是页面自己的“扫一扫”,扫完打开二维码里的内容)、`ui.connect(link)`(按配对链接连到另一个 Ta,`ta pair` 或让你进入的 Ta 给的设备,对方回答后切过去、页面重新加载;没回答或被拒绝时返回 false 并提示原因)。
|
|
69
69
|
|
|
70
70
|
## 手机与平板
|
|
71
71
|
|
|
@@ -99,8 +99,9 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
99
99
|
remove,
|
|
100
100
|
asking: task => {
|
|
101
101
|
var _a;
|
|
102
|
-
const
|
|
103
|
-
|
|
102
|
+
const { sessions, saved } = this.workbench.state;
|
|
103
|
+
const entry = ChatAskUtil.entryOf(sessions, saved, task);
|
|
104
|
+
return entry && ((_a = ChatAskUtil.asking(entry, this.persisted.get(LET_GO_ASKS))) === null || _a === void 0 ? void 0 : _a.question);
|
|
104
105
|
},
|
|
105
106
|
watchAsking: listener => {
|
|
106
107
|
const stops = [this.workbench.subscribe(() => listener()), this.persisted.subscribe(() => listener())];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TA_DOUBLE_FILE } from '@celljs/ta-protocol';
|
|
1
|
+
import { TA_DOUBLE_FILE, TA_DOUBLE_LOOK } from '@celljs/ta-protocol';
|
|
2
2
|
import { GAITS } from '../avatar/dino-motion.js';
|
|
3
3
|
import { DinoSpecies } from '../avatar/dino-species.js';
|
|
4
4
|
import { StateUtil } from '../state/state-protocol.js';
|
|
@@ -6,7 +6,7 @@ import { StateUtil } from '../state/state-protocol.js';
|
|
|
6
6
|
export const ASSISTANT_NAME_STATE = { key: 'assistant.name', tier: 'user', initial: '', parse: StateUtil.string };
|
|
7
7
|
/** The kind of dinosaur the double is and how it walks: the figure of the account follows it, in every browser. */
|
|
8
8
|
export const ASSISTANT_SPECIES_STATE = {
|
|
9
|
-
key:
|
|
9
|
+
key: TA_DOUBLE_LOOK.key,
|
|
10
10
|
tier: 'user',
|
|
11
11
|
initial: DinoSpecies.DEFAULT,
|
|
12
12
|
parse: value => DinoSpecies.IDS.find(id => id === value),
|
|
@@ -50,6 +50,7 @@ import { ShareHost } from './share-dialog.js';
|
|
|
50
50
|
import { DOUBLE_PAGE, SideListUtil } from './side-lists.js';
|
|
51
51
|
import { paneStyle, Sash, usePane } from './split-pane.js';
|
|
52
52
|
import { SurfaceFlyout } from './surface-flyout.js';
|
|
53
|
+
import { usePageVisible } from './use-seen-chats.js';
|
|
53
54
|
import { WorkbenchToggleContext } from './workbench-toggle.js';
|
|
54
55
|
import { SignIn, useDocument } from './workbench-view.js';
|
|
55
56
|
/**
|
|
@@ -267,6 +268,9 @@ function AppShell() {
|
|
|
267
268
|
React.useEffect(() => host.setConversationShown(conversationShown), [host, conversationShown]);
|
|
268
269
|
// What the user has seen is kept here, whichever list or tab is out: one read from the agents' list is seen too.
|
|
269
270
|
const { seen: seenChats, looking } = useSeenConversations(workbench.sessions, conversationShown ? store === null || store === void 0 ? void 0 : store.sessionId : undefined, (view === null || view === void 0 ? void 0 : view.id) === DOUBLE_PAGE && settings === undefined && (!phone || screenOpen || view === tabView));
|
|
271
|
+
// The others in the same Ta see who looks at a conversation with them (TaSessionInfo.people), while the page is seen.
|
|
272
|
+
const pageVisible = usePageVisible();
|
|
273
|
+
React.useEffect(() => bench.presence.look(pageVisible ? looking : undefined), [bench, pageVisible, looking]);
|
|
270
274
|
const state = useInject(TaState);
|
|
271
275
|
const { pageShown } = extensions;
|
|
272
276
|
// biome-ignore lint/correctness/useExhaustiveDependencies: follows the pages shown
|
|
@@ -29,6 +29,14 @@ export declare namespace ChatAskUtil {
|
|
|
29
29
|
function letGo(before: LetGoAsks, file: string, at: number): LetGoAsks;
|
|
30
30
|
/** What it still asks the user: none once answered or let go. */
|
|
31
31
|
function asking(entry: AskingEntry, letGo: LetGoAsks): TaAsking | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* What the lists know of the conversation of a session: as the server tells it while open, by its id or its file;
|
|
34
|
+
* from its file once closed (closed while idle, what it asked stays there, as the saved ones of the chats show).
|
|
35
|
+
*/
|
|
36
|
+
function entryOf(sessions: readonly TaSessionInfo[], saved: readonly TaSavedSessionInfo[], session: {
|
|
37
|
+
sessionId: string;
|
|
38
|
+
sessionFile?: string;
|
|
39
|
+
}): AskingEntry | undefined;
|
|
32
40
|
/** Whether it waits for the user: it asks, or a dialog of it waits. */
|
|
33
41
|
function waits(entry: AskingEntry, letGo: LetGoAsks): boolean;
|
|
34
42
|
/** How many of the conversations the list shows wait for the user: the count on the tab of the chats. */
|
|
@@ -53,6 +53,16 @@ export var ChatAskUtil;
|
|
|
53
53
|
return asking && asking.at > ((_a = letGo[fileOf(entry)]) !== null && _a !== void 0 ? _a : -1) ? asking : undefined;
|
|
54
54
|
}
|
|
55
55
|
ChatAskUtil.asking = asking;
|
|
56
|
+
/**
|
|
57
|
+
* What the lists know of the conversation of a session: as the server tells it while open, by its id or its file;
|
|
58
|
+
* from its file once closed (closed while idle, what it asked stays there, as the saved ones of the chats show).
|
|
59
|
+
*/
|
|
60
|
+
function entryOf(sessions, saved, session) {
|
|
61
|
+
const { sessionId, sessionFile } = session;
|
|
62
|
+
const open = sessions.find(each => each.sessionId === sessionId || (!!sessionFile && each.sessionFile === sessionFile));
|
|
63
|
+
return open !== null && open !== void 0 ? open : (sessionFile ? saved.find(each => each.sessionFile === sessionFile) : undefined);
|
|
64
|
+
}
|
|
65
|
+
ChatAskUtil.entryOf = entryOf;
|
|
56
66
|
/** Whether it waits for the user: it asks, or a dialog of it waits. */
|
|
57
67
|
function waits(entry, letGo) {
|
|
58
68
|
return !!entry.waiting || !!asking(entry, letGo);
|
|
@@ -15,6 +15,7 @@ import { useContextMenu } from './context-menu.js';
|
|
|
15
15
|
import { EmptyState } from './empty-state.js';
|
|
16
16
|
import { HostTag } from './host-tag.js';
|
|
17
17
|
import { Icon, IconButton } from './icon.js';
|
|
18
|
+
import { PeopleFaces, PresenceUtil } from './people.js';
|
|
18
19
|
import { SwipeRow } from './swipe-row.js';
|
|
19
20
|
import { DinoFace } from './ta-avatar.js';
|
|
20
21
|
/** The list by directory or package, else by day; in any browser. */
|
|
@@ -262,7 +263,8 @@ export var ChatListUtil;
|
|
|
262
263
|
a.cwd === b.cwd &&
|
|
263
264
|
a.group === b.group &&
|
|
264
265
|
(isOpen(a) && a.isStreaming) === (isOpen(b) && b.isStreaming) &&
|
|
265
|
-
(isOpen(a) && !!a.waiting) === (isOpen(b) && !!b.waiting)
|
|
266
|
+
(isOpen(a) && !!a.waiting) === (isOpen(b) && !!b.waiting) &&
|
|
267
|
+
PresenceUtil.same(isOpen(a) ? a.people : undefined, isOpen(b) ? b.people : undefined));
|
|
266
268
|
const x = before.source;
|
|
267
269
|
const y = after.source;
|
|
268
270
|
const sameSource = x === y || (x.key === y.key && x.label === y.label && x.title === y.title && x.host === y.host && x.initial === y.initial && x.tone === y.tone);
|
|
@@ -393,6 +395,11 @@ const ChatItem = React.memo(function ChatItem({ session, source, selected, time,
|
|
|
393
395
|
const asks = waiting || (!!asking && !streaming);
|
|
394
396
|
const mood = asks ? 'attention' : streaming ? 'working' : 'idle';
|
|
395
397
|
const state = React.createElement(ChatState, { streaming: streaming, waiting: waiting, task: task });
|
|
398
|
+
// Others in the same Ta: their faces while they look at it, and whose message it answers.
|
|
399
|
+
const people = ChatListUtil.isOpen(session) ? session.people : undefined;
|
|
400
|
+
const viewers = React.createElement(PeopleFaces, { people: PresenceUtil.viewing(people), size: 14, max: 3 });
|
|
401
|
+
const askers = streaming ? PresenceUtil.asked(people) : [];
|
|
402
|
+
const replying = askers.length > 0 && (React.createElement("span", { className: "ta-chat-flag ta-replying" }, t('ta.chat.replyingFor', { names: PresenceUtil.names(askers, t('ta.presence.separator'), count => t('ta.presence.more', { count })) })));
|
|
396
403
|
// As in a messaging app, the last thing said; its directory before the first, and on hover in place of its time.
|
|
397
404
|
const said = ChatListUtil.preview(session, title);
|
|
398
405
|
const place = who ? MessageUtil.basename(session.cwd) : source.label;
|
|
@@ -403,6 +410,7 @@ const ChatItem = React.memo(function ChatItem({ session, source, selected, time,
|
|
|
403
410
|
who && React.createElement(ChatAvatar, { session: session, source: source, who: who, size: 20, mood: mood }),
|
|
404
411
|
tag,
|
|
405
412
|
React.createElement("span", { className: "ta-chat-title" }, title),
|
|
413
|
+
viewers,
|
|
406
414
|
state,
|
|
407
415
|
React.createElement(ChatDot, { unseen: !!unseen, asks: asks }),
|
|
408
416
|
React.createElement("span", { className: "ta-chat-time" }, removing && handheld ? React.createElement("span", { className: "ta-spinner ta-later" }) : time)))) : (React.createElement(React.Fragment, null,
|
|
@@ -428,12 +436,14 @@ const ChatItem = React.memo(function ChatItem({ session, source, selected, time,
|
|
|
428
436
|
"[",
|
|
429
437
|
t('ta.chat.asking'),
|
|
430
438
|
"]"),
|
|
439
|
+
replying,
|
|
431
440
|
ended && !streaming && !asks && (React.createElement("span", { className: `ta-chat-flag ta-${ended}` },
|
|
432
441
|
"[",
|
|
433
442
|
t(ended === 'failed' ? 'ta.task.failed' : 'ta.task.stopped'),
|
|
434
443
|
"]")), (_a = (asks && !waiting ? asking : said)) !== null && _a !== void 0 ? _a : (React.createElement("span", { className: "ta-chat-dir" },
|
|
435
444
|
React.createElement(Icon, { icon: Folder, size: 12 }),
|
|
436
445
|
place))),
|
|
446
|
+
viewers,
|
|
437
447
|
streaming && React.createElement("span", { className: "ta-chat-state ta-spinner" })))))),
|
|
438
448
|
handheld ? null : onRestore ? (React.createElement(IconButton, { className: "ta-chat-delete", icon: Undo2, label: t('ta.chat.restore'), onClick: onRestore })) : (React.createElement(IconButton, { className: "ta-chat-delete", icon: Trash2, label: t('ta.sidebar.closeTitle'), busy: removing, onClick: onRemove }))));
|
|
439
449
|
}, ChatListUtil.sameRow);
|
|
@@ -80,6 +80,8 @@ export interface ComposerBoxProps {
|
|
|
80
80
|
onTalkSent?(): void;
|
|
81
81
|
onListening?(listening: boolean): void;
|
|
82
82
|
autoFocus?: boolean;
|
|
83
|
+
/** What the user typed changed: the text now. */
|
|
84
|
+
onTextChange?(text: string): void;
|
|
83
85
|
/** The directory of the conversation: files dragged in from it become `@` references relative to it. */
|
|
84
86
|
cwd?: string;
|
|
85
87
|
onError(error: unknown): void;
|
|
@@ -50,7 +50,7 @@ function talkTarget(target) {
|
|
|
50
50
|
}
|
|
51
51
|
export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
52
52
|
var _a;
|
|
53
|
-
const { placeholder, working = false, onStop, onSend, commands = [], onMentionQuery, mentions, mentionLabel, images: takesImages, recentShots, actions = [], above, head, after, voiceSends, talkPlace, onTalkSent, onListening, autoFocus, cwd, onError, } = props;
|
|
53
|
+
const { placeholder, working = false, onStop, onSend, commands = [], onMentionQuery, mentions, mentionLabel, images: takesImages, recentShots, actions = [], above, head, after, voiceSends, talkPlace, onTalkSent, onListening, autoFocus, onTextChange, cwd, onError, } = props;
|
|
54
54
|
const t = useT();
|
|
55
55
|
const [text, setText] = React.useState('');
|
|
56
56
|
const [caret, setCaret] = React.useState(0);
|
|
@@ -493,6 +493,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
493
493
|
talkMode && React.createElement(TalkBar, { talk: talk }),
|
|
494
494
|
React.createElement("textarea", { ref: input, hidden: talkMode, rows: 1, value: text, autoFocus: autoFocus, enterKeyHint: "send", "aria-label": t('ta.composer.label'), "aria-controls": items.length ? menuId : undefined, "aria-activedescendant": items.length ? `${menuId}-${selected}` : undefined, placeholder: listening ? t('ta.composer.listening') : placeholder, onChange: event => {
|
|
495
495
|
setText(event.target.value);
|
|
496
|
+
onTextChange === null || onTextChange === void 0 ? void 0 : onTextChange(event.target.value);
|
|
496
497
|
setCaret(event.target.selectionStart);
|
|
497
498
|
setSelected(0);
|
|
498
499
|
}, onSelect: event => setCaret(event.currentTarget.selectionStart), onKeyDown: onKeyDown, onPaste: onPaste, onFocus: () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SessionStore } from '@celljs/ta-client';
|
|
2
|
-
import type
|
|
2
|
+
import { type TaServer, type TaSlashCommand, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { type ComposerImage, type ComposerQueued } from '../util/composer.js';
|
|
5
5
|
import { type ComposerAction, type ComposerBoxHandle } from './composer-box.js';
|
|
@@ -41,6 +41,8 @@ export interface ComposerProps {
|
|
|
41
41
|
onStop?(): void;
|
|
42
42
|
/** A stop of the session's run pressed here ended (or failed): how long it took (useStopTimes). */
|
|
43
43
|
onStopTimed?(timing: StopTiming): void;
|
|
44
|
+
/** The user types (the box holds something and a key came), or no longer (it is empty, or sent). */
|
|
45
|
+
onTyping?(typing: boolean): void;
|
|
44
46
|
onError(error: unknown): void;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TA_OWNER, TaMessageAuthor } from '@celljs/ta-protocol';
|
|
1
2
|
import { Clock3, CornerDownRight, PenLine, X } from 'lucide-react';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { AssistantTaskUtil } from '../assistant/assistant-task-util.js';
|
|
@@ -5,8 +6,10 @@ import { useDevice } from '../device/device.js';
|
|
|
5
6
|
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
6
7
|
import { ComposerUtil } from '../util/composer.js';
|
|
7
8
|
import { ComposerBox } from './composer-box.js';
|
|
9
|
+
import { Face } from './face.js';
|
|
8
10
|
import { Icon } from './icon.js';
|
|
9
11
|
import { MessageOrigin, userWords } from './message-list.js';
|
|
12
|
+
import { MessagePeople } from './people.js';
|
|
10
13
|
import { StopClock } from './stop-times.js';
|
|
11
14
|
const FILE_LIMIT = 20;
|
|
12
15
|
const FILE_DELAY_MS = 120;
|
|
@@ -62,7 +65,7 @@ function useQueue(store, working) {
|
|
|
62
65
|
* and Alt+Enter queues a follow-up; Escape stops it.
|
|
63
66
|
*/
|
|
64
67
|
export const Composer = React.forwardRef(function Composer(props, ref) {
|
|
65
|
-
const { store, onSubmit, head, after, voiceSends, recentShots, talkPlace, onTalkSent, onListening, server, workspace, working, commands, cwd, actions, placeholder, above, onSending, onStop, onStopTimed, onError, } = props;
|
|
68
|
+
const { store, onSubmit, head, after, voiceSends, recentShots, talkPlace, onTalkSent, onListening, server, workspace, working, commands, cwd, actions, placeholder, above, onSending, onStop, onStopTimed, onTyping, onError, } = props;
|
|
66
69
|
// A finger: the keyboard opens on focus, over the conversation, and there are no keys to name.
|
|
67
70
|
const touch = useDevice(device => device.touch);
|
|
68
71
|
const t = useT();
|
|
@@ -102,6 +105,7 @@ export const Composer = React.forwardRef(function Composer(props, ref) {
|
|
|
102
105
|
const send = (message, images, followUp) => {
|
|
103
106
|
var _a;
|
|
104
107
|
onSending === null || onSending === void 0 ? void 0 : onSending();
|
|
108
|
+
onTyping === null || onTyping === void 0 ? void 0 : onTyping(false);
|
|
105
109
|
const prompt = { clientMessageId: crypto.randomUUID(), message, images: images.length ? images : undefined };
|
|
106
110
|
if (!store) {
|
|
107
111
|
return (_a = onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(message, prompt.images)) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
@@ -137,30 +141,38 @@ export const Composer = React.forwardRef(function Composer(props, ref) {
|
|
|
137
141
|
}, onError);
|
|
138
142
|
};
|
|
139
143
|
const waiting = ComposerUtil.queued(queue);
|
|
140
|
-
return (React.createElement(ComposerBox, { ref: box, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t(ComposerUtil.placeholderKey(working, touch)), working: working, onStop: stop, onSend: send, commands: listed, onMentionQuery: setQuery, mentions: files, mentionLabel: t('ta.composer.mentionFile'), images: true, recentShots: recentShots, actions: actions, head: head, after: after, voiceSends: voiceSends, talkPlace: talkPlace, onTalkSent: onTalkSent, onListening: onListening, autoFocus: !touch, cwd: cwd, onError: onError, above: React.createElement(React.Fragment, null,
|
|
144
|
+
return (React.createElement(ComposerBox, { ref: box, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t(ComposerUtil.placeholderKey(working, touch)), working: working, onStop: stop, onSend: send, commands: listed, onMentionQuery: setQuery, mentions: files, mentionLabel: t('ta.composer.mentionFile'), images: true, recentShots: recentShots, actions: actions, head: head, after: after, voiceSends: voiceSends, talkPlace: talkPlace, onTalkSent: onTalkSent, onListening: onListening, autoFocus: !touch, onTextChange: onTyping && (text => onTyping(!!text.trim())), cwd: cwd, onError: onError, above: React.createElement(React.Fragment, null,
|
|
141
145
|
above,
|
|
142
146
|
waiting.length > 0 && React.createElement(QueuedMessages, { waiting: waiting, onTakeBack: takeBack, onRemove: remove })) }));
|
|
143
147
|
});
|
|
144
148
|
/** What waits to be sent, tucked on top of the box: as the conversation will show it, the package that sent it apart. */
|
|
145
149
|
export function QueuedMessages({ waiting, onTakeBack, onRemove, }) {
|
|
146
150
|
const t = useT();
|
|
151
|
+
const { me, ownerName } = React.useContext(MessagePeople);
|
|
147
152
|
return (React.createElement("div", { className: "ta-queue", "aria-live": "polite" },
|
|
148
153
|
waiting.length > 1 && (React.createElement("div", { className: "ta-queue-head" },
|
|
149
154
|
React.createElement("span", null, t('ta.composer.queue.count', { count: waiting.length })),
|
|
150
155
|
React.createElement("button", { type: "button", className: "ta-queue-all", onClick: onTakeBack, title: t('ta.composer.queue.takeBackTitle') }, t('ta.composer.queue.takeBackAll')))),
|
|
151
156
|
waiting.map(entry => {
|
|
157
|
+
var _a, _b, _c;
|
|
152
158
|
const note = AssistantTaskUtil.noteOf(entry.text);
|
|
153
159
|
const shown = words(entry.text);
|
|
154
160
|
const text = note ? t('ta.task.ended', { title: note.title, status: t(`ta.task.${note.status}`) }) : shown.text || shown.copied;
|
|
155
161
|
const kind = t(entry.kind === 'steering' ? 'ta.composer.queue.steering' : 'ta.composer.queue.followUp');
|
|
162
|
+
// Another's waits as theirs: they take it back, or the owner of the Ta removes it (ta serve holds to it too).
|
|
163
|
+
const author = TaMessageAuthor.of(entry.text);
|
|
164
|
+
const mine = ((_a = author === null || author === void 0 ? void 0 : author.id) !== null && _a !== void 0 ? _a : TA_OWNER) === me;
|
|
156
165
|
return (React.createElement("div", { key: `${entry.kind}-${entry.index}-${entry.text}`, className: "ta-queue-row" },
|
|
157
166
|
React.createElement("span", { className: "ta-queue-kind", title: kind },
|
|
158
167
|
React.createElement(Icon, { icon: entry.kind === 'steering' ? CornerDownRight : Clock3, size: 13 }),
|
|
159
168
|
React.createElement("span", null, kind)),
|
|
169
|
+
!mine && (React.createElement("span", { className: "ta-origin" },
|
|
170
|
+
React.createElement(Face, { seed: (_b = author === null || author === void 0 ? void 0 : author.id) !== null && _b !== void 0 ? _b : TA_OWNER, size: 14, double: !author }),
|
|
171
|
+
React.createElement("span", { className: "ta-origin-name" }, (_c = author === null || author === void 0 ? void 0 : author.name) !== null && _c !== void 0 ? _c : (ownerName || t('ta.presence.owner'))))),
|
|
160
172
|
!note && React.createElement(MessageOrigin, { blocks: blocksOf(entry.text) }),
|
|
161
173
|
React.createElement("span", { className: "ta-ellipsis ta-queue-text", title: text }, text),
|
|
162
|
-
React.createElement("span", { className: "ta-queue-actions" },
|
|
163
|
-
!note && (React.createElement("button", { type: "button", className: "ta-icon-button", onClick: () => onRemove(entry, true), title: t('ta.composer.queue.editTitle'), "aria-label": t('ta.composer.queue.editTitle') },
|
|
174
|
+
React.createElement("span", { className: "ta-queue-actions", hidden: !mine && me !== TA_OWNER },
|
|
175
|
+
!note && mine && (React.createElement("button", { type: "button", className: "ta-icon-button", onClick: () => onRemove(entry, true), title: t('ta.composer.queue.editTitle'), "aria-label": t('ta.composer.queue.editTitle') },
|
|
164
176
|
React.createElement(Icon, { icon: PenLine, size: 13 }))),
|
|
165
177
|
React.createElement("button", { type: "button", className: "ta-icon-button", onClick: () => onRemove(entry, false), title: t('ta.composer.queue.remove'), "aria-label": t('ta.composer.queue.remove') },
|
|
166
178
|
React.createElement(Icon, { icon: X, size: 13 })))));
|
|
@@ -8,14 +8,26 @@ export interface FaceProps {
|
|
|
8
8
|
working?: boolean;
|
|
9
9
|
/** A dot at its corner: green online, grey not; none without. */
|
|
10
10
|
online?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The owner of this Ta: the close-up of its double, the dinosaur the user picked (as the account and the navigation
|
|
13
|
+
* show it), which changes with it; `face` and `seed` stand for it where the page cannot draw it.
|
|
14
|
+
*/
|
|
15
|
+
double?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Another Ta, as its double looks (TaRoomMember.look, TaFriend.look): the close-up of that dinosaur. One this page
|
|
18
|
+
* does not know is drawn by `face` and `seed`.
|
|
19
|
+
*/
|
|
20
|
+
look?: string;
|
|
11
21
|
}
|
|
12
22
|
/** One face; the eyes, cheeks and mouth are the same on every shape. */
|
|
13
|
-
export declare function Face(
|
|
23
|
+
export declare function Face(props: FaceProps): React.JSX.Element;
|
|
14
24
|
export interface GroupFaceProps {
|
|
15
25
|
/** Those of the group, the one in front first: their faces, or their ids (`seed` of {@link Face}). */
|
|
16
26
|
members: readonly {
|
|
17
27
|
face?: number;
|
|
18
28
|
seed?: string;
|
|
29
|
+
look?: string;
|
|
30
|
+
double?: boolean;
|
|
19
31
|
working?: boolean;
|
|
20
32
|
}[];
|
|
21
33
|
size: number;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { FaceUtil } from '@celljs/ta-relay/lib/common/relay-faces';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { DinoSpecies } from '../avatar/dino-species.js';
|
|
4
|
+
import { DinoFace } from './ta-avatar.js';
|
|
3
5
|
/*
|
|
4
6
|
* The faces of those who are not Ta (agents, the people of rooms), drawn from FaceUtil.art (ta-relay, which the page of
|
|
5
7
|
* web guests draws too), so that they are told apart at a glance; Ta itself keeps the dinosaur of the logo. The styles
|
|
@@ -16,7 +18,20 @@ function draw(node, key) {
|
|
|
16
18
|
return React.createElement(node.tag, { ...props, key }, ...((_a = node.children) !== null && _a !== void 0 ? _a : []).map((child, index) => draw(child, index)));
|
|
17
19
|
}
|
|
18
20
|
/** One face; the eyes, cheeks and mouth are the same on every shape. */
|
|
19
|
-
export function Face(
|
|
21
|
+
export function Face(props) {
|
|
22
|
+
if (props.double) {
|
|
23
|
+
return React.createElement(DoubleFace, { size: props.size, online: props.online });
|
|
24
|
+
}
|
|
25
|
+
const species = DinoSpecies.IDS.find(id => id === props.look);
|
|
26
|
+
return species ? React.createElement(DoubleFace, { species: species, size: props.size, online: props.online }) : React.createElement(ShapeFace, { ...props });
|
|
27
|
+
}
|
|
28
|
+
/** A Ta as its double: the close-up of the dinosaur, as the account shows it; this Ta's own without `species`. */
|
|
29
|
+
function DoubleFace({ species, size, online }) {
|
|
30
|
+
return (React.createElement("span", { className: "ta-face", style: { width: size, height: size }, "aria-hidden": "true" },
|
|
31
|
+
React.createElement(DinoFace, { species: species, size: size }),
|
|
32
|
+
online !== undefined && React.createElement("i", { className: `ta-face-dot${online ? ' ta-face-on' : ''}` })));
|
|
33
|
+
}
|
|
34
|
+
function ShapeFace({ face: given, seed = '', size, working, online }) {
|
|
20
35
|
const face = FaceUtil.pick(given, seed);
|
|
21
36
|
const art = React.useMemo(() => draw(FaceUtil.art(face)), [face]);
|
|
22
37
|
return (React.createElement("span", { className: `ta-face${working ? ' ta-face-working' : ''}`, style: { width: size, height: size }, "data-face": face, "aria-hidden": "true" },
|