@llmnative/runner 1.0.2 → 1.1.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.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <meta name="robots" content="noindex" />
7
7
  <title>Runner setup</title>
8
- <script type="module" crossorigin src="./assets/index-BAksVWhQ.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-m6kInQaG.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-XKyaHtl9.js">
10
10
  <link rel="stylesheet" crossorigin href="./assets/index-CmPc3Q2I.css">
11
11
  </head>
package/dist/steps.js CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`1.0.2`,t=`sherpadvisorylab/llmnative-runner`,n={systems:[`Ubuntu 22.04 or newer`,`Debian 12 or newer`],architectures:[`x86_64`,`arm64`],cpus:2,memoryGb:4,diskGb:20,ports:[22,80,443]},r=/^(?=.{4,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/,i=e=>r.test(e.trim().toLowerCase()),a=(n=e)=>`https://github.com/${t}/releases/download/v${n}/install.sh`,o=(t=e)=>`${a(t)}.sha256`;function s({domain:e,maxChats:t}){return[`--domain`,(e=>`'${e.replace(/'/g,`'\\''`)}'`)(e.trim().toLowerCase()),...t?[`--max-chats`,String(t)]:[]]}function c(e){return`curl -fsSL ${a(e.version)} | sudo sh -s -- ${s(e).join(` `)}`}function l(e){let t=e.version??`1.0.2`;return[`curl -fsSLO ${a(t)}`,`curl -fsSL ${o(t)} | sha256sum -c -`,`sudo sh install.sh ${s(e).join(` `)}`]}var u=[{id:`server`},{id:`dns`,check:`dns`},{id:`access`},{id:`install`},{id:`pair`,check:`health`}];function d(e){let t=t=>RegExp(`^${t}=(.+)$`,`m`).exec(e)?.[1]?.trim(),n=t(`RUNNER_URL`),r=t(`PAIRING_CODE`),i=t(`RUNNER_ERROR`);return{...n?{url:n}:{},...r?{pairingCode:r}:{},...i?{error:i}:{}}}var f=[`check`,`docker`,`files`,`start`,`agent`,`health`,`pair`,`tls`,`done`],p=e=>{let t=/^STEP=([a-z]+)$/.exec(e.trim());return t&&f.includes(t[1])?t[1]:void 0};async function m(e,t={}){let n=t.resolver??`https://cloudflare-dns.com/dns-query`,r=async r=>{let i=await(t.fetch??fetch)(`${n}?name=${encodeURIComponent(e)}&type=${r}`,{headers:{accept:`application/dns-json`}});return i.ok?((await i.json()).Answer??[]).filter(e=>e.type===(r===`A`?1:28)).map(e=>e.data):[]},[i,a]=await Promise.all([r(`A`),r(`AAAA`)]);return[...i,...a]}async function h(e,t=fetch){try{let n=await t(`${e.replace(/\/+$/,``)}/health`);if(!n.ok)return{ok:!1,reason:`not-a-runner`};let r=await n.json();return r.ok&&typeof r.version==`string`?{ok:!0,version:r.version}:{ok:!1,reason:`not-a-runner`}}catch{return{ok:!1,reason:`unreachable`}}}exports.DOMAIN_PATTERN=r,exports.GUIDE_STEPS=u,exports.INSTALL_PHASES=f,exports.RUNNER_REPOSITORY=t,exports.RUNNER_REQUIREMENTS=n,exports.RUNNER_VERSION=e,exports.checkRunner=h,exports.checksumUrl=o,exports.installArguments=s,exports.installCommand=c,exports.installScriptUrl=a,exports.isDomain=i,exports.lookupDomain=m,exports.parseInstallOutput=d,exports.phaseOf=p,exports.verifiedInstallCommands=l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`1.1.0`,t=`sherpadvisorylab/llmnative-runner`,n={systems:[`Ubuntu 22.04 or newer`,`Debian 12 or newer`],architectures:[`x86_64`,`arm64`],cpus:2,memoryGb:4,diskGb:20,ports:[22,80,443]},r=/^(?=.{4,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/,i=e=>r.test(e.trim().toLowerCase()),a=(n=e)=>`https://github.com/${t}/releases/download/v${n}/install.sh`,o=(t=e)=>`${a(t)}.sha256`;function s({domain:e,maxChats:t}){return[`--domain`,(e=>`'${e.replace(/'/g,`'\\''`)}'`)(e.trim().toLowerCase()),...t?[`--max-chats`,String(t)]:[]]}function c(e){return`curl -fsSL ${a(e.version)} | sudo sh -s -- ${s(e).join(` `)}`}function l(e){let t=e.version??`1.1.0`;return[`curl -fsSLO ${a(t)}`,`curl -fsSL ${o(t)} | sha256sum -c -`,`sudo sh install.sh ${s(e).join(` `)}`]}var u=[{id:`server`},{id:`dns`,check:`dns`},{id:`access`},{id:`install`},{id:`pair`,check:`health`}];function d(e){let t=t=>RegExp(`^${t}=(.+)$`,`m`).exec(e)?.[1]?.trim(),n=t(`RUNNER_URL`),r=t(`PAIRING_CODE`),i=t(`RUNNER_ERROR`);return{...n?{url:n}:{},...r?{pairingCode:r}:{},...i?{error:i}:{}}}var f=[`check`,`docker`,`files`,`start`,`agent`,`health`,`pair`,`tls`,`done`],p=e=>{let t=/^STEP=([a-z]+)$/.exec(e.trim());return t&&f.includes(t[1])?t[1]:void 0};async function m(e,t={}){let n=t.resolver??`https://cloudflare-dns.com/dns-query`,r=async r=>{let i=await(t.fetch??fetch)(`${n}?name=${encodeURIComponent(e)}&type=${r}`,{headers:{accept:`application/dns-json`}});return i.ok?((await i.json()).Answer??[]).filter(e=>e.type===(r===`A`?1:28)).map(e=>e.data):[]},[i,a]=await Promise.all([r(`A`),r(`AAAA`)]);return[...i,...a]}async function h(e,t=fetch){try{let n=await t(`${e.replace(/\/+$/,``)}/health`);if(!n.ok)return{ok:!1,reason:`not-a-runner`};let r=await n.json();return r.ok&&typeof r.version==`string`?{ok:!0,version:r.version}:{ok:!1,reason:`not-a-runner`}}catch{return{ok:!1,reason:`unreachable`}}}exports.DOMAIN_PATTERN=r,exports.GUIDE_STEPS=u,exports.INSTALL_PHASES=f,exports.RUNNER_REPOSITORY=t,exports.RUNNER_REQUIREMENTS=n,exports.RUNNER_VERSION=e,exports.checkRunner=h,exports.checksumUrl=o,exports.installArguments=s,exports.installCommand=c,exports.installScriptUrl=a,exports.isDomain=i,exports.lookupDomain=m,exports.parseInstallOutput=d,exports.phaseOf=p,exports.verifiedInstallCommands=l;
2
2
  //# sourceMappingURL=steps.js.map
package/dist/steps.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/setup/steps.ts
2
- var e = "1.0.2", t = "sherpadvisorylab/llmnative-runner", n = {
2
+ var e = "1.1.0", t = "sherpadvisorylab/llmnative-runner", n = {
3
3
  systems: ["Ubuntu 22.04 or newer", "Debian 12 or newer"],
4
4
  architectures: ["x86_64", "arm64"],
5
5
  cpus: 2,
@@ -22,7 +22,7 @@ function c(e) {
22
22
  return `curl -fsSL ${a(e.version)} | sudo sh -s -- ${s(e).join(" ")}`;
23
23
  }
24
24
  function l(e) {
25
- let t = e.version ?? "1.0.2";
25
+ let t = e.version ?? "1.1.0";
26
26
  return [
27
27
  `curl -fsSLO ${a(t)}`,
28
28
  `curl -fsSL ${o(t)} | sha256sum -c -`,
@@ -52,6 +52,29 @@ export type RunnerStatus = {
52
52
  };
53
53
  tenants: RunnerTenant[];
54
54
  };
55
+ /** A pairing request made by a platform: `request` is its secret (keep it in the backend), `code` is shown on both sides. */
56
+ export type RunnerPairingRequest = {
57
+ request: string;
58
+ code: string;
59
+ approveUrl: string;
60
+ expiresAt: string;
61
+ interval: number;
62
+ };
63
+ export type RunnerPairingPoll = {
64
+ status: 'pending' | 'denied' | 'expired';
65
+ } | {
66
+ status: 'approved';
67
+ key: string;
68
+ record: RunnerKey;
69
+ version: string;
70
+ };
71
+ export type RunnerPairingRequestView = {
72
+ code: string;
73
+ name: string;
74
+ from?: string;
75
+ createdAt: string;
76
+ expiresAt: string;
77
+ };
55
78
  export type RunnerHealth = {
56
79
  ok: boolean;
57
80
  version: string;
@@ -152,6 +175,12 @@ export declare class RunnerClient {
152
175
  record: RunnerKey;
153
176
  version: string;
154
177
  }>;
178
+ /**
179
+ * Asks to connect (device flow): the admin of the runner approves it in the console at `approveUrl`, where the
180
+ * same `code` is shown; meanwhile `pollPairing(request)` every `interval` seconds, until it gives the key.
181
+ */
182
+ requestPairing(name: string): Promise<RunnerPairingRequest>;
183
+ pollPairing(request: string): Promise<RunnerPairingPoll>;
155
184
  info(): Promise<{
156
185
  version: string;
157
186
  harnesses: string[];
@@ -163,6 +192,8 @@ export declare class RunnerClient {
163
192
  code: string;
164
193
  expiresAt: string;
165
194
  }>;
195
+ pairingRequests(): Promise<RunnerPairingRequestView[]>;
196
+ answerPairing(code: string, approve: boolean): Promise<RunnerPairingRequestView>;
166
197
  readonly platform: {
167
198
  status: () => Promise<RunnerStatus>;
168
199
  tenants: () => Promise<RunnerTenant[]>;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import { type RunnerClient } from '../client';
3
3
  import { type RunnerUiTexts } from './texts';
4
+ /** `approve`: the code of the request a platform sent the person here for (`/console/?approve=ABCD-EFGH`). */
4
5
  export type RunnerConsoleProps = {
5
6
  client: RunnerClient;
6
7
  locale?: string;
7
8
  texts?: Partial<RunnerUiTexts>;
8
9
  onSignOut?: () => void;
10
+ approve?: string;
9
11
  };
10
- export declare function RunnerConsole({ client, locale, texts, onSignOut }: RunnerConsoleProps): React.JSX.Element;
12
+ export declare function RunnerConsole({ client, locale, texts, onSignOut, approve }: RunnerConsoleProps): React.JSX.Element;
@@ -9,6 +9,18 @@ export type RunnerEntry = {
9
9
  isDefault?: boolean;
10
10
  draining?: boolean;
11
11
  };
12
+ export type RunnerPairingStart = {
13
+ id: string;
14
+ code: string;
15
+ approveUrl: string;
16
+ expiresAt: string;
17
+ };
18
+ export type RunnerPairingState = {
19
+ status: 'pending' | 'denied' | 'expired';
20
+ } | {
21
+ status: 'approved';
22
+ runner: RunnerEntry;
23
+ };
12
24
  export type RunnerSshAccess = {
13
25
  host: string;
14
26
  port?: number;
@@ -38,6 +50,17 @@ export interface RunnerFleet {
38
50
  line: string;
39
51
  phase?: InstallPhase;
40
52
  }) => void): Promise<RunnerEntry>;
53
+ /**
54
+ * Connects a runner already installed by asking it (device flow): the backend asks the runner and keeps the
55
+ * secret of the request, the person approves on the runner (`approveUrl`, the same `code` on both sides).
56
+ * None: only with a pairing code.
57
+ */
58
+ startPairing?(input: {
59
+ name: string;
60
+ url: string;
61
+ }): Promise<RunnerPairingStart>;
62
+ /** How the request is going; approved, the runner connected. */
63
+ pairingStatus?(id: string): Promise<RunnerPairingState>;
41
64
  /** The backend runs on the computer of the person (`npx @llmnative/runner setup`): it can use its SSH keys. */
42
65
  localKeys?: boolean;
43
66
  /** The tenants of the platform and their runner; none: no distribution on this page. */
@@ -1,5 +1,5 @@
1
1
  export { RunnerAccounts, type RunnerAccountsProps } from './RunnerAccounts';
2
2
  export { InstallGuide, type InstallGuideProps } from './InstallGuide';
3
- export { RunnersSettings, AddRunner, type RunnerFleet, type RunnerEntry, type RunnerSshAccess, type RunnersSettingsProps } from './RunnersSettings';
3
+ export { RunnersSettings, AddRunner, type RunnerFleet, type RunnerEntry, type RunnerSshAccess, type RunnerPairingStart, type RunnerPairingState, type RunnersSettingsProps } from './RunnersSettings';
4
4
  export { RunnerConsole, type RunnerConsoleProps } from './RunnerConsole';
5
5
  export { runnerTexts, textsFor, fill, type RunnerUiTexts, type RunnerLocale } from './texts';
@@ -110,6 +110,26 @@ export declare const en: {
110
110
  consoleRemoveTenant: string;
111
111
  consoleRemoveTenantConfirm: string;
112
112
  consoleAccounts: string;
113
+ pairNext: string;
114
+ pairWaitingTitle: string;
115
+ pairWaitingHint: string;
116
+ pairOpen: string;
117
+ pairWaiting: string;
118
+ pairDenied: string;
119
+ pairExpired: string;
120
+ pairAgain: string;
121
+ pairWithCode: string;
122
+ pairWithApproval: string;
123
+ consoleRequests: string;
124
+ consoleRequestsHint: string;
125
+ consoleRequestsEmpty: string;
126
+ consoleRequestFrom: string;
127
+ consoleRequestMatch: string;
128
+ consoleApprove: string;
129
+ consoleDeny: string;
130
+ consoleApproved: string;
131
+ consoleDenied: string;
132
+ consoleRemember: string;
113
133
  close: string;
114
134
  cancel: string;
115
135
  };
@@ -228,6 +248,26 @@ export declare const runnerTexts: {
228
248
  consoleRemoveTenant: string;
229
249
  consoleRemoveTenantConfirm: string;
230
250
  consoleAccounts: string;
251
+ pairNext: string;
252
+ pairWaitingTitle: string;
253
+ pairWaitingHint: string;
254
+ pairOpen: string;
255
+ pairWaiting: string;
256
+ pairDenied: string;
257
+ pairExpired: string;
258
+ pairAgain: string;
259
+ pairWithCode: string;
260
+ pairWithApproval: string;
261
+ consoleRequests: string;
262
+ consoleRequestsHint: string;
263
+ consoleRequestsEmpty: string;
264
+ consoleRequestFrom: string;
265
+ consoleRequestMatch: string;
266
+ consoleApprove: string;
267
+ consoleDeny: string;
268
+ consoleApproved: string;
269
+ consoleDenied: string;
270
+ consoleRemember: string;
231
271
  close: string;
232
272
  cancel: string;
233
273
  };
@@ -343,6 +383,26 @@ export declare const runnerTexts: {
343
383
  consoleRemoveTenant: string;
344
384
  consoleRemoveTenantConfirm: string;
345
385
  consoleAccounts: string;
386
+ pairNext: string;
387
+ pairWaitingTitle: string;
388
+ pairWaitingHint: string;
389
+ pairOpen: string;
390
+ pairWaiting: string;
391
+ pairDenied: string;
392
+ pairExpired: string;
393
+ pairAgain: string;
394
+ pairWithCode: string;
395
+ pairWithApproval: string;
396
+ consoleRequests: string;
397
+ consoleRequestsHint: string;
398
+ consoleRequestsEmpty: string;
399
+ consoleRequestFrom: string;
400
+ consoleRequestMatch: string;
401
+ consoleApprove: string;
402
+ consoleDeny: string;
403
+ consoleApproved: string;
404
+ consoleDenied: string;
405
+ consoleRemember: string;
346
406
  close: string;
347
407
  cancel: string;
348
408
  };
package/dist/ui.js CHANGED
@@ -1,4 +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`,addLocalKey:`The SSH key of this computer`,addLocalKeyHint:`The key ~/.ssh/config gives this host (or ~/.ssh/id_ed25519), and its user when it says one: leave the user empty to take it from there.`,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`,addLocalKey:`La chiave SSH di questo computer`,addLocalKeyHint:`La chiave che ~/.ssh/config indica per questo host (o ~/.ssh/id_ed25519), e il suo utente se lo indica: lascia vuoto l'utente per prenderlo da lì.`,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,localKeys:!!e.localKeys,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,localKeys:t,install:n,onDone:r,onError:i}){let[a,o]=(0,u.useState)({host:``,port:`22`,username:t?``:`root`,auth:t?`local`:`key`,privateKey:``,password:``,domain:``}),[s,c]=(0,u.useState)([]),[l,p]=(0,u.useState)(null),[m,h]=(0,u.useState)(!1),g=e=>({value:t})=>o(n=>({...n,[e]:String(t??``)})),_=a.host.trim()&&a.domain.trim()&&(a.auth===`local`||a.username.trim())&&(a.auth===`local`||(a.auth===`key`?a.privateKey.trim():a.password));return(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!m&&(0,f.jsxs)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,defaultValues:a,children:[(0,f.jsx)(d.String,{name:`domain`,label:e.guideDomain,placeholder:`runner.example.com`,onChange:g(`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:g(`host`)}),(0,f.jsx)(d.String,{name:`port`,label:e.addPort,onChange:g(`port`)}),(0,f.jsx)(d.String,{name:`username`,label:e.addUser,onChange:g(`username`)})]}),(0,f.jsx)(d.Select,{name:`auth`,label:e.addAuth,options:[...t?[{label:e.addLocalKey,value:`local`}]:[],{label:e.addKey,value:`key`},{label:e.addPassword,value:`password`}],onChange:g(`auth`)}),a.auth===`local`&&(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.addLocalKeyHint}),a.auth===`local`?null:a.auth===`key`?(0,f.jsx)(d.TextArea,{name:`privateKey`,label:e.addKey,placeholder:`-----BEGIN OPENSSH PRIVATE KEY-----`,onChange:g(`privateKey`)}):(0,f.jsx)(d.Password,{name:`password`,label:e.addPassword,autoComplete:`off`,onChange:g(`password`)})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.addCredentialsNote}),m&&(0,f.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:k.map(e=>(0,f.jsx)(d.Badge,{variant:l===e?`primary`:k.indexOf(e)<k.indexOf(l??`check`)?`success`:`light`,children:e},e))}),s.length>0&&(0,f.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-md bg-muted p-2 text-xs`,children:s.slice(-200).join(`
3
- `)}),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.LoadingButton,{label:m?e.addInstalling:e.addInstall,variant:`primary`,disabled:!_||m,onClick:async()=>{h(!0),c([]);try{await r(await n(a.domain.trim().toLowerCase(),{host:a.host.trim(),port:Number(a.port)||22,username:a.username.trim(),...a.auth===`key`?{privateKey:a.privateKey}:a.auth===`password`?{password:a.password}:{}},({line:e,phase:t})=>{t&&p(t),/^[A-Z_]+=/.test(e)||c(t=>[...t,e])}))}catch(e){i(e)}finally{h(!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;
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: you approve on the runner.`,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`,addLocalKey:`The SSH key of this computer`,addLocalKeyHint:`The key ~/.ssh/config gives this host (or ~/.ssh/id_ed25519), and its user when it says one: leave the user empty to take it from there.`,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`,pairNext:`Continue`,pairWaitingTitle:`Approve on the runner`,pairWaitingHint:`Open the runner and approve the request: check that it shows this same code.`,pairOpen:`Open the runner to approve`,pairWaiting:`Waiting for the approval… (until {at})`,pairDenied:`The request was refused on the runner.`,pairExpired:`The request expired: ask again.`,pairAgain:`Ask again`,pairWithCode:`I have a pairing code`,pairWithApproval:`Approve on the runner instead`,consoleRequests:`Requests to connect`,consoleRequestsHint:`A platform asked to connect to this runner. Approve only if you asked from there and the code is the one it shows.`,consoleRequestsEmpty:`No requests waiting.`,consoleRequestFrom:`{name}, from {from}, asked at {at}`,consoleRequestMatch:`The request you opened`,consoleApprove:`Approve`,consoleDeny:`Refuse`,consoleApproved:`Approved: {name} is connected.`,consoleDenied:`Refused.`,consoleRemember:`Remember on this browser`,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: approvi sul runner.`,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`,addLocalKey:`La chiave SSH di questo computer`,addLocalKeyHint:`La chiave che ~/.ssh/config indica per questo host (o ~/.ssh/id_ed25519), e il suo utente se lo indica: lascia vuoto l'utente per prenderlo da lì.`,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`,pairNext:`Continua`,pairWaitingTitle:`Approva sul runner`,pairWaitingHint:`Apri il runner e approva la richiesta: controlla che mostri questo stesso codice.`,pairOpen:`Apri il runner per approvare`,pairWaiting:`In attesa dell'approvazione… (fino alle {at})`,pairDenied:`La richiesta è stata rifiutata sul runner.`,pairExpired:`La richiesta è scaduta: chiedi di nuovo.`,pairAgain:`Chiedi di nuovo`,pairWithCode:`Ho un codice di abbinamento`,pairWithApproval:`Approva sul runner invece`,consoleRequests:`Richieste di collegamento`,consoleRequestsHint:`Una piattaforma ha chiesto di collegarsi a questo runner. Approva solo se l'hai chiesto tu da lì e il codice è quello che mostra.`,consoleRequestsEmpty:`Nessuna richiesta in attesa.`,consoleRequestFrom:`{name}, da {from}, alle {at}`,consoleRequestMatch:`La richiesta che hai aperto`,consoleApprove:`Approva`,consoleDeny:`Rifiuta`,consoleApproved:`Approvata: {name} è collegato.`,consoleDenied:`Rifiutata.`,consoleRemember:`Ricorda su questo browser`,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)(M,{t,localKeys:!!e.localKeys,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)(A,{t,name:s,nameField:h,pairing:e.startPairing&&e.pairingStatus?{start:e.startPairing.bind(e),status:e.pairingStatus.bind(e)}:void 0,onAdded:i,onError:m,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})]})}var O=e=>(/^https?:\/\//.test(e.trim())?e.trim():`https://${e.trim()}`).replace(/\/+$/,``),k=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});function A({t:e,name:t,nameField:n,pairing:r,onAdded:i,onError:a,onConnect:o}){let[s,c]=(0,u.useState)(``),[l,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(!r),[g,v]=(0,u.useState)(null),[y,b]=(0,u.useState)(null);return(0,u.useEffect)(()=>{if(!g||!r)return;let e=!1,t,n=async()=>{try{let t=await r.status(g.id);if(e)return;if(t.status===`approved`){await i(t.runner);return}if(t.status!==`pending`){b(t.status),v(null);return}}catch(t){e||a(t)}e||(t=setTimeout(()=>void n(),2e3))};return t=setTimeout(()=>void n(),2e3),()=>{e=!0,clearTimeout(t)}},[g,r,i,a]),g?(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,f.jsx)(`h4`,{className:`font-semibold`,children:e.pairWaitingTitle}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.pairWaitingHint}),(0,f.jsx)(`div`,{className:`rounded-lg border border-border p-4 text-center font-mono text-3xl font-semibold tracking-widest`,children:g.code}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(d.ActionButton,{icon:`external-link`,label:e.pairOpen,variant:`primary`,onClick:()=>window.open(g.approveUrl,`_blank`,`noopener`)}),(0,f.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:_(e.pairWaiting,{at:k(g.expiresAt)})})]})]}):(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n,y&&(0,f.jsx)(d.Alert,{variant:y===`denied`?`danger`:`warning`,children:y===`denied`?e.pairDenied:e.pairExpired}),(0,f.jsxs)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,defaultValues:{url:s,code:l},children:[(0,f.jsx)(d.String,{name:`url`,label:e.addUrl,placeholder:`https://runner.example.com`,onChange:({value:e})=>c(String(e??``))}),m&&(0,f.jsx)(d.String,{name:`code`,label:e.addCode,placeholder:`ABCD-EFGH`,autoComplete:`off`,onChange:({value:e})=>p(String(e??``))})]}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m?(0,f.jsx)(d.LoadingButton,{label:e.addConnect,variant:`primary`,disabled:!s.trim()||l.trim().length<8,onClick:()=>o(O(s),l.trim())}):(0,f.jsx)(d.LoadingButton,{label:y?e.pairAgain:e.pairNext,variant:`primary`,disabled:!s.trim(),onClick:async()=>{b(null);try{let e=O(s);v(await r.start({name:t.trim()||new URL(e).hostname,url:e}))}catch(e){a(e)}}}),r&&(0,f.jsx)(d.ActionButton,{label:m?e.pairWithApproval:e.pairWithCode,variant:`link`,onClick:()=>h(e=>!e)})]})]})}var j=[`check`,`docker`,`files`,`start`,`agent`,`health`,`pair`,`tls`,`done`];function M({t:e,localKeys:t,install:n,onDone:r,onError:i}){let[a,o]=(0,u.useState)({host:``,port:`22`,username:t?``:`root`,auth:t?`local`:`key`,privateKey:``,password:``,domain:``}),[s,c]=(0,u.useState)([]),[l,p]=(0,u.useState)(null),[m,h]=(0,u.useState)(!1),g=e=>({value:t})=>o(n=>({...n,[e]:String(t??``)})),_=a.host.trim()&&a.domain.trim()&&(a.auth===`local`||a.username.trim())&&(a.auth===`local`||(a.auth===`key`?a.privateKey.trim():a.password));return(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!m&&(0,f.jsxs)(d.Form,{appearance:`empty`,showNotice:!1,onSubmit:()=>!1,defaultValues:a,children:[(0,f.jsx)(d.String,{name:`domain`,label:e.guideDomain,placeholder:`runner.example.com`,onChange:g(`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:g(`host`)}),(0,f.jsx)(d.String,{name:`port`,label:e.addPort,onChange:g(`port`)}),(0,f.jsx)(d.String,{name:`username`,label:e.addUser,onChange:g(`username`)})]}),(0,f.jsx)(d.Select,{name:`auth`,label:e.addAuth,options:[...t?[{label:e.addLocalKey,value:`local`}]:[],{label:e.addKey,value:`key`},{label:e.addPassword,value:`password`}],onChange:g(`auth`)}),a.auth===`local`&&(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.addLocalKeyHint}),a.auth===`local`?null:a.auth===`key`?(0,f.jsx)(d.TextArea,{name:`privateKey`,label:e.addKey,placeholder:`-----BEGIN OPENSSH PRIVATE KEY-----`,onChange:g(`privateKey`)}):(0,f.jsx)(d.Password,{name:`password`,label:e.addPassword,autoComplete:`off`,onChange:g(`password`)})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.addCredentialsNote}),m&&(0,f.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:j.map(e=>(0,f.jsx)(d.Badge,{variant:l===e?`primary`:j.indexOf(e)<j.indexOf(l??`check`)?`success`:`light`,children:e},e))}),s.length>0&&(0,f.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-md bg-muted p-2 text-xs`,children:s.slice(-200).join(`
3
+ `)}),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.LoadingButton,{label:m?e.addInstalling:e.addInstall,variant:`primary`,disabled:!_||m,onClick:async()=>{h(!0),c([]);try{await r(await n(a.domain.trim().toLowerCase(),{host:a.host.trim(),port:Number(a.port)||22,username:a.username.trim(),...a.auth===`key`?{privateKey:a.privateKey}:a.auth===`password`?{password:a.password}:{}},({line:e,phase:t})=>{t&&p(t),/^[A-Z_]+=/.test(e)||c(t=>[...t,e])}))}catch(e){i(e)}finally{h(!1)}}})})]})}var N=e=>(e/1024**3).toFixed(1),P=e=>new Date(e).toLocaleString(void 0,{dateStyle:`short`,timeStyle:`short`});function F({client:e,locale:t,texts:n,onSignOut:r,approve:i}){let a=g(t,n),[o,s]=(0,u.useState)(null),[l,p]=(0,u.useState)(null),[m,h]=(0,u.useState)(null),[v,y]=(0,u.useState)({id:``,name:``}),[b,x]=(0,u.useState)(null),S=(0,u.useCallback)(async()=>{try{s(await e.platform.status()),p(null)}catch(e){p(_(a.error,{error:e instanceof c.RunnerError?e.code:String(e)}))}},[e,a]);return(0,u.useEffect)(()=>{S()},[S]),(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:a.consoleTitle}),r&&(0,f.jsx)(d.ActionButton,{icon:`log-out`,label:a.consoleSignOut,variant:`outline-secondary`,onClick:r})]}),l&&(0,f.jsx)(d.Alert,{variant:`danger`,children:l}),(0,f.jsx)(R,{client:e,t:a,approve:i,onAnswered:S}),(0,f.jsx)(d.Card,{title:a.consoleStatus,loading:!o&&!l,loaderMinHeight:100,children:o&&(0,f.jsx)(d.DescriptionList,{items:[{label:`Version`,value:o.version},{label:`URL`,value:o.url},{label:`Chats`,value:`${o.load.chats} / ${o.load.maxChats}`},{label:`Machine`,value:_(a.consoleMachine,{memory:N(o.machine.availableBytes),total:N(o.machine.totalBytes),cpus:o.machine.cpus})},{label:`Agent`,value:o.agentImage}]})}),(0,f.jsx)(d.Card,{title:a.consolePairing,children:(0,f.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a.consolePairingHint}),m&&(0,f.jsx)(d.Code,{showCopy:!0,children:m.code}),m&&(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(a.consoleCode,{code:m.code,at:P(m.expiresAt)})}),(0,f.jsx)(`div`,{children:(0,f.jsx)(d.LoadingButton,{label:a.consoleNewCode,variant:`outline-primary`,onClick:async()=>h(await e.createPairing())})})]})}),(0,f.jsx)(d.Card,{title:a.consoleTenants,children:(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b&&(0,f.jsx)(d.Alert,{variant:`warning`,onClose:()=>x(null),children:(0,f.jsx)(`span`,{className:`break-all`,children:_(a.consoleKeyShown,{key:b})})}),o?.tenants.map(n=>(0,f.jsx)(I,{client:e,tenant:n,t:a,locale:t,onKey:x,onChange:S},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:a.consoleTenantId,placeholder:`acme`,onChange:({value:e})=>y(t=>({...t,id:String(e??``)}))}),(0,f.jsx)(d.String,{name:`tenantName`,label:a.consoleTenantName,placeholder:`Acme`,onChange:({value:e})=>y(t=>({...t,name:String(e??``)}))}),(0,f.jsx)(d.LoadingButton,{label:a.consoleCreate,variant:`primary`,disabled:!/^[a-z0-9][a-z0-9-]{0,62}$/.test(v.id),onClick:async()=>{try{let t=await e.platform.createTenant(v.id,{name:v.name||void 0});t.key&&x(t.key),await S()}catch(e){p(_(a.error,{error:e instanceof c.RunnerError?e.code:String(e)}))}}})]})})]})})]})}function I({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})})]})}var L=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,``);function R({client:e,t,approve:n,onAnswered:r}){let[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(null),c=(0,u.useCallback)(async()=>{try{let t=await e.pairingRequests(),r=n?L(n):``;a([...t].sort((e,t)=>Number(L(t.code)===r)-Number(L(e.code)===r)))}catch{a([])}},[e,n]);return(0,u.useEffect)(()=>{c();let e=setInterval(()=>void c(),5e3);return()=>clearInterval(e)},[c]),!n&&!i?.length&&!o?null:(0,f.jsx)(d.Card,{title:t.consoleRequests,loading:i===null,loaderMinHeight:80,children:(0,f.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.consoleRequestsHint}),o&&(0,f.jsx)(d.Alert,{variant:o.variant,children:o.text}),i?.length===0&&!o&&(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.consoleRequestsEmpty}),i?.map(i=>{let a=!!n&&L(i.code)===L(n),o=async n=>{let a=await e.answerPairing(i.code,n);s(n?{variant:`success`,text:_(t.consoleApproved,{name:a.name})}:{variant:`info`,text:t.consoleDenied}),await c(),await r()};return(0,f.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3 ${a?`border-primary`:`border-border`}`,children:[a&&(0,f.jsx)(d.Badge,{variant:`primary`,children:t.consoleRequestMatch}),(0,f.jsx)(`div`,{className:`font-mono text-2xl font-semibold tracking-widest`,children:i.code}),(0,f.jsx)(`p`,{className:`text-sm`,children:_(t.consoleRequestFrom,{name:i.name,from:i.from??`?`,at:P(i.createdAt)})}),(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsx)(d.LoadingButton,{label:t.consoleApprove,variant:`primary`,onClick:()=>o(!0)}),(0,f.jsx)(d.LoadingButton,{label:t.consoleDeny,variant:`outline-danger`,onClick:()=>o(!1)})]})]},i.code)})]})})}exports.AddRunner=E,exports.InstallGuide=w,exports.RunnerAccounts=b,exports.RunnerConsole=F,exports.RunnersSettings=T,exports.fill=_,exports.runnerTexts=h,exports.textsFor=g;
4
4
  //# sourceMappingURL=ui.js.map