@celljs/ta-web 4.19.0 → 4.20.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.
Files changed (91) hide show
  1. package/esm/browser/assistant/assistant-chat-list.js +2 -1
  2. package/esm/browser/components/account-menu.js +3 -1
  3. package/esm/browser/components/app-view.js +2 -2
  4. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  5. package/esm/browser/components/dino-look.d.ts +9 -1
  6. package/esm/browser/components/dino-look.js +46 -1
  7. package/esm/browser/components/environment-view.js +12 -1
  8. package/esm/browser/components/face-pictures.d.ts +10 -0
  9. package/esm/browser/components/face-pictures.js +24 -0
  10. package/esm/browser/components/face.d.ts +4 -1
  11. package/esm/browser/components/face.js +16 -1
  12. package/esm/browser/components/host-view.d.ts +1 -1
  13. package/esm/browser/components/picture-dialog.d.ts +18 -0
  14. package/esm/browser/components/picture-dialog.js +116 -0
  15. package/esm/browser/extension/icons.js +2 -1
  16. package/esm/browser/extension/web-api-home.d.ts +13 -0
  17. package/esm/browser/extension/web-api-home.js +2 -0
  18. package/esm/browser/extension/web-extension-api.d.ts +4 -4
  19. package/esm/browser/extension/web-extension-context.js +2 -1
  20. package/esm/browser/extension/web-home.d.ts +8 -0
  21. package/esm/browser/extension/web-home.js +20 -0
  22. package/esm/browser/gateway/console-limits.d.ts +15 -0
  23. package/esm/browser/gateway/console-limits.js +2 -2
  24. package/esm/browser/gateway/console-tenant.js +33 -2
  25. package/esm/browser/gateway/console-updates.d.ts +12 -0
  26. package/esm/browser/gateway/console-updates.js +76 -0
  27. package/esm/browser/gateway/console-util.d.ts +7 -1
  28. package/esm/browser/gateway/console-util.js +18 -0
  29. package/esm/browser/gateway/console-view.js +9 -2
  30. package/esm/browser/i18n/locales.d.ts +44 -3
  31. package/esm/browser/i18n/locales.js +9 -3
  32. package/esm/browser/i18n/messages-all.d.ts +7 -0
  33. package/esm/browser/i18n/messages-all.js +14 -0
  34. package/esm/browser/i18n/messages-ja.js +39 -0
  35. package/esm/browser/i18n/messages-zh-tw.js +39 -0
  36. package/esm/browser/i18n/messages.d.ts +45 -8
  37. package/esm/browser/i18n/messages.js +111 -11
  38. package/esm/browser/i18n/use-t.js +4 -3
  39. package/esm/browser/settings/settings.js +3 -1
  40. package/esm/browser/style/pages.d.ts +1 -1
  41. package/esm/browser/style/pages.js +5 -0
  42. package/esm/browser/style/surfaces.d.ts +1 -1
  43. package/esm/browser/style/surfaces.js +1 -0
  44. package/esm/browser/util/picture.d.ts +5 -0
  45. package/esm/browser/util/picture.js +43 -0
  46. package/lib/browser/assistant/assistant-chat-list.js +2 -1
  47. package/lib/browser/components/account-menu.js +2 -0
  48. package/lib/browser/components/app-view.js +1 -1
  49. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  50. package/lib/browser/components/dino-look.d.ts +9 -1
  51. package/lib/browser/components/dino-look.js +48 -1
  52. package/lib/browser/components/environment-view.js +11 -0
  53. package/lib/browser/components/face-pictures.d.ts +11 -0
  54. package/lib/browser/components/face-pictures.js +60 -0
  55. package/lib/browser/components/face.d.ts +4 -1
  56. package/lib/browser/components/face.js +16 -1
  57. package/lib/browser/components/host-view.d.ts +1 -1
  58. package/lib/browser/components/picture-dialog.d.ts +19 -0
  59. package/lib/browser/components/picture-dialog.js +153 -0
  60. package/lib/browser/extension/icons.js +1 -0
  61. package/lib/browser/extension/web-api-home.d.ts +14 -0
  62. package/lib/browser/extension/web-api-home.js +3 -0
  63. package/lib/browser/extension/web-extension-api.d.ts +4 -4
  64. package/lib/browser/extension/web-extension-context.js +2 -1
  65. package/lib/browser/extension/web-home.d.ts +8 -0
  66. package/lib/browser/extension/web-home.js +54 -1
  67. package/lib/browser/gateway/console-limits.d.ts +15 -0
  68. package/lib/browser/gateway/console-limits.js +2 -0
  69. package/lib/browser/gateway/console-tenant.js +32 -1
  70. package/lib/browser/gateway/console-updates.d.ts +13 -0
  71. package/lib/browser/gateway/console-updates.js +113 -0
  72. package/lib/browser/gateway/console-util.d.ts +7 -1
  73. package/lib/browser/gateway/console-util.js +18 -0
  74. package/lib/browser/gateway/console-view.js +9 -2
  75. package/lib/browser/i18n/locales.d.ts +44 -3
  76. package/lib/browser/i18n/locales.js +8 -2
  77. package/lib/browser/i18n/messages-all.d.ts +8 -0
  78. package/lib/browser/i18n/messages-all.js +17 -0
  79. package/lib/browser/i18n/messages-ja.js +39 -0
  80. package/lib/browser/i18n/messages-zh-tw.js +39 -0
  81. package/lib/browser/i18n/messages.d.ts +45 -8
  82. package/lib/browser/i18n/messages.js +113 -13
  83. package/lib/browser/i18n/use-t.js +4 -3
  84. package/lib/browser/settings/settings.js +3 -1
  85. package/lib/browser/style/pages.d.ts +1 -1
  86. package/lib/browser/style/pages.js +5 -0
  87. package/lib/browser/style/surfaces.d.ts +1 -1
  88. package/lib/browser/style/surfaces.js +1 -0
  89. package/lib/browser/util/picture.d.ts +6 -0
  90. package/lib/browser/util/picture.js +46 -0
  91. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- import { Gift, Pause, Play, Power, RotateCw, ShieldCheck, ShieldOff } from 'lucide-react';
