@celljs/ta-web 4.15.0 → 4.15.2

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.
Files changed (129) hide show
  1. package/esm/browser/components/access-view.d.ts +6 -0
  2. package/esm/browser/components/access-view.js +4 -4
  3. package/esm/browser/components/account-menu.js +8 -1
  4. package/esm/browser/components/app-view.js +8 -1
  5. package/esm/browser/components/environment-view.js +9 -2
  6. package/esm/browser/components/face.js +7 -2
  7. package/esm/browser/components/gallery.d.ts +9 -0
  8. package/esm/browser/components/gallery.js +57 -0
  9. package/esm/browser/components/host-view.d.ts +1 -1
  10. package/esm/browser/components/lightbox.d.ts +8 -1
  11. package/esm/browser/components/lightbox.js +4 -1
  12. package/esm/browser/components/markdown.js +6 -1
  13. package/esm/browser/components/media.d.ts +12 -2
  14. package/esm/browser/components/media.js +55 -13
  15. package/esm/browser/components/message-list.js +3 -2
  16. package/esm/browser/components/notice-center.js +6 -2
  17. package/esm/browser/components/serve-restart.d.ts +26 -0
  18. package/esm/browser/components/serve-restart.js +91 -0
  19. package/esm/browser/components/session-view.js +19 -11
  20. package/esm/browser/components/settings-parts.js +18 -6
  21. package/esm/browser/extension/icons.js +3 -1
  22. package/esm/browser/extension/web-extension-protocol.d.ts +6 -0
  23. package/esm/browser/extension/web-extensions.d.ts +3 -0
  24. package/esm/browser/extension/web-extensions.js +7 -0
  25. package/esm/browser/gateway/console-extension.d.ts +20 -0
  26. package/esm/browser/gateway/console-extension.js +75 -0
  27. package/esm/browser/gateway/console-parts.d.ts +62 -0
  28. package/esm/browser/gateway/console-parts.js +271 -0
  29. package/esm/browser/gateway/console-tenant.d.ts +22 -0
  30. package/esm/browser/gateway/console-tenant.js +286 -0
  31. package/esm/browser/gateway/console-util.d.ts +59 -0
  32. package/esm/browser/gateway/console-util.js +187 -0
  33. package/esm/browser/gateway/console-view.d.ts +2 -0
  34. package/esm/browser/gateway/console-view.js +218 -0
  35. package/esm/browser/i18n/locales.d.ts +186 -3
  36. package/esm/browser/i18n/messages-ja.js +183 -0
  37. package/esm/browser/i18n/messages-zh-tw.js +183 -0
  38. package/esm/browser/i18n/messages.d.ts +183 -0
  39. package/esm/browser/i18n/messages.js +366 -0
  40. package/esm/browser/index.d.ts +3 -0
  41. package/esm/browser/index.js +3 -0
  42. package/esm/browser/style/conversation.d.ts +1 -1
  43. package/esm/browser/style/conversation.js +18 -0
  44. package/esm/browser/style/layout.d.ts +1 -1
  45. package/esm/browser/style/layout.js +2 -0
  46. package/esm/browser/style/pages.d.ts +1 -1
  47. package/esm/browser/style/pages.js +140 -0
  48. package/esm/browser/style/shell.d.ts +1 -1
  49. package/esm/browser/style/shell.js +2 -0
  50. package/esm/browser/style/surfaces.d.ts +1 -1
  51. package/esm/browser/style/surfaces.js +1 -0
  52. package/esm/browser/util/desktop.d.ts +6 -1
  53. package/esm/browser/util/desktop.js +10 -0
  54. package/esm/browser/util/gallery.d.ts +18 -0
  55. package/esm/browser/util/gallery.js +123 -0
  56. package/esm/browser/util/link.d.ts +8 -0
  57. package/esm/browser/util/link.js +14 -0
  58. package/esm/browser/util/markdown.d.ts +11 -0
  59. package/esm/browser/util/markdown.js +4 -0
  60. package/esm/browser/util/thumbnail.d.ts +18 -0
  61. package/esm/browser/util/thumbnail.js +26 -0
  62. package/esm/browser/workbench-protocol.d.ts +8 -0
  63. package/esm/browser/workbench.d.ts +16 -0
  64. package/esm/browser/workbench.js +67 -0
  65. package/lib/browser/components/access-view.d.ts +6 -0
  66. package/lib/browser/components/access-view.js +5 -4
  67. package/lib/browser/components/account-menu.js +7 -0
  68. package/lib/browser/components/app-view.js +8 -1
  69. package/lib/browser/components/environment-view.js +9 -2
  70. package/lib/browser/components/face.js +7 -2
  71. package/lib/browser/components/gallery.d.ts +10 -0
  72. package/lib/browser/components/gallery.js +93 -0
  73. package/lib/browser/components/host-view.d.ts +1 -1
  74. package/lib/browser/components/lightbox.d.ts +8 -1
  75. package/lib/browser/components/lightbox.js +4 -1
  76. package/lib/browser/components/markdown.js +6 -1
  77. package/lib/browser/components/media.d.ts +12 -2
  78. package/lib/browser/components/media.js +57 -13
  79. package/lib/browser/components/message-list.js +3 -2
  80. package/lib/browser/components/notice-center.js +6 -2
  81. package/lib/browser/components/serve-restart.d.ts +27 -0
  82. package/lib/browser/components/serve-restart.js +129 -0
  83. package/lib/browser/components/session-view.js +21 -13
  84. package/lib/browser/components/settings-parts.js +17 -5
  85. package/lib/browser/extension/icons.js +2 -0
  86. package/lib/browser/extension/web-extension-protocol.d.ts +6 -0
  87. package/lib/browser/extension/web-extensions.d.ts +3 -0
  88. package/lib/browser/extension/web-extensions.js +7 -0
  89. package/lib/browser/gateway/console-extension.d.ts +21 -0
  90. package/lib/browser/gateway/console-extension.js +111 -0
  91. package/lib/browser/gateway/console-parts.d.ts +63 -0
  92. package/lib/browser/gateway/console-parts.js +315 -0
  93. package/lib/browser/gateway/console-tenant.d.ts +23 -0
  94. package/lib/browser/gateway/console-tenant.js +327 -0
  95. package/lib/browser/gateway/console-util.d.ts +60 -0
  96. package/lib/browser/gateway/console-util.js +190 -0
  97. package/lib/browser/gateway/console-view.d.ts +3 -0
  98. package/lib/browser/gateway/console-view.js +254 -0
  99. package/lib/browser/i18n/locales.d.ts +186 -3
  100. package/lib/browser/i18n/messages-ja.js +183 -0
  101. package/lib/browser/i18n/messages-zh-tw.js +183 -0
  102. package/lib/browser/i18n/messages.d.ts +183 -0
  103. package/lib/browser/i18n/messages.js +366 -0
  104. package/lib/browser/index.d.ts +3 -0
  105. package/lib/browser/index.js +3 -0
  106. package/lib/browser/style/conversation.d.ts +1 -1
  107. package/lib/browser/style/conversation.js +18 -0
  108. package/lib/browser/style/layout.d.ts +1 -1
  109. package/lib/browser/style/layout.js +2 -0
  110. package/lib/browser/style/pages.d.ts +1 -1
  111. package/lib/browser/style/pages.js +140 -0
  112. package/lib/browser/style/shell.d.ts +1 -1
  113. package/lib/browser/style/shell.js +2 -0
  114. package/lib/browser/style/surfaces.d.ts +1 -1
  115. package/lib/browser/style/surfaces.js +1 -0
  116. package/lib/browser/util/desktop.d.ts +6 -1
  117. package/lib/browser/util/desktop.js +10 -0
  118. package/lib/browser/util/gallery.d.ts +19 -0
  119. package/lib/browser/util/gallery.js +126 -0
  120. package/lib/browser/util/link.d.ts +8 -0
  121. package/lib/browser/util/link.js +14 -0
  122. package/lib/browser/util/markdown.d.ts +11 -0
  123. package/lib/browser/util/markdown.js +4 -0
  124. package/lib/browser/util/thumbnail.d.ts +19 -0
  125. package/lib/browser/util/thumbnail.js +29 -0
  126. package/lib/browser/workbench-protocol.d.ts +8 -0
  127. package/lib/browser/workbench.d.ts +16 -0
  128. package/lib/browser/workbench.js +67 -0
  129. package/package.json +7 -7
