@llmnative/runner 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +9 -3
  3. package/bin/runner.mjs +21 -10
  4. package/bin/setup-server.mjs +160 -0
  5. package/bin/ssh-keys.mjs +15 -0
  6. package/dist/setup-app/assets/NetworkCanvasImpl-DIYuzg6x-B7pXHLvO.js +7 -0
  7. package/dist/setup-app/assets/dist-9W_fpPLL.js +11 -0
  8. package/dist/setup-app/assets/index-CmPc3Q2I.css +2 -0
  9. package/dist/setup-app/assets/index-DMRj6ej7.js +32 -0
  10. package/dist/setup-app/assets/index.es-uN19ZvBn.js +1 -0
  11. package/dist/setup-app/assets/index.esm-7HxyOcz9.js +9 -0
  12. package/dist/setup-app/assets/index.esm-Bo_uP467.js +1 -0
  13. package/dist/setup-app/assets/index.esm-D6oehhSQ.js +1 -0
  14. package/dist/setup-app/assets/index.esm-D983b7TD.js +1 -0
  15. package/dist/setup-app/assets/index.esm-H_whZvB-.js +4 -0
  16. package/dist/setup-app/assets/index.esm-NAFJB7JL.js +31 -0
  17. package/dist/setup-app/assets/lucide-react-29AuFPtd.js +1 -0
  18. package/dist/setup-app/assets/prism-BjaHQ1lq.js +2 -0
  19. package/dist/setup-app/assets/prism-bash-D6zCJ74D.js +1 -0
  20. package/dist/setup-app/assets/prism-c-04YixN25.js +1 -0
  21. package/dist/setup-app/assets/prism-clike-DapgWyxx.js +1 -0
  22. package/dist/setup-app/assets/prism-cpp-C-lJbC-6.js +1 -0
  23. package/dist/setup-app/assets/prism-csharp-XPn2bw0d.js +1 -0
  24. package/dist/setup-app/assets/prism-css-CPgOzxXp.js +1 -0
  25. package/dist/setup-app/assets/prism-docker-DkT6yOFj.js +1 -0
  26. package/dist/setup-app/assets/prism-git-BZB8f0uj.js +1 -0
  27. package/dist/setup-app/assets/prism-go-C_8qAH5n.js +1 -0
  28. package/dist/setup-app/assets/prism-graphql-XjvHrdQl.js +1 -0
  29. package/dist/setup-app/assets/prism-ini-BESK3y0r.js +1 -0
  30. package/dist/setup-app/assets/prism-java-6wtusvIl.js +1 -0
  31. package/dist/setup-app/assets/prism-javascript-BnO-swvr.js +1 -0
  32. package/dist/setup-app/assets/prism-json-Dp_-W-Hv.js +1 -0
  33. package/dist/setup-app/assets/prism-jsx-D-D0NWtC.js +1 -0
  34. package/dist/setup-app/assets/prism-markup-Cp04rIa1.js +1 -0
  35. package/dist/setup-app/assets/prism-php-Co4fM40K.js +1 -0
  36. package/dist/setup-app/assets/prism-powershell-Cvud8pPk.js +1 -0
  37. package/dist/setup-app/assets/prism-python-CfiSVtM6.js +1 -0
  38. package/dist/setup-app/assets/prism-ruby-Cb5nlQRI.js +1 -0
  39. package/dist/setup-app/assets/prism-sql-CYhVDMEE.js +1 -0
  40. package/dist/setup-app/assets/prism-tsx-p6J2Kc_4.js +1 -0
  41. package/dist/setup-app/assets/prism-typescript-BMqONzxf.js +1 -0
  42. package/dist/setup-app/assets/prism-yaml-C0JHu8gr.js +1 -0
  43. package/dist/setup-app/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  44. package/dist/setup-app/assets/style-DLioOiRN.css +1 -0
  45. package/dist/setup-app/index.html +15 -0
  46. package/dist/setup.js +1 -1
  47. package/dist/setup.js.map +1 -1
  48. package/dist/setup.mjs +21 -1
  49. package/dist/setup.mjs.map +1 -1
  50. package/dist/steps.js +1 -1
  51. package/dist/steps.js.map +1 -1
  52. package/dist/steps.mjs +2 -2
  53. package/dist/steps.mjs.map +1 -1
  54. package/dist/types/setup/index.d.ts +8 -0
  55. package/dist/types/ui/RunnersSettings.d.ts +2 -0
  56. package/dist/types/ui/texts.d.ts +6 -0
  57. package/dist/ui.js +3 -3
  58. package/dist/ui.js.map +1 -1
  59. package/dist/ui.mjs +54 -38
  60. package/dist/ui.mjs.map +1 -1
  61. package/install/compose.yaml +18 -1
  62. package/install/coolify.yaml +2 -2
  63. package/install/install.sh +62 -10
  64. package/llms.txt +1 -1
  65. package/package.json +23 -7
