@celljs/ta-web 4.34.0 → 4.36.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 +1 -1
- package/README.md +1 -1
- package/esm/browser/apps/app-icon.d.ts +23 -0
- package/esm/browser/apps/app-icon.js +98 -0
- package/esm/browser/apps/app-settings.d.ts +6 -0
- package/esm/browser/apps/app-settings.js +67 -0
- package/esm/browser/apps/app-window-util.d.ts +23 -0
- package/esm/browser/apps/app-window-util.js +27 -0
- package/esm/browser/apps/app-window.d.ts +9 -0
- package/esm/browser/apps/app-window.js +90 -0
- package/esm/browser/apps/web-apps.d.ts +29 -0
- package/esm/browser/apps/web-apps.js +57 -0
- package/esm/browser/assistant/assistant-thread.js +2 -2
- package/esm/browser/assistant/call-keeper.d.ts +2 -5
- package/esm/browser/assistant/call-keeper.js +7 -11
- package/esm/browser/assistant/mic-capture.d.ts +34 -0
- package/esm/browser/assistant/mic-capture.js +87 -0
- package/esm/browser/assistant/realtime-voice.d.ts +2 -2
- package/esm/browser/assistant/realtime-voice.js +6 -15
- package/esm/browser/components/access-settings.d.ts +6 -0
- package/esm/browser/components/access-settings.js +52 -0
- package/esm/browser/components/app-root.d.ts +6 -0
- package/esm/browser/components/app-root.js +34 -0
- package/esm/browser/components/app-view.d.ts +8 -2
- package/esm/browser/components/app-view.js +1 -25
- package/esm/browser/components/board.d.ts +2 -2
- package/esm/browser/components/board.js +2 -2
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/composer-box-hooks.d.ts +12 -0
- package/esm/browser/components/composer-box-hooks.js +12 -0
- package/esm/browser/components/composer-box-protocol.d.ts +12 -1
- package/esm/browser/components/composer-box.js +14 -11
- package/esm/browser/components/composer.js +69 -3
- package/esm/browser/components/extension-settings.d.ts +7 -0
- package/esm/browser/components/extension-settings.js +32 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/message-list.js +3 -3
- package/esm/browser/components/message-steps.js +3 -3
- package/esm/browser/components/phone-shell.d.ts +2 -2
- package/esm/browser/components/request-error.d.ts +9 -0
- package/esm/browser/components/request-error.js +21 -0
- package/esm/browser/components/settings-more.js +13 -24
- package/esm/browser/components/storage-settings.d.ts +17 -0
- package/esm/browser/components/storage-settings.js +145 -0
- package/esm/browser/device/screen-awake.d.ts +16 -0
- package/esm/browser/device/screen-awake.js +37 -0
- package/esm/browser/device/sheet-swipe.js +4 -0
- package/esm/browser/extension/icons.js +2 -1
- package/esm/browser/extension/web-access.d.ts +16 -0
- package/esm/browser/extension/web-access.js +75 -0
- package/esm/browser/extension/web-api-contributions.d.ts +6 -7
- package/esm/browser/extension/web-api-desktop.d.ts +23 -0
- package/esm/browser/extension/web-api-spec.d.ts +70 -0
- package/esm/browser/extension/web-api-spec.js +225 -0
- package/esm/browser/extension/web-api-targets.d.ts +11 -0
- package/esm/browser/extension/web-api-targets.js +2 -0
- package/esm/browser/extension/web-extension-api.d.ts +11 -1
- package/esm/browser/extension/web-extension-context.d.ts +3 -2
- package/esm/browser/extension/web-extension-context.js +22 -17
- package/esm/browser/extension/web-extension-run.d.ts +8 -1
- package/esm/browser/extension/web-extension-run.js +37 -0
- package/esm/browser/extension/web-extensions-running.d.ts +20 -1
- package/esm/browser/extension/web-extensions-running.js +107 -9
- package/esm/browser/extension/web-extensions.js +1 -0
- package/esm/browser/extension/web-pages.d.ts +5 -0
- package/esm/browser/extension/web-pages.js +3 -0
- package/esm/browser/game/game-control.d.ts +6 -0
- package/esm/browser/game/game-control.js +28 -0
- package/esm/browser/game/game-host.d.ts +9 -2
- package/esm/browser/game/game-host.js +5 -1
- package/esm/browser/game/game-protocol.d.ts +8 -0
- package/esm/browser/game/game-runner.d.ts +7 -1
- package/esm/browser/game/game-runner.js +24 -2
- package/esm/browser/game/game-target.d.ts +22 -0
- package/esm/browser/game/game-target.js +84 -0
- package/esm/browser/game/game-util.d.ts +2 -0
- package/esm/browser/game/game-util.js +2 -0
- package/esm/browser/game/game-view.d.ts +5 -2
- package/esm/browser/game/game-view.js +4 -4
- package/esm/browser/game/game3d-protocol.d.ts +3 -1
- package/esm/browser/game/game3d-runner.d.ts +6 -1
- package/esm/browser/game/game3d-runner.js +26 -2
- package/esm/browser/i18n/en/chat.d.ts +4 -0
- package/esm/browser/i18n/en/chat.js +4 -0
- package/esm/browser/i18n/en/common.d.ts +1 -0
- package/esm/browser/i18n/en/common.js +1 -0
- package/esm/browser/i18n/en/discover.d.ts +11 -0
- package/esm/browser/i18n/en/discover.js +11 -0
- package/esm/browser/i18n/en/settings.d.ts +43 -0
- package/esm/browser/i18n/en/settings.js +43 -0
- package/esm/browser/i18n/ja/chat.js +4 -0
- package/esm/browser/i18n/ja/common.js +1 -0
- package/esm/browser/i18n/ja/discover.js +11 -0
- package/esm/browser/i18n/ja/settings.js +43 -0
- package/esm/browser/i18n/locales.d.ts +60 -3
- package/esm/browser/i18n/messages.d.ts +59 -2
- package/esm/browser/i18n/zh/chat.js +4 -0
- package/esm/browser/i18n/zh/common.js +1 -0
- package/esm/browser/i18n/zh/discover.js +11 -0
- package/esm/browser/i18n/zh/settings.js +43 -0
- package/esm/browser/i18n/zh-tw/chat.js +4 -0
- package/esm/browser/i18n/zh-tw/common.js +1 -0
- package/esm/browser/i18n/zh-tw/discover.js +11 -0
- package/esm/browser/i18n/zh-tw/settings.js +43 -0
- package/esm/browser/index.d.ts +3 -0
- package/esm/browser/index.js +3 -0
- package/esm/browser/notices/notices.js +1 -0
- package/esm/browser/sandbox/channel/channel.d.ts +56 -0
- package/esm/browser/sandbox/channel/channel.js +124 -0
- package/esm/browser/sandbox/channel/codec.d.ts +80 -0
- package/esm/browser/sandbox/channel/codec.js +251 -0
- package/esm/browser/sandbox/hook-host.d.ts +23 -0
- package/esm/browser/sandbox/hook-host.js +61 -0
- package/esm/browser/sandbox/isolated-host.d.ts +105 -0
- package/esm/browser/sandbox/isolated-host.js +395 -0
- package/esm/browser/sandbox/remote/remote-copy.d.ts +57 -0
- package/esm/browser/sandbox/remote/remote-copy.js +318 -0
- package/esm/browser/sandbox/remote/remote-mirror.d.ts +61 -0
- package/esm/browser/sandbox/remote/remote-mirror.js +341 -0
- package/esm/browser/sandbox/remote/remote-protocol.d.ts +79 -0
- package/esm/browser/sandbox/remote/remote-protocol.js +54 -0
- package/esm/browser/sandbox/remote/remote-styles.d.ts +10 -0
- package/esm/browser/sandbox/remote/remote-styles.js +113 -0
- package/esm/browser/sandbox/remote-root.d.ts +11 -0
- package/esm/browser/sandbox/remote-root.js +81 -0
- package/esm/browser/sandbox/runtime/frame-api.d.ts +28 -0
- package/esm/browser/sandbox/runtime/frame-api.js +147 -0
- package/esm/browser/sandbox/runtime/frame-features.d.ts +6 -0
- package/esm/browser/sandbox/runtime/frame-features.js +50 -0
- package/esm/browser/sandbox/runtime/frame-parts.d.ts +36 -0
- package/esm/browser/sandbox/runtime/frame-parts.js +69 -0
- package/esm/browser/sandbox/runtime/frame-roots.d.ts +26 -0
- package/esm/browser/sandbox/runtime/frame-roots.js +76 -0
- package/esm/browser/sandbox/runtime/frame-store.d.ts +9 -0
- package/esm/browser/sandbox/runtime/frame-store.js +18 -0
- package/esm/browser/sandbox/runtime/sandbox-runtime.d.ts +11 -0
- package/esm/browser/sandbox/runtime/sandbox-runtime.js +45 -0
- package/esm/browser/sandbox/sandbox-features.d.ts +25 -0
- package/esm/browser/sandbox/sandbox-features.js +32 -0
- package/esm/browser/sandbox/sandbox-frame.d.ts +21 -0
- package/esm/browser/sandbox/sandbox-frame.js +75 -0
- package/esm/browser/sandbox/sandbox-guards.d.ts +19 -0
- package/esm/browser/sandbox/sandbox-guards.js +74 -0
- package/esm/browser/sandbox/sandbox-protocol.d.ts +57 -0
- package/esm/browser/sandbox/sandbox-protocol.js +49 -0
- package/esm/browser/sandbox/sandbox-runtime-code.d.ts +1 -0
- package/esm/browser/sandbox/sandbox-runtime-code.js +3 -0
- package/esm/browser/sandbox/web-sandbox.d.ts +28 -0
- package/esm/browser/sandbox/web-sandbox.js +44 -0
- package/esm/browser/settings/agent-settings.js +5 -1
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -0
- package/esm/browser/style/surfaces.d.ts +1 -1
- package/esm/browser/style/surfaces.js +4 -0
- package/esm/browser/style/tints.d.ts +2 -0
- package/esm/browser/style/tints.js +10 -0
- package/esm/browser/targets/targets-protocol.d.ts +54 -0
- package/esm/browser/targets/targets-protocol.js +34 -0
- package/esm/browser/targets/targets.d.ts +13 -0
- package/esm/browser/targets/targets.js +64 -0
- package/esm/browser/util/composer.d.ts +4 -2
- package/esm/browser/util/composer.js +7 -1
- package/esm/browser/util/desktop.d.ts +31 -1
- package/esm/browser/util/desktop.js +20 -0
- package/esm/browser/util/message.d.ts +6 -0
- package/esm/browser/util/message.js +21 -0
- package/esm/browser/util/process.d.ts +1 -0
- package/esm/browser/util/process.js +6 -1
- package/esm/browser/util/progress.d.ts +2 -1
- package/esm/browser/util/progress.js +2 -11
- package/esm/browser/view.js +1 -1
- package/lib/browser/apps/app-icon.d.ts +24 -0
- package/lib/browser/apps/app-icon.js +134 -0
- package/lib/browser/apps/app-settings.d.ts +7 -0
- package/lib/browser/apps/app-settings.js +103 -0
- package/lib/browser/apps/app-window-util.d.ts +24 -0
- package/lib/browser/apps/app-window-util.js +30 -0
- package/lib/browser/apps/app-window.d.ts +10 -0
- package/lib/browser/apps/app-window.js +126 -0
- package/lib/browser/apps/web-apps.d.ts +30 -0
- package/lib/browser/apps/web-apps.js +61 -0
- package/lib/browser/assistant/assistant-thread.js +2 -2
- package/lib/browser/assistant/call-keeper.d.ts +2 -5
- package/lib/browser/assistant/call-keeper.js +6 -10
- package/lib/browser/assistant/mic-capture.d.ts +35 -0
- package/lib/browser/assistant/mic-capture.js +91 -0
- package/lib/browser/assistant/realtime-voice.d.ts +2 -2
- package/lib/browser/assistant/realtime-voice.js +6 -15
- package/lib/browser/components/access-settings.d.ts +7 -0
- package/lib/browser/components/access-settings.js +88 -0
- package/lib/browser/components/app-root.d.ts +7 -0
- package/lib/browser/components/app-root.js +70 -0
- package/lib/browser/components/app-view.d.ts +8 -2
- package/lib/browser/components/app-view.js +1 -25
- package/lib/browser/components/board.d.ts +2 -2
- package/lib/browser/components/board.js +2 -2
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/composer-box-hooks.d.ts +12 -0
- package/lib/browser/components/composer-box-hooks.js +13 -0
- package/lib/browser/components/composer-box-protocol.d.ts +12 -1
- package/lib/browser/components/composer-box.js +13 -10
- package/lib/browser/components/composer.js +69 -3
- package/lib/browser/components/extension-settings.d.ts +8 -0
- package/lib/browser/components/extension-settings.js +69 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/message-list.js +3 -3
- package/lib/browser/components/message-steps.js +3 -3
- package/lib/browser/components/phone-shell.d.ts +2 -2
- package/lib/browser/components/request-error.d.ts +10 -0
- package/lib/browser/components/request-error.js +57 -0
- package/lib/browser/components/settings-more.js +12 -23
- package/lib/browser/components/storage-settings.d.ts +18 -0
- package/lib/browser/components/storage-settings.js +182 -0
- package/lib/browser/device/screen-awake.d.ts +16 -0
- package/lib/browser/device/screen-awake.js +39 -1
- package/lib/browser/device/sheet-swipe.js +4 -0
- package/lib/browser/extension/icons.js +1 -0
- package/lib/browser/extension/web-access.d.ts +17 -0
- package/lib/browser/extension/web-access.js +78 -0
- package/lib/browser/extension/web-api-contributions.d.ts +6 -7
- package/lib/browser/extension/web-api-desktop.d.ts +23 -0
- package/lib/browser/extension/web-api-spec.d.ts +71 -0
- package/lib/browser/extension/web-api-spec.js +228 -0
- package/lib/browser/extension/web-api-targets.d.ts +12 -0
- package/lib/browser/extension/web-api-targets.js +3 -0
- package/lib/browser/extension/web-extension-api.d.ts +11 -1
- package/lib/browser/extension/web-extension-context.d.ts +3 -2
- package/lib/browser/extension/web-extension-context.js +22 -17
- package/lib/browser/extension/web-extension-run.d.ts +8 -1
- package/lib/browser/extension/web-extension-run.js +37 -0
- package/lib/browser/extension/web-extensions-running.d.ts +20 -1
- package/lib/browser/extension/web-extensions-running.js +107 -9
- package/lib/browser/extension/web-extensions.js +1 -0
- package/lib/browser/extension/web-pages.d.ts +5 -0
- package/lib/browser/extension/web-pages.js +3 -0
- package/lib/browser/game/game-control.d.ts +6 -0
- package/lib/browser/game/game-control.js +28 -0
- package/lib/browser/game/game-host.d.ts +9 -2
- package/lib/browser/game/game-host.js +5 -1
- package/lib/browser/game/game-protocol.d.ts +8 -0
- package/lib/browser/game/game-runner.d.ts +7 -1
- package/lib/browser/game/game-runner.js +24 -2
- package/lib/browser/game/game-target.d.ts +23 -0
- package/lib/browser/game/game-target.js +87 -0
- package/lib/browser/game/game-util.d.ts +2 -0
- package/lib/browser/game/game-util.js +2 -0
- package/lib/browser/game/game-view.d.ts +5 -2
- package/lib/browser/game/game-view.js +4 -4
- package/lib/browser/game/game3d-protocol.d.ts +3 -1
- package/lib/browser/game/game3d-runner.d.ts +6 -1
- package/lib/browser/game/game3d-runner.js +26 -2
- package/lib/browser/i18n/en/chat.d.ts +4 -0
- package/lib/browser/i18n/en/chat.js +4 -0
- package/lib/browser/i18n/en/common.d.ts +1 -0
- package/lib/browser/i18n/en/common.js +1 -0
- package/lib/browser/i18n/en/discover.d.ts +11 -0
- package/lib/browser/i18n/en/discover.js +11 -0
- package/lib/browser/i18n/en/settings.d.ts +43 -0
- package/lib/browser/i18n/en/settings.js +43 -0
- package/lib/browser/i18n/ja/chat.js +4 -0
- package/lib/browser/i18n/ja/common.js +1 -0
- package/lib/browser/i18n/ja/discover.js +11 -0
- package/lib/browser/i18n/ja/settings.js +43 -0
- package/lib/browser/i18n/locales.d.ts +60 -3
- package/lib/browser/i18n/messages.d.ts +59 -2
- package/lib/browser/i18n/zh/chat.js +4 -0
- package/lib/browser/i18n/zh/common.js +1 -0
- package/lib/browser/i18n/zh/discover.js +11 -0
- package/lib/browser/i18n/zh/settings.js +43 -0
- package/lib/browser/i18n/zh-tw/chat.js +4 -0
- package/lib/browser/i18n/zh-tw/common.js +1 -0
- package/lib/browser/i18n/zh-tw/discover.js +11 -0
- package/lib/browser/i18n/zh-tw/settings.js +43 -0
- package/lib/browser/index.d.ts +3 -0
- package/lib/browser/index.js +3 -0
- package/lib/browser/notices/notices.js +1 -0
- package/lib/browser/sandbox/channel/channel.d.ts +57 -0
- package/lib/browser/sandbox/channel/channel.js +128 -0
- package/lib/browser/sandbox/channel/codec.d.ts +81 -0
- package/lib/browser/sandbox/channel/codec.js +256 -0
- package/lib/browser/sandbox/hook-host.d.ts +24 -0
- package/lib/browser/sandbox/hook-host.js +98 -0
- package/lib/browser/sandbox/isolated-host.d.ts +106 -0
- package/lib/browser/sandbox/isolated-host.js +432 -0
- package/lib/browser/sandbox/remote/remote-copy.d.ts +58 -0
- package/lib/browser/sandbox/remote/remote-copy.js +322 -0
- package/lib/browser/sandbox/remote/remote-mirror.d.ts +62 -0
- package/lib/browser/sandbox/remote/remote-mirror.js +345 -0
- package/lib/browser/sandbox/remote/remote-protocol.d.ts +80 -0
- package/lib/browser/sandbox/remote/remote-protocol.js +57 -0
- package/lib/browser/sandbox/remote/remote-styles.d.ts +11 -0
- package/lib/browser/sandbox/remote/remote-styles.js +116 -0
- package/lib/browser/sandbox/remote-root.d.ts +12 -0
- package/lib/browser/sandbox/remote-root.js +117 -0
- package/lib/browser/sandbox/runtime/frame-api.d.ts +29 -0
- package/lib/browser/sandbox/runtime/frame-api.js +183 -0
- package/lib/browser/sandbox/runtime/frame-features.d.ts +7 -0
- package/lib/browser/sandbox/runtime/frame-features.js +53 -0
- package/lib/browser/sandbox/runtime/frame-parts.d.ts +37 -0
- package/lib/browser/sandbox/runtime/frame-parts.js +106 -0
- package/lib/browser/sandbox/runtime/frame-roots.d.ts +27 -0
- package/lib/browser/sandbox/runtime/frame-roots.js +113 -0
- package/lib/browser/sandbox/runtime/frame-store.d.ts +10 -0
- package/lib/browser/sandbox/runtime/frame-store.js +22 -0
- package/lib/browser/sandbox/runtime/sandbox-runtime.d.ts +12 -0
- package/lib/browser/sandbox/runtime/sandbox-runtime.js +47 -0
- package/lib/browser/sandbox/sandbox-features.d.ts +26 -0
- package/lib/browser/sandbox/sandbox-features.js +35 -0
- package/lib/browser/sandbox/sandbox-frame.d.ts +22 -0
- package/lib/browser/sandbox/sandbox-frame.js +79 -0
- package/lib/browser/sandbox/sandbox-guards.d.ts +20 -0
- package/lib/browser/sandbox/sandbox-guards.js +77 -0
- package/lib/browser/sandbox/sandbox-protocol.d.ts +58 -0
- package/lib/browser/sandbox/sandbox-protocol.js +52 -0
- package/lib/browser/sandbox/sandbox-runtime-code.d.ts +2 -0
- package/lib/browser/sandbox/sandbox-runtime-code.js +6 -0
- package/lib/browser/sandbox/web-sandbox.d.ts +29 -0
- package/lib/browser/sandbox/web-sandbox.js +47 -0
- package/lib/browser/settings/agent-settings.js +5 -1
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -0
- package/lib/browser/style/surfaces.d.ts +1 -1
- package/lib/browser/style/surfaces.js +4 -0
- package/lib/browser/style/tints.d.ts +2 -0
- package/lib/browser/style/tints.js +10 -0
- package/lib/browser/targets/targets-protocol.d.ts +55 -0
- package/lib/browser/targets/targets-protocol.js +37 -0
- package/lib/browser/targets/targets.d.ts +14 -0
- package/lib/browser/targets/targets.js +67 -0
- package/lib/browser/util/composer.d.ts +4 -2
- package/lib/browser/util/composer.js +7 -1
- package/lib/browser/util/desktop.d.ts +31 -1
- package/lib/browser/util/desktop.js +20 -0
- package/lib/browser/util/message.d.ts +6 -0
- package/lib/browser/util/message.js +21 -0
- package/lib/browser/util/process.d.ts +1 -0
- package/lib/browser/util/process.js +6 -1
- package/lib/browser/util/progress.d.ts +2 -1
- package/lib/browser/util/progress.js +2 -11
- package/lib/browser/view.js +2 -2
- package/package.json +8 -8
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; a page is under Discover until the user pins it, in the group of its `group`: `people`, `work`, `share`, `tools`, `play`, `more` by default, or `me`, an entry of Me; `navigation: false` keeps a page only shown by something else out of the navigation and Discover, and a panel out of the tools the workbench's + lists), `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 (the replies on the double's home too, a conversation like any other; 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; a row with `gathered` stands for several things the user does themselves, as the double's row of the conversations going on, and the lists count what `gathered` counts, not the row), `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. Each is a part of the screen (`game-<n>`) that Ta plays for the user: `app_do` taps, moves the pointer, presses a key or holds on its canvas; under its `title`, else the title of the package, and with its score and whether its round is over once the game sets `score` and `over` in its registry, or returns them from `state()` of the loop of `ui.Game3D`), `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.showChats` (shows the list of chats, on a phone its tab; with `busy` only the conversations going on, under a chip Going on that clears it), `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; `transcribe` writes down what is said until stopped, as a meeting: through the Ta service with the service of Settings → Voice when one is chosen, else with the recognizer of the device, listening again as a stretch of speech ends; older Ta apps have none), 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.EditorActions` (the tools of a tab, a few icon buttons and a short note, drawn in the head of the workbench beside the tabs, so that no row over the tab names the file again; `tooltip` of `openEditor` is what its tab says under a pointer, such as the path of a file), `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; given a `folder`, those of the same folder fold into one row of the list of conversations that opens a list of their own, closed ones of the extension's group too, as the runs of scheduled tasks, pinned to the top the first time it is there), `registerHomeItems` / `ui.useHomeItems` (rows of the double's list, pinned to the top the first time they are there, for what the user looks at each day, such as a daily brief; given a `sessionFile` the conversation it stands for is not listed again), `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), `registerPartners` (the agents, friends and group chats an extension keeps: the page lists them by kind on the page of the partners, and what is said with each among the conversations of the double's list; `ui.openPartner(id, kind?)` opens one of any extension as its row does, `ui.startGroup(partner?)` starts a chat as the + of the partners does), `registerRoomAddon` / `ui.useRoomAddons` (apps of group chats: a tile among the apps of a room, a line above its chat, a page pushed in its panel), `registerChatTag` (a small label after the name of a conversation, as Work on a directory marked so), `registerFileMenu` / `ui.fileMenu` (a section of the extension's own in the menu of a file or a folder of a list of files), `registerCallPartner` / `registerCallMouth` / `registerCallMoves` (what answers in calls in place of the conversation called, the mouth and the moves of the person of video calls), `spoken` of `registerCodeRenderer` (what of such a block is said aloud in a call or a reply read out), `ui.openHome` / `ui.useHomeShown` (open a row of the double's home as its list does, and know whose page is in front), `ui.addToComposer` (a quote or pictures into the box of the conversation in front), `ui.ShareSheet` (the one sheet everything shared goes out from, never a dialog of its own; `ShareSheetCompat` of ta-web for Ta apps older than it), `ui.Conversation` (a conversation to read, drawn as the page's with the cards of extensions), `ui.ChatImages` (the pictures of a message of a chat), `ui.TaskIcon` (the face of a task), `ui.useBackLayer` (what an extension opens over the page closes with the back of the system), `ui.Loading` (what shows while something is on its way; `ui.Skeleton` its old name), `screenShare` / `onScreenShareEvent` (desktops of other computers), and page services: `server` (session, pi's RPC commands), `workspace` (files and commands in directory), `terminals` (terminals), `packages` (packages), and `rooms`, group chats 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; a page is under Discover until the user pins it, in the group of its `group`: `people`, `work`, `share`, `tools`, `play`, `more` by default, or `me`, an entry of Me; `navigation: false` keeps a page only shown by something else out of the navigation and Discover, and a panel out of the tools the workbench's + lists), `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 (the replies on the double's home too, a conversation like any other; 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; a row with `gathered` stands for several things the user does themselves, as the double's row of the conversations going on, and the lists count what `gathered` counts, not the row), `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. Each is a part of the screen (`game-<n>`) that Ta plays for the user: `app_do` taps, moves the pointer, presses a key or holds on its canvas; under its `title`, else the title of the package, and with its score and whether its round is over once the game sets `score` and `over` in its registry, or returns them from `state()` of the loop of `ui.Game3D`), `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.showChats` (shows the list of chats, on a phone its tab; with `busy` only the conversations going on, under a chip Going on that clears it), `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; `transcribe` writes down what is said until stopped, as a meeting: through the Ta service with the service of Settings → Voice when one is chosen, else with the recognizer of the device, listening again as a stretch of speech ends; older Ta apps have none; it ends as the extension stops), `ui.keepAwake` (the screen kept on till the function it returns is called or the extension stops, as while a meeting is written down; older Ta apps have none), 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.EditorActions` (the tools of a tab, a few icon buttons and a short note, drawn in the head of the workbench beside the tabs, so that no row over the tab names the file again; `tooltip` of `openEditor` is what its tab says under a pointer, such as the path of a file), `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; given a `folder`, those of the same folder fold into one row of the list of conversations that opens a list of their own, closed ones of the extension's group too, as the runs of scheduled tasks, pinned to the top the first time it is there), `registerHomeItems` / `ui.useHomeItems` (rows of the double's list, pinned to the top the first time they are there, for what the user looks at each day, such as a daily brief; given a `sessionFile` the conversation it stands for is not listed again), `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), `registerPartners` (the agents, friends and group chats an extension keeps: the page lists them by kind on the page of the partners, and what is said with each among the conversations of the double's list; `ui.openPartner(id, kind?)` opens one of any extension as its row does, `ui.startGroup(partner?)` starts a chat as the + of the partners does), `registerRoomAddon` / `ui.useRoomAddons` (apps of group chats: a tile among the apps of a room, a line above its chat, a page pushed in its panel), `registerChatTag` (a small label after the name of a conversation, as Work on a directory marked so; `open` shows what the tag on top of a conversation means and how to change it once tapped), `registerFileMenu` / `ui.fileMenu` (a section of the extension's own in the menu of a file or a folder of a list of files), `registerCallPartner` / `registerCallMouth` / `registerCallMoves` (what answers in calls in place of the conversation called, the mouth and the moves of the person of video calls), `spoken` of `registerCodeRenderer` (what of such a block is said aloud in a call or a reply read out), `ui.openHome` / `ui.useHomeShown` (open a row of the double's home as its list does, and know whose page is in front), `ui.addToComposer` (a quote or pictures into the box of the conversation in front), `ui.ShareSheet` (the one sheet everything shared goes out from, never a dialog of its own; `ShareSheetCompat` of ta-web for Ta apps older than it), `ui.Conversation` (a conversation to read, drawn as the page's with the cards of extensions), `ui.ChatImages` (the pictures of a message of a chat), `ui.TaskIcon` (the face of a task), `ui.useBackLayer` (what an extension opens over the page closes with the back of the system), `ui.Loading` (what shows while something is on its way; `ui.Skeleton` its old name), `screenShare` / `onScreenShareEvent` (desktops of other computers), and page services: `server` (session, pi's RPC commands), `workspace` (files and commands in directory), `terminals` (terminals), `packages` (packages), and `rooms`, group chats 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
|
- **Ta works an extension's page for the user**: `ui.useScreenPart({ id, title, state?, items?, actions?, scroll?, floats? })` says what a part of the page is, its rows and what it does, for Ta's `app_look` / `app_do` to read and work it as the user does; mark the elements `data-ta-part`, `data-ta-item`, `data-ta-action`. A part that floats over every page (as Ta's own call bar, there on any page while a call goes on) says `floats: true`: it is listed first, and never taken for what the page scrolls. What scrolls under a part's mark Ta scrolls too (`app_do` with `scroll`: a screen down or up, to the top or the bottom, or a row into sight), and `app_look` lists only the rows in sight and says where it is (an item outside what scrolls, a dialog over it, says `fixed: true` and is always listed); a list that loads as it scrolls says at which end more comes with `scroll.more()` and that it loads with `scroll.loading()`. `ui.screen.scroll(part, to)` / `ui.screen.pageScroll()` do the same.
|
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` 做;带 `gathered` 的一行代表多件用户自己在做的事,如分身任务里的"进行中的对话",列表按 `gathered` 里各状态的个数计数,不把这一行当成一个任务)、`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。每个游戏都是屏幕上的一个部分(`game-<n>`),Ta 能替用户玩:`app_do` 在画布上点一下、移动指针、按键或按住;名字是 `title`,没有时用包的标题;游戏在 registry 里设了 `score` 和 `over`(`ui.Game3D` 由循环的 `state()` 返回)时,Ta 看得到分数和是否结束)、`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.showChats`(打开对话列表,手机上是"对话"标签;`busy` 时只列进行中的对话,顶部一个可清除的"进行中"标签)、`ui.Composer` / `ui.Markdown`(和对话一样的输入框与 Markdown,麦克风和按住说话也一样;输入框的 `commands` 让 `/` 列出在 `cwd` 新开对话时会有的命令,`voiceSends`、`onTalkSent`、`onListening`、`working` / `onStop`、`after` 和分身的输入框一样:听到的话直接发出、知道哪句是说的以便朗读回答、正在听、正在回答时发送键变成停止、右侧放自己的按钮)、`ui.HoldToTalk`(按住说话的按钮,和输入框的“按住 说话”条一样:页面变暗、用页面的识别器听,可滑到“取消”“编辑”,松手交出文字;页面不能识别语音时不显示)、`ui.voice`(`canListen` / `canSpeak` / `speak` / `hush`:用设置里的声音朗读;`transcribe` 连续听写直到停下,如一场会议:选了 设置 → 语音 的服务就由 Ta 服务转写,否则用本机的识别器,一段话说完接着听,旧版 App 没有它)、视图的 `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.EditorActions`(标签自己的工具:几个图标按钮和一句短说明,显示在工作台顶栏、标签旁边,标签内容上方不再单独占一行重复文件名;`openEditor` 的 `tooltip` 是鼠标停在标签上时的说明,如文件路径)、`ui.DiffEditor`(Monaco 差异编辑器,并排或内联,可编辑右侧)、`ui.confirm` 的 `confirmLabel` / `danger`、视图的 `head`(自己的顶栏)、`ui.input` / `ui.editor`(向用户要一行或多行文字,取消时为 `undefined`)、页面的 `menu`(侧栏列出该页面时悬浮显示的 … 菜单)与 `pages`(侧栏列出的页面,导航栏不再单列)、页面的 `group`(页面默认收在"发现"、用户固定后才进导航栏,`group` 是它在"发现"里的分组:`people`、`work`、`share`、`tools`、`play`,默认 `more`;`me` 放进"我")与 `navigation: false`(只由别处打开的页面:不进导航栏和"发现";工作台工具则不出现在 + 列表里)、`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`(扩展自己的、不是智能体的对话(如它写的简报、它问的问题)在列表和通知里的图标,代替目录的字母;给了 `folder` 时,同一个 `folder` 的对话在对话列表里收成一行,点开是它们自己的列表,扩展分组里已关闭的对话也列在那里,如定时任务的运行;第一次出现时默认置顶)、`registerHomeItems` / `ui.useHomeItems`(分身对话列表里的行,放用户每天要看的东西,如每日简报;第一次出现时默认置顶,用户可取消;带 `sessionFile` 时它代表的对话不再单独列出)、`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 时先显示新状态,失败再退回)、`registerPartners`(扩展管理的智能体、好友、群聊:页面在伙伴页按类列出,和它们说的话进分身的对话列表;`ui.openPartner(id, kind?)` 像点那一行一样打开任意扩展的伙伴,`ui.startGroup(partner?)` 像伙伴页的 + 一样发起聊天)、`registerRoomAddon` / `ui.useRoomAddons`(群聊里的应用:房间应用区的方块、聊天上方的一行、推入房间面板的页面)、`registerChatTag`(对话名字后的小标签,如标了"工作"
|
|
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` 做;带 `gathered` 的一行代表多件用户自己在做的事,如分身任务里的"进行中的对话",列表按 `gathered` 里各状态的个数计数,不把这一行当成一个任务)、`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。每个游戏都是屏幕上的一个部分(`game-<n>`),Ta 能替用户玩:`app_do` 在画布上点一下、移动指针、按键或按住;名字是 `title`,没有时用包的标题;游戏在 registry 里设了 `score` 和 `over`(`ui.Game3D` 由循环的 `state()` 返回)时,Ta 看得到分数和是否结束)、`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.showChats`(打开对话列表,手机上是"对话"标签;`busy` 时只列进行中的对话,顶部一个可清除的"进行中"标签)、`ui.Composer` / `ui.Markdown`(和对话一样的输入框与 Markdown,麦克风和按住说话也一样;输入框的 `commands` 让 `/` 列出在 `cwd` 新开对话时会有的命令,`voiceSends`、`onTalkSent`、`onListening`、`working` / `onStop`、`after` 和分身的输入框一样:听到的话直接发出、知道哪句是说的以便朗读回答、正在听、正在回答时发送键变成停止、右侧放自己的按钮)、`ui.HoldToTalk`(按住说话的按钮,和输入框的“按住 说话”条一样:页面变暗、用页面的识别器听,可滑到“取消”“编辑”,松手交出文字;页面不能识别语音时不显示)、`ui.voice`(`canListen` / `canSpeak` / `speak` / `hush`:用设置里的声音朗读;`transcribe` 连续听写直到停下,如一场会议:选了 设置 → 语音 的服务就由 Ta 服务转写,否则用本机的识别器,一段话说完接着听,旧版 App 没有它;扩展停止时随之结束)、`ui.keepAwake`(屏幕常亮,直到调用它返回的函数或扩展停止,如会议记录时;旧版 App 没有它)、视图的 `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.EditorActions`(标签自己的工具:几个图标按钮和一句短说明,显示在工作台顶栏、标签旁边,标签内容上方不再单独占一行重复文件名;`openEditor` 的 `tooltip` 是鼠标停在标签上时的说明,如文件路径)、`ui.DiffEditor`(Monaco 差异编辑器,并排或内联,可编辑右侧)、`ui.confirm` 的 `confirmLabel` / `danger`、视图的 `head`(自己的顶栏)、`ui.input` / `ui.editor`(向用户要一行或多行文字,取消时为 `undefined`)、页面的 `menu`(侧栏列出该页面时悬浮显示的 … 菜单)与 `pages`(侧栏列出的页面,导航栏不再单列)、页面的 `group`(页面默认收在"发现"、用户固定后才进导航栏,`group` 是它在"发现"里的分组:`people`、`work`、`share`、`tools`、`play`,默认 `more`;`me` 放进"我")与 `navigation: false`(只由别处打开的页面:不进导航栏和"发现";工作台工具则不出现在 + 列表里)、`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`(扩展自己的、不是智能体的对话(如它写的简报、它问的问题)在列表和通知里的图标,代替目录的字母;给了 `folder` 时,同一个 `folder` 的对话在对话列表里收成一行,点开是它们自己的列表,扩展分组里已关闭的对话也列在那里,如定时任务的运行;第一次出现时默认置顶)、`registerHomeItems` / `ui.useHomeItems`(分身对话列表里的行,放用户每天要看的东西,如每日简报;第一次出现时默认置顶,用户可取消;带 `sessionFile` 时它代表的对话不再单独列出)、`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 时先显示新状态,失败再退回)、`registerPartners`(扩展管理的智能体、好友、群聊:页面在伙伴页按类列出,和它们说的话进分身的对话列表;`ui.openPartner(id, kind?)` 像点那一行一样打开任意扩展的伙伴,`ui.startGroup(partner?)` 像伙伴页的 + 一样发起聊天)、`registerRoomAddon` / `ui.useRoomAddons`(群聊里的应用:房间应用区的方块、聊天上方的一行、推入房间面板的页面)、`registerChatTag`(对话名字后的小标签,如标了"工作"的目录;`open` 在点对话顶部的标签时说明它的意思和怎么改)、`registerFileMenu` / `ui.fileMenu`(文件列表里文件或文件夹菜单中扩展自己的一组条目)、`registerCallPartner` / `registerCallMouth` / `registerCallMoves`(通话里代替被呼叫的对话回答、视频通话人物的口型和动作)、`registerCodeRenderer` 的 `spoken`(通话或朗读时这种代码块念出来的话)、`ui.openHome` / `ui.useHomeShown`(像分身列表一样打开首页的一行、知道哪一行的页面在前面)、`ui.addToComposer`(把引用或图片放进前面那个对话的输入框)、`ui.ShareSheet`(所有分享都从这一张面板发出,不自己画弹窗;旧版 App 用 ta-web 的 `ShareSheetCompat`)、`ui.Conversation`(只读地画一段对话,和页面一样画出扩展的卡片)、`ui.ChatImages`(聊天消息里的图片)、`ui.TaskIcon`(任务的头像)、`ui.useBackLayer`(扩展盖在页面上的东西由系统返回关闭)、`ui.Loading`(加载中,旧名 `ui.Skeleton`)、`screenShare` / `onScreenShareEvent`(远程桌面),以及页面的 `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
|
- **让 Ta 替你操作扩展页**:`ui.useScreenPart({ id, title, state?, items?, actions?, scroll?, floats? })` 说明页面的一块是什么、有哪些行、能做什么,Ta 的 `app_look` / `app_do` 照用户的方式读它、操作它;元素标上 `data-ta-part`、`data-ta-item`、`data-ta-action`。浮在所有页面之上的一块(比如 Ta 自己的通话条,通话中在哪一页都在)写 `floats: true`:它排在最前面,也不会被当成页面的滚动区。标了 `data-ta-part` 的那块里能滚动的区域,Ta 也能滚(`app_do` 的 `scroll`:向下、向上一屏,到顶、到底,或滚到某一行),`app_look` 只列看得见的行并说明位置(不在滚动区里的条目,如盖在上面的对话框,标 `fixed: true`,总会列出);边滚边加载的列表用 `scroll.more()` 说明更多内容在哪一头、`scroll.loading()` 说明正在加载。`ui.screen.scroll(part, to)` / `ui.screen.pageScroll()` 是同一套能力。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WebIcon } from '../extension/web-extension-api.js';
|
|
2
|
+
/** The colours of the icon of an app, in CSS: the tile of the launcher in the light theme, a little deeper at its foot. */
|
|
3
|
+
export interface AppIconColors {
|
|
4
|
+
top: string;
|
|
5
|
+
bottom: string;
|
|
6
|
+
ink: string;
|
|
7
|
+
edge: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The icon of a page installed as an app (docs/design/ta-install-as-app.md): its tile of the launcher (the glyph of the
|
|
11
|
+
* page in its tint, TintUtil) on the grid of the icons of macOS, a rounded square of 824 in 1024 with room for its shadow,
|
|
12
|
+
* which reads as well in the Start menu and the menus of Linux.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace AppIcon {
|
|
15
|
+
const SIZE = 1024;
|
|
16
|
+
/** The most an ICO of Windows holds. */
|
|
17
|
+
const SMALL = 256;
|
|
18
|
+
function colors(tint: number): AppIconColors;
|
|
19
|
+
/** The glyph in an SVG of its own, its strokes in `ink`: drawn by React in a detached element, as the page draws it. */
|
|
20
|
+
function svg(Glyph: WebIcon, ink: string, size: number): string | undefined;
|
|
21
|
+
/** The icon as a PNG of `size` pixels; `fallback` drawn when the page's own glyph draws nothing (one of a sandbox). */
|
|
22
|
+
function draw(Glyph: WebIcon, fallback: WebIcon, tint: number, size?: number): Promise<Uint8Array>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { flushSync } from 'react-dom';
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
|
+
import { TintUtil } from '../style/tints.js';
|
|
5
|
+
/**
|
|
6
|
+
* The icon of a page installed as an app (docs/design/ta-install-as-app.md): its tile of the launcher (the glyph of the
|
|
7
|
+
* page in its tint, TintUtil) on the grid of the icons of macOS, a rounded square of 824 in 1024 with room for its shadow,
|
|
8
|
+
* which reads as well in the Start menu and the menus of Linux.
|
|
9
|
+
*/
|
|
10
|
+
export var AppIcon;
|
|
11
|
+
(function (AppIcon) {
|
|
12
|
+
AppIcon.SIZE = 1024;
|
|
13
|
+
/** The most an ICO of Windows holds. */
|
|
14
|
+
AppIcon.SMALL = 256;
|
|
15
|
+
/** The square and its corners, in a canvas of SIZE. */
|
|
16
|
+
const BODY = { at: 100, size: 824, radius: 185 };
|
|
17
|
+
/** How much of the square the glyph takes. */
|
|
18
|
+
const GLYPH = 0.5;
|
|
19
|
+
function colors(tint) {
|
|
20
|
+
const { tile, ink } = TintUtil.tint(TintUtil.FACES[tint % TintUtil.FACES.length], 'light');
|
|
21
|
+
return {
|
|
22
|
+
top: TintUtil.css({ ...tile, l: 0.985, c: tile.c * 2 }),
|
|
23
|
+
bottom: TintUtil.css({ ...tile, l: 0.92, c: tile.c * 3 }),
|
|
24
|
+
ink: TintUtil.css(ink),
|
|
25
|
+
edge: TintUtil.css({ ...ink, l: 0.5, c: ink.c * 0.4 }),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
AppIcon.colors = colors;
|
|
29
|
+
/** The glyph in an SVG of its own, its strokes in `ink`: drawn by React in a detached element, as the page draws it. */
|
|
30
|
+
function svg(Glyph, ink, size) {
|
|
31
|
+
const holder = document.createElement('div');
|
|
32
|
+
const root = createRoot(holder);
|
|
33
|
+
try {
|
|
34
|
+
flushSync(() => root.render(React.createElement(Glyph, { size, strokeWidth: 1.6 })));
|
|
35
|
+
const drawn = holder.querySelector('svg');
|
|
36
|
+
if (!drawn) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
drawn.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
40
|
+
drawn.setAttribute('width', String(size));
|
|
41
|
+
drawn.setAttribute('height', String(size));
|
|
42
|
+
drawn.setAttribute('color', ink);
|
|
43
|
+
return drawn.outerHTML.replace(/currentColor/g, ink);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
root.unmount();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
AppIcon.svg = svg;
|
|
50
|
+
/** The icon as a PNG of `size` pixels; `fallback` drawn when the page's own glyph draws nothing (one of a sandbox). */
|
|
51
|
+
async function draw(Glyph, fallback, tint, size = AppIcon.SIZE) {
|
|
52
|
+
var _a;
|
|
53
|
+
const { top, bottom, ink, edge } = colors(tint);
|
|
54
|
+
const canvas = document.createElement('canvas');
|
|
55
|
+
canvas.width = size;
|
|
56
|
+
canvas.height = size;
|
|
57
|
+
const context = canvas.getContext('2d');
|
|
58
|
+
if (!context) {
|
|
59
|
+
throw new Error('This page cannot draw an icon.');
|
|
60
|
+
}
|
|
61
|
+
context.scale(size / AppIcon.SIZE, size / AppIcon.SIZE);
|
|
62
|
+
const { at, size: body, radius } = BODY;
|
|
63
|
+
context.save();
|
|
64
|
+
context.shadowColor = 'rgba(0, 0, 0, 0.22)';
|
|
65
|
+
context.shadowBlur = 28;
|
|
66
|
+
context.shadowOffsetY = 12;
|
|
67
|
+
const fill = context.createLinearGradient(0, at, 0, at + body);
|
|
68
|
+
fill.addColorStop(0, top);
|
|
69
|
+
fill.addColorStop(1, bottom);
|
|
70
|
+
context.fillStyle = fill;
|
|
71
|
+
context.beginPath();
|
|
72
|
+
context.roundRect(at, at, body, body, radius);
|
|
73
|
+
context.fill();
|
|
74
|
+
context.restore();
|
|
75
|
+
context.strokeStyle = edge;
|
|
76
|
+
context.globalAlpha = 0.12;
|
|
77
|
+
context.lineWidth = 3;
|
|
78
|
+
context.beginPath();
|
|
79
|
+
context.roundRect(at + 1.5, at + 1.5, body - 3, body - 3, radius - 1.5);
|
|
80
|
+
context.stroke();
|
|
81
|
+
context.globalAlpha = 1;
|
|
82
|
+
const glyph = Math.round(body * GLYPH);
|
|
83
|
+
const text = (_a = svg(Glyph, ink, glyph)) !== null && _a !== void 0 ? _a : svg(fallback, ink, glyph);
|
|
84
|
+
if (text) {
|
|
85
|
+
const image = new Image();
|
|
86
|
+
image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(text)}`;
|
|
87
|
+
await image.decode();
|
|
88
|
+
context.drawImage(image, at + (body - glyph) / 2, at + (body - glyph) / 2, glyph, glyph);
|
|
89
|
+
}
|
|
90
|
+
const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png'));
|
|
91
|
+
if (!blob) {
|
|
92
|
+
throw new Error('This page cannot draw an icon.');
|
|
93
|
+
}
|
|
94
|
+
return new Uint8Array(await blob.arrayBuffer());
|
|
95
|
+
}
|
|
96
|
+
AppIcon.draw = draw;
|
|
97
|
+
})(AppIcon || (AppIcon = {}));
|
|
98
|
+
//# sourceMappingURL=app-icon.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type RowEntry } from '../components/settings-controls.js';
|
|
2
|
+
/**
|
|
3
|
+
* The rows of Settings, Extensions, for pages installed as apps (docs/design/ta-install-as-app.md 1): the switch of this
|
|
4
|
+
* device, and those installed, each to open or remove. None where Ta Desktop does not install them.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useAppRows(): RowEntry[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AppWindow, X } from 'lucide-react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { BusyMark, useBusy } from '../components/busy.js';
|
|
4
|
+
import { IconButton } from '../components/icon.js';
|
|
5
|
+
import { Row, row, Switch } from '../components/settings-controls.js';
|
|
6
|
+
import { useNotices, useSettings } from '../hooks.js';
|
|
7
|
+
import { useT } from '../i18n/use-t.js';
|
|
8
|
+
import { DesktopUtil } from '../util/desktop.js';
|
|
9
|
+
/** The pages installed as apps, read again as the window comes back (one removed from its own window meanwhile). */
|
|
10
|
+
function useInstalledApps() {
|
|
11
|
+
const desktop = React.useMemo(() => DesktopUtil.apps(), []);
|
|
12
|
+
const [apps, setApps] = React.useState([]);
|
|
13
|
+
const [, notices] = useNotices();
|
|
14
|
+
const read = React.useCallback(() => {
|
|
15
|
+
desktop === null || desktop === void 0 ? void 0 : desktop.list().then(setApps, () => undefined);
|
|
16
|
+
}, [desktop]);
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
read();
|
|
19
|
+
window.addEventListener('focus', read);
|
|
20
|
+
return () => window.removeEventListener('focus', read);
|
|
21
|
+
}, [read]);
|
|
22
|
+
const remove = React.useCallback(async (id) => {
|
|
23
|
+
try {
|
|
24
|
+
await (desktop === null || desktop === void 0 ? void 0 : desktop.remove(id));
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
notices.error(error);
|
|
28
|
+
}
|
|
29
|
+
read();
|
|
30
|
+
}, [desktop, notices, read]);
|
|
31
|
+
return [apps, remove];
|
|
32
|
+
}
|
|
33
|
+
/** Open of an app installed, turning while it runs. */
|
|
34
|
+
function OpenButton({ open }) {
|
|
35
|
+
const t = useT();
|
|
36
|
+
const [busy, run] = useBusy();
|
|
37
|
+
return (React.createElement("button", { type: "button", className: busy ? 'ta-button ta-busy' : 'ta-button', "aria-busy": busy || undefined, onClick: () => void run(open) },
|
|
38
|
+
t('ta.apps.open'),
|
|
39
|
+
React.createElement(BusyMark, { busy: busy })));
|
|
40
|
+
}
|
|
41
|
+
/** Remove of an app installed, turning while it runs. */
|
|
42
|
+
function RemoveButton({ remove }) {
|
|
43
|
+
const t = useT();
|
|
44
|
+
const [busy, run] = useBusy();
|
|
45
|
+
return React.createElement(IconButton, { icon: X, label: t('ta.apps.remove'), busy: busy, onClick: () => void run(remove) });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The rows of Settings, Extensions, for pages installed as apps (docs/design/ta-install-as-app.md 1): the switch of this
|
|
49
|
+
* device, and those installed, each to open or remove. None where Ta Desktop does not install them.
|
|
50
|
+
*/
|
|
51
|
+
export function useAppRows() {
|
|
52
|
+
const t = useT();
|
|
53
|
+
const [{ settings }, store] = useSettings();
|
|
54
|
+
const [apps, remove] = useInstalledApps();
|
|
55
|
+
const desktop = React.useMemo(() => DesktopUtil.apps(), []);
|
|
56
|
+
if (!desktop) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
return [
|
|
60
|
+
row('install-apps', [t('ta.settings.installApps'), t('ta.settings.installAppsDescription')], React.createElement(Row, { label: t('ta.settings.installApps'), description: t('ta.settings.installAppsDescription') },
|
|
61
|
+
React.createElement(Switch, { label: t('ta.settings.installApps'), checked: settings.installApps, onChange: on => store.update({ installApps: on }) }))),
|
|
62
|
+
...apps.map(app => row(`app:${app.id}`, [app.name, t('ta.settings.apps')], React.createElement(Row, { icon: AppWindow, label: app.name, description: t('ta.settings.apps') },
|
|
63
|
+
React.createElement(OpenButton, { open: () => desktop.open(app.id) }),
|
|
64
|
+
React.createElement(RemoveButton, { remove: () => remove(app.id) })))),
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=app-settings.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** What the window of an app needs to know of the page it shows, pure, for the tests. */
|
|
2
|
+
export declare namespace AppWindowUtil {
|
|
3
|
+
/** How long an extension that is starting (one in a sandbox registers its views late) may take before its page is taken for gone. */
|
|
4
|
+
const START_MS = 10000;
|
|
5
|
+
/** The page a window of Ta Desktop shows alone, installed as an app: `?app=<page id>` of its address. */
|
|
6
|
+
function id(search?: string): string | undefined;
|
|
7
|
+
/** Whether a view is the page of the app: that id, or a page of the extension the id names. */
|
|
8
|
+
function shows(id: string, view: string): boolean;
|
|
9
|
+
/** Whether the page is there to show: a page view of it, or the extension started on open it names. */
|
|
10
|
+
function known(id: string, views: readonly {
|
|
11
|
+
id: string;
|
|
12
|
+
location: string;
|
|
13
|
+
}[], onOpen: readonly {
|
|
14
|
+
info: {
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
}[]): boolean;
|
|
18
|
+
/** Whether the extension of the page runs, its views maybe still on their way. */
|
|
19
|
+
function starting(id: string, extensions: readonly {
|
|
20
|
+
name: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
}[]): boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** What the window of an app needs to know of the page it shows, pure, for the tests. */
|
|
2
|
+
export var AppWindowUtil;
|
|
3
|
+
(function (AppWindowUtil) {
|
|
4
|
+
/** How long an extension that is starting (one in a sandbox registers its views late) may take before its page is taken for gone. */
|
|
5
|
+
AppWindowUtil.START_MS = 10000;
|
|
6
|
+
/** The page a window of Ta Desktop shows alone, installed as an app: `?app=<page id>` of its address. */
|
|
7
|
+
function id(search = typeof location === 'undefined' ? '' : location.search) {
|
|
8
|
+
return new URLSearchParams(search).get('app') || undefined;
|
|
9
|
+
}
|
|
10
|
+
AppWindowUtil.id = id;
|
|
11
|
+
/** Whether a view is the page of the app: that id, or a page of the extension the id names. */
|
|
12
|
+
function shows(id, view) {
|
|
13
|
+
return view === id || view.startsWith(`${id}/`);
|
|
14
|
+
}
|
|
15
|
+
AppWindowUtil.shows = shows;
|
|
16
|
+
/** Whether the page is there to show: a page view of it, or the extension started on open it names. */
|
|
17
|
+
function known(id, views, onOpen) {
|
|
18
|
+
return views.some(view => view.location === 'page' && shows(id, view.id)) || onOpen.some(entry => entry.info.name === id);
|
|
19
|
+
}
|
|
20
|
+
AppWindowUtil.known = known;
|
|
21
|
+
/** Whether the extension of the page runs, its views maybe still on their way. */
|
|
22
|
+
function starting(id, extensions) {
|
|
23
|
+
return extensions.some(extension => !extension.error && shows(extension.name, id));
|
|
24
|
+
}
|
|
25
|
+
AppWindowUtil.starting = starting;
|
|
26
|
+
})(AppWindowUtil || (AppWindowUtil = {}));
|
|
27
|
+
//# sourceMappingURL=app-window-util.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The window of a page installed as an app (docs/design/ta-install-as-app.md 2): the web client connected as in the main
|
|
4
|
+
* window, with its extensions loaded, showing that page alone; the notices, dialogs and sharing of the page over it. No
|
|
5
|
+
* conversation, no navigation: what the page opens of those opens in the main window.
|
|
6
|
+
*/
|
|
7
|
+
export declare function AppWindow({ id }: {
|
|
8
|
+
id: string;
|
|
9
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useInject } from '@celljs/react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { AppContexts } from '../components/app-contexts.js';
|
|
4
|
+
import { PageView } from '../components/app-nav.js';
|
|
5
|
+
import { useRefresh, useTitlebarColor } from '../components/app-shell-hooks.js';
|
|
6
|
+
import { CustomHost } from '../components/custom-host.js';
|
|
7
|
+
import { EmptyState } from '../components/empty-state.js';
|
|
8
|
+
import { LinkDialog } from '../components/link-dialog.js';
|
|
9
|
+
import { Loading } from '../components/loading.js';
|
|
10
|
+
import { NoticeCenter } from '../components/notice-center.js';
|
|
11
|
+
import { RemotePrompts } from '../components/remote-prompts.js';
|
|
12
|
+
import { ShareHost } from '../components/share-dialog.js';
|
|
13
|
+
import { SignIn, useDocument } from '../components/workbench-view.js';
|
|
14
|
+
import { TaFiles } from '../files/files-protocol.js';
|
|
15
|
+
import { useOpenLink, useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
|
|
16
|
+
import { useT } from '../i18n/use-t.js';
|
|
17
|
+
import { DesktopUtil } from '../util/desktop.js';
|
|
18
|
+
import { ThumbnailUtil } from '../util/thumbnail.js';
|
|
19
|
+
import { AppWindowUtil } from './app-window-util.js';
|
|
20
|
+
/**
|
|
21
|
+
* The window of a page installed as an app (docs/design/ta-install-as-app.md 2): the web client connected as in the main
|
|
22
|
+
* window, with its extensions loaded, showing that page alone; the notices, dialogs and sharing of the page over it. No
|
|
23
|
+
* conversation, no navigation: what the page opens of those opens in the main window.
|
|
24
|
+
*/
|
|
25
|
+
export function AppWindow({ id }) {
|
|
26
|
+
const t = useT();
|
|
27
|
+
const [workbench, bench] = useWorkbench();
|
|
28
|
+
const [extensions, host] = useWebExtensions();
|
|
29
|
+
const [{ theme }] = useSettings();
|
|
30
|
+
const files = useInject(TaFiles);
|
|
31
|
+
const fileUrl = React.useCallback(async (path, box) => files.loadable(ThumbnailUtil.boxed(await bench.workspace.fileUrl(path), box)), [bench, files]);
|
|
32
|
+
const openLink = useOpenLink(undefined);
|
|
33
|
+
const online = workbench.status === 'online';
|
|
34
|
+
// Offline, its extension starts from the code this device kept, as in the main window.
|
|
35
|
+
const reachable = online || workbench.status === 'offline';
|
|
36
|
+
useDocument();
|
|
37
|
+
useRefresh(online);
|
|
38
|
+
useTitlebarColor(workbench.status !== 'signed-out', theme);
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
void bench.start();
|
|
41
|
+
}, [bench]);
|
|
42
|
+
// The list of extensions read once: the page is there, or on its way, or gone.
|
|
43
|
+
const [listed, setListed] = React.useState(false);
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (!reachable) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let live = true;
|
|
49
|
+
void host
|
|
50
|
+
.refresh()
|
|
51
|
+
.catch(() => undefined)
|
|
52
|
+
.then(() => live && setListed(true));
|
|
53
|
+
return () => {
|
|
54
|
+
live = false;
|
|
55
|
+
};
|
|
56
|
+
}, [reachable, host]);
|
|
57
|
+
const page = extensions.page;
|
|
58
|
+
// Its page alone (one of its extension, for an id that is the extension's name), never what the tab showed before.
|
|
59
|
+
const ours = AppWindowUtil.shows(id, page);
|
|
60
|
+
const known = AppWindowUtil.known(id, extensions.views, extensions.onOpen);
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
if (listed && known && !ours) {
|
|
63
|
+
void host.showView(id);
|
|
64
|
+
}
|
|
65
|
+
}, [listed, known, ours, host, id]);
|
|
66
|
+
const [late, setLate] = React.useState(false);
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (!listed) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const timer = setTimeout(() => setLate(true), AppWindowUtil.START_MS);
|
|
72
|
+
return () => clearTimeout(timer);
|
|
73
|
+
}, [listed]);
|
|
74
|
+
const gone = listed && !known && (late || !AppWindowUtil.starting(id, extensions.extensions));
|
|
75
|
+
if (workbench.status === 'signed-out') {
|
|
76
|
+
return workbench.leaving ? React.createElement("div", { className: "ta-signin" }) : React.createElement(SignIn, { error: workbench.error });
|
|
77
|
+
}
|
|
78
|
+
const view = ours ? extensions.views.find(candidate => candidate.id === page && candidate.location === 'page') : undefined;
|
|
79
|
+
const remove = () => { var _a; return void ((_a = DesktopUtil.apps()) === null || _a === void 0 ? void 0 : _a.remove(id)); };
|
|
80
|
+
return (React.createElement(AppContexts, { fileUrl: fileUrl, openLink: openLink },
|
|
81
|
+
React.createElement("div", { className: "ta-app ta-app-alone" },
|
|
82
|
+
React.createElement("main", { className: "ta-main" }, view ? (React.createElement(PageView, { view: view })) : gone ? (React.createElement(EmptyState, { title: t('ta.apps.gone'), hint: t('ta.apps.goneHint') },
|
|
83
|
+
React.createElement("button", { type: "button", className: "ta-button", onClick: remove }, t('ta.apps.remove')))) : (React.createElement(Loading, null))),
|
|
84
|
+
React.createElement(NoticeCenter, null),
|
|
85
|
+
React.createElement(LinkDialog, null),
|
|
86
|
+
React.createElement(RemotePrompts, null),
|
|
87
|
+
React.createElement(ShareHost, null),
|
|
88
|
+
React.createElement(CustomHost, null))));
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=app-window.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { WebApps, WebIcon, WebInstalledApp } from '../extension/web-extension-api.js';
|
|
2
|
+
import type { WebPageInfo } from '../extension/web-pages.js';
|
|
3
|
+
import type { TaNotices } from '../notices/notices-protocol.js';
|
|
4
|
+
import type { TaSettings } from '../settings/settings-protocol.js';
|
|
5
|
+
import { type DesktopApps } from '../util/desktop.js';
|
|
6
|
+
/** What installing a page reads of the page: its pages as the launcher lists them, the settings, where it tells. */
|
|
7
|
+
export interface WebAppsHost {
|
|
8
|
+
pages(): readonly WebPageInfo[];
|
|
9
|
+
readonly settings: TaSettings;
|
|
10
|
+
readonly notices: TaNotices;
|
|
11
|
+
/** Drawn for a page without a glyph of its own, or one a sandbox draws. */
|
|
12
|
+
readonly fallbackIcon: WebIcon;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `ui.apps` (docs/design/ta-install-as-app.md 2): a page installed with the title and the tile the launcher shows it
|
|
16
|
+
* with, through Ta Desktop (DesktopUtil.apps), which knows pages by id, name and icon alone.
|
|
17
|
+
*/
|
|
18
|
+
export declare class TaWebApps implements WebApps {
|
|
19
|
+
protected readonly desktop: DesktopApps;
|
|
20
|
+
protected readonly host: WebAppsHost;
|
|
21
|
+
constructor(desktop: DesktopApps, host: WebAppsHost);
|
|
22
|
+
/** Where Ta Desktop installs pages as apps; none elsewhere. */
|
|
23
|
+
static of(host: WebAppsHost): TaWebApps | undefined;
|
|
24
|
+
get installable(): boolean;
|
|
25
|
+
list(): Promise<WebInstalledApp[]>;
|
|
26
|
+
install(id: string): Promise<void>;
|
|
27
|
+
remove(id: string): Promise<void>;
|
|
28
|
+
open(id: string): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { translator } from '../i18n/use-t.js';
|
|
2
|
+
import { TintUtil } from '../style/tints.js';
|
|
3
|
+
import { DesktopUtil } from '../util/desktop.js';
|
|
4
|
+
import { AppIcon } from './app-icon.js';
|
|
5
|
+
/**
|
|
6
|
+
* `ui.apps` (docs/design/ta-install-as-app.md 2): a page installed with the title and the tile the launcher shows it
|
|
7
|
+
* with, through Ta Desktop (DesktopUtil.apps), which knows pages by id, name and icon alone.
|
|
8
|
+
*/
|
|
9
|
+
export class TaWebApps {
|
|
10
|
+
constructor(desktop, host) {
|
|
11
|
+
this.desktop = desktop;
|
|
12
|
+
this.host = host;
|
|
13
|
+
}
|
|
14
|
+
/** Where Ta Desktop installs pages as apps; none elsewhere. */
|
|
15
|
+
static of(host) {
|
|
16
|
+
const desktop = DesktopUtil.apps();
|
|
17
|
+
return desktop ? new TaWebApps(desktop, host) : undefined;
|
|
18
|
+
}
|
|
19
|
+
get installable() {
|
|
20
|
+
return this.host.settings.state.settings.installApps;
|
|
21
|
+
}
|
|
22
|
+
async list() {
|
|
23
|
+
return (await this.desktop.list()).map(({ id, name, installedAt }) => ({ id, name, installedAt }));
|
|
24
|
+
}
|
|
25
|
+
async install(id) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
const say = translator(this.host.settings.state.language);
|
|
28
|
+
if (!this.installable) {
|
|
29
|
+
throw new Error(say('ta.apps.off'));
|
|
30
|
+
}
|
|
31
|
+
const page = this.host.pages().find(candidate => candidate.id === id);
|
|
32
|
+
if (!page) {
|
|
33
|
+
throw new Error(say('ta.apps.gone'));
|
|
34
|
+
}
|
|
35
|
+
const tint = (_a = page.tint) !== null && _a !== void 0 ? _a : TintUtil.of(page.extension);
|
|
36
|
+
const glyph = (_b = page.icon) !== null && _b !== void 0 ? _b : this.host.fallbackIcon;
|
|
37
|
+
const [png, small] = await Promise.all([
|
|
38
|
+
AppIcon.draw(glyph, this.host.fallbackIcon, tint, AppIcon.SIZE),
|
|
39
|
+
AppIcon.draw(glyph, this.host.fallbackIcon, tint, AppIcon.SMALL),
|
|
40
|
+
]);
|
|
41
|
+
const installed = await this.desktop.install({ id, name: page.title, png, small });
|
|
42
|
+
await this.desktop.open(id);
|
|
43
|
+
if (installed.problem) {
|
|
44
|
+
this.host.notices.notify(say('ta.apps.noEntry', { name: page.title }), { level: 'warning', detail: installed.problem });
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.host.notices.notify(say('ta.apps.installed', { name: page.title }));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
remove(id) {
|
|
51
|
+
return this.desktop.remove(id);
|
|
52
|
+
}
|
|
53
|
+
open(id) {
|
|
54
|
+
return this.desktop.open(id);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=web-apps.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TaMessageSource } from '@celljs/ta-protocol';
|
|
2
2
|
import { ChevronRight } from 'lucide-react';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { Callout } from '../components/callout.js';
|
|
5
4
|
import { ContextLine } from '../components/context-line.js';
|
|
6
5
|
import { ASK_CLASS } from '../components/conversation-scroll-util.js';
|
|
7
6
|
import { Icon } from '../components/icon.js';
|
|
@@ -11,6 +10,7 @@ import { endsInSteps, quiet, TurnAvatar, useThreadRows } from '../components/mes
|
|
|
11
10
|
import { useMessageMenu } from '../components/message-menu.js';
|
|
12
11
|
import { Process } from '../components/message-steps.js';
|
|
13
12
|
import { NoticeMessage, SkillUse, UserMarks, UserSaid, userWords } from '../components/message-user.js';
|
|
13
|
+
import { RequestError } from '../components/request-error.js';
|
|
14
14
|
import { RunStatus } from '../components/run-status.js';
|
|
15
15
|
import { CustomMessage, MessageRenderers } from '../extension/extension-view.js';
|
|
16
16
|
import { WebTaskUtil } from '../extension/web-tasks.js';
|
|
@@ -57,7 +57,7 @@ function DoubleRowView({ item, tools, mood, status, latest, started, onTask, t }
|
|
|
57
57
|
React.createElement(Process, { steps: item.steps, active: item.active, results: results, tools: tools, leading: React.createElement(TurnAvatar, { mood: mood }), status: status }),
|
|
58
58
|
React.createElement(TaskCards, { tasks: started }),
|
|
59
59
|
item.reply.map((text, index) => (React.createElement(Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
|
|
60
|
-
!item.active && stopReason === 'error' && errorMessage && React.createElement(
|
|
60
|
+
!item.active && stopReason === 'error' && errorMessage && React.createElement(RequestError, { error: errorMessage })));
|
|
61
61
|
}
|
|
62
62
|
const { role } = item.message;
|
|
63
63
|
if (role === 'custom') {
|