@@ -6,6 +6,7 @@ import { WEB_ICONS } from '../extension/icons.js';
6
6
  import { useLanguage, useT } from '../i18n/use-t.js';
7
7
  import { CodeAnswer, CodeRenderers } from '../markdown/code-renderers.js';
8
8
  import { Recent } from '../markdown/lazy.js';
9
+ import { GalleryUtil } from '../util/gallery.js';
9
10
  import { MessageUtil } from '../util/message.js';
10
11
  import { FreshRows, ProcessUtil } from '../util/process.js';
11
12
  import { ProgressUtil } from '../util/progress.js';
@@ -164,9 +165,9 @@ export function UserImages({ blocks, timestamp }) {
164
165
  }
165
166
  const single = images.length === 1 ? UserImageUtil.box(UserImageUtil.size(images[0].block)) : undefined;
166
167
  const shown = open !== undefined ? sources[open] : undefined;
167
- return (React.createElement("div", { className: "ta-user-images", "data-count": Math.min(images.length, 3) },
168
+ return (React.createElement("div", { className: "ta-user-images", "data-count": Math.min(images.length, 3), style: { '--ta-user-image-columns': GalleryUtil.columns(images.length) } },
168
169
  images.map(({ index }, at) => (React.createElement("button", { key: index, type: "button", className: "ta-user-image", title: t('ta.markdown.enlarge'), disabled: !sources[at], onClick: () => setOpen(at) }, sources[at] ? (React.createElement("img", { className: "ta-thumb", src: sources[at], alt: "", style: single })) : (React.createElement("span", { className: "ta-thumb ta-thumb-waiting", style: single }))))),
169
- open !== undefined && shown && (React.createElement(Lightbox, { src: shown, alt: "", onClose: () => setOpen(undefined), onPrevious: open > 0 && sources[open - 1] ? () => setOpen(open - 1) : undefined, onNext: open < images.length - 1 && sources[open + 1] ? () => setOpen(open + 1) : undefined }))));
170
+ open !== undefined && shown && (React.createElement(Lightbox, { src: shown, alt: "", count: { at: open, of: images.length }, onClose: () => setOpen(undefined), onPrevious: open > 0 && sources[open - 1] ? () => setOpen(open - 1) : undefined, onNext: open < images.length - 1 && sources[open + 1] ? () => setOpen(open + 1) : undefined }))));
170
171
  }