package/dist/steps.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/setup/steps.ts
2
- var e = "1.0.0", t = "sherpadvisorylab/llmnative-runner", n = {
2
+ var e = "1.0.3", 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.0";
25
+ let t = e.version ?? "1.0.3";
26
26
  return [
27
27
  `curl -fsSLO ${a(t)}`,
28
28
  `curl -fsSL ${o(t)} | sha256sum -c -`,
@@ -1 +1 @@
1
- {"version":3,"file":"steps.mjs","names":["RUNNER_VERSION","RUNNER_REPOSITORY","RUNNER_REQUIREMENTS","DOMAIN_PATTERN","isDomain","value","installScriptUrl","version","checksumUrl","installArguments","domain","maxChats","installCommand","options","verifiedInstallCommands","GUIDE_STEPS","parseInstallOutput","name","text","url","pairingCode","error","INSTALL_PHASES","phaseOf","match","line","lookupDomain","resolver","ask","response","type","answer","v4","v6","checkRunner","fetchImpl","data"],"sources":["../src/setup/steps.ts"],"sourcesContent":["// @llmnative/runner/steps — how a runner is installed, said once: the requirements, the command, the steps of the\r\n// guide and what the installer prints. The installer over SSH (`/setup`), the command line and the guide of the UI\r\n// all read it, so they never drift apart. Pure: browser and Node.\r\n\r\n/** Set by the build from package.json. */\r\ndeclare const __RUNNER_VERSION__: string;\r\n\r\n/** The release these steps install: the version of this package (images and package share it). */\r\nexport const RUNNER_VERSION: string = typeof __RUNNER_VERSION__ === 'string' ? __RUNNER_VERSION__ : '0.0.0';\r\nexport const RUNNER_REPOSITORY = 'sherpadvisorylab/llmnative-runner';\r\n\r\nexport const RUNNER_REQUIREMENTS = {\r\n systems: ['Ubuntu 22.04 or newer', 'Debian 12 or newer'],\r\n architectures: ['x86_64', 'arm64'],\r\n cpus: 2,\r\n memoryGb: 4,\r\n diskGb: 20,\r\n ports: [22, 80, 443],\r\n} as const;\r\n\r\n/** The domain of a runner: a host name of its own (`runner.example.com`), pointed at the VPS. */\r\nexport const DOMAIN_PATTERN = /^(?=.{4,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/;\r\nexport const isDomain = (value: string) => DOMAIN_PATTERN.test(value.trim().toLowerCase());\r\n\r\nexport const installScriptUrl = (version = RUNNER_VERSION) => `https://github.com/${RUNNER_REPOSITORY}/releases/download/v${version}/install.sh`;\r\nexport const checksumUrl = (version = RUNNER_VERSION) => `${installScriptUrl(version)}.sha256`;\r\n\r\nexport type InstallOptions = { domain: string; version?: string; maxChats?: number };\r\n\r\n/** The arguments of install.sh, each quoted for a shell. */\r\nexport function installArguments({ domain, maxChats }: InstallOptions): string[] {\r\n const quote = (value: string) => `'${value.replace(/'/g, `'\\\\''`)}'`;\r\n return ['--domain', quote(domain.trim().toLowerCase()), ...(maxChats ? ['--max-chats', String(maxChats)] : [])];\r\n}\r\n\r\n/** The command to paste on the VPS (as root, or with sudo). */\r\nexport function installCommand(options: InstallOptions): string {\r\n return `curl -fsSL ${installScriptUrl(options.version)} | sudo sh -s -- ${installArguments(options).join(' ')}`;\r\n}\r\n\r\n/** The same, for who checks the script before running it. */\r\nexport function verifiedInstallCommands(options: InstallOptions): string[] {\r\n const version = options.version ?? RUNNER_VERSION;\r\n return [\r\n `curl -fsSLO ${installScriptUrl(version)}`,\r\n `curl -fsSL ${checksumUrl(version)} | sha256sum -c -`,\r\n `sudo sh install.sh ${installArguments(options).join(' ')}`,\r\n ];\r\n}\r\n\r\n/** The steps of the guide, in order; `check` says what the guide can verify by itself at that step. */\r\nexport const GUIDE_STEPS = [\r\n { id: 'server' },\r\n { id: 'dns', check: 'dns' },\r\n { id: 'access' },\r\n { id: 'install' },\r\n { id: 'pair', check: 'health' },\r\n] as const;\r\nexport type GuideStepId = (typeof GUIDE_STEPS)[number]['id'];\r\n\r\n/** What install.sh prints for a machine to read: `RUNNER_URL=…`, `PAIRING_CODE=…`, `RUNNER_ERROR=…`. */\r\nexport function parseInstallOutput(text: string): { url?: string; pairingCode?: string; error?: string } {\r\n const value = (name: string) => new RegExp(`^${name}=(.+)$`, 'm').exec(text)?.[1]?.trim();\r\n const url = value('RUNNER_URL');\r\n const pairingCode = value('PAIRING_CODE');\r\n const error = value('RUNNER_ERROR');\r\n return { ...(url ? { url } : {}), ...(pairingCode ? { pairingCode } : {}), ...(error ? { error } : {}) };\r\n}\r\n\r\n/** The steps install.sh announces (`STEP=<id>`), for a progress shown while it runs. */\r\nexport const INSTALL_PHASES = ['check', 'docker', 'files', 'start', 'agent', 'health', 'pair', 'tls', 'done'] as const;\r\nexport type InstallPhase = (typeof INSTALL_PHASES)[number];\r\nexport const phaseOf = (line: string): InstallPhase | undefined => {\r\n const match = /^STEP=([a-z]+)$/.exec(line.trim());\r\n return match && (INSTALL_PHASES as readonly string[]).includes(match[1]) ? match[1] as InstallPhase : undefined;\r\n};\r\n\r\n/**\r\n * The addresses a domain points to, asked over DNS-over-HTTPS (no DNS from a browser otherwise). `resolver`: a\r\n * service that answers `application/dns-json` (by default Cloudflare's; any other can be given).\r\n */\r\nexport async function lookupDomain(domain: string, options: { fetch?: typeof fetch; resolver?: string } = {}): Promise<string[]> {\r\n const resolver = options.resolver ?? 'https://cloudflare-dns.com/dns-query';\r\n const ask = async (type: 'A' | 'AAAA') => {\r\n const response = await (options.fetch ?? fetch)(`${resolver}?name=${encodeURIComponent(domain)}&type=${type}`, { headers: { accept: 'application/dns-json' } });\r\n if (!response.ok) return [];\r\n const data = await response.json() as { Answer?: Array<{ type: number; data: string }> };\r\n return (data.Answer ?? []).filter((answer) => answer.type === (type === 'A' ? 1 : 28)).map((answer) => answer.data);\r\n };\r\n const [v4, v6] = await Promise.all([ask('A'), ask('AAAA')]);\r\n return [...v4, ...v6];\r\n}\r\n\r\n/** Whether a runner answers at its address, over HTTPS: its version, or why not. */\r\nexport async function checkRunner(url: string, fetchImpl: typeof fetch = fetch): Promise<{ ok: true; version: string } | { ok: false; reason: 'unreachable' | 'not-a-runner' }> {\r\n try {\r\n const response = await fetchImpl(`${url.replace(/\\/+$/, '')}/health`);\r\n if (!response.ok) return { ok: false, reason: 'not-a-runner' };\r\n const data = await response.json() as { ok?: boolean; version?: string };\r\n return data.ok && typeof data.version === 'string' ? { ok: true, version: data.version } : { ok: false, reason: 'not-a-runner' };\r\n } catch {\r\n return { ok: false, reason: 'unreachable' };\r\n }\r\n}\r\n"],"mappings":"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"}
1
+ {"version":3,"file":"steps.mjs","names":["RUNNER_VERSION","RUNNER_REPOSITORY","RUNNER_REQUIREMENTS","DOMAIN_PATTERN","isDomain","value","installScriptUrl","version","checksumUrl","installArguments","domain","maxChats","installCommand","options","verifiedInstallCommands","GUIDE_STEPS","parseInstallOutput","name","text","url","pairingCode","error","INSTALL_PHASES","phaseOf","match","line","lookupDomain","resolver","ask","response","type","answer","v4","v6","checkRunner","fetchImpl","data"],"sources":["../src/setup/steps.ts"],"sourcesContent":["// @llmnative/runner/steps — how a runner is installed, said once: the requirements, the command, the steps of the\n// guide and what the installer prints. The installer over SSH (`/setup`), the command line and the guide of the UI\n// all read it, so they never drift apart. Pure: browser and Node.\n\n/** Set by the build from package.json. */\ndeclare const __RUNNER_VERSION__: string;\n\n/** The release these steps install: the version of this package (images and package share it). */\nexport const RUNNER_VERSION: string = typeof __RUNNER_VERSION__ === 'string' ? __RUNNER_VERSION__ : '0.0.0';\nexport const RUNNER_REPOSITORY = 'sherpadvisorylab/llmnative-runner';\n\nexport const RUNNER_REQUIREMENTS = {\n systems: ['Ubuntu 22.04 or newer', 'Debian 12 or newer'],\n architectures: ['x86_64', 'arm64'],\n cpus: 2,\n memoryGb: 4,\n diskGb: 20,\n ports: [22, 80, 443],\n} as const;\n\n/** The domain of a runner: a host name of its own (`runner.example.com`), pointed at the VPS. */\nexport const DOMAIN_PATTERN = /^(?=.{4,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/;\nexport const isDomain = (value: string) => DOMAIN_PATTERN.test(value.trim().toLowerCase());\n\nexport const installScriptUrl = (version = RUNNER_VERSION) => `https://github.com/${RUNNER_REPOSITORY}/releases/download/v${version}/install.sh`;\nexport const checksumUrl = (version = RUNNER_VERSION) => `${installScriptUrl(version)}.sha256`;\n\nexport type InstallOptions = { domain: string; version?: string; maxChats?: number };\n\n/** The arguments of install.sh, each quoted for a shell. */\nexport function installArguments({ domain, maxChats }: InstallOptions): string[] {\n const quote = (value: string) => `'${value.replace(/'/g, `'\\\\''`)}'`;\n return ['--domain', quote(domain.trim().toLowerCase()), ...(maxChats ? ['--max-chats', String(maxChats)] : [])];\n}\n\n/** The command to paste on the VPS (as root, or with sudo). */\nexport function installCommand(options: InstallOptions): string {\n return `curl -fsSL ${installScriptUrl(options.version)} | sudo sh -s -- ${installArguments(options).join(' ')}`;\n}\n\n/** The same, for who checks the script before running it. */\nexport function verifiedInstallCommands(options: InstallOptions): string[] {\n const version = options.version ?? RUNNER_VERSION;\n return [\n `curl -fsSLO ${installScriptUrl(version)}`,\n `curl -fsSL ${checksumUrl(version)} | sha256sum -c -`,\n `sudo sh install.sh ${installArguments(options).join(' ')}`,\n ];\n}\n\n/** The steps of the guide, in order; `check` says what the guide can verify by itself at that step. */\nexport const GUIDE_STEPS = [\n { id: 'server' },\n { id: 'dns', check: 'dns' },\n { id: 'access' },\n { id: 'install' },\n { id: 'pair', check: 'health' },\n] as const;\nexport type GuideStepId = (typeof GUIDE_STEPS)[number]['id'];\n\n/** What install.sh prints for a machine to read: `RUNNER_URL=…`, `PAIRING_CODE=…`, `RUNNER_ERROR=…`. */\nexport function parseInstallOutput(text: string): { url?: string; pairingCode?: string; error?: string } {\n const value = (name: string) => new RegExp(`^${name}=(.+)$`, 'm').exec(text)?.[1]?.trim();\n const url = value('RUNNER_URL');\n const pairingCode = value('PAIRING_CODE');\n const error = value('RUNNER_ERROR');\n return { ...(url ? { url } : {}), ...(pairingCode ? { pairingCode } : {}), ...(error ? { error } : {}) };\n}\n\n/** The steps install.sh announces (`STEP=<id>`), for a progress shown while it runs. */\nexport const INSTALL_PHASES = ['check', 'docker', 'files', 'start', 'agent', 'health', 'pair', 'tls', 'done'] as const;\nexport type InstallPhase = (typeof INSTALL_PHASES)[number];\nexport const phaseOf = (line: string): InstallPhase | undefined => {\n const match = /^STEP=([a-z]+)$/.exec(line.trim());\n return match && (INSTALL_PHASES as readonly string[]).includes(match[1]) ? match[1] as InstallPhase : undefined;\n};\n\n/**\n * The addresses a domain points to, asked over DNS-over-HTTPS (no DNS from a browser otherwise). `resolver`: a\n * service that answers `application/dns-json` (by default Cloudflare's; any other can be given).\n */\nexport async function lookupDomain(domain: string, options: { fetch?: typeof fetch; resolver?: string } = {}): Promise<string[]> {\n const resolver = options.resolver ?? 'https://cloudflare-dns.com/dns-query';\n const ask = async (type: 'A' | 'AAAA') => {\n const response = await (options.fetch ?? fetch)(`${resolver}?name=${encodeURIComponent(domain)}&type=${type}`, { headers: { accept: 'application/dns-json' } });\n if (!response.ok) return [];\n const data = await response.json() as { Answer?: Array<{ type: number; data: string }> };\n return (data.Answer ?? []).filter((answer) => answer.type === (type === 'A' ? 1 : 28)).map((answer) => answer.data);\n };\n const [v4, v6] = await Promise.all([ask('A'), ask('AAAA')]);\n return [...v4, ...v6];\n}\n\n/** Whether a runner answers at its address, over HTTPS: its version, or why not. */\nexport async function checkRunner(url: string, fetchImpl: typeof fetch = fetch): Promise<{ ok: true; version: string } | { ok: false; reason: 'unreachable' | 'not-a-runner' }> {\n try {\n const response = await fetchImpl(`${url.replace(/\\/+$/, '')}/health`);\n if (!response.ok) return { ok: false, reason: 'not-a-runner' };\n const data = await response.json() as { ok?: boolean; version?: string };\n return data.ok && typeof data.version === 'string' ? { ok: true, version: data.version } : { ok: false, reason: 'not-a-runner' };\n } catch {\n return { ok: false, reason: 'unreachable' };\n }\n}\n"],"mappings":"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"}
@@ -48,3 +48,11 @@ export declare function installAndPair(target: SshTarget, options: InstallOption
48
48
  platformKey: string;
49
49
  version: string;
50
50
  }>;
51
+ /**
52
+ * What ~/.ssh/config says for a host: its user and its key files, in the order ssh tries them (first match of each
53
+ * option wins, as ssh does). `~` left as is: the caller resolves it.
54
+ */
55
+ export declare function sshConfigFor(configText: string, host: string): {
56
+ user?: string;
57
+ identityFiles: string[];
58
+ };
@@ -38,6 +38,8 @@ export interface RunnerFleet {
38
38
  line: string;
39
39
  phase?: InstallPhase;
40
40
  }) => void): Promise<RunnerEntry>;
