@llmnative/runner 0.0.0-stage → 1.0.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.
@@ -0,0 +1,50 @@
1
+ import { type InstallOptions, type InstallPhase } from './steps';
2
+ export * from './steps';
3
+ export type SshTarget = {
4
+ host: string;
5
+ port?: number;
6
+ username: string;
7
+ /** A private key (PEM/OpenSSH), or a password. */
8
+ privateKey?: string;
9
+ passphrase?: string;
10
+ password?: string;
11
+ /**
12
+ * The fingerprint the server must have (`SHA256:…`, as `ssh-keygen -lf` prints it); none: the first one is taken
13
+ * and given back in the result, to be kept for the next time.
14
+ */
15
+ hostFingerprint?: string;
16
+ };
17
+ export type InstallProgress = {
18
+ line: string;
19
+ phase?: InstallPhase;
20
+ };
21
+ export type InstallResult = {
22
+ url: string;
23
+ pairingCode: string;
24
+ hostFingerprint: string;
25
+ };
26
+ export declare class InstallError extends Error {
27
+ readonly code: string;
28
+ readonly output: string;
29
+ constructor(code: string, message: string, output?: string);
30
+ }
31
+ /** The command run on the VPS: the script of the release, with sudo unless the user is root. */
32
+ export declare function remoteInstallCommand(options: InstallOptions & {
33
+ root: boolean;
34
+ }): string;
35
+ /** Installs a runner over SSH; `onProgress` gets every line it prints (and the phase when one starts). */
36
+ export declare function installOverSsh(target: SshTarget, options: InstallOptions & {
37
+ onProgress?: (progress: InstallProgress) => void;
38
+ timeoutMs?: number;
39
+ }): Promise<InstallResult>;
40
+ /** Installs and pairs at once: the platform key, seen once, to keep in the backend of the host. */
41
+ export declare function installAndPair(target: SshTarget, options: InstallOptions & {
42
+ name?: string;
43
+ onProgress?: (progress: InstallProgress) => void;
44
+ fetch?: typeof fetch;
45
+ }): Promise<{
46
+ url: string;
47
+ hostFingerprint: string;
48
+ platformKey: string;
49
+ version: string;
50
+ }>;
@@ -0,0 +1,68 @@
1
+ /** The release these steps install: the version of this package (images and package share it). */
2
+ export declare const RUNNER_VERSION: string;
3
+ export declare const RUNNER_REPOSITORY = "sherpadvisorylab/llmnative-runner";
4
+ export declare const RUNNER_REQUIREMENTS: {
5
+ readonly systems: readonly ['Ubuntu 22.04 or newer', 'Debian 12 or newer'];
6
+ readonly architectures: readonly ['x86_64', 'arm64'];
7
+ readonly cpus: 2;
8
+ readonly memoryGb: 4;
9
+ readonly diskGb: 20;
10
+ readonly ports: readonly [22, 80, 443];
11
+ };
12
+ /** The domain of a runner: a host name of its own (`runner.example.com`), pointed at the VPS. */
13
+ export declare const DOMAIN_PATTERN: RegExp;
14
+ export declare const isDomain: (value: string) => boolean;
15
+ export declare const installScriptUrl: (version?: string) => string;
16
+ export declare const checksumUrl: (version?: string) => string;
17
+ export type InstallOptions = {
18
+ domain: string;
19
+ version?: string;
20
+ maxChats?: number;
21
+ };
22
+ /** The arguments of install.sh, each quoted for a shell. */
23
+ export declare function installArguments({ domain, maxChats }: InstallOptions): string[];
24
+ /** The command to paste on the VPS (as root, or with sudo). */
25
+ export declare function installCommand(options: InstallOptions): string;
26
+ /** The same, for who checks the script before running it. */
27
+ export declare function verifiedInstallCommands(options: InstallOptions): string[];
28
+ /** The steps of the guide, in order; `check` says what the guide can verify by itself at that step. */
29
+ export declare const GUIDE_STEPS: readonly [{
30
+ readonly id: 'server';
31
+ }, {
32
+ readonly id: 'dns';
33
+ readonly check: 'dns';
34
+ }, {
35
+ readonly id: 'access';
36
+ }, {
37
+ readonly id: 'install';
38
+ }, {
39
+ readonly id: 'pair';
40
+ readonly check: 'health';
41
+ }];
42
+ export type GuideStepId = (typeof GUIDE_STEPS)[number]['id'];
43
+ /** What install.sh prints for a machine to read: `RUNNER_URL=…`, `PAIRING_CODE=…`, `RUNNER_ERROR=…`. */
44
+ export declare function parseInstallOutput(text: string): {
45
+ url?: string;
46
+ pairingCode?: string;
47
+ error?: string;
48
+ };
49
+ /** The steps install.sh announces (`STEP=<id>`), for a progress shown while it runs. */
50
+ export declare const INSTALL_PHASES: readonly ['check', 'docker', 'files', 'start', 'agent', 'health', 'pair', 'tls', 'done'];
51
+ export type InstallPhase = (typeof INSTALL_PHASES)[number];
52
+ export declare const phaseOf: (line: string) => InstallPhase | undefined;
53
+ /**
54
+ * The addresses a domain points to, asked over DNS-over-HTTPS (no DNS from a browser otherwise). `resolver`: a
55
+ * service that answers `application/dns-json` (by default Cloudflare's; any other can be given).
56
+ */
57
+ export declare function lookupDomain(domain: string, options?: {
58
+ fetch?: typeof fetch;
59
+ resolver?: string;
60
+ }): Promise<string[]>;
61
+ /** Whether a runner answers at its address, over HTTPS: its version, or why not. */
62
+ export declare function checkRunner(url: string, fetchImpl?: typeof fetch): Promise<{
63
+ ok: true;
64
+ version: string;
65
+ } | {
66
+ ok: false;
67
+ reason: 'unreachable' | 'not-a-runner';
68
+ }>;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { checkRunner } from '../setup/steps';
3
+ import { type RunnerUiTexts } from './texts';
4
+ export type InstallGuideProps = {
5
+ locale?: string;
6
+ texts?: Partial<RunnerUiTexts>;
7
+ /** The pairing code given back, with the address of the runner: the host connects it. */
8
+ onPair: (input: {
9
+ url: string;
10
+ code: string;
11
+ }) => Promise<void>;
12
+ /** How a domain is looked up; by default DNS-over-HTTPS. */
13
+ lookup?: (domain: string) => Promise<string[]>;
14
+ /** How the runner is checked; by default its /health. */
15
+ check?: typeof checkRunner;
16
+ version?: string;
17
+ };
18
+ export declare function InstallGuide({ locale, texts, onPair, lookup, check, version }: InstallGuideProps): React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { type RunnerAccount, type RunnerClient } from '../client';
3
+ import { type RunnerUiTexts } from './texts';
4
+ export type RunnerAccountsProps = {
5
+ /** A client for this scope: through the backend of the host for a person, with the admin token in the console. */
6
+ client: RunnerClient;
7
+ scope: 'user' | 'tenant';
8
+ locale?: string;
9
+ texts?: Partial<RunnerUiTexts>;
10
+ /** Called after an account was added or removed (the host refreshes its list of models). */
11
+ onChange?: (accounts: RunnerAccount[]) => void;
12
+ };
13
+ export declare function RunnerAccounts({ client, scope, locale, texts, onChange }: RunnerAccountsProps): React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { type RunnerClient } from '../client';
3
+ import { type RunnerUiTexts } from './texts';
4
+ export type RunnerConsoleProps = {
5
+ client: RunnerClient;
6
+ locale?: string;
7
+ texts?: Partial<RunnerUiTexts>;
8
+ onSignOut?: () => void;
9
+ };
10
+ export declare function RunnerConsole({ client, locale, texts, onSignOut }: RunnerConsoleProps): React.JSX.Element;
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import type { RunnerStatus } from '../client';
3
+ import type { InstallPhase } from '../setup/steps';
4
+ import { type RunnerUiTexts } from './texts';
5
+ export type RunnerEntry = {
6
+ id: string;
7
+ name: string;
8
+ url: string;
9
+ isDefault?: boolean;
10
+ draining?: boolean;
11
+ };
12
+ export type RunnerSshAccess = {
13
+ host: string;
14
+ port?: number;
15
+ username: string;
16
+ privateKey?: string;
17
+ password?: string;
18
+ };
19
+ /** What the platform does for this page, in its backend (where the platform keys are). */
20
+ export interface RunnerFleet {
21
+ list(): Promise<RunnerEntry[]>;
22
+ /** Connects a runner: with a pairing code (the backend pairs and keeps the platform key), or a key made before. */
23
+ add(input: {
24
+ name: string;
25
+ url: string;
26
+ code?: string;
27
+ key?: string;
28
+ }): Promise<RunnerEntry>;
29
+ update(id: string, patch: Partial<Pick<RunnerEntry, 'name' | 'isDefault' | 'draining'>>): Promise<void>;
30
+ remove(id: string): Promise<void>;
31
+ status(id: string): Promise<RunnerStatus>;
32
+ /** Installs and connects a runner over SSH (`@llmnative/runner/setup` in the backend); none: only by hand. */
33
+ install?(input: {
34
+ name: string;
35
+ domain: string;
36
+ access: RunnerSshAccess;
37
+ }, onProgress: (progress: {
38
+ line: string;
39
+ phase?: InstallPhase;
40
+ }) => void): Promise<RunnerEntry>;
41
+ /** The tenants of the platform and their runner; none: no distribution on this page. */
42
+ tenants?: {
43
+ list(): Promise<Array<{
44
+ id: string;
45
+ name: string;
46
+ runnerId?: string;
47
+ }>>;
48
+ assign(tenantId: string, runnerId: string): Promise<void>;
49
+ };
50
+ }
51
+ export type RunnersSettingsProps = {
52
+ fleet: RunnerFleet;
53
+ locale?: string;
54
+ texts?: Partial<RunnerUiTexts>;
55
+ };
56
+ export declare function RunnersSettings({ fleet, locale, texts }: RunnersSettingsProps): React.JSX.Element;
57
+ /** Adding a runner: the three ways, in one modal. */
58
+ export declare function AddRunner({ fleet, t, locale, onClose, onAdded }: {
59
+ fleet: RunnerFleet;
60
+ t: RunnerUiTexts;
61
+ locale?: string;
62
+ onClose: () => void;
63
+ onAdded: (entry: RunnerEntry) => void | Promise<void>;
64
+ }): React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ export { RunnerAccounts, type RunnerAccountsProps } from './RunnerAccounts';
2
+ export { InstallGuide, type InstallGuideProps } from './InstallGuide';
3
+ export { RunnersSettings, AddRunner, type RunnerFleet, type RunnerEntry, type RunnerSshAccess, type RunnersSettingsProps } from './RunnersSettings';
4
+ export { RunnerConsole, type RunnerConsoleProps } from './RunnerConsole';
5
+ export { runnerTexts, textsFor, fill, type RunnerUiTexts, type RunnerLocale } from './texts';
@@ -0,0 +1,348 @@
1
+ export declare const en: {
2
+ accountsTitleUser: string;
3
+ accountsTitleTenant: string;
4
+ accountsIntroUser: string;
5
+ accountsIntroTenant: string;
6
+ accountsEmpty: string;
7
+ accountsNoCredit: string;
8
+ accountsConnected: string;
9
+ accountsRemove: string;
10
+ accountsRemoveConfirm: string;
11
+ claudeConnect: string;
12
+ claudeStep1: string;
13
+ claudeOpen: string;
14
+ claudeStep2: string;
15
+ claudeCode: string;
16
+ claudeLabel: string;
17
+ claudeLabelPlaceholder: string;
18
+ claudeFinish: string;
19
+ claudeRefused: string;
20
+ claudeNoLink: string;
21
+ opencodeConnect: string;
22
+ opencodeKey: string;
23
+ opencodeAdd: string;
24
+ termsNote: string;
25
+ guideTitle: string;
26
+ guideServerTitle: string;
27
+ guideServer: string;
28
+ guideDnsTitle: string;
29
+ guideDns: string;
30
+ guideDomain: string;
31
+ guideCheckDns: string;
32
+ guideDnsOk: string;
33
+ guideDnsMissing: string;
34
+ guideAccessTitle: string;
35
+ guideAccess: string;
36
+ guideInstallTitle: string;
37
+ guideInstall: string;
38
+ guideVerified: string;
39
+ guideCopy: string;
40
+ guideCopied: string;
41
+ guidePairTitle: string;
42
+ guidePair: string;
43
+ guideCheckHealth: string;
44
+ guideHealthOk: string;
45
+ guideHealthKo: string;
46
+ guideTroubleTitle: string;
47
+ guideTrouble: string;
48
+ runnersTitle: string;
49
+ runnersIntro: string;
50
+ runnersEmpty: string;
51
+ runnersAdd: string;
52
+ runnersDefault: string;
53
+ runnersDraining: string;
54
+ runnersRemove: string;
55
+ runnersRemoveConfirm: string;
56
+ runnersLoad: string;
57
+ runnersTenants: string;
58
+ runnersUnreachable: string;
59
+ runnersVersion: string;
60
+ distributionTitle: string;
61
+ distributionIntro: string;
62
+ distributionRunner: string;
63
+ distributionNone: string;
64
+ addTitle: string;
65
+ addAutomatic: string;
66
+ addAutomaticHint: string;
67
+ addGuided: string;
68
+ addGuidedHint: string;
69
+ addExisting: string;
70
+ addExistingHint: string;
71
+ addName: string;
72
+ addNamePlaceholder: string;
73
+ addUrl: string;
74
+ addCode: string;
75
+ addConnect: string;
76
+ addHost: string;
77
+ addPort: string;
78
+ addUser: string;
79
+ addAuth: string;
80
+ addKey: string;
81
+ addPassword: string;
82
+ addInstall: string;
83
+ addInstalling: string;
84
+ addCredentialsNote: string;
85
+ addBack: string;
86
+ addDone: string;
87
+ error: string;
88
+ consoleTitle: string;
89
+ consoleSignIn: string;
90
+ consoleToken: string;
91
+ consoleTokenHint: string;
92
+ consoleSignOut: string;
93
+ consoleStatus: string;
94
+ consoleMachine: string;
95
+ consolePairing: string;
96
+ consolePairingHint: string;
97
+ consoleNewCode: string;
98
+ consoleCode: string;
99
+ consoleTenants: string;
100
+ consoleNewTenant: string;
101
+ consoleTenantId: string;
102
+ consoleTenantName: string;
103
+ consoleCreate: string;
104
+ consoleKeys: string;
105
+ consoleNewKey: string;
106
+ consoleKeyShown: string;
107
+ consoleRevoke: string;
108
+ consoleRemoveTenant: string;
109
+ consoleRemoveTenantConfirm: string;
110
+ consoleAccounts: string;
111
+ close: string;
112
+ cancel: string;
113
+ };
114
+ export type RunnerUiTexts = typeof en;
115
+ export declare const it: RunnerUiTexts;
116
+ export declare const runnerTexts: {
117
+ en: {
118
+ accountsTitleUser: string;
119
+ accountsTitleTenant: string;
120
+ accountsIntroUser: string;
121
+ accountsIntroTenant: string;
122
+ accountsEmpty: string;
123
+ accountsNoCredit: string;
124
+ accountsConnected: string;
125
+ accountsRemove: string;
126
+ accountsRemoveConfirm: string;
127
+ claudeConnect: string;
128
+ claudeStep1: string;
129
+ claudeOpen: string;
130
+ claudeStep2: string;
131
+ claudeCode: string;
132
+ claudeLabel: string;
133
+ claudeLabelPlaceholder: string;
134
+ claudeFinish: string;
135
+ claudeRefused: string;
136
+ claudeNoLink: string;
137
+ opencodeConnect: string;
138
+ opencodeKey: string;
139
+ opencodeAdd: string;
140
+ termsNote: string;
141
+ guideTitle: string;
142
+ guideServerTitle: string;
143
+ guideServer: string;
144
+ guideDnsTitle: string;
145
+ guideDns: string;
146
+ guideDomain: string;
147
+ guideCheckDns: string;
148
+ guideDnsOk: string;
149
+ guideDnsMissing: string;
150
+ guideAccessTitle: string;
151
+ guideAccess: string;
152
+ guideInstallTitle: string;
153
+ guideInstall: string;
154
+ guideVerified: string;
155
+ guideCopy: string;
156
+ guideCopied: string;
157
+ guidePairTitle: string;
158
+ guidePair: string;
159
+ guideCheckHealth: string;
160
+ guideHealthOk: string;
161
+ guideHealthKo: string;
162
+ guideTroubleTitle: string;
163
+ guideTrouble: string;
164
+ runnersTitle: string;
165
+ runnersIntro: string;
166
+ runnersEmpty: string;
167
+ runnersAdd: string;
168
+ runnersDefault: string;
169
+ runnersDraining: string;
170
+ runnersRemove: string;
171
+ runnersRemoveConfirm: string;
172
+ runnersLoad: string;
173
+ runnersTenants: string;
174
+ runnersUnreachable: string;
175
+ runnersVersion: string;
176
+ distributionTitle: string;
177
+ distributionIntro: string;
178
+ distributionRunner: string;
179
+ distributionNone: string;
180
+ addTitle: string;
181
+ addAutomatic: string;
182
+ addAutomaticHint: string;
183
+ addGuided: string;
184
+ addGuidedHint: string;
185
+ addExisting: string;
186
+ addExistingHint: string;
187
+ addName: string;
188
+ addNamePlaceholder: string;
189
+ addUrl: string;
190
+ addCode: string;
191
+ addConnect: string;
192
+ addHost: string;
193
+ addPort: string;
194
+ addUser: string;
195
+ addAuth: string;
196
+ addKey: string;
197
+ addPassword: string;
198
+ addInstall: string;
199
+ addInstalling: string;
200
+ addCredentialsNote: string;
201
+ addBack: string;
202
+ addDone: string;
203
+ error: string;
204
+ consoleTitle: string;
205
+ consoleSignIn: string;
206
+ consoleToken: string;
207
+ consoleTokenHint: string;
208
+ consoleSignOut: string;
209
+ consoleStatus: string;
210
+ consoleMachine: string;
211
+ consolePairing: string;
212
+ consolePairingHint: string;
213
+ consoleNewCode: string;
214
+ consoleCode: string;
215
+ consoleTenants: string;
216
+ consoleNewTenant: string;
217
+ consoleTenantId: string;
218
+ consoleTenantName: string;
219
+ consoleCreate: string;
220
+ consoleKeys: string;
221
+ consoleNewKey: string;
222
+ consoleKeyShown: string;
223
+ consoleRevoke: string;
224
+ consoleRemoveTenant: string;
225
+ consoleRemoveTenantConfirm: string;
226
+ consoleAccounts: string;
227
+ close: string;
228
+ cancel: string;
229
+ };
230
+ it: {
231
+ accountsTitleUser: string;
232
+ accountsTitleTenant: string;
233
+ accountsIntroUser: string;
234
+ accountsIntroTenant: string;
235
+ accountsEmpty: string;
236
+ accountsNoCredit: string;
237
+ accountsConnected: string;
238
+ accountsRemove: string;
239
+ accountsRemoveConfirm: string;
240
+ claudeConnect: string;
241
+ claudeStep1: string;
242
+ claudeOpen: string;
243
+ claudeStep2: string;
244
+ claudeCode: string;
245
+ claudeLabel: string;
246
+ claudeLabelPlaceholder: string;
247
+ claudeFinish: string;
248
+ claudeRefused: string;
249
+ claudeNoLink: string;
250
+ opencodeConnect: string;
251
+ opencodeKey: string;
252
+ opencodeAdd: string;
253
+ termsNote: string;
254
+ guideTitle: string;
255
+ guideServerTitle: string;
256
+ guideServer: string;
257
+ guideDnsTitle: string;
258
+ guideDns: string;
259
+ guideDomain: string;
260
+ guideCheckDns: string;
261
+ guideDnsOk: string;
262
+ guideDnsMissing: string;
263
+ guideAccessTitle: string;
264
+ guideAccess: string;
265
+ guideInstallTitle: string;
266
+ guideInstall: string;
267
+ guideVerified: string;
268
+ guideCopy: string;
269
+ guideCopied: string;
270
+ guidePairTitle: string;
271
+ guidePair: string;
272
+ guideCheckHealth: string;
273
+ guideHealthOk: string;
274
+ guideHealthKo: string;
275
+ guideTroubleTitle: string;
276
+ guideTrouble: string;
277
+ runnersTitle: string;
278
+ runnersIntro: string;
279
+ runnersEmpty: string;
280
+ runnersAdd: string;
281
+ runnersDefault: string;
282
+ runnersDraining: string;
283
+ runnersRemove: string;
284
+ runnersRemoveConfirm: string;
285
+ runnersLoad: string;
286
+ runnersTenants: string;
287
+ runnersUnreachable: string;
288
+ runnersVersion: string;
289
+ distributionTitle: string;
290
+ distributionIntro: string;
291
+ distributionRunner: string;
292
+ distributionNone: string;
293
+ addTitle: string;
294
+ addAutomatic: string;
295
+ addAutomaticHint: string;
296
+ addGuided: string;
297
+ addGuidedHint: string;
298
+ addExisting: string;
299
+ addExistingHint: string;
300
+ addName: string;
301
+ addNamePlaceholder: string;
302
+ addUrl: string;
303
+ addCode: string;
304
+ addConnect: string;
305
+ addHost: string;
306
+ addPort: string;
307
+ addUser: string;
308
+ addAuth: string;
309
+ addKey: string;
310
+ addPassword: string;
311
+ addInstall: string;
312
+ addInstalling: string;
313
+ addCredentialsNote: string;
314
+ addBack: string;
315
+ addDone: string;
316
+ error: string;
317
+ consoleTitle: string;
318
+ consoleSignIn: string;
319
+ consoleToken: string;
320
+ consoleTokenHint: string;
321
+ consoleSignOut: string;
322
+ consoleStatus: string;
323
+ consoleMachine: string;
324
+ consolePairing: string;
325
+ consolePairingHint: string;
326
+ consoleNewCode: string;
327
+ consoleCode: string;
328
+ consoleTenants: string;
329
+ consoleNewTenant: string;
330
+ consoleTenantId: string;
331
+ consoleTenantName: string;
332
+ consoleCreate: string;
333
+ consoleKeys: string;
334
+ consoleNewKey: string;
335
+ consoleKeyShown: string;
336
+ consoleRevoke: string;
337
+ consoleRemoveTenant: string;
338
+ consoleRemoveTenantConfirm: string;
339
+ consoleAccounts: string;
340
+ close: string;
341
+ cancel: string;
342
+ };
343
+ };
344
+ export type RunnerLocale = keyof typeof runnerTexts;
345
+ /** The words for a locale, with those of the host over them. */
346
+ export declare function textsFor(locale: string | undefined, override?: Partial<RunnerUiTexts>): RunnerUiTexts;
347
+ /** `{name}` in a text replaced by its value. */
348
+ export declare const fill: (text: string, values: Record<string, string | number>) => string;
package/dist/ui.js ADDED
@@ -0,0 +1,4 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./client.js"),l=require("./steps.js");let u=require("react");u=s(u,1);let d=require("@llmnative/react"),f=require("react/jsx-runtime");var p={accountsTitleUser:`My subscriptions`,accountsTitleTenant:`Subscriptions of the tenant`,accountsIntroUser:`Connect your own subscription: it is used only for your requests. Without one, the API keys of the workspace are used.`,accountsIntroTenant:`Accounts used by everyone of the tenant, after their own.`,accountsEmpty:`No subscription connected.`,accountsNoCredit:`Limit reached, back at {at}`,accountsConnected:`Connected {at}`,accountsRemove:`Disconnect`,accountsRemoveConfirm:`Disconnect {name}? Its token is deleted from the runner.`,claudeConnect:`Connect Claude`,claudeStep1:`Open the page of Anthropic and sign in with your Claude account (Pro or Max).`,claudeOpen:`Open the page of Anthropic`,claudeStep2:`Anthropic shows a code: paste it here.`,claudeCode:`Code`,claudeLabel:`Name (optional)`,claudeLabelPlaceholder:`Personal Max`,claudeFinish:`Connect`,claudeRefused:`Anthropic did not accept the code: start again.`,claudeNoLink:`The runner could not start the sign-in. Try again in a minute.`,opencodeConnect:`Add OpenCode Go`,opencodeKey:`API key of OpenCode Go`,opencodeAdd:`Add`,termsNote:`A Pro or Max subscription is personal: connect only your own.`,guideTitle:`Install a runner by hand`,guideServerTitle:`1. A VPS`,guideServer:`Any provider works. It needs {systems}, at least {cpus} cores, {memory} GB of memory and {disk} GB of disk, with ports {ports} open.`,guideDnsTitle:`2. The domain`,guideDns:`In the DNS of your domain, create a record A for the runner (e.g. runner.example.com) with the IP address of the VPS.`,guideDomain:`Domain of the runner`,guideCheckDns:`Check`,guideDnsOk:`The domain points to {ips}.`,guideDnsMissing:`The domain does not point anywhere yet: DNS changes can take some minutes.`,guideAccessTitle:`3. Enter the VPS`,guideAccess:`From a terminal: ssh root@<IP of the VPS>. Or open the web console of your provider.`,guideInstallTitle:`4. Run the installer`,guideInstall:`Paste this command and press Enter. It takes 3–10 minutes.`,guideVerified:`Prefer to check the script first?`,guideCopy:`Copy`,guideCopied:`Copied`,guidePairTitle:`5. Connect it`,guidePair:`At the end the installer prints a pairing code (valid 15 minutes). Paste it here.`,guideCheckHealth:`Check the runner`,guideHealthOk:`The runner {version} answers at {url}.`,guideHealthKo:`No runner answers at {url} yet: check the domain and that ports 80 and 443 are open.`,guideTroubleTitle:`If something goes wrong`,guideTrouble:`"port is used": another web server is running (stop it). "certificate": the domain does not point to the VPS yet. Run the command again at any time: nothing is lost.`,runnersTitle:`Runners`,runnersIntro:`The servers where Claude Code and opencode run. Each tenant uses one of them.`,runnersEmpty:`No runner yet.`,runnersAdd:`Add a runner`,runnersDefault:`Default for new tenants`,runnersDraining:`Draining (no new chats)`,runnersRemove:`Remove`,runnersRemoveConfirm:`Remove {name}? Its tenants must be moved first.`,runnersLoad:`{chats} of {max} chats`,runnersTenants:`{count} tenants`,runnersUnreachable:`Not reachable`,runnersVersion:`Version {version}`,distributionTitle:`Tenants`,distributionIntro:`Which runner each tenant uses. Moving a tenant asks its people to connect their subscriptions again.`,distributionRunner:`Runner`,distributionNone:`None`,addTitle:`Add a runner`,addAutomatic:`Install it for me`,addAutomaticHint:`Give the access to a new VPS: the runner is installed and connected by itself.`,addGuided:`Guide me`,addGuidedHint:`Step by step instructions to install it by hand.`,addExisting:`It is already installed`,addExistingHint:`Its address and a pairing code.`,addName:`Name`,addNamePlaceholder:`Runner Europe 1`,addUrl:`Address`,addCode:`Pairing code`,addConnect:`Connect`,addHost:`IP address of the VPS`,addPort:`SSH port`,addUser:`User`,addAuth:`Access`,addKey:`Private SSH key`,addPassword:`Password`,addInstall:`Install`,addInstalling:`Installing…`,addCredentialsNote:`The access is used only for this installation and is not kept.`,addBack:`Back`,addDone:`The runner is connected.`,error:`Something went wrong: {error}`,consoleTitle:`Runner console`,consoleSignIn:`Sign in`,consoleToken:`Admin token`,consoleTokenHint:`On the VPS: docker compose -f /opt/llmnative-runner/compose.yaml exec runner node src/cli.ts admin-token`,consoleSignOut:`Sign out`,consoleStatus:`Status`,consoleMachine:`{memory} GB of memory free of {total}, {cpus} cores`,consolePairing:`Connect a platform`,consolePairingHint:`A code to connect this runner to a CMS or a studio (15 minutes, once).`,consoleNewCode:`New pairing code`,consoleCode:`Code: {code} (until {at})`,consoleTenants:`Tenants`,consoleNewTenant:`New tenant`,consoleTenantId:`Id (lowercase, digits, -)`,consoleTenantName:`Name`,consoleCreate:`Create`,consoleKeys:`Keys`,consoleNewKey:`New key`,consoleKeyShown:`The key, shown this once: {key}`,consoleRevoke:`Revoke`,consoleRemoveTenant:`Remove tenant`,consoleRemoveTenantConfirm:`Remove {name}, its keys and chats?`,consoleAccounts:`Accounts`,close:`Close`,cancel:`Cancel`},m={accountsTitleUser:`I miei abbonamenti`,accountsTitleTenant:`Abbonamenti del tenant`,accountsIntroUser:`Collega il tuo abbonamento: lo usano solo le tue richieste. Senza, si usano le API key del workspace.`,accountsIntroTenant:`Account usati da tutti nel tenant, dopo i loro.`,accountsEmpty:`Nessun abbonamento collegato.`,accountsNoCredit:`Limite raggiunto, torna alle {at}`,accountsConnected:`Collegato il {at}`,accountsRemove:`Scollega`,accountsRemoveConfirm:`Scollegare {name}? Il token viene cancellato dal runner.`,claudeConnect:`Collega Claude`,claudeStep1:`Apri la pagina di Anthropic ed entra con il tuo account Claude (Pro o Max).`,claudeOpen:`Apri la pagina di Anthropic`,claudeStep2:`Anthropic mostra un codice: incollalo qui.`,claudeCode:`Codice`,claudeLabel:`Nome (facoltativo)`,claudeLabelPlaceholder:`Max personale`,claudeFinish:`Collega`,claudeRefused:`Anthropic non ha accettato il codice: ricomincia.`,claudeNoLink:`Il runner non è riuscito ad avviare l'accesso. Riprova tra un minuto.`,opencodeConnect:`Aggiungi OpenCode Go`,opencodeKey:`API key di OpenCode Go`,opencodeAdd:`Aggiungi`,termsNote:`Un abbonamento Pro o Max è personale: collega solo il tuo.`,guideTitle:`Installa un runner a mano`,guideServerTitle:`1. Una VPS`,guideServer:`Va bene qualunque fornitore. Servono {systems}, almeno {cpus} core, {memory} GB di memoria e {disk} GB di disco, con le porte {ports} aperte.`,guideDnsTitle:`2. Il dominio`,guideDns:`Nel DNS del tuo dominio crea un record A per il runner (es. runner.example.com) con l'indirizzo IP della VPS.`,guideDomain:`Dominio del runner`,guideCheckDns:`Controlla`,guideDnsOk:`Il dominio punta a {ips}.`,guideDnsMissing:`Il dominio non punta ancora da nessuna parte: le modifiche al DNS possono richiedere qualche minuto.`,guideAccessTitle:`3. Entra nella VPS`,guideAccess:`Da un terminale: ssh root@<IP della VPS>. Oppure apri la console web del fornitore.`,guideInstallTitle:`4. Lancia l'installazione`,guideInstall:`Incolla questo comando e premi Invio. Ci vogliono 3–10 minuti.`,guideVerified:`Preferisci controllare lo script prima?`,guideCopy:`Copia`,guideCopied:`Copiato`,guidePairTitle:`5. Collegalo`,guidePair:`Alla fine l'installazione stampa un codice di abbinamento (valido 15 minuti). Incollalo qui.`,guideCheckHealth:`Controlla il runner`,guideHealthOk:`Il runner {version} risponde su {url}.`,guideHealthKo:`Nessun runner risponde ancora su {url}: controlla il dominio e che le porte 80 e 443 siano aperte.`,guideTroubleTitle:`Se qualcosa non va`,guideTrouble:`"port is used": c'è già un altro server web (fermalo). "certificate": il dominio non punta ancora alla VPS. Puoi rilanciare il comando quando vuoi: non si perde niente.`,runnersTitle:`Runner`,runnersIntro:`I server dove girano Claude Code e opencode. Ogni tenant ne usa uno.`,runnersEmpty:`Nessun runner.`,runnersAdd:`Aggiungi un runner`,runnersDefault:`Predefinito per i nuovi tenant`,runnersDraining:`In svuotamento (niente chat nuove)`,runnersRemove:`Rimuovi`,runnersRemoveConfirm:`Rimuovere {name}? Prima vanno spostati i suoi tenant.`,runnersLoad:`{chats} chat su {max}`,runnersTenants:`{count} tenant`,runnersUnreachable:`Non raggiungibile`,runnersVersion:`Versione {version}`,distributionTitle:`Tenant`,distributionIntro:`Quale runner usa ogni tenant. Spostare un tenant chiede alle sue persone di ricollegare gli abbonamenti.`,distributionRunner:`Runner`,distributionNone:`Nessuno`,addTitle:`Aggiungi un runner`,addAutomatic:`Installalo tu`,addAutomaticHint:`Dai l'accesso a una VPS nuova: il runner si installa e si collega da solo.`,addGuided:`Guidami`,addGuidedHint:`Istruzioni passo passo per installarlo a mano.`,addExisting:`È già installato`,addExistingHint:`Il suo indirizzo e un codice di abbinamento.`,addName:`Nome`,addNamePlaceholder:`Runner Europa 1`,addUrl:`Indirizzo`,addCode:`Codice di abbinamento`,addConnect:`Collega`,addHost:`Indirizzo IP della VPS`,addPort:`Porta SSH`,addUser:`Utente`,addAuth:`Accesso`,addKey:`Chiave SSH privata`,addPassword:`Password`,addInstall:`Installa`,addInstalling:`Installazione in corso…`,addCredentialsNote:`L'accesso serve solo per questa installazione e non viene salvato.`,addBack:`Indietro`,addDone:`Il runner è collegato.`,error:`Qualcosa è andato storto: {error}`,consoleTitle:`Console del runner`,consoleSignIn:`Entra`,consoleToken:`Token di amministrazione`,consoleTokenHint:`Sulla VPS: docker compose -f /opt/llmnative-runner/compose.yaml exec runner node src/cli.ts admin-token`,consoleSignOut:`Esci`,consoleStatus:`Stato`,consoleMachine:`{memory} GB di memoria liberi su {total}, {cpus} core`,consolePairing:`Collega una piattaforma`,consolePairingHint:`Un codice per collegare questo runner a un CMS o a uno studio (15 minuti, una volta).`,consoleNewCode:`Nuovo codice di abbinamento`,consoleCode:`Codice: {code} (fino alle {at})`,consoleTenants:`Tenant`,consoleNewTenant:`Nuovo tenant`,consoleTenantId:`Id (minuscole, cifre, -)`,consoleTenantName:`Nome`,consoleCreate:`Crea`,consoleKeys:`Chiavi`,consoleNewKey:`Nuova chiave`,consoleKeyShown:`La chiave, mostrata solo ora: {key}`,consoleRevoke:`Revoca`,consoleRemoveTenant:`Rimuovi tenant`,consoleRemoveTenantConfirm:`Rimuovere {name}, le sue chiavi e le sue chat?`,consoleAccounts:`Account`,close:`Chiudi`,cancel:`Annulla`},h={en:p,it:m};function g(e,t){let n=e&&e.toLowerCase().startsWith(`it`)?m:p;return t?{...n,...t}:n}var _=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e),v={"claude-code":`Claude Code`,"opencode-go":`OpenCode Go`,opencode:`OpenCode Zen`},y=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`});function b({client:e,scope:t,locale:n,texts:r,onChange:i}){let a=g(n,r),[o,s]=(0,u.useState)(null),[l,p]=(0,u.useState)(null),[m,h]=(0,u.useState)(null),[b,C]=(0,u.useState)(null),w=(0,u.useCallback)(async()=>{try{let{accounts:t}=await e.accounts.list();return s(t),p(null),t}catch(e){return p(e instanceof c.RunnerError?e.code:String(e)),s([]),[]}},[e]);(0,u.useEffect)(()=>{w()},[w]);let T=async()=>{h(null);let e=await w();i?.(e)};return(0,f.jsxs)(d.Card,{title:t===`user`?a.accountsTitleUser:a.accountsTitleTenant,loading:o===null,loaderMinHeight:120,children:[(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t===`user`?a.accountsIntroUser:a.accountsIntroTenant}),l&&(0,f.jsx)(d.Alert,{variant:`danger`,children:_(a.error,{error:l})}),o?.length===0&&!l&&(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a.accountsEmpty}),o?.map(e=>(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-border p-3`,children:[(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`font-medium`,children:e.label??v[e.provider]??e.provider}),(0,f.jsx)(d.Badge,{variant:`secondary`,children:v[e.provider]??e.provider}),e.noCreditUntil&&(0,f.jsx)(d.Badge,{variant:`warning`,children:_(a.accountsNoCredit,{at:y(e.noCreditUntil)})})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(a.accountsConnected,{at:y(e.at)})})]}),(0,f.jsx)(d.ActionButton,{icon:`unlink`,label:a.accountsRemove,variant:`outline-danger`,onClick:()=>C(e)})]},`${e.provider}/${e.id}`)),m===`claude`&&(0,f.jsx)(x,{client:e,t:a,onDone:T,onCancel:()=>h(null)}),m===`opencode`&&(0,f.jsx)(S,{client:e,t:a,onDone:T,onCancel:()=>h(null)}),!m&&(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsx)(d.ActionButton,{icon:`plus`,label:a.claudeConnect,variant:`primary`,onClick:()=>h(`claude`)}),(0,f.jsx)(d.ActionButton,{icon:`plus`,label:a.opencodeConnect,variant:`outline-secondary`,onClick:()=>h(`opencode`)})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a.termsNote})]}),b&&(0,f.jsx)(d.ModalYesNo,{title:a.accountsRemove,danger:!0,onClose:()=>C(null),onYes:async()=>(await e.accounts.remove(b.provider,b.id).catch(()=>!1),C(null),await T(),!0),children:_(a.accountsRemoveConfirm,{name:b.label??v[b.provider]??b.provider})})]})}function x({client:e,t,onDone:n,onCancel:r}){let[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(``),[l,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let n=!1;return e.accounts.startClaudeLogin().then(({url:e})=>!n&&a(e)).catch(()=>!n&&h(t.claudeNoLink)),()=>{n=!0}},[e,t]),(0,f.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border border-border p-3`,children:[m&&(0,f.jsx)(d.Alert,{variant:`danger`,children:m}),(0,f.jsx)(`p`,{className:`text-sm`,children:t.claudeStep1}),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.ActionButton,{icon:`external-link`,label:t.claudeOpen,variant:`primary`,disabled:!i,onClick:()=>i&&window.open(i,`_blank`,`noopener,noreferrer`)})}),(0,f.jsx)(`p`,{className:`text-sm`,children:t.claudeStep2}),(0,f.jsxs)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,children:[(0,f.jsx)(d.String,{name:`code`,label:t.claudeCode,autoComplete:`off`,onChange:({value:e})=>s(String(e??``))}),(0,f.jsx)(d.String,{name:`label`,label:t.claudeLabel,placeholder:t.claudeLabelPlaceholder,onChange:({value:e})=>p(String(e??``))})]}),(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(d.LoadingButton,{label:t.claudeFinish,variant:`primary`,disabled:!i||!o.trim(),onClick:async()=>{try{await e.accounts.finishClaudeLogin(o.trim(),l.trim()||void 0),n()}catch(e){h(e instanceof c.RunnerError&&e.code===`refused`?t.claudeRefused:_(t.error,{error:e instanceof c.RunnerError?e.code:String(e)}))}}}),(0,f.jsx)(d.ActionButton,{label:t.cancel,variant:`outline-secondary`,onClick:r})]})]})}function S({client:e,t,onDone:n,onCancel:r}){let[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[l,p]=(0,u.useState)(null);return(0,f.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border border-border p-3`,children:[l&&(0,f.jsx)(d.Alert,{variant:`danger`,children:l}),(0,f.jsxs)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,children:[(0,f.jsx)(d.Password,{name:`key`,label:t.opencodeKey,autoComplete:`off`,onChange:({value:e})=>a(String(e??``))}),(0,f.jsx)(d.String,{name:`label`,label:t.claudeLabel,onChange:({value:e})=>s(String(e??``))})]}),(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(d.LoadingButton,{label:t.opencodeAdd,variant:`primary`,disabled:!i.trim(),onClick:async()=>{try{await e.accounts.addKey(`opencode-go`,i.trim(),o.trim()||void 0),n()}catch(e){p(_(t.error,{error:e instanceof c.RunnerError?e.code:String(e)}))}}}),(0,f.jsx)(d.ActionButton,{label:t.cancel,variant:`outline-secondary`,onClick:r})]})]})}function C({title:e,children:t,done:n}){return(0,f.jsxs)(`section`,{className:`flex flex-col gap-2 border-l-2 border-border pl-4`,children:[(0,f.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[e,n&&(0,f.jsx)(d.Badge,{variant:`success`,children:`✓`})]}),t]})}function w({locale:e,texts:t,onPair:n,lookup:r=e=>l.lookupDomain(e),check:i=l.checkRunner,version:a}){let o=g(e,t),[s,c]=(0,u.useState)(``),[p,m]=(0,u.useState)(null),[h,v]=(0,u.useState)(null),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(!1),[w,T]=(0,u.useState)(null),E=l.isDomain(s),D=`https://${s.trim().toLowerCase()}`,O=l.RUNNER_REQUIREMENTS;return(0,f.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,f.jsx)(C,{title:o.guideServerTitle,children:(0,f.jsx)(`p`,{className:`text-sm`,children:_(o.guideServer,{systems:O.systems.join(`, `),cpus:O.cpus,memory:O.memoryGb,disk:O.diskGb,ports:O.ports.join(`, `)})})}),(0,f.jsxs)(C,{title:o.guideDnsTitle,done:!!p?.ips.length,children:[(0,f.jsx)(`p`,{className:`text-sm`,children:o.guideDns}),(0,f.jsx)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,children:(0,f.jsx)(d.String,{name:`domain`,label:o.guideDomain,placeholder:`runner.example.com`,autoComplete:`off`,onChange:({value:e})=>{c(String(e??``)),m(null),v(null)}})}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(d.LoadingButton,{label:o.guideCheckDns,variant:`outline-secondary`,disabled:!E,onClick:async()=>m({ips:await r(s.trim().toLowerCase()).catch(()=>[])})}),p&&(p.ips.length?(0,f.jsx)(d.Alert,{variant:`success`,appearance:`text`,children:_(o.guideDnsOk,{ips:p.ips.join(`, `)})}):(0,f.jsx)(d.Alert,{variant:`warning`,appearance:`text`,children:o.guideDnsMissing}))]})]}),(0,f.jsx)(C,{title:o.guideAccessTitle,children:(0,f.jsx)(`p`,{className:`text-sm`,children:o.guideAccess})}),(0,f.jsxs)(C,{title:o.guideInstallTitle,children:[(0,f.jsx)(`p`,{className:`text-sm`,children:o.guideInstall}),(0,f.jsx)(d.Code,{language:`bash`,showCopy:!0,children:l.installCommand({domain:E?s:`runner.example.com`,...a?{version:a}:{}})}),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.ActionButton,{label:o.guideVerified,variant:`link`,onClick:()=>S(e=>!e)})}),x&&(0,f.jsx)(d.Code,{language:`bash`,showCopy:!0,children:l.verifiedInstallCommands({domain:E?s:`runner.example.com`,...a?{version:a}:{}}).join(`
2
+ `)})]}),(0,f.jsxs)(C,{title:o.guidePairTitle,done:h?.ok,children:[(0,f.jsx)(`p`,{className:`text-sm`,children:o.guidePair}),(0,f.jsx)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,children:(0,f.jsx)(d.String,{name:`code`,label:o.addCode,placeholder:`ABCD-EFGH`,autoComplete:`off`,onChange:({value:e})=>b(String(e??``))})}),h&&(0,f.jsx)(d.Alert,{variant:h.ok?`success`:`warning`,appearance:`text`,children:h.text}),w&&(0,f.jsx)(d.Alert,{variant:`danger`,children:w}),(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsx)(d.LoadingButton,{label:o.guideCheckHealth,variant:`outline-secondary`,disabled:!E,onClick:async()=>{let e=await i(D);v(e.ok?{ok:!0,text:_(o.guideHealthOk,{version:e.version,url:D})}:{ok:!1,text:_(o.guideHealthKo,{url:D})})}}),(0,f.jsx)(d.LoadingButton,{label:o.addConnect,variant:`primary`,disabled:!E||y.trim().length<8,onClick:async()=>{try{T(null),await n({url:D,code:y.trim()})}catch(e){T(_(o.error,{error:e.message}))}}})]})]}),(0,f.jsx)(C,{title:o.guideTroubleTitle,children:(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.guideTrouble})})]})}function T({fleet:e,locale:t,texts:n}){let r=g(t,n),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(null),[c,l]=(0,u.useState)(!1),[p,m]=(0,u.useState)(null),[h,v]=(0,u.useState)(null),y=(0,u.useCallback)(async()=>{try{let t=await e.list();a(t);let n=await Promise.all(t.map(t=>e.status(t.id).catch(()=>null)));a(t.map((e,t)=>({...e,status:n[t]}))),e.tenants&&s(await e.tenants.list())}catch(e){v(_(r.error,{error:e.message})),a([])}},[e,r]);(0,u.useEffect)(()=>{y()},[y]);let b=async(t,n)=>{await e.update(t,n),await y()};return(0,f.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,f.jsx)(d.Card,{header:(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`h3`,{className:`flex-1 text-base font-semibold`,children:r.runnersTitle}),(0,f.jsx)(d.ActionButton,{icon:`plus`,label:r.runnersAdd,variant:`primary`,onClick:()=>l(!0)})]}),loading:i===null,loaderMinHeight:120,children:(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.runnersIntro}),h&&(0,f.jsx)(d.Alert,{variant:`danger`,children:h}),i?.length===0&&(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.runnersEmpty}),i?.map(e=>(0,f.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border p-3`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.url}),e.status===null&&(0,f.jsx)(d.Badge,{variant:`danger`,children:r.runnersUnreachable}),e.status&&(0,f.jsx)(d.Badge,{variant:`secondary`,children:_(r.runnersVersion,{version:e.status.version})}),e.status&&(0,f.jsx)(d.Badge,{variant:`info`,children:_(r.runnersLoad,{chats:e.status.load.chats,max:e.status.load.maxChats})}),e.status&&(0,f.jsx)(d.Badge,{variant:`light`,children:_(r.runnersTenants,{count:e.status.tenants.length})}),(0,f.jsx)(`div`,{className:`ml-auto`,children:(0,f.jsx)(d.ActionButton,{icon:`trash`,label:r.runnersRemove,variant:`outline-danger`,onClick:()=>m(e)})})]}),(0,f.jsx)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,defaultValues:{isDefault:e.isDefault?`true`:``,draining:e.draining?`true`:``},children:(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,f.jsx)(d.Switch,{name:`isDefault`,label:r.runnersDefault,valueChecked:`true`,onChange:({value:t})=>void b(e.id,{isDefault:!!t})}),(0,f.jsx)(d.Switch,{name:`draining`,label:r.runnersDraining,valueChecked:`true`,onChange:({value:t})=>void b(e.id,{draining:!!t})})]})})]},e.id))]})}),e.tenants&&i&&i.length>0&&(0,f.jsx)(d.Card,{title:r.distributionTitle,loading:o===null,loaderMinHeight:80,children:(0,f.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.distributionIntro}),(0,f.jsx)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,defaultValues:Object.fromEntries((o??[]).map(e=>[`runner_${e.id}`,e.runnerId??``])),children:(o??[]).map(t=>(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`min-w-40 flex-1 text-sm`,children:t.name}),(0,f.jsx)(d.Select,{name:`runner_${t.id}`,title:r.distributionRunner,placeholderOption:{label:r.distributionNone,value:``},options:i.map(e=>({label:e.name,value:e.id})),onChange:({value:n})=>{n&&e.tenants.assign(t.id,String(n)).then(y)}})]},t.id))})]})}),c&&(0,f.jsx)(E,{fleet:e,t:r,locale:t,onClose:()=>l(!1),onAdded:async()=>{l(!1),await y()}}),p&&(0,f.jsx)(d.ModalYesNo,{title:r.runnersRemove,danger:!0,onClose:()=>m(null),onYes:async()=>(await e.remove(p.id).catch(e=>v(_(r.error,{error:e.message}))),m(null),await y(),!0),children:_(r.runnersRemoveConfirm,{name:p.name})})]})}function E({fleet:e,t,locale:n,onClose:r,onAdded:i}){let[a,o]=(0,u.useState)(`choose`),[s,c]=(0,u.useState)(``),[l,p]=(0,u.useState)(null),m=e=>p(_(t.error,{error:e.message})),h=(0,f.jsx)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,children:(0,f.jsx)(d.String,{name:`name`,label:t.addName,placeholder:t.addNamePlaceholder,onChange:({value:e})=>c(String(e??``))})});return(0,f.jsx)(d.Modal,{title:t.addTitle,size:`lg`,onClose:r,footer:!1,children:(0,f.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l&&(0,f.jsx)(d.Alert,{variant:`danger`,children:l}),a===`choose`&&(0,f.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[e.install&&(0,f.jsx)(D,{title:t.addAutomatic,hint:t.addAutomaticHint,onClick:()=>o(`automatic`)}),(0,f.jsx)(D,{title:t.addGuided,hint:t.addGuidedHint,onClick:()=>o(`guided`)}),(0,f.jsx)(D,{title:t.addExisting,hint:t.addExistingHint,onClick:()=>o(`existing`)})]}),a!==`choose`&&(0,f.jsx)(`div`,{children:(0,f.jsx)(d.ActionButton,{icon:`arrow-left`,label:t.addBack,variant:`link`,onClick:()=>{o(`choose`),p(null)}})}),a===`automatic`&&e.install&&(0,f.jsxs)(f.Fragment,{children:[h,(0,f.jsx)(A,{t,install:(t,n,r)=>e.install({name:s.trim()||t,domain:t,access:n},r),onDone:i,onError:m})]}),a===`guided`&&(0,f.jsxs)(f.Fragment,{children:[h,(0,f.jsx)(w,{locale:n,texts:t,onPair:async({url:t,code:n})=>{await i(await e.add({name:s.trim()||new URL(t).hostname,url:t,code:n}))}})]}),a===`existing`&&(0,f.jsx)(O,{t,name:s,nameField:h,onConnect:async(t,n)=>{try{await i(await e.add({name:s.trim()||new URL(t).hostname,url:t,code:n}))}catch(e){m(e)}}})]})})}function D({title:e,hint:t,onClick:n}){return(0,f.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-border p-4 text-left transition-colors hover:border-primary hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,f.jsx)(`span`,{className:`block font-medium`,children:e}),(0,f.jsx)(`span`,{className:`mt-1 block text-sm text-muted-foreground`,children:t})]})}function O({t:e,nameField:t,onConnect:n}){let[r,i]=(0,u.useState)(``),[a,o]=(0,u.useState)(``),s=/^https?:\/\//.test(r.trim())?r.trim():`https://${r.trim()}`;return(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t,(0,f.jsxs)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,children:[(0,f.jsx)(d.String,{name:`url`,label:e.addUrl,placeholder:`https://runner.example.com`,onChange:({value:e})=>i(String(e??``))}),(0,f.jsx)(d.String,{name:`code`,label:e.addCode,placeholder:`ABCD-EFGH`,autoComplete:`off`,onChange:({value:e})=>o(String(e??``))})]}),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.LoadingButton,{label:e.addConnect,variant:`primary`,disabled:!r.trim()||a.trim().length<8,onClick:()=>n(s,a.trim())})})]})}var k=[`check`,`docker`,`files`,`start`,`agent`,`health`,`pair`,`tls`,`done`];function A({t:e,install:t,onDone:n,onError:r}){let[i,a]=(0,u.useState)({host:``,port:`22`,username:`root`,auth:`key`,privateKey:``,password:``,domain:``}),[o,s]=(0,u.useState)([]),[c,l]=(0,u.useState)(null),[p,m]=(0,u.useState)(!1),h=e=>({value:t})=>a(n=>({...n,[e]:String(t??``)})),g=i.host.trim()&&i.domain.trim()&&i.username.trim()&&(i.auth===`key`?i.privateKey.trim():i.password);return(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!p&&(0,f.jsxs)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,defaultValues:i,children:[(0,f.jsx)(d.String,{name:`domain`,label:e.guideDomain,placeholder:`runner.example.com`,onChange:h(`domain`)}),(0,f.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,f.jsx)(d.String,{name:`host`,label:e.addHost,placeholder:`203.0.113.10`,onChange:h(`host`)}),(0,f.jsx)(d.String,{name:`port`,label:e.addPort,onChange:h(`port`)}),(0,f.jsx)(d.String,{name:`username`,label:e.addUser,onChange:h(`username`)})]}),(0,f.jsx)(d.Select,{name:`auth`,label:e.addAuth,options:[{label:e.addKey,value:`key`},{label:e.addPassword,value:`password`}],onChange:h(`auth`)}),i.auth===`key`?(0,f.jsx)(d.TextArea,{name:`privateKey`,label:e.addKey,placeholder:`-----BEGIN OPENSSH PRIVATE KEY-----`,onChange:h(`privateKey`)}):(0,f.jsx)(d.Password,{name:`password`,label:e.addPassword,autoComplete:`off`,onChange:h(`password`)})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.addCredentialsNote}),p&&(0,f.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:k.map(e=>(0,f.jsx)(d.Badge,{variant:c===e?`primary`:k.indexOf(e)<k.indexOf(c??`check`)?`success`:`light`,children:e},e))}),o.length>0&&(0,f.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-md bg-muted p-2 text-xs`,children:o.slice(-200).join(`
3
+ `)}),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.LoadingButton,{label:p?e.addInstalling:e.addInstall,variant:`primary`,disabled:!g||p,onClick:async()=>{m(!0),s([]);try{await n(await t(i.domain.trim().toLowerCase(),{host:i.host.trim(),port:Number(i.port)||22,username:i.username.trim(),...i.auth===`key`?{privateKey:i.privateKey}:{password:i.password}},({line:e,phase:t})=>{t&&l(t),/^[A-Z_]+=/.test(e)||s(t=>[...t,e])}))}catch(e){r(e)}finally{m(!1)}}})})]})}var j=e=>(e/1024**3).toFixed(1),M=e=>new Date(e).toLocaleString(void 0,{dateStyle:`short`,timeStyle:`short`});function N({client:e,locale:t,texts:n,onSignOut:r}){let i=g(t,n),[a,o]=(0,u.useState)(null),[s,l]=(0,u.useState)(null),[p,m]=(0,u.useState)(null),[h,v]=(0,u.useState)({id:``,name:``}),[y,b]=(0,u.useState)(null),x=(0,u.useCallback)(async()=>{try{o(await e.platform.status()),l(null)}catch(e){l(_(i.error,{error:e instanceof c.RunnerError?e.code:String(e)}))}},[e,i]);return(0,u.useEffect)(()=>{x()},[x]),(0,f.jsxs)(`div`,{className:`mx-auto flex max-w-4xl flex-col gap-4 p-4`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`h1`,{className:`flex-1 text-xl font-semibold`,children:i.consoleTitle}),r&&(0,f.jsx)(d.ActionButton,{icon:`log-out`,label:i.consoleSignOut,variant:`outline-secondary`,onClick:r})]}),s&&(0,f.jsx)(d.Alert,{variant:`danger`,children:s}),(0,f.jsx)(d.Card,{title:i.consoleStatus,loading:!a&&!s,loaderMinHeight:100,children:a&&(0,f.jsx)(d.DescriptionList,{items:[{label:`Version`,value:a.version},{label:`URL`,value:a.url},{label:`Chats`,value:`${a.load.chats} / ${a.load.maxChats}`},{label:`Machine`,value:_(i.consoleMachine,{memory:j(a.machine.availableBytes),total:j(a.machine.totalBytes),cpus:a.machine.cpus})},{label:`Agent`,value:a.agentImage}]})}),(0,f.jsx)(d.Card,{title:i.consolePairing,children:(0,f.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i.consolePairingHint}),p&&(0,f.jsx)(d.Code,{showCopy:!0,children:p.code}),p&&(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(i.consoleCode,{code:p.code,at:M(p.expiresAt)})}),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.LoadingButton,{label:i.consoleNewCode,variant:`outline-primary`,onClick:async()=>m(await e.createPairing())})})]})}),(0,f.jsx)(d.Card,{title:i.consoleTenants,children:(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[y&&(0,f.jsx)(d.Alert,{variant:`warning`,onClose:()=>b(null),children:(0,f.jsx)(`span`,{className:`break-all`,children:_(i.consoleKeyShown,{key:y})})}),a?.tenants.map(n=>(0,f.jsx)(P,{client:e,tenant:n,t:i,locale:t,onKey:b,onChange:x},n.id)),(0,f.jsx)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,children:(0,f.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_1fr_auto] sm:items-end`,children:[(0,f.jsx)(d.String,{name:`tenantId`,label:i.consoleTenantId,placeholder:`acme`,onChange:({value:e})=>v(t=>({...t,id:String(e??``)}))}),(0,f.jsx)(d.String,{name:`tenantName`,label:i.consoleTenantName,placeholder:`Acme`,onChange:({value:e})=>v(t=>({...t,name:String(e??``)}))}),(0,f.jsx)(d.LoadingButton,{label:i.consoleCreate,variant:`primary`,disabled:!/^[a-z0-9][a-z0-9-]{0,62}$/.test(h.id),onClick:async()=>{try{let t=await e.platform.createTenant(h.id,{name:h.name||void 0});t.key&&b(t.key),await x()}catch(e){l(_(i.error,{error:e instanceof c.RunnerError?e.code:String(e)}))}}})]})})]})})]})}function P({client:e,tenant:t,t:n,locale:r,onKey:i,onChange:a}){let[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(null),[p,m]=(0,u.useState)(!1),h=(0,u.useMemo)(()=>e.as({tenant:t.id}),[e,t.id]),g=(0,u.useCallback)(async()=>l(await e.platform.keys(t.id)),[e,t.id]);return(0,u.useEffect)(()=>{o&&g()},[o,g]),(0,f.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsxs)(`button`,{type:`button`,className:`flex-1 text-left font-medium`,onClick:()=>s(e=>!e),children:[t.name,` `,(0,f.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),t.usersWithAccounts!==void 0&&(0,f.jsxs)(d.Badge,{variant:`light`,children:[t.usersWithAccounts,` 👤`]}),(0,f.jsx)(d.ActionButton,{icon:`trash`,label:n.consoleRemoveTenant,variant:`outline-danger`,onClick:()=>m(!0)})]}),o&&(0,f.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3`,children:[(0,f.jsx)(`h4`,{className:`text-sm font-semibold`,children:n.consoleKeys}),c?.map(r=>(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,f.jsx)(`span`,{className:`flex-1`,children:r.name}),r.permissions.map(e=>(0,f.jsx)(d.Badge,{variant:`info`,children:e},e)),(0,f.jsx)(d.ActionButton,{label:n.consoleRevoke,variant:`outline-danger`,onClick:async()=>{await e.platform.revokeKey(t.id,r.id),await g()}})]},r.id)),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.LoadingButton,{label:n.consoleNewKey,variant:`outline-secondary`,onClick:async()=>{i((await e.platform.createKey(t.id,{name:`console`,permissions:[`complete`,`chat`,`chat:tools`,`accounts`,`act-as-user`]})).key),await g()}})}),(0,f.jsx)(`h4`,{className:`text-sm font-semibold`,children:n.consoleAccounts}),(0,f.jsx)(b,{client:h,scope:`tenant`,locale:r,texts:n})]}),p&&(0,f.jsx)(d.ModalYesNo,{title:n.consoleRemoveTenant,danger:!0,onClose:()=>m(!1),onYes:async()=>(await e.platform.removeTenant(t.id),m(!1),await a(),!0),children:_(n.consoleRemoveTenantConfirm,{name:t.name})})]})}exports.AddRunner=E,exports.InstallGuide=w,exports.RunnerAccounts=b,exports.RunnerConsole=N,exports.RunnersSettings=T,exports.fill=_,exports.runnerTexts=h,exports.textsFor=g;
4
+ //# sourceMappingURL=ui.js.map