171
172
  /**
172
173
  * What the user said, in the bubble of a message of theirs, with the pictures they sent with it in the same
@@ -74,6 +74,7 @@ function SessionToast({ notice, leaving, leave, hold, }) {
74
74
  React.createElement(IconButton, { icon: X, label: t('ta.dismiss'), className: "ta-toast-close", onClick: leave })));
75
75
  }
76
76
  function Toast({ notice, notices }) {
77
+ var _a;
77
78
  const t = useT();
78
79
  const [leaving, setLeaving] = React.useState(false);
79
80
  const leave = React.useCallback(() => {
@@ -94,11 +95,14 @@ function Toast({ notice, notices }) {
94
95
  notice.count)),
95
96
  notice.detail && React.createElement("div", { className: "ta-toast-detail" }, notice.detail),
96
97
  notice.art && React.createElement(TerminalArt, { art: notice.art, className: "ta-toast-art", label: t('ta.notice.picture') }),
97
- notice.action && (React.createElement("button", { type: "button", className: "ta-toast-action", onClick: () => {
98
+ ((_a = notice.actions) === null || _a === void 0 ? void 0 : _a.length) ? (React.createElement("div", { className: "ta-toast-actions" }, [...notice.actions, ...(notice.action ? [notice.action] : [])].map(action => (React.createElement("button", { key: action.label, type: "button", className: "ta-toast-action", onClick: () => {
99
+ action.run();
100
+ leave();
101
+ } }, action.label))))) : (notice.action && (React.createElement("button", { type: "button", className: "ta-toast-action", onClick: () => {
98
102
  var _a;
99
103
  (_a = notice.action) === null || _a === void 0 ? void 0 : _a.run();
100
104
  leave();
101
- } }, notice.action.label))),
105
+ } }, notice.action.label)))),
102
106
  React.createElement(IconButton, { icon: X, label: t('ta.dismiss'), className: "ta-toast-close", onClick: leave })));
103
107
  }
104
108
  function ConfirmDialog({ request, notices }) {
@@ -0,0 +1,26 @@
1
+ import type { TaServerInfo, TaServerUpdate } from '@celljs/ta-protocol';
2
+ export declare namespace ServeRestartUtil {
3
+ /** `v4.16.0`, with the commit of a build of the development channel: `v4.16.0 (695fbe1)`. */
4
+ function label(build: {
5
+ version: string;
6
+ build?: string;
7
+ }): string;
8
+ function key(update: TaServerUpdate): string;
9
+ /** Whether the page may restart Ta: the owner, of a Ta service that can restart itself. */
10
+ function restartable(server: TaServerInfo | undefined): boolean;
11
+ }
12
+ export interface RestartTa {
13
+ /** The page may restart Ta. */
14
+ can: boolean;
15
+ restarting: boolean;
16
+ /** Another build installed, which a restart runs. */
17
+ update?: TaServerUpdate;
18
+ /** Asks the user first, unless they already said so (the button of the notice of an update). */
19
+ restart(ask?: boolean): Promise<void>;
20
+ }
21
+ export declare function useRestartTa(): RestartTa;
22
+ /**
23
+ * Tells of what restarting Ta is about, in a corner: another build installed (an update of Ta Desktop, `npm i -g`, a
24
+ * build of the repository), with Restart and Later, once for each build; Ta restarting, then back with its version.
25
+ */
26
+ export declare function ServeRestartNotices(): null;
@@ -0,0 +1,91 @@
1
+ import * as React from 'react';
2
+ import { useNotices, useWorkbench } from '../hooks.js';
3
+ import { useT } from '../i18n/use-t.js';
4
+ import { storage } from '../workbench-util.js';
5
+ /** The build installed that the user put off restarting for (Later): not asked about again on this device. */
6
+ const LATER_KEY = 'ta.update.later';
7
+ export var ServeRestartUtil;
8
+ (function (ServeRestartUtil) {
9
+ /** `v4.16.0`, with the commit of a build of the development channel: `v4.16.0 (695fbe1)`. */
10
+ function label(build) {
11
+ return `v${build.version}${build.build ? ` (${build.build})` : ''}`;
12
+ }
13
+ ServeRestartUtil.label = label;
14
+ function key(update) {
15
+ var _a;
16
+ return `${update.version}+${(_a = update.build) !== null && _a !== void 0 ? _a : ''}`;
17
+ }
18
+ ServeRestartUtil.key = key;
19
+ /** Whether the page may restart Ta: the owner, of a Ta service that can restart itself. */
20
+ function restartable(server) {
21
+ return !!server && !server.member && server.restartable === true;
22
+ }
23
+ ServeRestartUtil.restartable = restartable;
24
+ })(ServeRestartUtil || (ServeRestartUtil = {}));
25
+ export function useRestartTa() {
26
+ const t = useT();
27
+ const [{ server, restarting }, workbench] = useWorkbench();
28
+ const [, notices] = useNotices();
29
+ const restart = React.useCallback(async (ask = true) => {
30
+ if (ask && !(await notices.confirm({ title: t('ta.restart.confirm'), message: t('ta.restart.detail'), confirmLabel: t('ta.restart') }))) {
31
+ return;
32
+ }
33
+ await workbench.restartServer().catch(error => notices.error(error));
34
+ }, [t, notices, workbench]);
35
+ const can = ServeRestartUtil.restartable(server);
36
+ return { can, restarting: !!restarting, update: can ? server === null || server === void 0 ? void 0 : server.update : undefined, restart };
37
+ }
38
+ /**
39
+ * Tells of what restarting Ta is about, in a corner: another build installed (an update of Ta Desktop, `npm i -g`, a
40
+ * build of the repository), with Restart and Later, once for each build; Ta restarting, then back with its version.
41
+ */
42
+ export function ServeRestartNotices() {
43
+ const t = useT();
44
+ const [{ server }] = useWorkbench();
45
+ const [, notices] = useNotices();
46
+ const { update, restarting, restart } = useRestartTa();
47
+ const told = React.useRef(undefined);
48
+ const key = update && ServeRestartUtil.key(update);
49
+ React.useEffect(() => {
50
+ var _a, _b;
51
+ if (!update || !key || restarting || ((_a = told.current) === null || _a === void 0 ? void 0 : _a.key) === key || ((_b = storage()) === null || _b === void 0 ? void 0 : _b.getItem(LATER_KEY)) === key) {
52
+ return;
53
+ }
54
+ told.current = {
55
+ key,
56
+ id: notices.notify(t('ta.update.ready', { version: ServeRestartUtil.label(update) }), {
57
+ detail: t('ta.update.readyDetail'),
58
+ key: 'ta-serve-update',
59
+ sticky: true,
60
+ actions: [{ label: t('ta.update.later'), run: () => { var _a; return (_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(LATER_KEY, key); } }],
61
+ action: { label: t('ta.restart'), run: () => void restart(false) },
62
+ }),
63
+ };
64
+ }, [update, key, restarting, notices, restart, t]);
65
+ React.useEffect(() => {
66
+ // Restarted, or put in place some other way: nothing to restart for any more.
67
+ if (!key && told.current) {
68
+ notices.dismiss(told.current.id);
69
+ told.current = undefined;
70
+ }
71
+ }, [key, notices]);
72
+ const restartingId = React.useRef(undefined);
73
+ // Read once the restart ended: a server read again meanwhile says nothing.
74
+ const serverNow = React.useRef(server);
75
+ serverNow.current = server;
76
+ React.useEffect(() => {
77
+ if (restarting) {
78
+ restartingId.current = notices.notify(t('ta.restart.restarting'), { key: 'ta-serve-restart', sticky: true });
79
+ }
80
+ else if (restartingId.current !== undefined) {
81
+ notices.dismiss(restartingId.current);
82
+ restartingId.current = undefined;
83
+ const back = serverNow.current;
84
+ if (back) {
85
+ notices.notify(t('ta.restart.done', { version: ServeRestartUtil.label(back) }), { level: 'success', key: 'ta-serve-restart' });
86
+ }
87
+ }
88
+ }, [restarting, notices, t]);
89
+ return null;
90
+ }
91
+ //# sourceMappingURL=serve-restart.js.map
@@ -7,8 +7,10 @@ import { TaFiles } from '../files/files-protocol.js';
7
7
  import { useNotices, useOpenLink, usePersisted, useSessionState, useSettings, useSettingsServer } from '../hooks.js';
8
8
  import { useT } from '../i18n/use-t.js';
9
9
  import { CodeReply } from '../markdown/code-renderers.js';
10
+ import { LinkUtil } from '../util/link.js';
10
11
  import { MessageUtil } from '../util/message.js';
11
12
  import { TerminalText } from '../util/terminal-text.js';
13
+ import { ThumbnailUtil } from '../util/thumbnail.js';
12
14
  import { TaWorkbench } from '../workbench-protocol.js';
13
15
  import { ChatAskUtil, LET_GO_ASKS } from './chat-asks.js';
14
16
  import { Composer } from './composer.js';
@@ -29,14 +31,17 @@ import { TerminalArt } from './terminal-art.js';
29
31
  import { useStopTimes } from './use-stop-times.js';
30
32
  /**
31
33
  * What the extensions of the session say with `notify` goes to the notices of the page; what was said before it
32
- * opened stays quiet. A picture in it (a QR code to sign in) is drawn, and stays until the next notice of the
33
- * session, which says how it went or brings a new code.
34
+ * opened stays quiet. A picture in it (a QR code to sign in) is drawn, a web address in it (a page to sign in on)
35
+ * is a button that opens it, and either stays until the next notice of the session, which says how it went or
36
+ * brings a new one.
34
37
  */
35
38
  function useSessionNotices(store, notices) {
39
+ const t = useT();
36
40
  const [, center] = useNotices();
41
+ const openLink = useOpenLink(undefined);
37
42
  // Of the store shown: one that took the place of another (attached for what the device showed) starts quiet too.
38
43
  const seen = React.useRef(undefined);
39
- const picture = React.useRef(undefined);
44
+ const lasting = React.useRef(undefined);
40
45
  React.useEffect(() => {
41
46
  var _a;
42
47
  if (((_a = seen.current) === null || _a === void 0 ? void 0 : _a.store) !== store) {
@@ -46,16 +51,19 @@ function useSessionNotices(store, notices) {
46
51
  for (const notice of notices) {
47
52
  if (!seen.current.ids.has(notice.id)) {
48
53
  seen.current.ids.add(notice.id);
49
- if (picture.current !== undefined) {
50
- center.dismiss(picture.current);
51
- picture.current = undefined;
54
+ if (lasting.current !== undefined) {
55
+ center.dismiss(lasting.current);
56
+ lasting.current = undefined;
52
57
  }
53
- const { text, art } = TerminalText.art(notice.message);
54
- const id = center.notify(text, { level: notice.type, art, sticky: art !== undefined });
55
- picture.current = art ? id : undefined;
58
+ const art = TerminalText.art(notice.message);
59
+ const { text, url } = LinkUtil.noticeLink(art.text);
60
+ const action = url ? { label: t('ta.notice.openLink'), run: () => openLink({ type: 'url', url }, false) } : undefined;
61
+ const keep = art.art !== undefined || url !== undefined;
62
+ const id = center.notify(text, { level: notice.type, art: art.art, action, sticky: keep });
63
+ lasting.current = keep ? id : undefined;
56
64
  }
57
65
  }
58
- }, [store, notices, center]);
66
+ }, [store, notices, center, t, openLink]);
59
67
  }
60
68
  /** What an extension shows above or below the message box (`setWidget`): its lines as a terminal draws them, a picture in them drawn. */
61
69
  function WidgetView({ lines }) {
@@ -123,7 +131,7 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
123
131
  }
124
132
  }, [draftText]);
