@celljs/ta-web 4.47.0 → 4.48.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/esm/browser/assistant/assistant-role.d.ts +1 -1
- package/esm/browser/assistant/assistant-role.js +1 -1
- package/esm/browser/assistant/assistant-task-source.js +6 -1
- package/esm/browser/assistant/assistant-task-util.d.ts +1 -0
- package/esm/browser/assistant/assistant-task-util.js +9 -3
- package/esm/browser/assistant/assistant-view.js +5 -2
- package/esm/browser/chat/chat-view.js +2 -1
- package/esm/browser/cloud/cloud-sign-in.d.ts +26 -4
- package/esm/browser/cloud/cloud-sign-in.js +88 -18
- package/esm/browser/components/app-nav.d.ts +3 -1
- package/esm/browser/components/app-nav.js +3 -3
- package/esm/browser/components/app-shell-state.js +11 -0
- package/esm/browser/components/app-view.js +16 -6
- package/esm/browser/components/asks-badge.d.ts +12 -0
- package/esm/browser/components/asks-badge.js +17 -1
- package/esm/browser/components/chat-list-row.d.ts +4 -1
- package/esm/browser/components/chat-list-row.js +7 -1
- package/esm/browser/components/chats-dot.d.ts +4 -1
- package/esm/browser/components/chats-dot.js +6 -2
- package/esm/browser/components/cloud-sign-in-view.d.ts +2 -1
- package/esm/browser/components/cloud-sign-in-view.js +28 -5
- package/esm/browser/components/composer-box-protocol.d.ts +5 -3
- package/esm/browser/components/composer-box.js +11 -11
- package/esm/browser/components/composer.d.ts +8 -1
- package/esm/browser/components/composer.js +57 -34
- package/esm/browser/components/discover-view.js +1 -1
- package/esm/browser/components/first-steps-util.d.ts +30 -0
- package/esm/browser/components/first-steps-util.js +36 -3
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/lightbox.d.ts +15 -1
- package/esm/browser/components/lightbox.js +14 -2
- package/esm/browser/components/link.js +8 -3
- package/esm/browser/components/list-rows.d.ts +1 -1
- package/esm/browser/components/list-rows.js +1 -1
- package/esm/browser/components/markdown.d.ts +4 -2
- package/esm/browser/components/markdown.js +13 -4
- package/esm/browser/components/media.d.ts +6 -0
- package/esm/browser/components/media.js +9 -1
- package/esm/browser/components/message-images.d.ts +5 -0
- package/esm/browser/components/message-images.js +40 -4
- package/esm/browser/components/message-user.js +4 -2
- package/esm/browser/components/partner-row.js +4 -4
- package/esm/browser/components/phone-hint.d.ts +6 -0
- package/esm/browser/components/phone-hint.js +63 -0
- package/esm/browser/components/phone-shell.d.ts +2 -0
- package/esm/browser/components/phone-shell.js +2 -2
- package/esm/browser/components/sending.d.ts +19 -0
- package/esm/browser/components/sending.js +27 -0
- package/esm/browser/components/session-view.js +5 -3
- package/esm/browser/components/settings-choices.js +1 -0
- package/esm/browser/components/settings-parts.js +28 -17
- package/esm/browser/components/share-dialog.js +3 -2
- package/esm/browser/components/share-item-sheet.js +1 -1
- package/esm/browser/components/share-sheet.d.ts +4 -2
- package/esm/browser/components/share-sheet.js +16 -2
- package/esm/browser/components/sign-in-accounts.js +7 -1
- package/esm/browser/components/unseen-drop.d.ts +2 -2
- package/esm/browser/components/unseen-drop.js +1 -1
- package/esm/browser/device/app-badge.d.ts +8 -0
- package/esm/browser/device/app-badge.js +28 -0
- package/esm/browser/device/code-scan.js +1 -1
- package/esm/browser/extension/web-api-code.d.ts +26 -0
- package/esm/browser/extension/web-api-components.d.ts +31 -0
- package/esm/browser/extension/web-api-menus.d.ts +15 -0
- package/esm/browser/extension/web-api-messages.d.ts +15 -0
- package/esm/browser/extension/web-api-messages.js +2 -0
- package/esm/browser/extension/web-api-partners.d.ts +16 -0
- package/esm/browser/extension/web-api-spec.js +1 -0
- package/esm/browser/extension/web-extension-api.d.ts +7 -13
- package/esm/browser/extension/web-extension-context.js +2 -0
- package/esm/browser/extension/web-session-notices.js +11 -2
- package/esm/browser/extension/web-share-ui.js +1 -0
- package/esm/browser/extension/web-share.js +3 -3
- package/esm/browser/extension/web-sharing.js +1 -1
- package/esm/browser/i18n/en/assistant.d.ts +2 -0
- package/esm/browser/i18n/en/assistant.js +2 -0
- package/esm/browser/i18n/en/chat.d.ts +11 -0
- package/esm/browser/i18n/en/chat.js +13 -2
- package/esm/browser/i18n/en/common.d.ts +4 -0
- package/esm/browser/i18n/en/common.js +4 -0
- package/esm/browser/i18n/en/service.d.ts +7 -0
- package/esm/browser/i18n/en/service.js +7 -0
- package/esm/browser/i18n/en/settings.d.ts +6 -0
- package/esm/browser/i18n/en/settings.js +8 -2
- package/esm/browser/i18n/ja/assistant.js +2 -0
- package/esm/browser/i18n/ja/chat.js +13 -2
- package/esm/browser/i18n/ja/common.js +4 -0
- package/esm/browser/i18n/ja/service.js +7 -0
- package/esm/browser/i18n/ja/settings.js +10 -4
- package/esm/browser/i18n/locales.d.ts +31 -1
- package/esm/browser/i18n/messages.d.ts +30 -0
- package/esm/browser/i18n/zh/assistant.js +2 -0
- package/esm/browser/i18n/zh/chat.js +13 -2
- package/esm/browser/i18n/zh/common.js +4 -0
- package/esm/browser/i18n/zh/service.js +7 -0
- package/esm/browser/i18n/zh/settings.js +8 -2
- package/esm/browser/i18n/zh-tw/assistant.js +2 -0
- package/esm/browser/i18n/zh-tw/chat.js +13 -2
- package/esm/browser/i18n/zh-tw/common.js +4 -0
- package/esm/browser/i18n/zh-tw/service.js +7 -0
- package/esm/browser/i18n/zh-tw/settings.js +8 -2
- package/esm/browser/links/links.js +1 -1
- package/esm/browser/notices/session-notices.d.ts +4 -4
- package/esm/browser/notices/session-notices.js +3 -6
- package/esm/browser/partners/partners-util.d.ts +6 -0
- package/esm/browser/partners/partners-util.js +22 -0
- package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
- package/esm/browser/settings/agent-settings.d.ts +2 -0
- package/esm/browser/settings/agent-settings.js +2 -0
- package/esm/browser/settings/settings-protocol.d.ts +8 -0
- package/esm/browser/settings/settings-protocol.js +5 -0
- package/esm/browser/style/base.d.ts +1 -1
- package/esm/browser/style/base.js +3 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +8 -3
- package/esm/browser/style/conversation-column.d.ts +1 -1
- package/esm/browser/style/conversation-column.js +10 -1
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +18 -0
- package/esm/browser/style/phone.d.ts +1 -1
- package/esm/browser/style/phone.js +2 -0
- package/esm/browser/style/skins.d.ts +1 -1
- package/esm/browser/style/skins.js +1 -1
- package/esm/browser/util/composer.d.ts +18 -3
- package/esm/browser/util/composer.js +31 -5
- package/esm/browser/util/desktop.d.ts +8 -1
- package/esm/browser/util/desktop.js +10 -0
- package/esm/browser/util/image-shrink.d.ts +5 -1
- package/esm/browser/util/image-shrink.js +1 -1
- package/esm/browser/util/markdown.d.ts +3 -5
- package/esm/browser/util/markdown.js +5 -29
- package/esm/browser/util/process.js +2 -2
- package/lib/browser/assistant/assistant-role.d.ts +1 -1
- package/lib/browser/assistant/assistant-role.js +1 -1
- package/lib/browser/assistant/assistant-task-source.js +5 -0
- package/lib/browser/assistant/assistant-task-util.d.ts +1 -0
- package/lib/browser/assistant/assistant-task-util.js +8 -2
- package/lib/browser/assistant/assistant-view.js +5 -2
- package/lib/browser/chat/chat-view.js +2 -1
- package/lib/browser/cloud/cloud-sign-in.d.ts +26 -4
- package/lib/browser/cloud/cloud-sign-in.js +89 -19
- package/lib/browser/components/app-nav.d.ts +3 -1
- package/lib/browser/components/app-nav.js +2 -2
- package/lib/browser/components/app-shell-state.js +11 -0
- package/lib/browser/components/app-view.js +16 -6
- package/lib/browser/components/asks-badge.d.ts +12 -0
- package/lib/browser/components/asks-badge.js +19 -1
- package/lib/browser/components/chat-list-row.d.ts +4 -1
- package/lib/browser/components/chat-list-row.js +7 -1
- package/lib/browser/components/chats-dot.d.ts +4 -1
- package/lib/browser/components/chats-dot.js +6 -2
- package/lib/browser/components/cloud-sign-in-view.d.ts +2 -1
- package/lib/browser/components/cloud-sign-in-view.js +28 -5
- package/lib/browser/components/composer-box-protocol.d.ts +5 -3
- package/lib/browser/components/composer-box.js +11 -11
- package/lib/browser/components/composer.d.ts +8 -1
- package/lib/browser/components/composer.js +56 -33
- package/lib/browser/components/discover-view.js +1 -1
- package/lib/browser/components/first-steps-util.d.ts +30 -0
- package/lib/browser/components/first-steps-util.js +37 -4
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/lightbox.d.ts +15 -1
- package/lib/browser/components/lightbox.js +15 -2
- package/lib/browser/components/link.js +8 -3
- package/lib/browser/components/list-rows.d.ts +1 -1
- package/lib/browser/components/list-rows.js +1 -1
- package/lib/browser/components/markdown.d.ts +4 -2
- package/lib/browser/components/markdown.js +11 -2
- package/lib/browser/components/media.d.ts +6 -0
- package/lib/browser/components/media.js +10 -2
- package/lib/browser/components/message-images.d.ts +5 -0
- package/lib/browser/components/message-images.js +40 -4
- package/lib/browser/components/message-user.js +4 -2
- package/lib/browser/components/partner-row.js +4 -4
- package/lib/browser/components/phone-hint.d.ts +7 -0
- package/lib/browser/components/phone-hint.js +99 -0
- package/lib/browser/components/phone-shell.d.ts +2 -0
- package/lib/browser/components/phone-shell.js +1 -1
- package/lib/browser/components/sending.d.ts +20 -0
- package/lib/browser/components/sending.js +63 -0
- package/lib/browser/components/session-view.js +5 -3
- package/lib/browser/components/settings-choices.js +1 -0
- package/lib/browser/components/settings-parts.js +26 -15
- package/lib/browser/components/share-dialog.js +3 -2
- package/lib/browser/components/share-item-sheet.js +1 -1
- package/lib/browser/components/share-sheet.d.ts +4 -2
- package/lib/browser/components/share-sheet.js +16 -2
- package/lib/browser/components/sign-in-accounts.js +7 -1
- package/lib/browser/components/unseen-drop.d.ts +2 -2
- package/lib/browser/components/unseen-drop.js +1 -1
- package/lib/browser/device/app-badge.d.ts +9 -0
- package/lib/browser/device/app-badge.js +31 -0
- package/lib/browser/device/code-scan.js +1 -1
- package/lib/browser/extension/web-api-code.d.ts +26 -0
- package/lib/browser/extension/web-api-components.d.ts +31 -0
- package/lib/browser/extension/web-api-menus.d.ts +15 -0
- package/lib/browser/extension/web-api-messages.d.ts +16 -0
- package/lib/browser/extension/web-api-messages.js +3 -0
- package/lib/browser/extension/web-api-partners.d.ts +16 -0
- package/lib/browser/extension/web-api-spec.js +1 -0
- package/lib/browser/extension/web-extension-api.d.ts +7 -13
- package/lib/browser/extension/web-extension-context.js +2 -0
- package/lib/browser/extension/web-session-notices.js +10 -1
- package/lib/browser/extension/web-share-ui.js +1 -0
- package/lib/browser/extension/web-share.js +3 -3
- package/lib/browser/extension/web-sharing.js +1 -1
- package/lib/browser/i18n/en/assistant.d.ts +2 -0
- package/lib/browser/i18n/en/assistant.js +2 -0
- package/lib/browser/i18n/en/chat.d.ts +11 -0
- package/lib/browser/i18n/en/chat.js +13 -2
- package/lib/browser/i18n/en/common.d.ts +4 -0
- package/lib/browser/i18n/en/common.js +4 -0
- package/lib/browser/i18n/en/service.d.ts +7 -0
- package/lib/browser/i18n/en/service.js +7 -0
- package/lib/browser/i18n/en/settings.d.ts +6 -0
- package/lib/browser/i18n/en/settings.js +8 -2
- package/lib/browser/i18n/ja/assistant.js +2 -0
- package/lib/browser/i18n/ja/chat.js +13 -2
- package/lib/browser/i18n/ja/common.js +4 -0
- package/lib/browser/i18n/ja/service.js +7 -0
- package/lib/browser/i18n/ja/settings.js +10 -4
- package/lib/browser/i18n/locales.d.ts +31 -1
- package/lib/browser/i18n/messages.d.ts +30 -0
- package/lib/browser/i18n/zh/assistant.js +2 -0
- package/lib/browser/i18n/zh/chat.js +13 -2
- package/lib/browser/i18n/zh/common.js +4 -0
- package/lib/browser/i18n/zh/service.js +7 -0
- package/lib/browser/i18n/zh/settings.js +8 -2
- package/lib/browser/i18n/zh-tw/assistant.js +2 -0
- package/lib/browser/i18n/zh-tw/chat.js +13 -2
- package/lib/browser/i18n/zh-tw/common.js +4 -0
- package/lib/browser/i18n/zh-tw/service.js +7 -0
- package/lib/browser/i18n/zh-tw/settings.js +8 -2
- package/lib/browser/links/links.js +1 -1
- package/lib/browser/notices/session-notices.d.ts +4 -4
- package/lib/browser/notices/session-notices.js +3 -6
- package/lib/browser/partners/partners-util.d.ts +6 -0
- package/lib/browser/partners/partners-util.js +22 -0
- package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
- package/lib/browser/settings/agent-settings.d.ts +2 -0
- package/lib/browser/settings/agent-settings.js +3 -1
- package/lib/browser/settings/settings-protocol.d.ts +8 -0
- package/lib/browser/settings/settings-protocol.js +6 -1
- package/lib/browser/style/base.d.ts +1 -1
- package/lib/browser/style/base.js +3 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +8 -3
- package/lib/browser/style/conversation-column.d.ts +1 -1
- package/lib/browser/style/conversation-column.js +10 -1
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +18 -0
- package/lib/browser/style/phone.d.ts +1 -1
- package/lib/browser/style/phone.js +2 -0
- package/lib/browser/style/skins.d.ts +1 -1
- package/lib/browser/style/skins.js +1 -1
- package/lib/browser/util/composer.d.ts +18 -3
- package/lib/browser/util/composer.js +31 -5
- package/lib/browser/util/desktop.d.ts +8 -1
- package/lib/browser/util/desktop.js +10 -0
- package/lib/browser/util/image-shrink.d.ts +5 -1
- package/lib/browser/util/image-shrink.js +1 -1
- package/lib/browser/util/markdown.d.ts +3 -5
- package/lib/browser/util/markdown.js +5 -29
- package/lib/browser/util/process.js +1 -1
- package/package.json +7 -7
- package/esm/browser/util/share-link.d.ts +0 -21
- package/esm/browser/util/share-link.js +0 -61
- package/lib/browser/util/share-link.d.ts +0 -22
- package/lib/browser/util/share-link.js +0 -64
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TaDelegateLevel } from '@celljs/ta-protocol';
|
|
2
2
|
/** The role of ta in its conversation with the user. */
|
|
3
|
-
export declare const ASSISTANT_PROMPT = "You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.\n- To hand out work, call start_task with a short title and complete, self-contained instructions: a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.\n- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.\n- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.\n- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as \"bun test\", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.\n- When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.\n- When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.\n- What the user says is often spoken and transcribed, with wrong words and sentences cut off: read it for what they mean, with what was said before. A message from a call ([ta:from @celljs/ta-call \u2026]) is the user's own request, retold by the call: \"the user wants X\" means they ask you for X.\n- When they ask for something to be done (\"\u5E2E\u6211\u5F04\", \"\u5E2E\u6211\u6539\", \"\u6362\u4E00\u4E2A\", \"\u88C5\u4E0A\", \"\u6253\u5F00\u2026\"), that is their go: start it now, in this turn, then say in one sentence what you started, with asked: true. Do not ask first whether to start, nor offer to, nor stop at saying what you would do.\n- A short go (\"\u6765\", \"\u597D\", \"\u5F00\u59CB\", \"\u884C\", \"\u55EF\") answers what you said last: do what you proposed, or the most likely of what waits for them (the step they usually take next, as installing what was just changed, before what needs their taste), with asked: true, and say in one sentence which you took. Ask only when two are as likely, and then one yes-or-no question with your best guess (\"\u88C5\u5230\u624B\u673A\u4E0A\uFF0C\u5BF9\u5427\uFF1F\"), never a card of choices.\n- What a task can find out (which voices a service has, where a setting is, which file) is no question for the user: the task finds it, picks what fits, does it and tries it. A taste they did not say (a man's or a woman's voice) is yours to pick: say what you picked, so they can change it.\n- Instructions of a task say to get it done and checked: the result the user wants, how the task shows it works (it tries it, as the user would), and that it asks them only before what is risky or cannot be undone.\n- What the user asks of their screen (open a page, look at what is wrong, press something) is done on the page in front of them, on the device they use, a phone's on a phone: do it yourself, with app_look, app_go and app_do; a message from a call says which device. Never the computer's desktop (screenshots, tools that drive the computer) unless they name the computer.\n- When you cannot tell what they want at all (words that ask for nothing, a sentence cut off), say in one short sentence what you heard and ask them to say it again; never answer nothing.\n- Ask first only before what is risky or cannot be undone (deleting, publishing, sending or paying for them) that they did not clearly ask for.\n- Your replies are read aloud: short plain sentences, no tables, no code unless asked. Short is not vague: say what you started, picked or found. Reply in the user's language.";
|
|
3
|
+
export declare const ASSISTANT_PROMPT = "You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.\n- To hand out work, call start_task with a short title and complete, self-contained instructions (its two required fields, named title and instructions): a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.\n- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.\n- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.\n- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as \"bun test\", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.\n- When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.\n- When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.\n- What the user says is often spoken and transcribed, with wrong words and sentences cut off: read it for what they mean, with what was said before. A message from a call ([ta:from @celljs/ta-call \u2026]) is the user's own request, retold by the call: \"the user wants X\" means they ask you for X.\n- When they ask for something to be done (\"\u5E2E\u6211\u5F04\", \"\u5E2E\u6211\u6539\", \"\u6362\u4E00\u4E2A\", \"\u88C5\u4E0A\", \"\u6253\u5F00\u2026\"), that is their go: start it now, in this turn, then say in one sentence what you started, with asked: true. Do not ask first whether to start, nor offer to, nor stop at saying what you would do.\n- A short go (\"\u6765\", \"\u597D\", \"\u5F00\u59CB\", \"\u884C\", \"\u55EF\") answers what you said last: do what you proposed, or the most likely of what waits for them (the step they usually take next, as installing what was just changed, before what needs their taste), with asked: true, and say in one sentence which you took. Ask only when two are as likely, and then one yes-or-no question with your best guess (\"\u88C5\u5230\u624B\u673A\u4E0A\uFF0C\u5BF9\u5427\uFF1F\"), never a card of choices.\n- What a task can find out (which voices a service has, where a setting is, which file) is no question for the user: the task finds it, picks what fits, does it and tries it. A taste they did not say (a man's or a woman's voice) is yours to pick: say what you picked, so they can change it.\n- Instructions of a task say to get it done and checked: the result the user wants, how the task shows it works (it tries it, as the user would), and that it asks them only before what is risky or cannot be undone.\n- What the user asks of their screen (open a page, look at what is wrong, press something) is done on the page in front of them, on the device they use, a phone's on a phone: do it yourself, with app_look, app_go and app_do; a message from a call says which device. Never the computer's desktop (screenshots, tools that drive the computer) unless they name the computer.\n- When you cannot tell what they want at all (words that ask for nothing, a sentence cut off), say in one short sentence what you heard and ask them to say it again; never answer nothing.\n- Ask first only before what is risky or cannot be undone (deleting, publishing, sending or paying for them) that they did not clearly ask for.\n- Your replies are read aloud: short plain sentences, no tables, no code unless asked. Short is not vague: say what you started, picked or found. Reply in the user's language.";
|
|
4
4
|
/**
|
|
5
5
|
* In the role while the user wants to be asked first (Settings.confirmTasks): of what the double starts of its own
|
|
6
6
|
* accord only, never twice (docs/design/ta-double.md, 听懂与派活). The team tools of ta-channels read the same words in the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TaDelegateUtil } from '@celljs/ta-protocol';
|
|
2
2
|
/** The role of ta in its conversation with the user. */
|
|
3
3
|
export const ASSISTANT_PROMPT = `You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.
|
|
4
|
-
- To hand out work, call start_task with a short title and complete, self-contained instructions: a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.
|
|
4
|
+
- To hand out work, call start_task with a short title and complete, self-contained instructions (its two required fields, named title and instructions): a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.
|
|
5
5
|
- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.
|
|
6
6
|
- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.
|
|
7
7
|
- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as "bun test", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TaSaid } from '@celljs/ta-protocol';
|
|
1
|
+
import { TaDeadEnd, TaSaid } from '@celljs/ta-protocol';
|
|
2
2
|
import { ShieldCheck } from 'lucide-react';
|
|
3
3
|
import { ProgressUtil } from '../util/progress.js';
|
|
4
4
|
import { AssistantTaskUtil } from './assistant-task-util.js';
|
|
@@ -13,6 +13,11 @@ export function activity(task, state, t) {
|
|
|
13
13
|
if (task.paused && task.status !== 'running') {
|
|
14
14
|
return t('ta.task.paused');
|
|
15
15
|
}
|
|
16
|
+
// Not done because its reply came to nothing (filtered, empty): why, in the user's language.
|
|
17
|
+
const deadEnd = task.status === 'failed' ? TaDeadEnd.describedKind(task.result) : undefined;
|
|
18
|
+
if (deadEnd) {
|
|
19
|
+
return t(deadEnd === 'empty' ? 'ta.task.deadEndEmpty' : 'ta.task.deadEndFiltered');
|
|
20
|
+
}
|
|
16
21
|
return task.status === 'running' ? t('ta.task.running') : TaSaid.line(said !== null && said !== void 0 ? said : '', { chars: 80 }) || t(`ta.task.${task.status}`);
|
|
17
22
|
}
|
|
18
23
|
/** How a task came out of a check: its own verdict for a check that ended, else the verdict of the check of it. */
|
|
@@ -41,6 +41,7 @@ export declare namespace AssistantTaskUtil {
|
|
|
41
41
|
timestamp?: number;
|
|
42
42
|
stopReason?: string;
|
|
43
43
|
errorMessage?: string;
|
|
44
|
+
content?: unknown;
|
|
44
45
|
} | undefined;
|
|
45
46
|
/** How the run of a task's session ended (ended), and the id of the message that tells the double, the same in every page. */
|
|
46
47
|
function outcome(state: SessionState): {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TaMessageSource, TaTaskNote } from '@celljs/ta-protocol';
|
|
1
|
+
import { TaDeadEnd, TaMessageSource, TaTaskNote } from '@celljs/ta-protocol';
|
|
2
2
|
import { MessageUtil } from '../util/message.js';
|
|
3
3
|
/** The tasks kept: the last ones, those taken off the list among them. */
|
|
4
4
|
export const MAX_TASKS = 50;
|
|
@@ -103,9 +103,12 @@ export var AssistantTaskUtil;
|
|
|
103
103
|
var _a, _b, _c;
|
|
104
104
|
const last = lastAnswer(state.messages);
|
|
105
105
|
const reason = MessageUtil.stopReason(last);
|
|
106
|
+
// A reply that came to nothing (filtered, refused, empty) is no answer: not done, and its words are not the result.
|
|
107
|
+
const deadEnd = TaDeadEnd.kind({ role: 'assistant', ...last });
|
|
106
108
|
// Its last answer asked for a tool, whose result never came: the run was cut, not done.
|
|
107
|
-
const status = state.closed || reason === 'aborted' || reason === 'toolUse' ? 'stopped' : reason === 'error' ? 'failed' : 'done';
|
|
108
|
-
const
|
|
109
|
+
const status = state.closed || reason === 'aborted' || reason === 'toolUse' ? 'stopped' : reason === 'error' || deadEnd ? 'failed' : 'done';
|
|
110
|
+
const failure = deadEnd ? TaDeadEnd.describe(deadEnd, last === null || last === void 0 ? void 0 : last.errorMessage) : last === null || last === void 0 ? void 0 : last.errorMessage;
|
|
111
|
+
const result = (_b = (_a = (status === 'failed' ? failure : undefined)) !== null && _a !== void 0 ? _a : lastWords(state.messages)) !== null && _b !== void 0 ? _b : '';
|
|
109
112
|
return { status, result, endedAt: state.closed ? undefined : last === null || last === void 0 ? void 0 : last.timestamp, key: `${status}:${(_c = last === null || last === void 0 ? void 0 : last.timestamp) !== null && _c !== void 0 ? _c : 0}` };
|
|
110
113
|
}
|
|
111
114
|
AssistantTaskUtil.outcome = outcome;
|
|
@@ -119,6 +122,9 @@ export var AssistantTaskUtil;
|
|
|
119
122
|
function updateNote(task) {
|
|
120
123
|
var _a, _b;
|
|
121
124
|
const lines = [((_a = task.result) !== null && _a !== void 0 ? _a : '').slice(0, RESULT_CHARS)];
|
|
125
|
+
if (task.status === 'failed' && TaDeadEnd.described(task.result)) {
|
|
126
|
+
lines.push('Do not start it again on your own: tell the user it is not done and why, and let them decide.');
|
|
127
|
+
}
|
|
122
128
|
if (task.paused) {
|
|
123
129
|
lines.push('The user paused it, with the other tasks that ran: leave it until they resume it.');
|
|
124
130
|
}
|
|
@@ -16,6 +16,7 @@ import { Loading } from '../components/loading.js';
|
|
|
16
16
|
import { useMessageActions } from '../components/message-actions.js';
|
|
17
17
|
import { MessageActions } from '../components/message-footer.js';
|
|
18
18
|
import { MessageImages } from '../components/message-images.js';
|
|
19
|
+
import { PhoneHint } from '../components/phone-hint.js';
|
|
19
20
|
import { useSessionSettings } from '../components/session-settings.js';
|
|
20
21
|
import { TaAvatar } from '../components/ta-avatar.js';
|
|
21
22
|
import { useStopTimes } from '../components/use-stop-times.js';
|
|
@@ -24,6 +25,7 @@ import { WorkbenchToggle } from '../components/workbench-toggle.js';
|
|
|
24
25
|
import { DraftPlaces } from '../drafts/drafts-protocol.js';
|
|
25
26
|
import { useNotices, usePersisted, useSessionState, useSettings, useTasks, useWebExtensions, useWorkbench } from '../hooks.js';
|
|
26
27
|
import { useT } from '../i18n/use-t.js';
|
|
28
|
+
import { QUEUE_SETTINGS } from '../settings/agent-settings.js';
|
|
27
29
|
import { MessageUtil } from '../util/message.js';
|
|
28
30
|
import { useAssistant, useLastActive, useNow, useTaskStates } from './assistant-hooks.js';
|
|
29
31
|
import { ASSISTANT_NAME_STATE } from './assistant-state.js';
|
|
@@ -95,7 +97,8 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
95
97
|
const [, notices] = useNotices();
|
|
96
98
|
const spoken = React.useRef(undefined);
|
|
97
99
|
const box = React.useRef(null);
|
|
98
|
-
const { speak, speakTalk, confirmTasks, delegate, voice } = settingsState.settings;
|
|
100
|
+
const { speak, speakTalk, confirmTasks, delegate, voice, sendWhileWorking } = settingsState.settings;
|
|
101
|
+
const [, extensions] = useWebExtensions();
|
|
99
102
|
const [name] = usePersisted(ASSISTANT_NAME_STATE);
|
|
100
103
|
const attentions = [
|
|
101
104
|
...state.pendingUi.map(request => ({ source: 'ta', store, request })),
|
|
@@ -320,7 +323,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
320
323
|
React.createElement(ConnectionBanner, null),
|
|
321
324
|
addons.above,
|
|
322
325
|
React.createElement(CallBar, { state: callState, call: call }),
|
|
323
|
-
React.createElement(Composer, { ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, compacting: !!state.compacting, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onStopTimed: stopTimed, onError: fail, after: speaking ? React.createElement(SpeakingButton, { onStop: hush }) : undefined, voiceSends: true, recentShots: settingsState.settings.recentShots, talkPlace: "double", draft: DraftPlaces.DOUBLE, onTalkSent: () => {
|
|
326
|
+
React.createElement(Composer, { above: React.createElement(PhoneHint, null), ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, compacting: !!state.compacting, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onStopTimed: stopTimed, onError: fail, after: speaking ? React.createElement(SpeakingButton, { onStop: hush }) : undefined, voiceSends: true, recentShots: settingsState.settings.recentShots, sendWhileWorking: sendWhileWorking, onQueueSettings: () => extensions.openSettings(QUEUE_SETTINGS), talkPlace: "double", draft: DraftPlaces.DOUBLE, onTalkSent: () => {
|
|
324
327
|
aloud.current = speakTalk;
|
|
325
328
|
}, onTalkCall: Voice.canSpeak() && Voice.canListen() && !callState.active ? talkCall(call) : undefined, talkCalls: talkCalls, onListening: on => {
|
|
326
329
|
setListening(on);
|
|
@@ -12,6 +12,7 @@ import { HeroCards, HeroCardsUtil } from '../components/hero-cards.js';
|
|
|
12
12
|
import { IconButton, SidebarLeft } from '../components/icon.js';
|
|
13
13
|
import { Loading } from '../components/loading.js';
|
|
14
14
|
import { MessageList } from '../components/message-list.js';
|
|
15
|
+
import { PhoneHint } from '../components/phone-hint.js';
|
|
15
16
|
import { useScreenArriving } from '../components/phone-shell.js';
|
|
16
17
|
import { SessionView } from '../components/session-view.js';
|
|
17
18
|
import { TaAvatar } from '../components/ta-avatar.js';
|
|
@@ -93,7 +94,7 @@ function DraftView({ draft, menu, aboveComposer, belowComposer }) {
|
|
|
93
94
|
React.createElement("div", { className: "ta-thread" }, sent ? React.createElement(MessageList, { state: sent, outbox: outbox }) : React.createElement(Hero, { cwd: draft.cwd, onPick: text => void submit(text).catch(fail) }))),
|
|
94
95
|
React.createElement("div", { className: "ta-bottom" },
|
|
95
96
|
aboveComposer,
|
|
96
|
-
React.createElement(Composer, { server: workbench.server, workspace: workbench.workspace, working: going, onStop: () => chat.stopDraft(), commands: commands, cwd: draft.cwd || undefined, onSubmit: submit, onError: fail, talkPlace: "draft", draft: DraftPlaces.NEW, recentShots: recentShots, actions: model ? [[model]] : undefined, head: going ? undefined : React.createElement(DirectoryButton, { cwd: draft.cwd, list: list, remote: workbench, onPick: cwd => chat.setDraftCwd(cwd) }) }),
|
|
97
|
+
React.createElement(Composer, { above: React.createElement(PhoneHint, null), server: workbench.server, workspace: workbench.workspace, working: going, onStop: () => chat.stopDraft(), commands: commands, cwd: draft.cwd || undefined, onSubmit: submit, onError: fail, talkPlace: "draft", draft: DraftPlaces.NEW, recentShots: recentShots, actions: model ? [[model]] : undefined, head: going ? undefined : React.createElement(DirectoryButton, { cwd: draft.cwd, list: list, remote: workbench, onPick: cwd => chat.setDraftCwd(cwd) }) }),
|
|
97
98
|
belowComposer)));
|
|
98
99
|
}
|
|
99
100
|
/** A conversation picked that is still loading, laid out as it will be: its head, a spinner, a message box that waits. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TaDeploymentUtil, type TaDeviceSignIn, type TaDeviceSignInState, type TaDistribution, type TaSignInProvider } from '@celljs/ta-protocol';
|
|
1
|
+
import { TaDeploymentUtil, type TaDeviceSignIn, type TaDeviceSignInFailure, type TaDeviceSignInState, type TaDistribution, type TaSignInProvider } from '@celljs/ta-protocol';
|
|
2
2
|
import type { Credential } from '../workbench-protocol.js';
|
|
3
3
|
/** Why signing in to Ta in the cloud stopped: the address answers no gateway, does not answer, or the code ran out. */
|
|
4
4
|
export declare class CloudSignInError extends Error {
|
|
@@ -12,7 +12,15 @@ export interface CloudSignInProgress {
|
|
|
12
12
|
waiting?: string;
|
|
13
13
|
/** The browser went straight to a way to sign in, no code to check there (CloudSignIn's `provider`). */
|
|
14
14
|
direct?: true;
|
|
15
|
+
/** The sign-in there did not go through (TaDeviceSignInState `failed`): the user starts it again from here. */
|
|
16
|
+
failed?: TaDeviceSignInFailure;
|
|
17
|
+
/** The code ran out, or the gateway lost it, and a new one is ready: the browser to be opened again. */
|
|
18
|
+
renewed?: true;
|
|
19
|
+
/** The gateway has not answered for a while (restarting, the network gone): asked on, and said so. */
|
|
20
|
+
offline?: true;
|
|
15
21
|
}
|
|
22
|
+
/** How long the gateway may not answer the polls before the sign-in says it is reconnecting. */
|
|
23
|
+
export declare const OFFLINE_MS = 6000;
|
|
16
24
|
/**
|
|
17
25
|
* Signing this device in to Ta in the cloud of a deployment, with an account (docs/design/ta-deploy.md 8.1): no code to
|
|
18
26
|
* scan, no token to paste. The gateway of the address gives a code (TA_DEVICE_SIGN_IN_PATH), the user signs in in a
|
|
@@ -61,12 +69,14 @@ export declare namespace CloudSignInUtil {
|
|
|
61
69
|
/** Where the browser signs in for the device of `code` with `provider` at once, as RFC 8628's verification_uri_complete. */
|
|
62
70
|
function direct(gateway: string, provider: string, code: string): string;
|
|
63
71
|
function start(gateway: string, name: string, fetcher?: typeof fetch): Promise<TaDeviceSignIn>;
|
|
64
|
-
/** One poll
|
|
65
|
-
function poll(gateway: string, device: string, fetcher?: typeof fetch): Promise<TaDeviceSignInState>;
|
|
72
|
+
/** One poll; undefined when the gateway did not answer (the network, a restart): nothing changed, asked again. */
|
|
73
|
+
function poll(gateway: string, device: string, fetcher?: typeof fetch): Promise<TaDeviceSignInState | undefined>;
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
68
76
|
* One sign-in to Ta in the cloud, from asking for the code until the token: it polls until then, or until stopped. What
|
|
69
|
-
* it shows goes to `onProgress`; the browser is opened by `open`.
|
|
77
|
+
* it shows goes to `onProgress`; the browser is opened by `open`. It does not end on what the user can get past from
|
|
78
|
+
* here: a sign-in that failed at the provider, the gateway away for a while, a code that ran out (`renews`) each show,
|
|
79
|
+
* and the browser opened again (`reopen`) takes it on (docs/design/ta-deploy.md 8.5).
|
|
70
80
|
*/
|
|
71
81
|
export declare class CloudSignIn {
|
|
72
82
|
protected readonly options: {
|
|
@@ -77,11 +87,16 @@ export declare class CloudSignIn {
|
|
|
77
87
|
onProgress(progress: CloudSignInProgress): void;
|
|
78
88
|
/** A way to sign in of the gateway the browser goes to at once, rather than the page that shows the code. */
|
|
79
89
|
provider?: string;
|
|
90
|
+
/** How many times a code that ran out is quietly replaced by a new one, rather than failing; none by default. */
|
|
91
|
+
renews?: number;
|
|
80
92
|
fetcher?: typeof fetch;
|
|
81
93
|
};
|
|
82
94
|
protected stopped: boolean;
|
|
83
95
|
protected timer?: ReturnType<typeof setTimeout>;
|
|
84
96
|
protected wake?: () => void;
|
|
97
|
+
protected progress?: CloudSignInProgress;
|
|
98
|
+
/** Opened again after it failed: what the gateway said before is old until it says something else. */
|
|
99
|
+
protected reopened: boolean;
|
|
85
100
|
constructor(options: {
|
|
86
101
|
gateway: string;
|
|
87
102
|
/** What the sign-ins of the account list this device as: its user agent, as a browser's. */
|
|
@@ -90,10 +105,17 @@ export declare class CloudSignIn {
|
|
|
90
105
|
onProgress(progress: CloudSignInProgress): void;
|
|
91
106
|
/** A way to sign in of the gateway the browser goes to at once, rather than the page that shows the code. */
|
|
92
107
|
provider?: string;
|
|
108
|
+
/** How many times a code that ran out is quietly replaced by a new one, rather than failing; none by default. */
|
|
109
|
+
renews?: number;
|
|
93
110
|
fetcher?: typeof fetch;
|
|
94
111
|
});
|
|
95
112
|
/** The credential of the gateway once signed in; undefined when stopped. */
|
|
96
113
|
run(): Promise<Credential | undefined>;
|
|
114
|
+
protected wait(started: TaDeviceSignIn): Promise<Credential | undefined | 'expired'>;
|
|
115
|
+
/** Tells `onProgress` once of what changed, not at every poll. */
|
|
116
|
+
protected show(change: Partial<CloudSignInProgress>): void;
|
|
117
|
+
/** Opens the browser where the user signs in again, the sign-in there started anew; at a tap of the user. */
|
|
118
|
+
reopen(): void;
|
|
97
119
|
/** Polls now rather than at the end of the wait: back from the browser. */
|
|
98
120
|
poke(): void;
|
|
99
121
|
stop(): void;
|
|
@@ -6,6 +6,8 @@ export class CloudSignInError extends Error {
|
|
|
6
6
|
this.reason = reason;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
/** How long the gateway may not answer the polls before the sign-in says it is reconnecting. */
|
|
10
|
+
export const OFFLINE_MS = 6000;
|
|
9
11
|
/**
|
|
10
12
|
* Signing this device in to Ta in the cloud of a deployment, with an account (docs/design/ta-deploy.md 8.1): no code to
|
|
11
13
|
* scan, no token to paste. The gateway of the address gives a code (TA_DEVICE_SIGN_IN_PATH), the user signs in in a
|
|
@@ -162,7 +164,7 @@ export var CloudSignInUtil;
|
|
|
162
164
|
return (await response.json());
|
|
163
165
|
}
|
|
164
166
|
CloudSignInUtil.start = start;
|
|
165
|
-
/** One poll
|
|
167
|
+
/** One poll; undefined when the gateway did not answer (the network, a restart): nothing changed, asked again. */
|
|
166
168
|
async function poll(gateway, device, fetcher = fetch) {
|
|
167
169
|
try {
|
|
168
170
|
const response = await fetcher(`${gateway}${TA_DEVICE_SIGN_IN_PATH}/poll`, {
|
|
@@ -170,36 +172,60 @@ export var CloudSignInUtil;
|
|
|
170
172
|
body: JSON.stringify({ device }),
|
|
171
173
|
signal: AbortSignal.timeout(CloudSignInUtil.GATEWAY_MS),
|
|
172
174
|
});
|
|
173
|
-
return response.ok ? (await response.json()) :
|
|
175
|
+
return response.ok ? (await response.json()) : undefined;
|
|
174
176
|
}
|
|
175
177
|
catch (_a) {
|
|
176
|
-
return
|
|
178
|
+
return undefined;
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
CloudSignInUtil.poll = poll;
|
|
180
182
|
})(CloudSignInUtil || (CloudSignInUtil = {}));
|
|
181
183
|
/**
|
|
182
184
|
* One sign-in to Ta in the cloud, from asking for the code until the token: it polls until then, or until stopped. What
|
|
183
|
-
* it shows goes to `onProgress`; the browser is opened by `open`.
|
|
185
|
+
* it shows goes to `onProgress`; the browser is opened by `open`. It does not end on what the user can get past from
|
|
186
|
+
* here: a sign-in that failed at the provider, the gateway away for a while, a code that ran out (`renews`) each show,
|
|
187
|
+
* and the browser opened again (`reopen`) takes it on (docs/design/ta-deploy.md 8.5).
|
|
184
188
|
*/
|
|
185
189
|
export class CloudSignIn {
|
|
186
190
|
constructor(options) {
|
|
187
191
|
this.options = options;
|
|
188
192
|
this.stopped = false;
|
|
193
|
+
/** Opened again after it failed: what the gateway said before is old until it says something else. */
|
|
194
|
+
this.reopened = false;
|
|
189
195
|
}
|
|
190
196
|
/** The credential of the gateway once signed in; undefined when stopped. */
|
|
191
197
|
async run() {
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
198
|
+
var _a;
|
|
199
|
+
const { gateway, fetcher, provider } = this.options;
|
|
200
|
+
for (let renewed = 0;; renewed++) {
|
|
201
|
+
if (renewed > ((_a = this.options.renews) !== null && _a !== void 0 ? _a : 0)) {
|
|
202
|
+
throw new CloudSignInError('expired');
|
|
203
|
+
}
|
|
204
|
+
const started = await CloudSignInUtil.start(gateway, this.options.name, fetcher);
|
|
205
|
+
if (this.stopped) {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
this.progress = {
|
|
209
|
+
...(provider
|
|
210
|
+
? { code: started.code, url: CloudSignInUtil.direct(gateway, provider, started.code), direct: true }
|
|
211
|
+
: { code: started.code, url: started.url }),
|
|
212
|
+
...(renewed > 0 ? { renewed: true } : {}),
|
|
213
|
+
};
|
|
214
|
+
this.reopened = false;
|
|
215
|
+
this.options.onProgress({ ...this.progress });
|
|
216
|
+
// A new code is not opened unasked: the user may be in the browser still, or away.
|
|
217
|
+
if (renewed === 0) {
|
|
218
|
+
this.options.open(this.progress.url);
|
|
219
|
+
}
|
|
220
|
+
const result = await this.wait(started);
|
|
221
|
+
if (result !== 'expired') {
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
196
224
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this.options.onProgress({ ...progress });
|
|
202
|
-
this.options.open(progress.url);
|
|
225
|
+
}
|
|
226
|
+
async wait(started) {
|
|
227
|
+
const { gateway, fetcher } = this.options;
|
|
228
|
+
let silentSince;
|
|
203
229
|
while (!this.stopped) {
|
|
204
230
|
await new Promise(resolve => {
|
|
205
231
|
this.wake = resolve;
|
|
@@ -212,19 +238,63 @@ export class CloudSignIn {
|
|
|
212
238
|
if (this.stopped) {
|
|
213
239
|
return undefined;
|
|
214
240
|
}
|
|
241
|
+
if (!state) {
|
|
242
|
+
silentSince !== null && silentSince !== void 0 ? silentSince : (silentSince = Date.now());
|
|
243
|
+
if (Date.now() - silentSince >= OFFLINE_MS) {
|
|
244
|
+
this.show({ offline: true });
|
|
245
|
+
}
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
silentSince = undefined;
|
|
249
|
+
this.show({ offline: undefined });
|
|
215
250
|
if (state.status === 'done') {
|
|
216
251
|
return { token: state.token, url: gateway };
|
|
217
252
|
}
|
|
218
253
|
if (state.status === 'expired') {
|
|
219
|
-
|
|
254
|
+
return 'expired';
|
|
220
255
|
}
|
|
221
|
-
if (state.status === '
|
|
222
|
-
|
|
223
|
-
|
|
256
|
+
if (state.status === 'failed') {
|
|
257
|
+
if (!this.reopened) {
|
|
258
|
+
this.show({ failed: state.reason });
|
|
259
|
+
}
|
|
260
|
+
continue;
|
|
224
261
|
}
|
|
262
|
+
this.reopened = false;
|
|
263
|
+
this.show({ failed: undefined, ...(state.status === 'waiting' ? { waiting: state.account } : {}) });
|
|
225
264
|
}
|
|
226
265
|
return undefined;
|
|
227
266
|
}
|
|
267
|
+
/** Tells `onProgress` once of what changed, not at every poll. */
|
|
268
|
+
show(change) {
|
|
269
|
+
const progress = this.progress;
|
|
270
|
+
if (!progress) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
let changed = false;
|
|
274
|
+
for (const [key, value] of Object.entries(change)) {
|
|
275
|
+
if (progress[key] !== value) {
|
|
276
|
+
changed = true;
|
|
277
|
+
if (value === undefined) {
|
|
278
|
+
delete progress[key];
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
progress[key] = value;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (changed) {
|
|
286
|
+
this.options.onProgress({ ...progress });
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/** Opens the browser where the user signs in again, the sign-in there started anew; at a tap of the user. */
|
|
290
|
+
reopen() {
|
|
291
|
+
if (!this.progress) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
this.reopened = Boolean(this.progress.failed);
|
|
295
|
+
this.show({ failed: undefined, renewed: undefined });
|
|
296
|
+
this.options.open(this.progress.url);
|
|
297
|
+
}
|
|
228
298
|
/** Polls now rather than at the end of the wait: back from the browser. */
|
|
229
299
|
poke() {
|
|
230
300
|
var _a;
|
|
@@ -35,6 +35,8 @@ export interface RailProps {
|
|
|
35
35
|
onDismissAsks?(): void;
|
|
36
36
|
/** A chat said something unseen: the amber dot on the double's entry, as on a phone's first tab; dragged away, all seen. */
|
|
37
37
|
onSeeAll?(): void;
|
|
38
|
+
/** How many messages people sent the user has not seen: a red number on the double's entry, before all else; dragged away, all seen (onSeeAll). */
|
|
39
|
+
count?: number;
|
|
38
40
|
/** A double click where nothing is: the sidebar and the workbench both go, or both come back. */
|
|
39
41
|
onToggleSides?(): void;
|
|
40
42
|
}
|
|
@@ -43,7 +45,7 @@ export interface RailProps {
|
|
|
43
45
|
* once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
|
|
44
46
|
* Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
|
|
45
47
|
*/
|
|
46
|
-
export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, onToggleSides, }: RailProps): React.JSX.Element;
|
|
48
|
+
export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, count, onToggleSides, }: RailProps): React.JSX.Element;
|
|
47
49
|
/** A sidebar view of a web extension, under its title or its own top bar. */
|
|
48
50
|
export declare function SidebarView({ view }: {
|
|
49
51
|
view: WebViewEntry;
|
|
@@ -8,7 +8,7 @@ import { useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
|
|
|
8
8
|
import { useT } from '../i18n/use-t.js';
|
|
9
9
|
import { NavigationUtil } from '../settings/navigation.js';
|
|
10
10
|
import { AccountMenu } from './account-menu.js';
|
|
11
|
-
import { AsksBadge } from './asks-badge.js';
|
|
11
|
+
import { AsksBadge, PeopleBadge } from './asks-badge.js';
|
|
12
12
|
import { ConnectionBanner } from './connection-bar.js';
|
|
13
13
|
import { useContextMenu } from './context-menu.js';
|
|
14
14
|
import { Dino } from './dino.js';
|
|
@@ -51,7 +51,7 @@ function RailItem({ label, place, active, onClick, onContextMenu, onPointerDown,
|
|
|
51
51
|
* once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
|
|
52
52
|
* Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
|
|
53
53
|
*/
|
|
54
|
-
export function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, onToggleSides, }) {
|
|
54
|
+
export function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, count, onToggleSides, }) {
|
|
55
55
|
const t = useT();
|
|
56
56
|
const [{ server }] = useWorkbench();
|
|
57
57
|
const [menu, openMenu] = useContextMenu();
|
|
@@ -77,7 +77,7 @@ export function Rail({ lists, list, onList, navigation, current, onPage, onDisco
|
|
|
77
77
|
lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, place: `list:${entry.id}`, active: list === entry.id, onClick: () => onList(entry.id), ...held(entryHold(entry.id, entry.double, holds)) },
|
|
78
78
|
entry.double ? React.createElement(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 }),
|
|
79
79
|
entry.double &&
|
|
80
|
-
(asks ? (React.createElement(AsksBadge, { count: asks, onDismiss: onDismissAsks })) : (onSeeAll && React.createElement(UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: onSeeAll, className: "ta-tabbar-dot ta-rail-dot" })))))),
|
|
80
|
+
(count ? (React.createElement(PeopleBadge, { count: count, onDismiss: onSeeAll })) : asks ? (React.createElement(AsksBadge, { count: asks, onDismiss: onDismissAsks })) : (onSeeAll && React.createElement(UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: onSeeAll, className: "ta-tabbar-dot ta-rail-dot" })))))),
|
|
81
81
|
(navigation.nav.length > 0 || discover) && React.createElement("hr", { className: "ta-rail-divider" }),
|
|
82
82
|
navigation.nav.map(view => item(view)),
|
|
83
83
|
discover && (React.createElement(RailItem, { label: t('ta.discover'), place: "discover", active: !settingsShown && current === DISCOVER, onClick: onDiscover, onContextMenu: event => openMenu(event, [settingsItem]) },
|
|
@@ -19,6 +19,7 @@ import { CARDS_ID, EDITOR, FIRST_SIDE, SETTINGS_SHOWN, SIDE, SIDEBAR, TAB_PAGE,
|
|
|
19
19
|
import { useSurfaces } from './board.js';
|
|
20
20
|
import { LET_GO_ASKS } from './chat-asks.js';
|
|
21
21
|
import { BY_DIRECTORY, FOLDED, PINNED } from './chat-list-util.js';
|
|
22
|
+
import { FirstStepsUtil } from './first-steps-util.js';
|
|
22
23
|
import { DISCOVER } from './nav-places.js';
|
|
23
24
|
import { DOUBLE_PAGE, SideListUtil } from './side-lists.js';
|
|
24
25
|
import { usePane } from './split-pane.js';
|
|
@@ -109,10 +110,20 @@ export function useAppShell() {
|
|
|
109
110
|
}, [offline, host]);
|
|
110
111
|
/** The conversation the page opens with is shown: those shown after are the user's doing. */
|
|
111
112
|
const started = React.useRef(false);
|
|
113
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: once a connection, with what the page has then
|
|
112
114
|
React.useEffect(() => {
|
|
113
115
|
if (online) {
|
|
114
116
|
void chat.start().then(() => {
|
|
115
117
|
started.current = true;
|
|
118
|
+
const { sessions, saved } = bench.state;
|
|
119
|
+
if (FirstStepsUtil.startOnDouble({
|
|
120
|
+
phone,
|
|
121
|
+
page: host.state.page,
|
|
122
|
+
conversation: !!chat.state.store,
|
|
123
|
+
answered: FirstStepsUtil.answered(sessions, saved),
|
|
124
|
+
})) {
|
|
125
|
+
host.showPage(DOUBLE_PAGE);
|
|
126
|
+
}
|
|
116
127
|
});
|
|
117
128
|
}
|
|
118
129
|
}, [online, chat]);
|
|
@@ -2,6 +2,7 @@ import { ChevronLeft } from 'lucide-react';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { AssistantChatList } from '../assistant/assistant-chat-list.js';
|
|
4
4
|
import { ChatView } from '../chat/chat-view.js';
|
|
5
|
+
import { AppBadge } from '../device/app-badge.js';
|
|
5
6
|
import { WebCwdUtil } from '../extension/web-extension-protocol.js';
|
|
6
7
|
import { usePersisted } from '../hooks.js';
|
|
7
8
|
import { SIGN_IN_EVENT, SIGNED_IN_EVENT } from '../notices/notices.js';
|
|
@@ -10,6 +11,7 @@ import { PageView, Rail, SidebarView } from './app-nav.js';
|
|
|
10
11
|
import { LOGIN_LATER, RAIL } from './app-shell-hooks.js';
|
|
11
12
|
import { useAppShell } from './app-shell-state.js';
|
|
12
13
|
import { AppUpdateNotices } from './app-update-view.js';
|
|
14
|
+
import { CountUtil } from './asks-badge.js';
|
|
13
15
|
import { AuthUtil, LoginPage, useAuthProviders } from './auth-view.js';
|
|
14
16
|
import { BoardSurface } from './board.js';
|
|
15
17
|
import { ChatAskUtil } from './chat-asks.js';
|
|
@@ -89,7 +91,7 @@ export function AppShell() {
|
|
|
89
91
|
// The chats' tab, and the double's on the rail, have the amber dot while a row of the double's list has one, as a
|
|
90
92
|
// messenger's; what waits for the user to decide is counted there until answered.
|
|
91
93
|
useFirstSteps(workbench.status === 'online', workbench.sessions, workbench.saved);
|
|
92
|
-
const { listed: listedChats, unseen: chatsUnseen } = useChatsDot({
|
|
94
|
+
const { listed: listedChats, unseen: chatsUnseen, count: chatsCount, seePeople, } = useChatsDot({
|
|
93
95
|
sessions: workbench.sessions,
|
|
94
96
|
saved: workbench.saved,
|
|
95
97
|
removed: removedChats,
|
|
@@ -101,6 +103,11 @@ export function AppShell() {
|
|
|
101
103
|
extensions,
|
|
102
104
|
host,
|
|
103
105
|
});
|
|
106
|
+
// As a messenger's: the messages of people unseen on the title of the tab and on the icon of Ta Desktop.
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
document.title = chatsCount ? `(${CountUtil.text(chatsCount)}) Ta` : 'Ta';
|
|
109
|
+
AppBadge.set(chatsCount);
|
|
110
|
+
}, [chatsCount]);
|
|
104
111
|
if (workbench.status === 'signed-out') {
|
|
105
112
|
return workbench.leaving ? React.createElement("div", { className: "ta-signin" }) : React.createElement(SignIn, { error: workbench.error });
|
|
106
113
|
}
|
|
@@ -240,8 +247,11 @@ export function AppShell() {
|
|
|
240
247
|
picked();
|
|
241
248
|
},
|
|
242
249
|
});
|
|
243
|
-
// Dragged away, the dot of the chats: all seen.
|
|
244
|
-
const seeAllChats = () =>
|
|
250
|
+
// Dragged away, the dot or the red number of the chats: all seen, what people said too, as WeChat's.
|
|
251
|
+
const seeAllChats = () => {
|
|
252
|
+
state.set(SEEN_CHATS, ChatSeenUtil.seeAll(state.get(SEEN_CHATS), listedChats, Date.now()));
|
|
253
|
+
seePeople();
|
|
254
|
+
};
|
|
245
255
|
// Dragged away, the count of the double: what the conversations ask let go; the double's own tasks wait on.
|
|
246
256
|
const letGoAllAsks = () => setLetGoAsks(before => ChatAskUtil.letGoAll(before, listedChats));
|
|
247
257
|
const tabs = phone
|
|
@@ -251,8 +261,8 @@ export function AppShell() {
|
|
|
251
261
|
fold: t('ta.nav.fold'),
|
|
252
262
|
settings: { label: t('ta.nav.settings'), run: () => openSettings('navigation') },
|
|
253
263
|
holds,
|
|
254
|
-
}).map(item => item.id === '' && chatsUnseen
|
|
255
|
-
? { ...item, unseen: true, onSeeAll: seeAllChats }
|
|
264
|
+
}).map(item => item.id === '' && (chatsUnseen || chatsCount)
|
|
265
|
+
? { ...item, unseen: true, count: chatsCount, onSeeAll: seeAllChats }
|
|
256
266
|
: item.double && deciding
|
|
257
267
|
? { ...item, asks: deciding, onSeeAll: letGoAllAsks }
|
|
258
268
|
: item)
|
|
@@ -287,7 +297,7 @@ export function AppShell() {
|
|
|
287
297
|
setSettings(undefined);
|
|
288
298
|
setNavOpen(false);
|
|
289
299
|
setTabPage('discover');
|
|
290
|
-
}, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds, asks: deciding, onDismissAsks: letGoAllAsks, onSeeAll: chatsUnseen ? seeAllChats : undefined, onToggleSides: toggleSides }),
|
|
300
|
+
}, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds, asks: deciding, onDismissAsks: letGoAllAsks, onSeeAll: chatsUnseen || chatsCount ? seeAllChats : undefined, count: chatsCount, onToggleSides: toggleSides }),
|
|
291
301
|
sideShown && (React.createElement(SidebarPane, { style: paneStyle(sidebar) },
|
|
292
302
|
sideList,
|
|
293
303
|
React.createElement(Sash, { pane: sidebar, side: "start", label: t('ta.layout.sidebar') })))),
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
export declare namespace CountUtil {
|
|
3
|
+
/** A count on a badge, as a messenger shows it: past 99, 99+. */
|
|
4
|
+
function text(count: number): string;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* How many conversations wait for the user to decide, on the entry of the chats (a tab, the rail): blue, as their ? on
|
|
4
8
|
* the rows. Dragged away as the amber dot (UnseenDrop), all of them are let go and seen (`onDismiss`).
|
|
@@ -7,3 +11,11 @@ export declare function AsksBadge({ count, onDismiss }: {
|
|
|
7
11
|
count: number;
|
|
8
12
|
onDismiss?: () => void;
|
|
9
13
|
}): React.JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* How many messages people sent the user has not seen (PartnersUtil.counted), on the entry of the chats: red, as the
|
|
16
|
+
* numbers of their rows and WeChat's tab. Dragged away as the amber dot (UnseenDrop), all is seen (`onDismiss`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function PeopleBadge({ count, onDismiss }: {
|
|
19
|
+
count: number;
|
|
20
|
+
onDismiss?: () => void;
|
|
21
|
+
}): React.JSX.Element;
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useT } from '../i18n/use-t.js';
|
|
3
3
|
import { UnseenDrop } from './unseen-drop.js';
|
|
4
|
+
export var CountUtil;
|
|
5
|
+
(function (CountUtil) {
|
|
6
|
+
/** A count on a badge, as a messenger shows it: past 99, 99+. */
|
|
7
|
+
function text(count) {
|
|
8
|
+
return count > 99 ? '99+' : String(count);
|
|
9
|
+
}
|
|
10
|
+
CountUtil.text = text;
|
|
11
|
+
})(CountUtil || (CountUtil = {}));
|
|
4
12
|
/**
|
|
5
13
|
* How many conversations wait for the user to decide, on the entry of the chats (a tab, the rail): blue, as their ? on
|
|
6
14
|
* the rows. Dragged away as the amber dot (UnseenDrop), all of them are let go and seen (`onDismiss`).
|
|
7
15
|
*/
|
|
8
16
|
export function AsksBadge({ count, onDismiss }) {
|
|
9
17
|
const t = useT();
|
|
10
|
-
return (React.createElement(UnseenDrop, { label: t('ta.chat.asksCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge", tone: "asks" }, count
|
|
18
|
+
return (React.createElement(UnseenDrop, { label: t('ta.chat.asksCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge", tone: "asks" }, CountUtil.text(count)));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* How many messages people sent the user has not seen (PartnersUtil.counted), on the entry of the chats: red, as the
|
|
22
|
+
* numbers of their rows and WeChat's tab. Dragged away as the amber dot (UnseenDrop), all is seen (`onDismiss`).
|
|
23
|
+
*/
|
|
24
|
+
export function PeopleBadge({ count, onDismiss }) {
|
|
25
|
+
const t = useT();
|
|
26
|
+
return (React.createElement(UnseenDrop, { label: t('ta.chat.unseenCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge ta-people", tone: "people" }, CountUtil.text(count)));
|
|
11
27
|
}
|
|
12
28
|
//# sourceMappingURL=asks-badge.js.map
|
|
@@ -69,11 +69,14 @@ export declare function ChatAvatar({ session, source, who, size, mood }: {
|
|
|
69
69
|
* Always there, so that it grows in and goes, the avatar never drawn again; told only while it is on. A conversation
|
|
70
70
|
* that waits for the user to decide has a blue ? instead, over an amber dot: seeing it does not end it, answering does.
|
|
71
71
|
* The amber dot drags away as a drop (UnseenDrop), as a messenger's unread: let go past its neck, it is seen (`onSee`).
|
|
72
|
+
* Messages of people (a friend, a group chat) have their `count` instead, a red number on the face, as WeChat's: what a
|
|
73
|
+
* person said reaches the user before what an agent answered.
|
|
72
74
|
*/
|
|
73
|
-
export declare function ChatDot({ unseen, asks, onSee }: {
|
|
75
|
+
export declare function ChatDot({ unseen, asks, onSee, count }: {
|
|
74
76
|
unseen: boolean;
|
|
75
77
|
asks: boolean;
|
|
76
78
|
onSee?: () => void;
|
|
79
|
+
count?: number;
|
|
77
80
|
}): React.JSX.Element;
|
|
78
81
|
/**
|
|
79
82
|
* The row of a folder (WebChatIcon.folder), as a messenger folds its subscriptions: its icon, its title, and the latest
|