1
+ import { ArrowUpCircle, Gift, Pause, Play, Power, RotateCw, ShieldCheck, ShieldOff, Undo2 } 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';
@@ -50,6 +50,7 @@ export function TenantRow({ tenant, onOpen }) {
50
50
  React.createElement("span", { className: "ta-console-entry-label ta-ellipsis" },
51
51
  label,
52
52
  React.createElement(RoleChip, { role: tenant.role }),
53
+ environment.latest && React.createElement("span", { className: "ta-console-chip" }, t('ta.console.updatable')),
53
54
  quota.blocked && (React.createElement("span", { className: "ta-console-chip ta-console-chip-warn" }, t(quota.blocked === 'suspended' ? 'ta.console.suspended' : 'ta.console.outOfMinutes')))),
54
55
  React.createElement("span", { className: "ta-console-entry-hint ta-ellipsis" }, label !== tenant.account ? `${tenant.account} · ${state}` : state)),
55
56
  React.createElement("span", { className: "ta-console-side" },
@@ -61,6 +62,7 @@ export function TenantRow({ tenant, onOpen }) {
61
62
  /** One account's Ta: who and where, what can be done to it, what it may use and took, its agents and its log. */
62
63
  export function TenantDetail({ tenant, info, onChanged }) {
63
64
  var _a;
65
+ var _b, _c;
64
66
  const t = useT();
65
67
  const language = useLanguage();
66
68
  const [, bench] = useWorkbench();
@@ -91,6 +93,16 @@ export function TenantDetail({ tenant, info, onChanged }) {
91
93
  if (environment.status !== 'running' && environment.status !== 'starting' && !tenant.quota.blocked) {
92
94
  actions.push({ key: 'start', icon: Play, label: t('ta.console.start'), run: () => act('start', () => bench.gateway.startTenant(tenant.id)) });
93
95
  }
96
+ if (environment.status === 'running' && environment.latest) {
97
+ const version = ConsoleUtil.version(environment.latest);
98
+ const working = (_b = (_a = tenant.agents) === null || _a === void 0 ? void 0 : _a.working) !== null && _b !== void 0 ? _b : 0;
99
+ actions.push({
100
+ key: 'update',
101
+ icon: ArrowUpCircle,
102
+ label: t('ta.console.update'),
103
+ run: () => void confirmThen('update', t('ta.console.updateConfirm', { account: name, version }), working > 0 ? `${t('ta.console.updateDetail')} ${t('ta.console.updateWorking', { count: working })}` : t('ta.console.updateDetail'), t('ta.console.update'), () => bench.gateway.updateTenant(tenant.id)),
104
+ });
105
+ }
94
106
  if (environment.status === 'running') {
95
107
  actions.push({
96
108
  key: 'restart',
@@ -121,6 +133,15 @@ export function TenantDetail({ tenant, info, onChanged }) {
121
133
  },
122
134
  });
123
135
  }
136
+ if (environment.previous && !own) {
137
+ const version = ConsoleUtil.version(environment.previous);
138
+ rows.push({
139
+ key: 'rollback',
140
+ icon: Undo2,
141
+ label: t('ta.console.rollback', { version }),
142
+ run: () => void confirmThen('rollback', t('ta.console.rollbackConfirm', { account: name, version }), t('ta.console.rollbackDetail'), t('ta.console.rollback', { version }), () => bench.gateway.rollbackTenant(tenant.id)),
143
+ });
144
+ }
124
145
  if (info.role === 'owner' && tenant.role !== 'owner') {
125
146
  const admin = tenant.role === 'admin';
126
147
  rows.push({
@@ -163,7 +184,7 @@ export function TenantDetail({ tenant, info, onChanged }) {
163
184
  React.createElement(Section, { title: t('ta.console.quota') },
164
185
  React.createElement(QuotaMeters, { quota: tenant.quota })),
165
186
  manage && tenant.role !== 'owner' && (React.createElement(Section, { title: t('ta.console.limits'), hint: t('ta.console.limitsHint') },
166
- React.createElement(LimitsCard, { 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
187
+ React.createElement(LimitsCard, { value: (_c = tenant.limits) !== null && _c !== void 0 ? _c : {}, defaults: info.policy.defaults, providers: info.providers, nullable: true, metered: info.models.length > 0, onSave: limits => bench.gateway
167
188
  .setTenantLimits(tenant.id, Object.keys(limits).length ? limits : null)
168
189
  .then(onChanged)
169
190
  .catch(error => notices.error(error)) }))),
@@ -180,6 +201,16 @@ export function TenantDetail({ tenant, info, onChanged }) {
180
201
  React.createElement(Section, { title: t('ta.console.about') },
181
202
  React.createElement(Card, null, [
182
203
  [t('ta.console.environment'), environment.url ? `${environment.name} · ${environment.url}` : environment.name],
204
+ ...(environment.version
205
+ ? [
206
+ [
207
+ t('ta.console.version'),
208
+ environment.latest
209
+ ? ConsoleUtil.move(environment.version, environment.latest)
210
+ : ConsoleUtil.version(environment.version),
211
+ ],
212
+ ]
213
+ : []),
183
214
  [t('ta.console.connectionsLabel'), String(tenant.connections)],
184
215
  [t('ta.console.active'), date(tenant.lastActiveAt)],
185
216
  [t('ta.console.created'), date(tenant.createdAt)],
@@ -0,0 +1,12 @@
1
+ import type { TaGatewayConsole } from '@celljs/ta-protocol';
2
+ import * as React from 'react';
3
+ /** How many running Ta may move to a newer version, to move them all; or how far a move of all went. */
4
+ export declare function UpdatesCallout({ info, onChanged }: {
5
+ info: TaGatewayConsole;
6
+ onChanged(): Promise<unknown>;
7
+ }): React.JSX.Element | null;
8
+ /** When running Ta move to a newer version, picked as a limit is; and a look for a newer one now. */
9
+ export declare function UpdatesSection({ info, onChanged }: {
10
+ info: TaGatewayConsole;
11
+ onChanged(): Promise<unknown>;
12
+ }): React.JSX.Element;
@@ -0,0 +1,76 @@
1
+ import { RefreshCw } from 'lucide-react';
2
+ import * as React from 'react';
3
+ import { useBusy } from '../components/busy.js';
4
+ import { Callout } from '../components/callout.js';
5
+ import { Icon } from '../components/icon.js';
6
+ import { useNotices, useWorkbench } from '../hooks.js';
7
+ import { useT } from '../i18n/use-t.js';
8
+ import { LimitRow, ValueButton } from './console-limits.js';
9
+ import { Card, Section } from './console-parts.js';
10
+ import { ConsoleUtil } from './console-util.js';
11
+ /*
12
+ * Newer versions of Ta for the sandboxes (docs/design/ta-sandbox-update.md): on the overview, how many running Ta may
13
+ * move and a way to move them all, or how far that went; in the policy, when running ones move on their own.
14
+ */
15
+ const MODES = [
16
+ { value: 'idle', label: 'ta.console.updateIdle', hint: 'ta.console.updateIdleHint' },
17
+ { value: 'manual', label: 'ta.console.updateManual', hint: 'ta.console.updateManualHint' },
18
+ ];
19
+ /** How many running Ta may move to a newer version, to move them all; or how far a move of all went. */
20
+ export function UpdatesCallout({ info, onChanged }) {
21
+ const t = useT();
22
+ const [, bench] = useWorkbench();
23
+ const [, notices] = useNotices();
24
+ const [busy, run] = useBusy();
25
+ const behind = ConsoleUtil.behind(info);
26
+ if (info.updating) {
27
+ const { done, total } = info.updating;
28
+ return React.createElement(Callout, { level: "info" }, t('ta.console.updatingProgress', { done: Math.min(total, done + 1), total }));
29
+ }
30
+ if (behind.length === 0) {
31
+ return null;
32
+ }
33
+ const version = ConsoleUtil.version(behind[0].environment.latest);
34
+ const updateAll = async () => {
35
+ const confirmed = await notices.confirm({
36
+ title: t('ta.console.updateAllConfirm', { count: behind.length, version }),
37
+ message: t('ta.console.updateAllDetail'),
38
+ confirmLabel: t('ta.console.updateAll'),
39
+ });
40
+ if (confirmed) {
41
+ await run(() => bench.gateway
42
+ .updateTenants()
43
+ .then(onChanged)
44
+ .catch(error => notices.error(error)));
45
+ }
46
+ };
47
+ return (React.createElement(Callout, { level: "info", action: React.createElement("button", { type: "button", className: `ta-link-button${busy ? ' ta-busy' : ''}`, disabled: busy, onClick: () => void updateAll() }, t('ta.console.updateAll')) }, t('ta.console.updatesAvailable', { count: behind.length, version })));
48
+ }
49
+ /** When running Ta move to a newer version, picked as a limit is; and a look for a newer one now. */
50
+ export function UpdatesSection({ info, onChanged }) {
51
+ var _a;
52
+ const t = useT();
53
+ const [, bench] = useWorkbench();
54
+ const [, notices] = useNotices();
55
+ const [saving, save] = useBusy();
56
+ const [checking, check] = useBusy();
57
+ const mode = (_a = MODES.find(each => each.value === info.policy.updates)) !== null && _a !== void 0 ? _a : MODES[0];
58
+ const pick = (value) => void save(() => bench.gateway
59
+ .setUpdatePolicy(value)
60
+ .then(onChanged)
61
+ .catch(error => notices.error(error)));
62
+ const look = () => void check(() => bench.gateway
63
+ .checkUpdates()
64
+ .then(count => notices.notify(t('ta.console.checked', { count }), { level: 'success' }))
65
+ .then(onChanged)
66
+ .catch(error => notices.error(error)));
67
+ return (React.createElement(Section, { title: t('ta.console.updates'), hint: t('ta.console.updatesHint') },
68
+ React.createElement(Card, null,
69
+ React.createElement(LimitRow, { label: t('ta.console.updateMode'), hint: t(mode.hint) },
70
+ React.createElement(ValueButton, { text: t(mode.label), busy: saving, disabled: info.role !== 'owner', label: t('ta.console.updateMode'), items: () => MODES.map(each => ({ label: t(each.label), checked: each.value === mode.value, run: () => pick(each.value) })) })),
71
+ React.createElement("button", { type: "button", className: `ta-console-entry ta-console-press ta-console-command${checking ? ' ta-busy' : ''}`, disabled: checking, onClick: look },
72
+ React.createElement(Icon, { icon: RefreshCw, size: 16 }),
73
+ React.createElement("span", { className: "ta-console-entry-label" }, t('ta.console.checkUpdates')),
74
+ checking && React.createElement("span", { className: "ta-spinner ta-busy-mark", "aria-hidden": "true" })))));
75
+ }
76
+ //# sourceMappingURL=console-updates.js.map
@@ -1,4 +1,4 @@
1
- import type { TaGatewayConsole, TaGatewayTenant, TaQuotaState, TaUsageTrend } from '@celljs/ta-protocol';
1
+ import type { TaGatewayConsole, TaGatewayTenant, TaQuotaState, TaSandboxVersion, TaUsageTrend } from '@celljs/ta-protocol';
2
2
  /** A bar of a trend: an hour or a day of the page's time zone. */
3
3
  export interface TrendPoint {
4
4
  /** Its start. */
@@ -33,6 +33,12 @@ export declare namespace ConsoleUtil {
33
33
  working: number;
34
34
  limited: number;
35
35
  };
36
+ /** `4.18.0`, else the start of the id of its image. */
37
+ function version(value: TaSandboxVersion | undefined): string;
38
+ /** `4.17.0 → 4.18.0`; two builds of one version told apart by their revisions. */
39
+ function move(from: TaSandboxVersion | undefined, to: TaSandboxVersion | undefined): string;
40
+ /** The running Ta that may move to a newer version: those an update of all moves. */
41
+ function behind(info: TaGatewayConsole): TaGatewayTenant[];
36
42
  /** 12.3k, 4.5M: as a person reads a count of tokens. */
37
43
  function count(value: number): string;
38
44
  /** $0.42, $12: what a model's prices made; none for nothing. */
@@ -70,6 +70,24 @@ export var ConsoleUtil;
70
70
  };
71
71
  }
72
72
  ConsoleUtil.counts = counts;
73
+ /** `4.18.0`, else the start of the id of its image. */
74
+ function version(value) {
75
+ var _a, _b;
76
+ return (_b = (_a = value === null || value === void 0 ? void 0 : value.version) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value.id.replace(/^sha256:/, '').slice(0, 12)) !== null && _b !== void 0 ? _b : '';
77
+ }
78
+ ConsoleUtil.version = version;
79
+ /** `4.17.0 → 4.18.0`; two builds of one version told apart by their revisions. */
80
+ function move(from, to) {
81
+ const same = (from === null || from === void 0 ? void 0 : from.version) !== undefined && from.version === (to === null || to === void 0 ? void 0 : to.version);
82
+ const each = (value) => (same && (value === null || value === void 0 ? void 0 : value.revision) ? `${version(value)} (${value.revision})` : version(value));
83
+ return `${each(from)} → ${each(to)}`;
84
+ }
85
+ ConsoleUtil.move = move;
86
+ /** The running Ta that may move to a newer version: those an update of all moves. */
87
+ function behind(info) {
88
+ return info.tenants.filter(tenant => tenant.environment.latest && tenant.environment.status === 'running');
89
+ }
90
+ ConsoleUtil.behind = behind;
73
91
  /** 12.3k, 4.5M: as a person reads a count of tokens. */
74
92
  function count(value) {
75
93
  if (value >= 1e9) {
@@ -15,6 +15,7 @@ import { LimitsCard } from './console-limits.js';
15
15
  import { Card, REFRESH_MS, Section, Stats, usePolled } from './console-parts.js';
16
16
  import { TenantDetail, TenantRow } from './console-tenant.js';
17
17
  import { TrendCard } from './console-trend.js';
18
+ import { UpdatesCallout, UpdatesSection } from './console-updates.js';
18
19
  import { ConsoleUtil } from './console-util.js';
19
20
  const FILTERS = [
20
21
  { value: 'all', label: 'ta.console.filterAll' },
@@ -32,6 +33,10 @@ const ACTIONS = {
32
33
  startTenant: 'ta.console.auditStart',
33
34
  stopTenant: 'ta.console.auditStop',
34
35
  restartTenant: 'ta.console.auditRestart',
36
+ updateTenant: 'ta.console.auditUpdate',
37
+ updateTenants: 'ta.console.auditUpdateAll',
38
+ rollbackTenant: 'ta.console.auditRollback',
39
+ setUpdatePolicy: 'ta.console.auditUpdatePolicy',
35
40
  getTenantLogs: 'ta.console.auditLogs',
36
41
  getAgentActivity: 'ta.console.auditActivity',
37
42
  createSignInLink: 'ta.console.auditInvite',
@@ -78,7 +83,7 @@ function useInvite(info) {
78
83
  t('ta.console.copy')))));
79
84
  return [shown, start];
80
85
  }
81
- function Overview({ info, onTenant, onTab }) {
86
+ function Overview({ info, onTenant, onTab, onChanged, }) {
82
87
  const t = useT();
83
88
  const [, host] = useWebExtensions();
84
89
  const counts = ConsoleUtil.counts(info);
@@ -100,6 +105,7 @@ function Overview({ info, onTenant, onTab }) {
100
105
  { value: counts.connections, label: t('ta.console.connectionsLabel') },
101
106
  ] }),
102
107
  info.requests > 0 && (React.createElement(Callout, { level: "info", action: React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => host.openSettings('access') }, t('ta.console.review')) }, t('ta.console.requestsWaiting', { count: info.requests }))),
108
+ React.createElement(UpdatesCallout, { info: info, onChanged: onChanged }),
103
109
  counts.limited > 0 && (React.createElement(Callout, { level: "warning", action: React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => onTab('accounts', 'limited') }, t('ta.console.view')) }, t('ta.console.limitedCount', { count: counts.limited }))),
104
110
  React.createElement(Section, { title: t('ta.console.trend') },
105
111
  React.createElement(TrendCard, { tenants: info.tenants, onTenant: onTenant })),
@@ -225,6 +231,7 @@ function Policy({ info, onChanged }) {
225
231
  React.createElement("span", { className: "ta-console-entry-label ta-ellipsis" }, provider.name || provider.id),
226
232
  React.createElement("span", { className: "ta-console-entry-hint" }, t('ta.console.modelsOf', { api: provider.api, count: provider.models }))))))))),
227
233
  React.createElement(Egress, { info: info, onChanged: onChanged }),
234
+ React.createElement(UpdatesSection, { info: info, onChanged: onChanged }),
228
235
  React.createElement(Section, { title: t('ta.console.managers'), hint: t('ta.console.managersHint') },
229
236
  React.createElement(Card, null, info.policy.admins.map(admin => (React.createElement("div", { key: admin.account, className: "ta-console-entry" },
230
237
  React.createElement("span", { className: "ta-console-tile" },
@@ -268,7 +275,7 @@ export function ConsolePage() {
268
275
  { value: 'accounts', label: 'ta.console.tabAccounts' },
269
276
  { value: 'policy', label: 'ta.console.tabPolicy' },
270
277
  ] }),
271
- tab === 'overview' && React.createElement(Overview, { info: info, onTenant: open, onTab: goTo }),
278
+ tab === 'overview' && React.createElement(Overview, { info: info, onTenant: open, onTab: goTo, onChanged: read }),
272
279
  tab === 'accounts' && React.createElement(Accounts, { info: info, onOpen: open, filter: filter, onFilter: setFilter }),
273
280
  tab === 'policy' && React.createElement(Policy, { info: info, onChanged: read }),
274
281
  React.createElement("p", { className: "ta-console-foot" }, [