125
133
  const files = useInject(TaFiles);
126
- const fileUrl = React.useCallback(async (path) => files.loadable(await workspace.fileUrl(path, cwd)), [workspace, cwd, files]);
134
+ const fileUrl = React.useCallback(async (path, box) => files.loadable(ThumbnailUtil.boxed(await workspace.fileUrl(path, cwd), box)), [workspace, cwd, files]);
127
135
  const namedPaths = React.useCallback(() => MessageUtil.namedPaths(store.state.messages), [store]);
128
136
  const openLink = useOpenLink(cwd, namedPaths);
129
137
  // biome-ignore lint/correctness/useExhaustiveDependencies: runs when a run starts or settles
@@ -1,4 +1,4 @@
1
- import { Blocks, Bot, Cloud, Compass, FolderOpen, Info, Keyboard, KeyRound, Languages, Link2, LogOut, MessagesSquare, Palette, Puzzle, RefreshCw, Server, ShieldCheck, Smartphone, Trash2, Volume2, Wrench, } from 'lucide-react';
1
+ import { Blocks, Bot, Cloud, Compass, FolderOpen, Info, Keyboard, KeyRound, Languages, Link2, LogOut, MessagesSquare, Palette, Puzzle, RefreshCw, RotateCw, Server, ShieldCheck, Smartphone, Trash2, Volume2, Wrench, } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import { useDevice } from '../device/device.js';
4
4
  import { ExtensionBoundary } from '../extension/extension-view.js';
