@celljs/ta-web 4.15.1 → 4.16.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/components/access-view.d.ts +6 -0
- package/esm/browser/components/access-view.js +4 -4
- package/esm/browser/components/app-view.js +11 -1
- package/esm/browser/components/chat-list.d.ts +3 -1
- package/esm/browser/components/chat-list.js +9 -4
- package/esm/browser/components/chat-seen.d.ts +7 -0
- package/esm/browser/components/chat-seen.js +57 -10
- package/esm/browser/components/environment-view.js +59 -3
- package/esm/browser/components/folder-picker.js +3 -3
- package/esm/browser/components/host-tag.js +2 -2
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/remote-hosts.js +66 -5
- package/esm/browser/components/settings-parts.js +4 -1
- package/esm/browser/extension/icons.js +23 -4
- package/esm/browser/extension/web-extension-protocol.d.ts +6 -0
- package/esm/browser/extension/web-extensions.d.ts +3 -0
- package/esm/browser/extension/web-extensions.js +7 -0
- package/esm/browser/gateway/console-extension.d.ts +20 -0
- package/esm/browser/gateway/console-extension.js +75 -0
- package/esm/browser/gateway/console-parts.d.ts +64 -0
- package/esm/browser/gateway/console-parts.js +278 -0
- package/esm/browser/gateway/console-tenant.d.ts +22 -0
- package/esm/browser/gateway/console-tenant.js +286 -0
- package/esm/browser/gateway/console-util.d.ts +59 -0
- package/esm/browser/gateway/console-util.js +187 -0
- package/esm/browser/gateway/console-view.d.ts +2 -0
- package/esm/browser/gateway/console-view.js +226 -0
- package/esm/browser/i18n/locales.d.ts +201 -3
- package/esm/browser/i18n/messages-ja.js +198 -0
- package/esm/browser/i18n/messages-zh-tw.js +198 -0
- package/esm/browser/i18n/messages.d.ts +198 -0
- package/esm/browser/i18n/messages.js +396 -0
- package/esm/browser/index.d.ts +3 -0
- package/esm/browser/index.js +3 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +141 -0
- package/lib/browser/components/access-view.d.ts +6 -0
- package/lib/browser/components/access-view.js +5 -4
- package/lib/browser/components/app-view.js +11 -1
- package/lib/browser/components/chat-list.d.ts +3 -1
- package/lib/browser/components/chat-list.js +9 -4
- package/lib/browser/components/chat-seen.d.ts +7 -0
- package/lib/browser/components/chat-seen.js +57 -10
- package/lib/browser/components/environment-view.js +58 -2
- package/lib/browser/components/folder-picker.js +2 -2
- package/lib/browser/components/host-tag.js +1 -1
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/remote-hosts.js +65 -4
- package/lib/browser/components/settings-parts.js +4 -1
- package/lib/browser/extension/icons.js +22 -3
- package/lib/browser/extension/web-extension-protocol.d.ts +6 -0
- package/lib/browser/extension/web-extensions.d.ts +3 -0
- package/lib/browser/extension/web-extensions.js +7 -0
- package/lib/browser/gateway/console-extension.d.ts +21 -0
- package/lib/browser/gateway/console-extension.js +111 -0
- package/lib/browser/gateway/console-parts.d.ts +65 -0
- package/lib/browser/gateway/console-parts.js +322 -0
- package/lib/browser/gateway/console-tenant.d.ts +23 -0
- package/lib/browser/gateway/console-tenant.js +327 -0
- package/lib/browser/gateway/console-util.d.ts +60 -0
- package/lib/browser/gateway/console-util.js +190 -0
- package/lib/browser/gateway/console-view.d.ts +3 -0
- package/lib/browser/gateway/console-view.js +262 -0
- package/lib/browser/i18n/locales.d.ts +201 -3
- package/lib/browser/i18n/messages-ja.js +198 -0
- package/lib/browser/i18n/messages-zh-tw.js +198 -0
- package/lib/browser/i18n/messages.d.ts +198 -0
- package/lib/browser/i18n/messages.js +396 -0
- package/lib/browser/index.d.ts +3 -0
- package/lib/browser/index.js +3 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +141 -0
- package/package.json +7 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TaLocation } from '@celljs/ta-protocol';
|
|
2
|
-
import { Plug, Plus, Server, Trash2, Unplug, X } from 'lucide-react';
|
|
2
|
+
import { Cloud, ExternalLink, KeyRound, Link2, Plug, Plus, Server, Tag, Trash2, Unplug, X } from 'lucide-react';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useNotices, useWorkbench } from '../hooks.js';
|
|
5
5
|
import { useT } from '../i18n/use-t.js';
|
|
@@ -26,6 +26,59 @@ function useRemote() {
|
|
|
26
26
|
}, [workbench.status, bench, read]);
|
|
27
27
|
return { bench, hosts, ports, read };
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* A cloud workspace to add: the address of a Ta gateway (or Ta service), a token of one's account there, and a name for
|
|
31
|
+
* its directories, `ta://<name>/…`. Checked by connecting before it is kept.
|
|
32
|
+
*/
|
|
33
|
+
function AddCloudHost({ onAdded }) {
|
|
34
|
+
const t = useT();
|
|
35
|
+
const [, bench] = useWorkbench();
|
|
36
|
+
const [, notices] = useNotices();
|
|
37
|
+
const [open, setOpen] = React.useState(false);
|
|
38
|
+
const [name, setName] = React.useState('');
|
|
39
|
+
const [url, setUrl] = React.useState('');
|
|
40
|
+
const [token, setToken] = React.useState('');
|
|
41
|
+
const [busy, setBusy] = React.useState(false);
|
|
42
|
+
const nameOk = TaLocation.isCloudName(name.trim());
|
|
43
|
+
if (!open) {
|
|
44
|
+
return (React.createElement("button", { type: "button", className: "ta-button", onClick: () => setOpen(true) },
|
|
45
|
+
React.createElement(Icon, { icon: Cloud, size: 14 }),
|
|
46
|
+
" ",
|
|
47
|
+
t('ta.remote.addCloud')));
|
|
48
|
+
}
|
|
49
|
+
return (React.createElement("form", { className: "ta-environment-own", onSubmit: async (event) => {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
setBusy(true);
|
|
52
|
+
try {
|
|
53
|
+
const added = await bench.remote.addCloudHost(name.trim(), url.trim(), token.trim());
|
|
54
|
+
notices.notify(t('ta.remote.cloudAdded', { name: TaLocation.hostLabel(added.host) }), { level: 'success' });
|
|
55
|
+
setOpen(false);
|
|
56
|
+
setName('');
|
|
57
|
+
setUrl('');
|
|
58
|
+
setToken('');
|
|
59
|
+
await onAdded();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
notices.error(error);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
setBusy(false);
|
|
66
|
+
}
|
|
67
|
+
} },
|
|
68
|
+
React.createElement("label", { className: "ta-field" },
|
|
69
|
+
React.createElement(Icon, { icon: Link2, size: 16 }),
|
|
70
|
+
React.createElement("input", { value: url, placeholder: "https://ta.example.com", "aria-label": t('ta.remote.cloudUrl'), spellCheck: false, autoCapitalize: "off", onChange: event => setUrl(event.target.value) })),
|
|
71
|
+
React.createElement("label", { className: "ta-field" },
|
|
72
|
+
React.createElement(Icon, { icon: KeyRound, size: 16 }),
|
|
73
|
+
React.createElement("input", { type: "password", value: token, placeholder: t('ta.remote.cloudToken'), "aria-label": t('ta.remote.cloudToken'), autoComplete: "off", onChange: event => setToken(event.target.value) })),
|
|
74
|
+
React.createElement("label", { className: "ta-field" },
|
|
75
|
+
React.createElement(Icon, { icon: Tag, size: 16 }),
|
|
76
|
+
React.createElement("input", { value: name, placeholder: t('ta.remote.cloudName'), "aria-label": t('ta.remote.cloudName'), "aria-invalid": name.trim() && !nameOk ? true : undefined, spellCheck: false, autoCapitalize: "off", onChange: event => setName(event.target.value.toLowerCase()) })),
|
|
77
|
+
React.createElement("p", { className: "ta-environment-hint" }, t('ta.remote.cloudHint')),
|
|
78
|
+
React.createElement("div", { className: "ta-auth-actions" },
|
|
79
|
+
React.createElement("button", { type: "button", className: "ta-button", onClick: () => setOpen(false) }, t('ta.cancel')),
|
|
80
|
+
React.createElement("button", { type: "submit", className: "ta-button ta-primary", disabled: busy || !nameOk || !url.trim() || !token.trim() }, busy ? React.createElement("span", { className: "ta-spinner" }) : t('ta.remote.cloudConnect')))));
|
|
81
|
+
}
|
|
29
82
|
/**
|
|
30
83
|
* The machines conversations can work on (`ssh://` directories): those of ~/.ssh/config and those added,
|
|
31
84
|
* whether Ta is connected to each, and the ports forwarded from them. Connecting checks a host the way a
|
|
@@ -70,24 +123,32 @@ export function RemoteHosts() {
|
|
|
70
123
|
React.createElement(Icon, { icon: Plus, size: 14 }),
|
|
71
124
|
" ",
|
|
72
125
|
t('ta.remote.add')))),
|
|
126
|
+
React.createElement(Row, { label: t('ta.remote.cloudTitle'), description: t('ta.remote.cloudDescription'), stacked: true },
|
|
127
|
+
React.createElement(AddCloudHost, { onAdded: read })),
|
|
73
128
|
hosts.length === 0 && React.createElement(EmptyRow, { picture: React.createElement(RemotePicture, null), title: t('ta.remote.none'), hint: t('ta.remote.noneHint') }),
|
|
74
|
-
hosts.map(host => (React.createElement(Row, { key: host.host, label: RemoteHostsUtil.breakable(host.host), description: React.createElement("span", { className: "ta-remote-state" },
|
|
129
|
+
hosts.map(host => { var _a; return (React.createElement(Row, { key: host.host, icon: host.source === 'cloud' ? Cloud : undefined, label: host.source === 'cloud' ? TaLocation.hostLabel(host.host) : RemoteHostsUtil.breakable(host.host), description: React.createElement("span", { className: "ta-remote-state" },
|
|
75
130
|
React.createElement("span", { className: `ta-remote-light${host.connected ? ' ta-on' : ''}` }),
|
|
76
131
|
[
|
|
77
132
|
t(host.connected ? 'ta.remote.connected' : 'ta.remote.disconnected'),
|
|
78
|
-
|
|
133
|
+
host.source === 'cloud'
|
|
134
|
+
? ((_a = host.url) !== null && _a !== void 0 ? _a : '').replace(/^https?:\/\//, '')
|
|
135
|
+
: t(host.source === 'config' ? 'ta.remote.fromConfig' : 'ta.remote.added'),
|
|
79
136
|
].join(' · ')) },
|
|
137
|
+
host.source === 'cloud' && host.url && (React.createElement("a", { className: "ta-button", href: host.url, target: "_blank", rel: "noreferrer noopener", title: t('ta.remote.openCloudHint') },
|
|
138
|
+
React.createElement(Icon, { icon: ExternalLink, size: 14 }),
|
|
139
|
+
" ",
|
|
140
|
+
t('ta.remote.openCloud'))),
|
|
80
141
|
host.connected ? (React.createElement("button", { type: "button", className: "ta-button", disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.disconnect(host.host)) },
|
|
81
142
|
React.createElement(Icon, { icon: Unplug, size: 14 }),
|
|
82
143
|
" ",
|
|
83
144
|
t('ta.remote.disconnect'))) : (React.createElement("button", { type: "button", className: "ta-button", disabled: busy === host.host, onClick: () => run(host.host, async () => {
|
|
84
145
|
await bench.remote.resolveLocation(TaLocation.ssh(host.host));
|
|
85
|
-
notices.notify(t('ta.remote.connectedTo', { host: host.host }), { level: 'success' });
|
|
146
|
+
notices.notify(t('ta.remote.connectedTo', { host: TaLocation.hostLabel(host.host) }), { level: 'success' });
|
|
86
147
|
}) },
|
|
87
148
|
busy === host.host ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: Plug, size: 14 }),
|
|
88
149
|
" ",
|
|
89
150
|
t('ta.remote.connect'))),
|
|
90
|
-
host.source
|
|
151
|
+
host.source !== 'config' && (React.createElement(IconButton, { icon: Trash2, label: t('ta.remote.remove', { host: host.host }), disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.removeHost(host.host)) })))); }),
|
|
91
152
|
ports.map(port => (React.createElement(Row, { key: `${port.host}:${port.remotePort}`, label: t('ta.remote.port', { host: port.host, port: port.remotePort }), description: `localhost:${port.localPort}` },
|
|
92
153
|
React.createElement(Icon, { icon: Server, size: 14, className: "ta-muted" }),
|
|
93
154
|
React.createElement(IconButton, { icon: X, label: t('ta.remote.closePort'), onClick: () => run(port.host, () => bench.remote.closeForwardedPort(port.host, port.remotePort)) }))))));
|
|
@@ -240,7 +240,10 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
240
240
|
title: t('ta.packages.builtinTitle'),
|
|
241
241
|
icon: Blocks,
|
|
242
242
|
rows: [
|
|
243
|
-
|
|
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) },
|
|
244
247
|
React.createElement(Switch, { label: t(builtin.title), checked: !settings.builtinsOff.includes(builtin.name), onChange: on => toggleBuiltin(builtin.name, on) }))); }),
|
|
245
248
|
...builtinPackages.map(info => {
|
|
246
249
|
const { title, summary, icon } = packageLabel(info, language);
|
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
1
|
+
import { AlarmClock, Aperture, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, BellOff, BookOpen, Bot, Box, Bug, Building2, Calendar, CaseSensitive, ChartSpline, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, CircleHelp, Clipboard, Clock, Cloud, Code, Coins, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Cpu, Crown, Database, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, FlaskConical, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, Gauge, GitBranch, GitCommitHorizontal, Globe, Grip, HardDrive, Hash, Heart, House, Image, ImagePlus, Info, KeyRound, Laptop, LayoutDashboard, Lightbulb, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, Lock, MapIcon, Megaphone, MemoryStick, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MonitorSmartphone, MousePointerClick, Package, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, Radar, RefreshCw, Regex, Replace, ReplaceAll, Rocket, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Send, Server, Share2, Shield, Smartphone, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Timer, Trash2, TrendingDown, TrendingUp, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, Wrench, X, Zap, } 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,
|
|
@@ -13,7 +13,9 @@ export const WEB_ICONS = Object.freeze({
|
|
|
13
13
|
BookOpen,
|
|
14
14
|
Bot,
|
|
15
15
|
Box,
|
|
16
|
+
Bug,
|
|
16
17
|
Building2,
|
|
18
|
+
Calendar,
|
|
17
19
|
CaseSensitive,
|
|
18
20
|
ChartSpline,
|
|
19
21
|
Check,
|
|
@@ -23,16 +25,18 @@ export const WEB_ICONS = Object.freeze({
|
|
|
23
25
|
ChevronsUpDown,
|
|
24
26
|
CircleAlert,
|
|
25
27
|
CircleHelp,
|
|
26
|
-
Cloud,
|
|
27
28
|
Clipboard,
|
|
28
29
|
Clock,
|
|
30
|
+
Cloud,
|
|
29
31
|
Code,
|
|
32
|
+
Coins,
|
|
30
33
|
Columns2,
|
|
31
34
|
Contact,
|
|
32
35
|
Copy,
|
|
33
36
|
CopyMinus,
|
|
34
37
|
CornerDownRight,
|
|
35
38
|
CornerUpLeft,
|
|
39
|
+
Cpu,
|
|
36
40
|
Crown,
|
|
37
41
|
Database,
|
|
38
42
|
Download,
|
|
@@ -43,21 +47,24 @@ export const WEB_ICONS = Object.freeze({
|
|
|
43
47
|
FileArchive,
|
|
44
48
|
FileDiff,
|
|
45
49
|
FilePlus,
|
|
46
|
-
FileText,
|
|
47
50
|
Files,
|
|
51
|
+
FileText,
|
|
48
52
|
Film,
|
|
53
|
+
FlaskConical,
|
|
49
54
|
Folder,
|
|
50
55
|
FolderInput,
|
|
51
56
|
FolderOpen,
|
|
52
|
-
Forward,
|
|
53
57
|
FolderPlus,
|
|
54
58
|
FolderSearch,
|
|
55
59
|
FolderTree,
|
|
60
|
+
Forward,
|
|
56
61
|
Gamepad2,
|
|
62
|
+
Gauge,
|
|
57
63
|
GitBranch,
|
|
58
64
|
GitCommitHorizontal,
|
|
59
65
|
Globe,
|
|
60
66
|
Grip,
|
|
67
|
+
HardDrive,
|
|
61
68
|
Hash,
|
|
62
69
|
Heart,
|
|
63
70
|
House,
|
|
@@ -67,6 +74,7 @@ export const WEB_ICONS = Object.freeze({
|
|
|
67
74
|
KeyRound,
|
|
68
75
|
Laptop,
|
|
69
76
|
LayoutDashboard,
|
|
77
|
+
Lightbulb,
|
|
70
78
|
Link,
|
|
71
79
|
List,
|
|
72
80
|
ListChecks,
|
|
@@ -75,8 +83,10 @@ export const WEB_ICONS = Object.freeze({
|
|
|
75
83
|
ListX,
|
|
76
84
|
LoaderCircle,
|
|
77
85
|
LocateFixed,
|
|
86
|
+
Lock,
|
|
78
87
|
Map: MapIcon,
|
|
79
88
|
Megaphone,
|
|
89
|
+
MemoryStick,
|
|
80
90
|
MessageCircle,
|
|
81
91
|
MessageSquareDot,
|
|
82
92
|
MessageSquareText,
|
|
@@ -85,6 +95,7 @@ export const WEB_ICONS = Object.freeze({
|
|
|
85
95
|
Minus,
|
|
86
96
|
MonitorSmartphone,
|
|
87
97
|
MousePointerClick,
|
|
98
|
+
Package,
|
|
88
99
|
PackageOpen,
|
|
89
100
|
Paperclip,
|
|
90
101
|
Pencil,
|
|
@@ -100,6 +111,7 @@ export const WEB_ICONS = Object.freeze({
|
|
|
100
111
|
Regex,
|
|
101
112
|
Replace,
|
|
102
113
|
ReplaceAll,
|
|
114
|
+
Rocket,
|
|
103
115
|
RotateCcw,
|
|
104
116
|
Rows2,
|
|
105
117
|
Save,
|
|
@@ -109,6 +121,8 @@ export const WEB_ICONS = Object.freeze({
|
|
|
109
121
|
Send,
|
|
110
122
|
Server,
|
|
111
123
|
Share2,
|
|
124
|
+
Shield,
|
|
125
|
+
Smartphone,
|
|
112
126
|
Sparkles,
|
|
113
127
|
Square,
|
|
114
128
|
SquareMinus,
|
|
@@ -118,7 +132,10 @@ export const WEB_ICONS = Object.freeze({
|
|
|
118
132
|
StarOff,
|
|
119
133
|
Store,
|
|
120
134
|
Text,
|
|
135
|
+
Timer,
|
|
121
136
|
Trash2,
|
|
137
|
+
TrendingDown,
|
|
138
|
+
TrendingUp,
|
|
122
139
|
Trophy,
|
|
123
140
|
Undo2,
|
|
124
141
|
Unplug,
|
|
@@ -128,7 +145,9 @@ export const WEB_ICONS = Object.freeze({
|
|
|
128
145
|
Users,
|
|
129
146
|
Volume2,
|
|
130
147
|
WholeWord,
|
|
148
|
+
Wrench,
|
|
131
149
|
X,
|
|
150
|
+
Zap,
|
|
132
151
|
});
|
|
133
152
|
export var WebIconUtil;
|
|
134
153
|
(function (WebIconUtil) {
|
|
@@ -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,64 @@
|
|
|
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, metered, onSave, }: {
|
|
53
|
+
value: TaGatewayLimits;
|
|
54
|
+
defaults?: TaGatewayLimits;
|
|
55
|
+
providers: {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
}[];
|
|
59
|
+
nullable: boolean;
|
|
60
|
+
readOnly?: boolean;
|
|
61
|
+
/** Whether the gateway gives models, so that a limit of tokens holds. */
|
|
62
|
+
metered?: boolean;
|
|
63
|
+
onSave(limits: TaGatewayLimits): Promise<unknown>;
|
|
64
|
+
}): React.JSX.Element;
|