@celljs/ta-web 4.15.2 → 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/app-view.js +7 -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 +50 -1
- 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/extension/icons.js +23 -4
- package/esm/browser/gateway/console-parts.d.ts +3 -1
- package/esm/browser/gateway/console-parts.js +11 -4
- package/esm/browser/gateway/console-tenant.js +1 -1
- package/esm/browser/gateway/console-util.js +2 -2
- package/esm/browser/gateway/console-view.js +10 -2
- package/esm/browser/i18n/locales.d.ts +30 -3
- package/esm/browser/i18n/messages-ja.js +27 -0
- package/esm/browser/i18n/messages-zh-tw.js +27 -0
- package/esm/browser/i18n/messages.d.ts +27 -0
- package/esm/browser/i18n/messages.js +54 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +1 -0
- package/lib/browser/components/app-view.js +7 -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 +49 -0
- 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/extension/icons.js +22 -3
- package/lib/browser/gateway/console-parts.d.ts +3 -1
- package/lib/browser/gateway/console-parts.js +11 -4
- package/lib/browser/gateway/console-tenant.js +1 -1
- package/lib/browser/gateway/console-util.js +2 -2
- package/lib/browser/gateway/console-view.js +9 -1
- package/lib/browser/i18n/locales.d.ts +30 -3
- package/lib/browser/i18n/messages-ja.js +27 -0
- package/lib/browser/i18n/messages-zh-tw.js +27 -0
- package/lib/browser/i18n/messages.d.ts +27 -0
- package/lib/browser/i18n/messages.js +54 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +1 -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)) }))))));
|
|
@@ -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) {
|
|
@@ -49,7 +49,7 @@ export declare function TrendCard({ tenantId, tenants, onTenant }: {
|
|
|
49
49
|
* Limits to change: the gateway's defaults (`nullable` false: a limit is a number or none), or an account's over them
|
|
50
50
|
* (each the default's, none, or its own). Saved as a whole.
|
|
51
51
|
*/
|
|
52
|
-
export declare function LimitsForm({ value, defaults, providers, nullable, readOnly, onSave, }: {
|
|
52
|
+
export declare function LimitsForm({ value, defaults, providers, nullable, readOnly, metered, onSave, }: {
|
|
53
53
|
value: TaGatewayLimits;
|
|
54
54
|
defaults?: TaGatewayLimits;
|
|
55
55
|
providers: {
|
|
@@ -58,5 +58,7 @@ export declare function LimitsForm({ value, defaults, providers, nullable, readO
|
|
|
58
58
|
}[];
|
|
59
59
|
nullable: boolean;
|
|
60
60
|
readOnly?: boolean;
|
|
61
|
+
/** Whether the gateway gives models, so that a limit of tokens holds. */
|
|
62
|
+
metered?: boolean;
|
|
61
63
|
onSave(limits: TaGatewayLimits): Promise<unknown>;
|
|
62
64
|
}): React.JSX.Element;
|
|
@@ -64,7 +64,13 @@ export function QuotaMeters({ quota }) {
|
|
|
64
64
|
: `${ConsoleUtil.minutes(minutes.used)} / ${ConsoleUtil.minutes(allowed)}`, share: allowed === undefined ? undefined : ConsoleUtil.share(minutes.used, allowed), hint: [minutes.bonus > 0 ? t('ta.console.bonus', { minutes: minutes.bonus }) : '', t('ta.console.resets', { date: resets })]
|
|
65
65
|
.filter(Boolean)
|
|
66
66
|
.join(' · ') }),
|
|
67
|
-
React.createElement(Meter, { label: t('ta.console.monthTokens'), value: [
|
|
67
|
+
React.createElement(Meter, { label: t('ta.console.monthTokens'), value: [
|
|
68
|
+
tokens.limit === undefined ? ConsoleUtil.count(tokens.used) : `${ConsoleUtil.count(tokens.used)} / ${ConsoleUtil.count(tokens.limit)}`,
|
|
69
|
+
ConsoleUtil.cost(tokens.cost),
|
|
70
|
+
]
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
.join(' · '), share: tokens.limit === undefined ? undefined : ConsoleUtil.share(tokens.used, tokens.limit), hint: [
|
|
73
|
+
t(tokens.metered ? 'ta.console.tokensMetered' : 'ta.console.tokensReported'),
|
|
68
74
|
quota.promptsPerMinute !== undefined ? t('ta.console.promptsLimit', { count: quota.promptsPerMinute }) : '',
|
|
69
75
|
quota.connections !== undefined ? t('ta.console.connectionsLimit', { count: quota.connections }) : '',
|
|
70
76
|
]
|
|
@@ -215,17 +221,18 @@ function NumberLimit({ label, hint, value, base, nullable, readOnly, onChange, }
|
|
|
215
221
|
* Limits to change: the gateway's defaults (`nullable` false: a limit is a number or none), or an account's over them
|
|
216
222
|
* (each the default's, none, or its own). Saved as a whole.
|
|
217
223
|
*/
|
|
218
|
-
export function LimitsForm({ value, defaults, providers, nullable, readOnly, onSave, }) {
|
|
224
|
+
export function LimitsForm({ value, defaults, providers, nullable, readOnly, metered, onSave, }) {
|
|
219
225
|
const t = useT();
|
|
220
226
|
const [draft, setDraft] = React.useState(value);
|
|
221
227
|
const [busy, setBusy] = React.useState(false);
|
|
222
228
|
React.useEffect(() => setDraft(value), [value]);
|
|
223
229
|
const changed = JSON.stringify(draft) !== JSON.stringify(value);
|
|
224
230
|
const set = (change) => setDraft(current => Object.fromEntries(Object.entries({ ...current, ...change }).filter(([, item]) => item !== undefined)));
|
|
225
|
-
const base = (key) =>
|
|
231
|
+
const base = (key) => typeof (defaults === null || defaults === void 0 ? void 0 : defaults[key]) === 'number' ? String(defaults[key]) : undefined;
|
|
226
232
|
const providersMode = draft.providers === null ? 'none' : draft.providers === undefined ? (nullable ? 'inherit' : 'none') : 'set';
|
|
227
233
|
return (React.createElement("div", { className: "ta-console-card ta-console-limits" },
|
|
228
234
|
React.createElement(NumberLimit, { label: t('ta.console.freeMinutes'), hint: t('ta.console.freeMinutesHint'), value: draft.freeMinutes, base: base('freeMinutes'), nullable: nullable, readOnly: readOnly, onChange: freeMinutes => set({ freeMinutes }) }),
|
|
235
|
+
React.createElement(NumberLimit, { label: t('ta.console.monthlyTokens'), hint: t(metered ? 'ta.console.monthlyTokensHint' : 'ta.console.monthlyTokensOff'), value: draft.monthlyTokens, base: base('monthlyTokens'), nullable: nullable, readOnly: readOnly, onChange: monthlyTokens => set({ monthlyTokens }) }),
|
|
229
236
|
React.createElement(NumberLimit, { label: t('ta.console.promptsPerMinute'), hint: t('ta.console.promptsPerMinuteHint'), value: draft.promptsPerMinute, base: base('promptsPerMinute'), nullable: nullable, readOnly: readOnly, onChange: promptsPerMinute => set({ promptsPerMinute }) }),
|
|
230
237
|
React.createElement(NumberLimit, { label: t('ta.console.connectionsMax'), hint: t('ta.console.connectionsMaxHint'), value: draft.connections, base: base('connections'), nullable: nullable, readOnly: readOnly, onChange: connections => set({ connections }) }),
|
|
231
238
|
React.createElement("div", { className: "ta-console-limit" },
|
|
@@ -263,7 +270,7 @@ export function LimitsForm({ value, defaults, providers, nullable, readOnly, onS
|
|
|
263
270
|
React.createElement("button", { type: "button", className: "ta-button", disabled: !changed || busy, onClick: () => setDraft(value) }, t('ta.console.reset')),
|
|
264
271
|
React.createElement("button", { type: "button", className: "ta-button ta-primary", disabled: !changed ||
|
|
265
272
|
busy ||
|
|
266
|
-
[draft.freeMinutes, draft.promptsPerMinute, draft.connections].some(item => typeof item === 'number' && Number.isNaN(item)), onClick: () => {
|
|
273
|
+
[draft.freeMinutes, draft.monthlyTokens, draft.promptsPerMinute, draft.connections].some(item => typeof item === 'number' && Number.isNaN(item)), onClick: () => {
|
|
267
274
|
setBusy(true);
|
|
268
275
|
void onSave(draft).finally(() => setBusy(false));
|
|
269
276
|
} }, busy ? React.createElement("span", { className: "ta-spinner" }) : t('ta.console.save'))))));
|
|
@@ -250,7 +250,7 @@ export function TenantDetail({ tenant, info, onChanged }) {
|
|
|
250
250
|
t('ta.console.grant')),
|
|
251
251
|
React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => setEditing(!editing) }, t(editing ? 'ta.console.limitsDone' : 'ta.console.limitsEdit')))) : undefined }, t('ta.console.quota')),
|
|
252
252
|
React.createElement(QuotaMeters, { quota: tenant.quota }),
|
|
253
|
-
editing && manage && (React.createElement(LimitsForm, { value: (_a = tenant.limits) !== null && _a !== void 0 ? _a : {}, defaults: info.policy.defaults, providers: info.providers, nullable: true, onSave: limits => bench.gateway
|
|
253
|
+
editing && manage && (React.createElement(LimitsForm, { value: (_a = tenant.limits) !== null && _a !== void 0 ? _a : {}, defaults: info.policy.defaults, providers: info.providers, nullable: true, metered: info.models.length > 0, onSave: limits => bench.gateway
|
|
254
254
|
.setTenantLimits(tenant.id, Object.keys(limits).length ? limits : null)
|
|
255
255
|
.then(() => notices.notify(t('ta.console.saved'), { level: 'success' }))
|
|
256
256
|
.then(onChanged)
|
|
@@ -30,14 +30,14 @@ export var ConsoleUtil;
|
|
|
30
30
|
ConsoleUtil.matches = matches;
|
|
31
31
|
function filter(tenant, by) {
|
|
32
32
|
var _a;
|
|
33
|
-
var _b, _c;
|
|
33
|
+
var _b, _c, _d;
|
|
34
34
|
switch (by) {
|
|
35
35
|
case 'running':
|
|
36
36
|
return tenant.environment.status === 'running';
|
|
37
37
|
case 'working':
|
|
38
38
|
return ((_b = (_a = tenant.agents) === null || _a === void 0 ? void 0 : _a.working) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
39
39
|
case 'limited':
|
|
40
|
-
return !!tenant.quota.blocked || ((_c = minutesShare(tenant.quota)) !== null && _c !== void 0 ? _c : 0) >= 80;
|
|
40
|
+
return (!!tenant.quota.blocked || ((_c = minutesShare(tenant.quota)) !== null && _c !== void 0 ? _c : 0) >= 80 || ((_d = share(tenant.quota.tokens.used, tenant.quota.tokens.limit)) !== null && _d !== void 0 ? _d : 0) >= 80);
|
|
41
41
|
case 'admins':
|
|
42
42
|
return tenant.role !== 'member';
|
|
43
43
|
default:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChevronLeft, Copy, RefreshCw, Search, Server, ShieldCheck, UserPlus } from 'lucide-react';
|
|
1
|
+
import { Bot, ChevronLeft, Copy, RefreshCw, Search, Server, ShieldCheck, UserPlus } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useBusy } from '../components/busy.js';
|
|
4
4
|
import { Callout } from '../components/callout.js';
|
|
@@ -153,11 +153,19 @@ function Policy({ info, onChanged }) {
|
|
|
153
153
|
return (React.createElement(React.Fragment, null,
|
|
154
154
|
React.createElement(SectionTitle, null, t('ta.console.defaults')),
|
|
155
155
|
React.createElement("p", { className: "ta-list-hint" }, t(owner ? 'ta.console.defaultsHint' : 'ta.console.defaultsReadOnly')),
|
|
156
|
-
React.createElement(LimitsForm, { value: info.policy.defaults, providers: info.providers, nullable: false, readOnly: !owner, onSave: limits => bench.gateway
|
|
156
|
+
React.createElement(LimitsForm, { value: info.policy.defaults, providers: info.providers, nullable: false, readOnly: !owner, metered: info.models.length > 0, onSave: limits => bench.gateway
|
|
157
157
|
.setDefaultLimits(limits)
|
|
158
158
|
.then(() => notices.notify(t('ta.console.saved'), { level: 'success' }))
|
|
159
159
|
.then(onChanged)
|
|
160
160
|
.catch(error => notices.error(error)) }),
|
|
161
|
+
React.createElement(SectionTitle, null, t('ta.console.models')),
|
|
162
|
+
info.models.length === 0 ? (React.createElement("p", { className: "ta-list-hint" }, t('ta.console.modelsNone'))) : (React.createElement(React.Fragment, null,
|
|
163
|
+
React.createElement(ListGroup, null, info.models.map(provider => (React.createElement("div", { key: provider.id, className: "ta-console-provider" },
|
|
164
|
+
React.createElement(Icon, { icon: Bot, size: 18, className: "ta-list-icon" }),
|
|
165
|
+
React.createElement("span", { className: "ta-console-tenant-text" },
|
|
166
|
+
React.createElement("span", { className: "ta-console-tenant-name ta-ellipsis" }, provider.name || provider.id),
|
|
167
|
+
React.createElement("span", { className: "ta-console-tenant-state" }, t('ta.console.modelsOf', { api: provider.api, count: provider.models }))))))),
|
|
168
|
+
React.createElement("p", { className: "ta-list-hint" }, t('ta.console.modelsHint')))),
|
|
161
169
|
React.createElement(SectionTitle, null, t('ta.console.managers')),
|
|
162
170
|
React.createElement("div", { className: "ta-list-group" }, info.policy.admins.map(admin => (React.createElement("div", { key: admin.account, className: "ta-console-audit" },
|
|
163
171
|
React.createElement("span", { className: "ta-console-audit-text ta-ellipsis" },
|