@@ -19,6 +19,7 @@ import { useLaunchRows } from './launch-settings.js';
19
19
  import { SettingsModelPicker } from './model-picker.js';
20
20
  import { RelayServices } from './relay-services.js';
21
21
  import { RemoteHosts } from './remote-hosts.js';
22
+ import { ServeRestartUtil, useRestartTa } from './serve-restart.js';
22
23
  import { ChoiceRow, EmptyRow, Keys, Row, row, Segmented, Switch } from './settings-controls.js';
23
24
  import { SignInSetupSettings, useSignInConfig } from './sign-in-setup.js';
24
25
  import { TrustedDomains } from './trusted-domains.js';
@@ -41,6 +42,7 @@ export function useParts(scope, onScope, onClose, onDialog) {
41
42
  const access = useAccess();
42
43
  const signInConfig = useSignInConfig();
43
44
  const gateway = useGateway();
45
+ const restartTa = useRestartTa();
44
46
  // As the menu of the account (useAccountEntries): a finger has no keys to learn; a phone is not the computer
45
47
  // that pairs phones, and signs out at the foot of Me.
46
48
  const touch = useDevice(device => device.touch);
@@ -238,7 +240,10 @@ export function useParts(scope, onScope, onClose, onDialog) {
238
240
  title: t('ta.packages.builtinTitle'),
239
241
  icon: Blocks,
240
242
  rows: [
241
- ...host.builtins.map(builtin => { var _a; return row(`web:${builtin.name}`, [t(builtin.title), t(builtin.description), t('ta.packages.builtinTitle')], React.createElement(Row, { icon: (_a = builtin.icon) !== null && _a !== void 0 ? _a : Puzzle, label: t(builtin.title), description: t(builtin.description) },
243
+ // The console only for administrators of a gateway, where it shows.
244
+ ...host.builtins
245
+ .filter(builtin => { var _a; return !builtin.gatewayAdmin || ((_a = gateway.info) === null || _a === void 0 ? void 0 : _a.admin); })
246
+ .map(builtin => { var _a; return row(`web:${builtin.name}`, [t(builtin.title), t(builtin.description), t('ta.packages.builtinTitle')], React.createElement(Row, { icon: (_a = builtin.icon) !== null && _a !== void 0 ? _a : Puzzle, label: t(builtin.title), description: t(builtin.description) },
242
247
  React.createElement(Switch, { label: t(builtin.title), checked: !settings.builtinsOff.includes(builtin.name), onChange: on => toggleBuiltin(builtin.name, on) }))); }),
243
248
  ...builtinPackages.map(info => {
244
249
  const { title, summary, icon } = packageLabel(info, language);
@@ -317,10 +322,17 @@ export function useParts(scope, onScope, onClose, onDialog) {
317
322
  icon: Info,
318
323
  rows: workbench.server
319
324
  ? [
320
- row('version', [t('ta.settings.version'), 'version'], React.createElement(Row, { label: t('ta.settings.version') },
321
- React.createElement("span", { className: "ta-path" },
322
- "v",
323
- workbench.server.version))),
325
+ row('version', [t('ta.settings.version'), 'version'], React.createElement(Row, { label: t('ta.settings.version'), description: restartTa.update && t('ta.update.ready', { version: ServeRestartUtil.label(restartTa.update) }) },
326
+ React.createElement("span", { className: "ta-path" }, ServeRestartUtil.label(workbench.server)))),
327
+ ...(restartTa.can
328
+ ? [
329
+ row('restart', [t('ta.restart'), t('ta.restart.description'), 'restart', 'update'], React.createElement(Row, { label: t('ta.restart'), description: t('ta.restart.description') },
330
+ React.createElement("button", { type: "button", className: `ta-button${restartTa.update ? ' ta-primary' : ''}`, disabled: restartTa.restarting, onClick: () => void restartTa.restart() },
331
+ restartTa.restarting ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: RotateCw, size: 15 }),
332
+ ' ',
333
+ t('ta.restart.button')))),
334
+ ]
335
+ : []),
324
336
  row('cwd', [t('ta.settings.cwd'), workbench.server.cwd], React.createElement(Row, { label: t('ta.settings.cwd'), description: t('ta.settings.cwdDescription', { path: workbench.server.cwd }) },
325
337
  React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('directory') },
326
338
  React.createElement(Icon, { icon: FolderOpen, size: 15 }),
@@ -1,4 +1,4 @@
1
- import { AlarmClock, Aperture, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, BellOff, BookOpen, Bot, Building2, CaseSensitive, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, CircleHelp, Clipboard, Clock, Cloud, Code, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Crown, Database, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, Heart, House, Image, ImagePlus, Info, KeyRound, Laptop, LayoutDashboard, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MapIcon, Megaphone, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MonitorSmartphone, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, Radar, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Send, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, X, } from 'lucide-react';
1
+ import { AlarmClock, Aperture, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, BellOff, BookOpen, Bot, Box, Building2, CaseSensitive, ChartSpline, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, CircleHelp, Clipboard, Clock, Cloud, Code, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Crown, Database, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, Heart, House, Image, ImagePlus, Info, KeyRound, Laptop, LayoutDashboard, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MapIcon, Megaphone, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MonitorSmartphone, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, Radar, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Send, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, X, } from 'lucide-react';
2
2
  /** The icons a web extension gets as `pi.ui.icons`; names are lucide's. Only add: removing one breaks extensions. */
3
3
  export const WEB_ICONS = Object.freeze({
4
4
  AlarmClock,
@@ -12,8 +12,10 @@ export const WEB_ICONS = Object.freeze({
12
12
  BellOff,
13
13
  BookOpen,
14
14
  Bot,
15
+ Box,
15
16
  Building2,
16
17
  CaseSensitive,
18
+ ChartSpline,
17
19
  Check,
18
20
  ChevronDown,
19
21
  ChevronRight,
@@ -15,6 +15,8 @@ export interface BuiltinWebExtension {
15
15
  readonly description: MessageId;
16
16
  /** Shown before its title in the settings. */
17
17
  readonly icon?: WebIcon;
18
+ /** Only for administrators of a gateway (`ta gateway`): listed in the settings there alone. */
19
+ readonly gatewayAdmin?: boolean;
18
20
  readonly activate: WebExtensionFactory;
19
21
  }
20
22
  export interface LoadedWebExtension {
@@ -271,4 +273,8 @@ export interface TaWebExtensions {
271
273
  setSessionSwitcher(switcher: WebSessionSwitcher | undefined): void;
272
274
  /** How the page shows a session as the conversation, once it said (setSessionSwitcher). */
273
275
  sessionSwitcher(): WebSessionSwitcher | undefined;
276
+ /** What `openSettings` does: the shell opens the settings at a section; `undefined` until it can. */
277
+ setSettingsOpener(opener: ((section?: string) => void) | undefined): void;
278
+ /** The settings, at a section (`access`) of them, from a page of the page's own (the console). */
279
+ openSettings(section?: string): void;
274
280
  }
@@ -39,6 +39,7 @@ export declare class TaWebExtensionsImpl implements TaWebExtensions {
39
39
  protected readonly listeners: Set<(state: WebExtensionsState) => void>;
40
40
  protected conversation?: WebExtensionConversation;
41
41
  protected switcher?: WebSessionSwitcher;
42
+ protected settingsOpener?: (section?: string) => void;
42
43
  protected refreshing: Promise<boolean>;
43
44
  /** The extensions of the list of the last time have started (startKept), once. */
44
45
  protected keptStarted: boolean;
@@ -92,6 +93,8 @@ export declare class TaWebExtensionsImpl implements TaWebExtensions {
92
93
  connect(conversation: WebExtensionConversation | undefined): void;
93
94
  setConversationShown(shown: boolean): void;
94
95
  setSessionSwitcher(switcher: WebSessionSwitcher | undefined): void;
96
+ setSettingsOpener(opener: ((section?: string) => void) | undefined): void;
97
+ openSettings(section?: string): void;
95
98
  sessionSwitcher(): WebSessionSwitcher | undefined;
96
99
  emit(event: TaEvent): void;
97
100
  protected reconcile(): Promise<boolean>;
@@ -284,6 +284,13 @@ let TaWebExtensionsImpl = class TaWebExtensionsImpl {
284
284
  setSessionSwitcher(switcher) {
285
285
  this.switcher = switcher;
286
286
  }
287
+ setSettingsOpener(opener) {
288
+ this.settingsOpener = opener;
289
+ }
290
+ openSettings(section) {
291
+ var _a;
292
+ (_a = this.settingsOpener) === null || _a === void 0 ? void 0 : _a.call(this, section);
293
+ }
287
294
  sessionSwitcher() {
288
295
  return this.switcher;
289
296
  }
@@ -0,0 +1,20 @@
1
+ import type { WebExtensionAPI } from '../extension/web-extension-api.js';
2
+ import { BuiltinWebExtension } from '../extension/web-extension-protocol.js';
3
+ import { TaWorkbench } from '../workbench-protocol.js';
4
+ export declare const CONSOLE_EXTENSION = "gateway";
5
+ export declare const CONSOLE_VIEW = "console";
6
+ /** The page of the console, as `openView` takes it. */
7
+ export declare const CONSOLE_VIEW_ID = "gateway/console";
8
+ /**
9
+ * The console of a gateway (`ta gateway`), as a built-in web extension: a page for its administrators alone,
10
+ * of everyone's Ta on it. Behind no gateway, or for anyone else, it adds nothing.
11
+ */
12
+ export declare class ConsoleWebExtension implements BuiltinWebExtension {
13
+ readonly name = "gateway";
14
+ readonly title = "ta.console.title";
15
+ readonly description = "ta.console.hint";
16
+ readonly icon: import("lucide-react").LucideIcon;
17
+ readonly gatewayAdmin = true;
18
+ protected readonly workbench: TaWorkbench;
19
+ readonly activate: (pi: WebExtensionAPI) => () => void;
20
+ }
@@ -0,0 +1,75 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Autowired, Component } from '@celljs/core';
11
+ import { Gauge } from 'lucide-react';
12
+ import * as React from 'react';
13
+ import { BuiltinWebExtension } from '../extension/web-extension-protocol.js';
14
+ import { message } from '../i18n/messages.js';
15
+ import { TaWorkbench } from '../workbench-protocol.js';
16
+ import { ConsolePage } from './console-view.js';
17
+ export const CONSOLE_EXTENSION = 'gateway';
18
+ export const CONSOLE_VIEW = 'console';
19
+ /** The page of the console, as `openView` takes it. */
20
+ export const CONSOLE_VIEW_ID = `${CONSOLE_EXTENSION}/${CONSOLE_VIEW}`;
21
+ /**
22
+ * The console of a gateway (`ta gateway`), as a built-in web extension: a page for its administrators alone,
23
+ * of everyone's Ta on it. Behind no gateway, or for anyone else, it adds nothing.
24
+ */
25
+ let ConsoleWebExtension = class ConsoleWebExtension {
26
+ constructor() {
27
+ this.name = CONSOLE_EXTENSION;
28
+ this.title = 'ta.console.title';
29
+ this.description = 'ta.console.hint';
30
+ this.icon = Gauge;
31
+ this.gatewayAdmin = true;
32
+ this.activate = (pi) => {
33
+ let registered = false;
34
+ let asking = false;
35
+ let online = false;
36
+ const check = () => {
37
+ const now = this.workbench.state.status === 'online';
38
+ // Asked again on each connection: the gateway, or the account, may be another since.
39
+ if (now && !online && !registered && !asking) {
40
+ asking = true;
41
+ this.workbench.gateway.getGateway().then(info => {
42
+ asking = false;
43
+ if (info.admin && !registered) {
44
+ registered = true;
45
+ pi.registerView(CONSOLE_VIEW, {
46
+ title: () => message(pi.ui.language, 'ta.console.title'),
47
+ icon: Gauge,
48
+ render: () => React.createElement(ConsolePage),
49
+ order: 90,
50
+ discover: true,
51
+ });
52
+ }
53
+ },
54
+ // A Ta service without a gateway has no TaGatewayServer.
55
+ () => {
56
+ asking = false;
57
+ });
58
+ }
59
+ online = now;
60
+ };
61
+ const stop = this.workbench.subscribe(check);
62
+ check();
63
+ return stop;
64
+ };
65
+ }
66
+ };
67
+ __decorate([
68
+ Autowired(TaWorkbench),
69
+ __metadata("design:type", Object)
70
+ ], ConsoleWebExtension.prototype, "workbench", void 0);
71
+ ConsoleWebExtension = __decorate([
72
+ Component(BuiltinWebExtension)
73
+ ], ConsoleWebExtension);
74
+ export { ConsoleWebExtension };
75
+ //# sourceMappingURL=console-extension.js.map
@@ -0,0 +1,62 @@
1
+ import type { TaGatewayLimits, TaGatewayTenant, TaQuotaState } from '@celljs/ta-protocol';
2
+ import * as React from 'react';
3
+ /** How often what the console shows is read again while it is seen. */
4
+ export declare const REFRESH_MS = 10000;
5
+ /** Reads `load` now and every `every` ms while the page is seen; again when `key` changes. */
6
+ export declare function usePolled<T>(load: () => Promise<T>, key: unknown, every?: number): {
7
+ value: T | undefined;
8
+ error: string | undefined;
9
+ read: () => Promise<void>;
10
+ readAt: number | undefined;
11
+ };
12
+ export declare function SectionTitle({ children, action }: {
13
+ children: React.ReactNode;
14
+ action?: React.ReactNode;
15
+ }): React.JSX.Element;
16
+ /** A bar that fills: of a limit (amber, then red, as it nears it), or a `part` of a whole, in one color. */
17
+ export declare function Bar({ share, small, part }: {
18
+ share: number;
19
+ small?: boolean;
20
+ part?: boolean;
21
+ }): React.JSX.Element;
22
+ export declare function Meter({ label, value, share, hint }: {
23
+ label: string;
24
+ value: string;
25
+ share?: number;
26
+ hint?: string;
27
+ }): React.JSX.Element;
28
+ export declare function Stat({ value, label, tone, onClick, title, }: {
29
+ value: React.ReactNode;
30
+ label: string;
31
+ tone?: 'good' | 'warn' | 'bad';
32
+ onClick?(): void;
33
+ title?: string;
34
+ }): React.JSX.Element;
35
+ /** This month's minutes and tokens of an account, as bars; the limits of messages and pages in a line. */
36
+ export declare function QuotaMeters({ quota }: {
37
+ quota: TaQuotaState;
38
+ }): React.JSX.Element;
39
+ /**
40
+ * What agents took over time, of the gateway or of one account: tokens or dollars by hour (a day) or by day (a week,
41
+ * a month), the totals, and the models and accounts that took most.
42
+ */
43
+ export declare function TrendCard({ tenantId, tenants, onTenant }: {
44
+ tenantId?: string;
45
+ tenants?: TaGatewayTenant[];
46
+ onTenant?(id: string): void;
47
+ }): React.JSX.Element;
48
+ /**
49
+ * Limits to change: the gateway's defaults (`nullable` false: a limit is a number or none), or an account's over them
50
+ * (each the default's, none, or its own). Saved as a whole.
51
+ */
52
+ export declare function LimitsForm({ value, defaults, providers, nullable, readOnly, onSave, }: {
53
+ value: TaGatewayLimits;
54
+ defaults?: TaGatewayLimits;
55
+ providers: {
56
+ id: string;
57
+ name: string;
58
+ }[];
59
+ nullable: boolean;
60
+ readOnly?: boolean;
61
+ onSave(limits: TaGatewayLimits): Promise<unknown>;
62
+ }): React.JSX.Element;