@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
|
@@ -4,10 +4,14 @@ export interface ImageShrinkLimits {
|
|
|
4
4
|
side: number;
|
|
5
5
|
bytes: number;
|
|
6
6
|
}
|
|
7
|
-
/** A picture as an extension gets it from the box: its type, base64 and size in pixels. */
|
|
7
|
+
/** A picture as an extension gets it from the box: its type, base64 and size in pixels; the picture picked when made smaller. */
|
|
8
8
|
export interface ShrunkImage extends ComposerImage {
|
|
9
9
|
width: number;
|
|
10
10
|
height: number;
|
|
11
|
+
original?: ComposerImage & {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
11
15
|
}
|
|
12
16
|
/** Pictures of the box made lighter in the page, for what keeps them or sends them on (a group chat, its agents). */
|
|
13
17
|
export declare namespace ImageShrink {
|
|
@@ -45,7 +45,7 @@ export var ImageShrink;
|
|
|
45
45
|
for (const quality of QUALITIES) {
|
|
46
46
|
const data = canvas.toDataURL('image/jpeg', quality).replace(/^data:[^,]*,/, '');
|
|
47
47
|
if (bytes(data) <= limits.bytes) {
|
|
48
|
-
return { type: 'image', data, mimeType: 'image/jpeg', ...size };
|
|
48
|
+
return { type: 'image', data, mimeType: 'image/jpeg', ...size, original: { ...image, ...natural } };
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LocalRefs } from '@celljs/ta-protocol/lib/common/local-refs';
|
|
1
2
|
/** A block of markdown. */
|
|
2
3
|
export type MarkdownBlock = {
|
|
3
4
|
type: 'paragraph';
|
|
@@ -151,9 +152,6 @@ export declare namespace MarkdownUtil {
|
|
|
151
152
|
* show nothing, as `javascript:`; without `guess`, also for a target whose extension is not known.
|
|
152
153
|
*/
|
|
153
154
|
function media(src: string, guess?: boolean): MediaKind | undefined;
|
|
154
|
-
/**
|
|
155
|
-
|
|
156
|
-
* undefined for URLs, which the page loads as they are.
|
|
157
|
-
*/
|
|
158
|
-
function localPath(src: string): string | undefined;
|
|
155
|
+
/** The path of a file a target names (LocalRefs.localPath); undefined for URLs, which the page loads as they are. */
|
|
156
|
+
const localPath: typeof LocalRefs.localPath;
|
|
159
157
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LocalRefs } from '@celljs/ta-protocol/lib/common/local-refs';
|
|
1
2
|
import { LinkUtil } from './link.js';
|
|
2
3
|
export const CALLOUT_KINDS = ['note', 'tip', 'important', 'warning', 'caution'];
|
|
3
4
|
export const MARKDOWN_TINTS = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'gray'];
|
|
@@ -7,7 +8,6 @@ const RULE = /^\s*([-*_])(\s*\1){2,}\s*$/;
|
|
|
7
8
|
const BULLET = /^\s*[-*+]\s+(.*)$/;
|
|
8
9
|
const NUMBERED = /^\s*\d+[.)]\s+(.*)$/;
|
|
9
10
|
const TABLE_SEPARATOR = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
|
|
10
|
-
const SCHEME = /^[a-z][a-z\d+.-]*:/i;
|
|
11
11
|
/** Data URLs of media, which show without a request; scripts in an SVG image do not run. */
|
|
12
12
|
const DATA_MEDIA = /^data:(image|video|audio)\/[\w.+-]+[;,]/i;
|
|
13
13
|
const EXTENSIONS = {
|
|
@@ -379,7 +379,7 @@ export var MarkdownUtil;
|
|
|
379
379
|
if (link) {
|
|
380
380
|
const href = (_d = link[2]) !== null && _d !== void 0 ? _d : link[3];
|
|
381
381
|
const target = LinkUtil.parse(href);
|
|
382
|
-
if ((target === null || target === void 0 ? void 0 : target.type) === 'path' && !target.selection && localPath(href) !== undefined && media(href, false)) {
|
|
382
|
+
if ((target === null || target === void 0 ? void 0 : target.type) === 'path' && !target.selection && MarkdownUtil.localPath(href) !== undefined && media(href, false)) {
|
|
383
383
|
// A link to a picture or a video of the workspace shows it.
|
|
384
384
|
push({ type: 'media', src: href, alt: link[1] });
|
|
385
385
|
}
|
|
@@ -429,39 +429,15 @@ export var MarkdownUtil;
|
|
|
429
429
|
if (data) {
|
|
430
430
|
return data[1].toLowerCase();
|
|
431
431
|
}
|
|
432
|
-
if (!/^https?:/i.test(src) && localPath(src) === undefined) {
|
|
432
|
+
if (!/^https?:/i.test(src) && MarkdownUtil.localPath(src) === undefined) {
|
|
433
433
|
return undefined;
|
|
434
434
|
}
|
|
435
435
|
const extension = (_a = /\.(\w+)$/.exec(src.split(/[?#]/)[0])) === null || _a === void 0 ? void 0 : _a[1].toLowerCase();
|
|
436
436
|
return (extension && EXTENSIONS[extension]) || (guess ? 'image' : undefined);
|
|
437
437
|
}
|
|
438
438
|
MarkdownUtil.media = media;
|
|
439
|
-
/**
|
|
440
|
-
|
|
441
|
-
* undefined for URLs, which the page loads as they are.
|
|
442
|
-
*/
|
|
443
|
-
function localPath(src) {
|
|
444
|
-
let path = src;
|
|
445
|
-
if (/^file:/i.test(src)) {
|
|
446
|
-
const url = /^file:\/\/(?:localhost)?(\/[^?#]*)/i.exec(src);
|
|
447
|
-
if (!url) {
|
|
448
|
-
return undefined;
|
|
449
|
-
}
|
|
450
|
-
path = url[1];
|
|
451
|
-
}
|
|
452
|
-
else if (SCHEME.test(src) || src.startsWith('//')) {
|
|
453
|
-
return undefined;
|
|
454
|
-
}
|
|
455
|
-
path = path.split(/[?#]/)[0];
|
|
456
|
-
try {
|
|
457
|
-
path = decodeURI(path);
|
|
458
|
-
}
|
|
459
|
-
catch (_a) {
|
|
460
|
-
// Kept as written.
|
|
461
|
-
}
|
|
462
|
-
return path || undefined;
|
|
463
|
-
}
|
|
464
|
-
MarkdownUtil.localPath = localPath;
|
|
439
|
+
/** The path of a file a target names (LocalRefs.localPath); undefined for URLs, which the page loads as they are. */
|
|
440
|
+
MarkdownUtil.localPath = LocalRefs.localPath;
|
|
465
441
|
/** `$$` or `\\[` starting at line `start`: its block and the line it ends on. */
|
|
466
442
|
function mathBlock(lines, start) {
|
|
467
443
|
const first = lines[start].trim();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TA_RESUME_MESSAGE, TaAgentSummary, TaMessageSource, TaPictureNote, TaSaid } from '@celljs/ta-protocol';
|
|
1
|
+
import { TA_RESUME_MESSAGE, TaAgentSummary, TaMessageContext, TaMessageSource, TaPictureNote, TaSaid, TaToolLeak } from '@celljs/ta-protocol';
|
|
2
2
|
import { MessageUtil } from './message.js';
|
|
3
3
|
/** While the agent works, only the latest steps show; the earlier ones fold into one row. */
|
|
4
4
|
export const VISIBLE_STEPS = 8;
|
|
@@ -195,7 +195,7 @@ export var ProcessUtil;
|
|
|
195
195
|
steps.push({ kind: 'summary', key, text: summary });
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
|
-
const { said, told } = TaPictureNote.take(block.text);
|
|
198
|
+
const { said, told } = TaPictureNote.take(TaMessageContext.echoed(TaToolLeak.strip(block.text)));
|
|
199
199
|
if (told.size) {
|
|
200
200
|
steps.push({ kind: 'pictures', key: `${key}.p`, told: [...told] });
|
|
201
201
|
}
|
|
@@ -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
|
|
@@ -5,7 +5,7 @@ exports.assistantRole = assistantRole;
|
|
|
5
5
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
6
6
|
/** The role of ta in its conversation with the user. */
|
|
7
7
|
exports.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.
|
|
8
|
-
- 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.
|
|
8
|
+
- 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.
|
|
9
9
|
- 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.
|
|
10
10
|
- 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.
|
|
11
11
|
- 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.
|
|
@@ -18,6 +18,11 @@ function activity(task, state, t) {
|
|
|
18
18
|
if (task.paused && task.status !== 'running') {
|
|
19
19
|
return t('ta.task.paused');
|
|
20
20
|
}
|
|
21
|
+
// Not done because its reply came to nothing (filtered, empty): why, in the user's language.
|
|
22
|
+
const deadEnd = task.status === 'failed' ? ta_protocol_1.TaDeadEnd.describedKind(task.result) : undefined;
|
|
23
|
+
if (deadEnd) {
|
|
24
|
+
return t(deadEnd === 'empty' ? 'ta.task.deadEndEmpty' : 'ta.task.deadEndFiltered');
|
|
25
|
+
}
|
|
21
26
|
return task.status === 'running' ? t('ta.task.running') : ta_protocol_1.TaSaid.line(said !== null && said !== void 0 ? said : '', { chars: 80 }) || t(`ta.task.${task.status}`);
|
|
22
27
|
}
|
|
23
28
|
/** 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): {
|
|
@@ -106,9 +106,12 @@ var AssistantTaskUtil;
|
|
|
106
106
|
var _a, _b, _c;
|
|
107
107
|
const last = lastAnswer(state.messages);
|
|
108
108
|
const reason = message_1.MessageUtil.stopReason(last);
|
|
109
|
+
// A reply that came to nothing (filtered, refused, empty) is no answer: not done, and its words are not the result.
|
|
110
|
+
const deadEnd = ta_protocol_1.TaDeadEnd.kind({ role: 'assistant', ...last });
|
|
109
111
|
// Its last answer asked for a tool, whose result never came: the run was cut, not done.
|
|
110
|
-
const status = state.closed || reason === 'aborted' || reason === 'toolUse' ? 'stopped' : reason === 'error' ? 'failed' : 'done';
|
|
111
|
-
const
|
|
112
|
+
const status = state.closed || reason === 'aborted' || reason === 'toolUse' ? 'stopped' : reason === 'error' || deadEnd ? 'failed' : 'done';
|
|
113
|
+
const failure = deadEnd ? ta_protocol_1.TaDeadEnd.describe(deadEnd, last === null || last === void 0 ? void 0 : last.errorMessage) : last === null || last === void 0 ? void 0 : last.errorMessage;
|
|
114
|
+
const result = (_b = (_a = (status === 'failed' ? failure : undefined)) !== null && _a !== void 0 ? _a : lastWords(state.messages)) !== null && _b !== void 0 ? _b : '';
|
|
112
115
|
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}` };
|
|
113
116
|
}
|
|
114
117
|
AssistantTaskUtil.outcome = outcome;
|
|
@@ -122,6 +125,9 @@ var AssistantTaskUtil;
|
|
|
122
125
|
function updateNote(task) {
|
|
123
126
|
var _a, _b;
|
|
124
127
|
const lines = [((_a = task.result) !== null && _a !== void 0 ? _a : '').slice(0, RESULT_CHARS)];
|
|
128
|
+
if (task.status === 'failed' && ta_protocol_1.TaDeadEnd.described(task.result)) {
|
|
129
|
+
lines.push('Do not start it again on your own: tell the user it is not done and why, and let them decide.');
|
|
130
|
+
}
|
|
125
131
|
if (task.paused) {
|
|
126
132
|
lines.push('The user paused it, with the other tasks that ran: leave it until they resume it.');
|
|
127
133
|
}
|
|
@@ -54,6 +54,7 @@ const loading_1 = require("../components/loading");
|
|
|
54
54
|
const message_actions_1 = require("../components/message-actions");
|
|
55
55
|
const message_footer_1 = require("../components/message-footer");
|
|
56
56
|
const message_images_1 = require("../components/message-images");
|
|
57
|
+
const phone_hint_1 = require("../components/phone-hint");
|
|
57
58
|
const session_settings_1 = require("../components/session-settings");
|
|
58
59
|
const ta_avatar_1 = require("../components/ta-avatar");
|
|
59
60
|
const use_stop_times_1 = require("../components/use-stop-times");
|
|
@@ -62,6 +63,7 @@ const workbench_toggle_1 = require("../components/workbench-toggle");
|
|
|
62
63
|
const drafts_protocol_1 = require("../drafts/drafts-protocol");
|
|
63
64
|
const hooks_1 = require("../hooks");
|
|
64
65
|
const use_t_1 = require("../i18n/use-t");
|
|
66
|
+
const agent_settings_1 = require("../settings/agent-settings");
|
|
65
67
|
const message_1 = require("../util/message");
|
|
66
68
|
const assistant_hooks_1 = require("./assistant-hooks");
|
|
67
69
|
const assistant_state_1 = require("./assistant-state");
|
|
@@ -136,7 +138,8 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
136
138
|
const [, notices] = (0, hooks_1.useNotices)();
|
|
137
139
|
const spoken = React.useRef(undefined);
|
|
138
140
|
const box = React.useRef(null);
|
|
139
|
-
const { speak, speakTalk, confirmTasks, delegate, voice } = settingsState.settings;
|
|
141
|
+
const { speak, speakTalk, confirmTasks, delegate, voice, sendWhileWorking } = settingsState.settings;
|
|
142
|
+
const [, extensions] = (0, hooks_1.useWebExtensions)();
|
|
140
143
|
const [name] = (0, hooks_1.usePersisted)(assistant_state_1.ASSISTANT_NAME_STATE);
|
|
141
144
|
const attentions = [
|
|
142
145
|
...state.pendingUi.map(request => ({ source: 'ta', store, request })),
|
|
@@ -361,7 +364,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
361
364
|
React.createElement(connection_bar_1.ConnectionBanner, null),
|
|
362
365
|
addons.above,
|
|
363
366
|
React.createElement(voice_call_bar_1.CallBar, { state: callState, call: call }),
|
|
364
|
-
React.createElement(composer_1.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(voice_button_1.SpeakingButton, { onStop: hush }) : undefined, voiceSends: true, recentShots: settingsState.settings.recentShots, talkPlace: "double", draft: drafts_protocol_1.DraftPlaces.DOUBLE, onTalkSent: () => {
|
|
367
|
+
React.createElement(composer_1.Composer, { above: React.createElement(phone_hint_1.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(voice_button_1.SpeakingButton, { onStop: hush }) : undefined, voiceSends: true, recentShots: settingsState.settings.recentShots, sendWhileWorking: sendWhileWorking, onQueueSettings: () => extensions.openSettings(agent_settings_1.QUEUE_SETTINGS), talkPlace: "double", draft: drafts_protocol_1.DraftPlaces.DOUBLE, onTalkSent: () => {
|
|
365
368
|
aloud.current = speakTalk;
|
|
366
369
|
}, onTalkCall: voice_1.Voice.canSpeak() && voice_1.Voice.canListen() && !callState.active ? (0, voice_call_bar_1.talkCall)(call) : undefined, talkCalls: talkCalls, onListening: on => {
|
|
367
370
|
setListening(on);
|
|
@@ -50,6 +50,7 @@ const hero_cards_1 = require("../components/hero-cards");
|
|
|
50
50
|
const icon_1 = require("../components/icon");
|
|
51
51
|
const loading_1 = require("../components/loading");
|
|
52
52
|
const message_list_1 = require("../components/message-list");
|
|
53
|
+
const phone_hint_1 = require("../components/phone-hint");
|
|
53
54
|
const phone_shell_1 = require("../components/phone-shell");
|
|
54
55
|
const session_view_1 = require("../components/session-view");
|
|
55
56
|
const ta_avatar_1 = require("../components/ta-avatar");
|
|
@@ -131,7 +132,7 @@ function DraftView({ draft, menu, aboveComposer, belowComposer }) {
|
|
|
131
132
|
React.createElement("div", { className: "ta-thread" }, sent ? React.createElement(message_list_1.MessageList, { state: sent, outbox: outbox }) : React.createElement(Hero, { cwd: draft.cwd, onPick: text => void submit(text).catch(fail) }))),
|
|
132
133
|
React.createElement("div", { className: "ta-bottom" },
|
|
133
134
|
aboveComposer,
|
|
134
|
-
React.createElement(composer_1.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: drafts_protocol_1.DraftPlaces.NEW, recentShots: recentShots, actions: model ? [[model]] : undefined, head: going ? undefined : React.createElement(folder_picker_1.DirectoryButton, { cwd: draft.cwd, list: list, remote: workbench, onPick: cwd => chat.setDraftCwd(cwd) }) }),
|
|
135
|
+
React.createElement(composer_1.Composer, { above: React.createElement(phone_hint_1.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: drafts_protocol_1.DraftPlaces.NEW, recentShots: recentShots, actions: model ? [[model]] : undefined, head: going ? undefined : React.createElement(folder_picker_1.DirectoryButton, { cwd: draft.cwd, list: list, remote: workbench, onPick: cwd => chat.setDraftCwd(cwd) }) }),
|
|
135
136
|
belowComposer)));
|
|
136
137
|
}
|
|
137
138
|
/** 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';
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CloudSignIn = exports.CloudSignInUtil = exports.CloudSignInError = void 0;
|
|
3
|
+
exports.CloudSignIn = exports.CloudSignInUtil = exports.OFFLINE_MS = exports.CloudSignInError = void 0;
|
|
4
4
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
5
5
|
/** Why signing in to Ta in the cloud stopped: the address answers no gateway, does not answer, or the code ran out. */
|
|
6
6
|
class CloudSignInError extends Error {
|
|
@@ -10,6 +10,8 @@ class CloudSignInError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
exports.CloudSignInError = CloudSignInError;
|
|
13
|
+
/** How long the gateway may not answer the polls before the sign-in says it is reconnecting. */
|
|
14
|
+
exports.OFFLINE_MS = 6000;
|
|
13
15
|
/**
|
|
14
16
|
* 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
|
|
15
17
|
* scan, no token to paste. The gateway of the address gives a code (TA_DEVICE_SIGN_IN_PATH), the user signs in in a
|
|
@@ -166,7 +168,7 @@ var CloudSignInUtil;
|
|
|
166
168
|
return (await response.json());
|
|
167
169
|
}
|
|
168
170
|
CloudSignInUtil.start = start;
|
|
169
|
-
/** One poll
|
|
171
|
+
/** One poll; undefined when the gateway did not answer (the network, a restart): nothing changed, asked again. */
|
|
170
172
|
async function poll(gateway, device, fetcher = fetch) {
|
|
171
173
|
try {
|
|
172
174
|
const response = await fetcher(`${gateway}${ta_protocol_1.TA_DEVICE_SIGN_IN_PATH}/poll`, {
|
|
@@ -174,36 +176,60 @@ var CloudSignInUtil;
|
|
|
174
176
|
body: JSON.stringify({ device }),
|
|
175
177
|
signal: AbortSignal.timeout(CloudSignInUtil.GATEWAY_MS),
|
|
176
178
|
});
|
|
177
|
-
return response.ok ? (await response.json()) :
|
|
179
|
+
return response.ok ? (await response.json()) : undefined;
|
|
178
180
|
}
|
|
179
181
|
catch (_a) {
|
|
180
|
-
return
|
|
182
|
+
return undefined;
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
CloudSignInUtil.poll = poll;
|
|
184
186
|
})(CloudSignInUtil || (exports.CloudSignInUtil = CloudSignInUtil = {}));
|
|
185
187
|
/**
|
|
186
188
|
* One sign-in to Ta in the cloud, from asking for the code until the token: it polls until then, or until stopped. What
|
|
187
|
-
* it shows goes to `onProgress`; the browser is opened by `open`.
|
|
189
|
+
* it shows goes to `onProgress`; the browser is opened by `open`. It does not end on what the user can get past from
|
|
190
|
+
* here: a sign-in that failed at the provider, the gateway away for a while, a code that ran out (`renews`) each show,
|
|
191
|
+
* and the browser opened again (`reopen`) takes it on (docs/design/ta-deploy.md 8.5).
|
|
188
192
|
*/
|
|
189
193
|
class CloudSignIn {
|
|
190
194
|
constructor(options) {
|
|
191
195
|
this.options = options;
|
|
192
196
|
this.stopped = false;
|
|
197
|
+
/** Opened again after it failed: what the gateway said before is old until it says something else. */
|
|
198
|
+
this.reopened = false;
|
|
193
199
|
}
|
|
194
200
|
/** The credential of the gateway once signed in; undefined when stopped. */
|
|
195
201
|
async run() {
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
var _a;
|
|
203
|
+
const { gateway, fetcher, provider } = this.options;
|
|
204
|
+
for (let renewed = 0;; renewed++) {
|
|
205
|
+
if (renewed > ((_a = this.options.renews) !== null && _a !== void 0 ? _a : 0)) {
|
|
206
|
+
throw new CloudSignInError('expired');
|
|
207
|
+
}
|
|
208
|
+
const started = await CloudSignInUtil.start(gateway, this.options.name, fetcher);
|
|
209
|
+
if (this.stopped) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
this.progress = {
|
|
213
|
+
...(provider
|
|
214
|
+
? { code: started.code, url: CloudSignInUtil.direct(gateway, provider, started.code), direct: true }
|
|
215
|
+
: { code: started.code, url: started.url }),
|
|
216
|
+
...(renewed > 0 ? { renewed: true } : {}),
|
|
217
|
+
};
|
|
218
|
+
this.reopened = false;
|
|
219
|
+
this.options.onProgress({ ...this.progress });
|
|
220
|
+
// A new code is not opened unasked: the user may be in the browser still, or away.
|
|
221
|
+
if (renewed === 0) {
|
|
222
|
+
this.options.open(this.progress.url);
|
|
223
|
+
}
|
|
224
|
+
const result = await this.wait(started);
|
|
225
|
+
if (result !== 'expired') {
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
200
228
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
this.options.onProgress({ ...progress });
|
|
206
|
-
this.options.open(progress.url);
|
|
229
|
+
}
|
|
230
|
+
async wait(started) {
|
|
231
|
+
const { gateway, fetcher } = this.options;
|
|
232
|
+
let silentSince;
|
|
207
233
|
while (!this.stopped) {
|
|
208
234
|
await new Promise(resolve => {
|
|
209
235
|
this.wake = resolve;
|
|
@@ -216,19 +242,63 @@ class CloudSignIn {
|
|
|
216
242
|
if (this.stopped) {
|
|
217
243
|
return undefined;
|
|
218
244
|
}
|
|
245
|
+
if (!state) {
|
|
246
|
+
silentSince !== null && silentSince !== void 0 ? silentSince : (silentSince = Date.now());
|
|
247
|
+
if (Date.now() - silentSince >= exports.OFFLINE_MS) {
|
|
248
|
+
this.show({ offline: true });
|
|
249
|
+
}
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
silentSince = undefined;
|
|
253
|
+
this.show({ offline: undefined });
|
|
219
254
|
if (state.status === 'done') {
|
|
220
255
|
return { token: state.token, url: gateway };
|
|
221
256
|
}
|
|
222
257
|
if (state.status === 'expired') {
|
|
223
|
-
|
|
258
|
+
return 'expired';
|
|
224
259
|
}
|
|
225
|
-
if (state.status === '
|
|
226
|
-
|
|
227
|
-
|
|
260
|
+
if (state.status === 'failed') {
|
|
261
|
+
if (!this.reopened) {
|
|
262
|
+
this.show({ failed: state.reason });
|
|
263
|
+
}
|
|
264
|
+
continue;
|
|
228
265
|
}
|
|
266
|
+
this.reopened = false;
|
|
267
|
+
this.show({ failed: undefined, ...(state.status === 'waiting' ? { waiting: state.account } : {}) });
|
|
229
268
|
}
|
|
230
269
|
return undefined;
|
|
231
270
|
}
|
|
271
|
+
/** Tells `onProgress` once of what changed, not at every poll. */
|
|
272
|
+
show(change) {
|
|
273
|
+
const progress = this.progress;
|
|
274
|
+
if (!progress) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
let changed = false;
|
|
278
|
+
for (const [key, value] of Object.entries(change)) {
|
|
279
|
+
if (progress[key] !== value) {
|
|
280
|
+
changed = true;
|
|
281
|
+
if (value === undefined) {
|
|
282
|
+
delete progress[key];
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
progress[key] = value;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (changed) {
|
|
290
|
+
this.options.onProgress({ ...progress });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/** Opens the browser where the user signs in again, the sign-in there started anew; at a tap of the user. */
|
|
294
|
+
reopen() {
|
|
295
|
+
if (!this.progress) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
this.reopened = Boolean(this.progress.failed);
|
|
299
|
+
this.show({ failed: undefined, renewed: undefined });
|
|
300
|
+
this.options.open(this.progress.url);
|
|
301
|
+
}
|
|
232
302
|
/** Polls now rather than at the end of the wait: back from the browser. */
|
|
233
303
|
poke() {
|
|
234
304
|
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;
|
|
@@ -90,7 +90,7 @@ function RailItem({ label, place, active, onClick, onContextMenu, onPointerDown,
|
|
|
90
90
|
* once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
|
|
91
91
|
* Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
|
|
92
92
|
*/
|
|
93
|
-
function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, onToggleSides, }) {
|
|
93
|
+
function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, count, onToggleSides, }) {
|
|
94
94
|
const t = (0, use_t_1.useT)();
|
|
95
95
|
const [{ server }] = (0, hooks_1.useWorkbench)();
|
|
96
96
|
const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
|
|
@@ -116,7 +116,7 @@ function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, on
|
|
|
116
116
|
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((0, nav_places_1.entryHold)(entry.id, entry.double, holds)) },
|
|
117
117
|
entry.double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 }),
|
|
118
118
|
entry.double &&
|
|
119
|
-
(asks ? (React.createElement(asks_badge_1.AsksBadge, { count: asks, onDismiss: onDismissAsks })) : (onSeeAll && React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: onSeeAll, className: "ta-tabbar-dot ta-rail-dot" })))))),
|
|
119
|
+
(count ? (React.createElement(asks_badge_1.PeopleBadge, { count: count, onDismiss: onSeeAll })) : asks ? (React.createElement(asks_badge_1.AsksBadge, { count: asks, onDismiss: onDismissAsks })) : (onSeeAll && React.createElement(unseen_drop_1.UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: onSeeAll, className: "ta-tabbar-dot ta-rail-dot" })))))),
|
|
120
120
|
(navigation.nav.length > 0 || discover) && React.createElement("hr", { className: "ta-rail-divider" }),
|
|
121
121
|
navigation.nav.map(view => item(view)),
|
|
122
122
|
discover && (React.createElement(RailItem, { label: t('ta.discover'), place: "discover", active: !settingsShown && current === nav_places_1.DISCOVER, onClick: onDiscover, onContextMenu: event => openMenu(event, [settingsItem]) },
|
|
@@ -55,6 +55,7 @@ const app_shell_hooks_1 = require("./app-shell-hooks");
|
|
|
55
55
|
const board_1 = require("./board");
|
|
56
56
|
const chat_asks_1 = require("./chat-asks");
|
|
57
57
|
const chat_list_util_1 = require("./chat-list-util");
|
|
58
|
+
const first_steps_util_1 = require("./first-steps-util");
|
|
58
59
|
const nav_places_1 = require("./nav-places");
|
|
59
60
|
const side_lists_1 = require("./side-lists");
|
|
60
61
|
const split_pane_1 = require("./split-pane");
|
|
@@ -145,10 +146,20 @@ function useAppShell() {
|
|
|
145
146
|
}, [offline, host]);
|
|
146
147
|
/** The conversation the page opens with is shown: those shown after are the user's doing. */
|
|
147
148
|
const started = React.useRef(false);
|
|
149
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: once a connection, with what the page has then
|
|
148
150
|
React.useEffect(() => {
|
|
149
151
|
if (online) {
|
|
150
152
|
void chat.start().then(() => {
|
|
151
153
|
started.current = true;
|
|
154
|
+
const { sessions, saved } = bench.state;
|
|
155
|
+
if (first_steps_util_1.FirstStepsUtil.startOnDouble({
|
|
156
|
+
phone,
|
|
157
|
+
page: host.state.page,
|
|
158
|
+
conversation: !!chat.state.store,
|
|
159
|
+
answered: first_steps_util_1.FirstStepsUtil.answered(sessions, saved),
|
|
160
|
+
})) {
|
|
161
|
+
host.showPage(side_lists_1.DOUBLE_PAGE);
|
|
162
|
+
}
|
|
152
163
|
});
|
|
153
164
|
}
|
|
154
165
|
}, [online, chat]);
|