41
+ /** The backend runs on the computer of the person (`npx @llmnative/runner setup`): it can use its SSH keys. */
42
+ localKeys?: boolean;
41
43
  /** The tenants of the platform and their runner; none: no distribution on this page. */
42
44
  tenants?: {
43
45
  list(): Promise<Array<{
@@ -78,6 +78,8 @@ export declare const en: {
78
78
  addUser: string;
79
79
  addAuth: string;
80
80
  addKey: string;
81
+ addLocalKey: string;
82
+ addLocalKeyHint: string;
81
83
  addPassword: string;
82
84
  addInstall: string;
83
85
  addInstalling: string;
@@ -194,6 +196,8 @@ export declare const runnerTexts: {
194
196
  addUser: string;
195
197
  addAuth: string;
196
198
  addKey: string;
199
+ addLocalKey: string;
200
+ addLocalKeyHint: string;
197
201
  addPassword: string;
198
202
  addInstall: string;
199
203
  addInstalling: string;
@@ -307,6 +311,8 @@ export declare const runnerTexts: {
307
311
  addUser: string;
308
312
  addAuth: string;
309
313
  addKey: string;
314
+ addLocalKey: string;
315
+ addLocalKeyHint: string;
310
316
  addPassword: string;
311
317
  addInstall: string;
312
318
  addInstalling: string;
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`,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;
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;
4
4
  //# sourceMappingURL=ui.js.map