kiteline 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +70 -2
- package/dist/auth-YhkfTv6K.mjs +60 -0
- package/dist/banner-DJdyE8-G.mjs +1067 -0
- package/dist/cli.mjs +107 -0
- package/dist/package-D46-e3oS.mjs +3 -0
- package/dist/service-1H4ozSPX.mjs +192 -0
- package/dist/show-pairing-jhFEXWi7.mjs +30 -0
- package/dist/show-pairing-u0LfkF9W.mjs +1 -0
- package/dist/src-BnClcgTs.mjs +13382 -0
- package/dist/web/apple-touch-icon-180x180.png +0 -0
- package/dist/web/assets/IconBase.es-CfbvcPwJ.js +9 -0
- package/dist/web/assets/MagnifyingGlass.es-DLNPT1gT.js +1 -0
- package/dist/web/assets/composer-B6OuQTWV.js +1 -0
- package/dist/web/assets/copy-button-DrJvfi1A.js +1 -0
- package/dist/web/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/web/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/dist/web/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/dist/web/assets/index-CA73h-Vn.css +1 -0
- package/dist/web/assets/index-Da9GDrpu.js +11 -0
- package/dist/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/web/assets/lazy/core-DbyPnbRm.js +12 -0
- package/dist/web/assets/lazy/css-BGIxQoYs.js +1 -0
- package/dist/web/assets/lazy/css-DgaLhXQH.js +1 -0
- package/dist/web/assets/lazy/diff-woXpYk--.js +1 -0
- package/dist/web/assets/lazy/dockerfile-IyjqRm3v.js +1 -0
- package/dist/web/assets/lazy/engine-javascript-C30F4iNc.js +141 -0
- package/dist/web/assets/lazy/github-dark-default-DXG-b-1a.js +1 -0
- package/dist/web/assets/lazy/github-light-default-BXViO-2h.js +1 -0
- package/dist/web/assets/lazy/go-rLFTqkRN.js +1 -0
- package/dist/web/assets/lazy/html-CvFb5cGI.js +1 -0
- package/dist/web/assets/lazy/javascript-BzbQS41l.js +1 -0
- package/dist/web/assets/lazy/javascript-CpIGwZ_Y.js +1 -0
- package/dist/web/assets/lazy/json-qhed-kSA.js +1 -0
- package/dist/web/assets/lazy/jsx-Bz0zcwM4.js +1 -0
- package/dist/web/assets/lazy/markdown-BYOwaDjH.js +1 -0
- package/dist/web/assets/lazy/python-gzcpVVnB.js +1 -0
- package/dist/web/assets/lazy/rust-DpiIf5JO.js +1 -0
- package/dist/web/assets/lazy/shellscript-CLZ0U2zV.js +1 -0
- package/dist/web/assets/lazy/sql-CEbI0hMM.js +1 -0
- package/dist/web/assets/lazy/toml-CcmNWLt0.js +1 -0
- package/dist/web/assets/lazy/tsx-udAQXfEw.js +1 -0
- package/dist/web/assets/lazy/typescript-bsJCZSQ-.js +1 -0
- package/dist/web/assets/lazy/yaml-rwi0_p6S.js +1 -0
- package/dist/web/assets/new-x01_nUpy.js +1 -0
- package/dist/web/assets/prefs-CliZrwNF.js +1 -0
- package/dist/web/assets/routes-NIOlnkZY.js +1 -0
- package/dist/web/assets/s._sessionId-BtgSN22Q.js +45 -0
- package/dist/web/assets/settings-B7yar__r.js +1 -0
- package/dist/web/assets/status-BFb0ZUqi.js +1 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/index.html +40 -0
- package/dist/web/logo.svg +12 -0
- package/dist/web/manifest.webmanifest +1 -0
- package/dist/web/maskable-icon-512x512.png +0 -0
- package/dist/web/pwa-192x192.png +0 -0
- package/dist/web/pwa-512x512.png +0 -0
- package/dist/web/pwa-64x64.png +0 -0
- package/dist/web/registerSW.js +1 -0
- package/dist/web/sw.js +1 -0
- package/dist/web/workbox-dcde9eb3.js +1 -0
- package/package.json +34 -4
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as version } from "./package-D46-e3oS.mjs";
|
|
3
|
+
import { i as dim, n as bold, p as startedFromCli, t as accent } from "./banner-DJdyE8-G.mjs";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
// src/cli.ts
|
|
6
|
+
const HELP = `
|
|
7
|
+
${accent("◆")} ${bold("Kiteline")} ${dim(version)}
|
|
8
|
+
Drive Claude Code on this computer from your phone.
|
|
9
|
+
|
|
10
|
+
${bold("Usage")}
|
|
11
|
+
kiteline Start Kiteline and show the code that pairs your phone
|
|
12
|
+
kiteline pair Show the pairing code again, while Kiteline runs
|
|
13
|
+
kiteline service install Keep it running in the background, from startup (Linux)
|
|
14
|
+
kiteline service uninstall Take the background service away
|
|
15
|
+
kiteline service Say whether it's running in the background
|
|
16
|
+
|
|
17
|
+
${bold("Options")}
|
|
18
|
+
-p, --port <number> Port to listen on. Default 4545
|
|
19
|
+
--host <address> Address to listen on. Default 0.0.0.0, every network;
|
|
20
|
+
127.0.0.1 keeps it to this computer, for Tailscale Serve
|
|
21
|
+
--public-url <url> The address your phone uses, like your Tailscale one;
|
|
22
|
+
the pairing code points there
|
|
23
|
+
--new-token Make a new pairing code, so every device pairs again
|
|
24
|
+
--force With service install: replace a service set up by hand
|
|
25
|
+
-v, --version Show the version
|
|
26
|
+
-h, --help Show this
|
|
27
|
+
|
|
28
|
+
The options also work as environment variables (PORT, HOST, KITELINE_PUBLIC_URL), and a few
|
|
29
|
+
more settings do too: ${accent("https://kiteline.seefun.dev/docs/#config")}
|
|
30
|
+
`;
|
|
31
|
+
function fail(message) {
|
|
32
|
+
console.error(`\n ${accent("◆")} ${message}\n`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const [major = 0, minor = 0] = process.versions.node.split(".").map(Number);
|
|
36
|
+
if (major < 22 || major === 22 && minor < 18) fail(`Kiteline needs Node.js 22.18 or newer, and this is ${process.version}.\n Get a newer one from ${accent("https://nodejs.org")}, then run it again.`);
|
|
37
|
+
let parsed;
|
|
38
|
+
function parse() {
|
|
39
|
+
return parseArgs({
|
|
40
|
+
allowPositionals: true,
|
|
41
|
+
options: {
|
|
42
|
+
port: {
|
|
43
|
+
type: "string",
|
|
44
|
+
short: "p"
|
|
45
|
+
},
|
|
46
|
+
host: { type: "string" },
|
|
47
|
+
"public-url": { type: "string" },
|
|
48
|
+
"new-token": { type: "boolean" },
|
|
49
|
+
force: { type: "boolean" },
|
|
50
|
+
help: {
|
|
51
|
+
type: "boolean",
|
|
52
|
+
short: "h"
|
|
53
|
+
},
|
|
54
|
+
version: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
short: "v"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
parsed = parse();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
const code = error.code;
|
|
65
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
+
const option = /'(-[^']+)'/.exec(message)?.[1];
|
|
67
|
+
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && option) fail(`Kiteline doesn't take ${option}. Run ${bold("kiteline --help")} to see what it does.`);
|
|
68
|
+
if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE") {
|
|
69
|
+
const name = /--[\w-]+/.exec(message)?.[0] ?? "That option";
|
|
70
|
+
fail(message.includes("argument missing") ? `${name} needs a value after it, like ${name === "--port" ? "--port 4546" : `${name} <value>`}.` : `${name} doesn't take a value.`);
|
|
71
|
+
}
|
|
72
|
+
fail(`${message}. Run ${bold("kiteline --help")} to see what it takes.`);
|
|
73
|
+
}
|
|
74
|
+
const { values, positionals } = parsed;
|
|
75
|
+
if (values.version) {
|
|
76
|
+
console.log(version);
|
|
77
|
+
process.exit(0);
|
|
78
|
+
}
|
|
79
|
+
if (values.help || positionals[0] === "help") {
|
|
80
|
+
console.log(HELP);
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}
|
|
83
|
+
if (values.port !== void 0) process.env.PORT = values.port;
|
|
84
|
+
if (values.host !== void 0) process.env.HOST = values.host;
|
|
85
|
+
if (values["public-url"] !== void 0) process.env.KITELINE_PUBLIC_URL = values["public-url"];
|
|
86
|
+
startedFromCli();
|
|
87
|
+
const [command, action, ...rest] = positionals;
|
|
88
|
+
if (rest.length) fail(`"${rest.join(" ")}" isn't something Kiteline takes. Run ${bold("kiteline --help")}.`);
|
|
89
|
+
switch (command) {
|
|
90
|
+
case void 0:
|
|
91
|
+
case "start":
|
|
92
|
+
if (action) fail(`"${action}" isn't something Kiteline takes. Run ${bold("kiteline --help")}.`);
|
|
93
|
+
await import("./src-BnClcgTs.mjs");
|
|
94
|
+
break;
|
|
95
|
+
case "pair": {
|
|
96
|
+
const { showPairing } = await import("./show-pairing-u0LfkF9W.mjs");
|
|
97
|
+
await showPairing();
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "service": {
|
|
101
|
+
const { service } = await import("./service-1H4ozSPX.mjs");
|
|
102
|
+
await service(action, { force: values.force === true });
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
default: fail(`Kiteline doesn't know "${command}". Run ${bold("kiteline --help")} to see what it does.`);
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { i as kitelineHome } from "./auth-YhkfTv6K.mjs";
|
|
2
|
+
import { f as readSettings, i as dim, l as SettingsError, n as bold, t as accent } from "./banner-DJdyE8-G.mjs";
|
|
3
|
+
import { t as showPairing } from "./show-pairing-jhFEXWi7.mjs";
|
|
4
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { homedir, userInfo } from "node:os";
|
|
6
|
+
import { delimiter, dirname, join } from "node:path";
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
// src/service.ts
|
|
9
|
+
/**
|
|
10
|
+
* `kiteline service`: Kiteline as a systemd user service, written for this computer, so it starts with
|
|
11
|
+
* it, restarts if it stops, and keeps going after you log out. What the docs once listed as steps.
|
|
12
|
+
*/
|
|
13
|
+
const NAME = process.env.KITELINE_SERVICE_NAME?.trim() || "kiteline";
|
|
14
|
+
const MARK = "# Written by `kiteline service install`. Run it again to change these settings.";
|
|
15
|
+
/** The settings worth keeping in the service, when they're set now. Never the pairing token. */
|
|
16
|
+
const KEPT = [
|
|
17
|
+
"PORT",
|
|
18
|
+
"HOST",
|
|
19
|
+
"KITELINE_PUBLIC_URL",
|
|
20
|
+
"KITELINE_HOME",
|
|
21
|
+
"CLAUDE_PATH",
|
|
22
|
+
"KITELINE_ALLOW_BYPASS",
|
|
23
|
+
"KITELINE_MAX_SESSIONS",
|
|
24
|
+
"KITELINE_IDLE_MINUTES"
|
|
25
|
+
];
|
|
26
|
+
/** A label and a command, lined up with the others. */
|
|
27
|
+
const row = (label, value) => `${dim(label.padEnd(22))}${value}`;
|
|
28
|
+
function say(...lines) {
|
|
29
|
+
console.log([
|
|
30
|
+
"",
|
|
31
|
+
...lines.map((line) => line ? ` ${line}` : ""),
|
|
32
|
+
""
|
|
33
|
+
].join("\n"));
|
|
34
|
+
}
|
|
35
|
+
function fail(...lines) {
|
|
36
|
+
console.error([
|
|
37
|
+
"",
|
|
38
|
+
...lines.map((line, i) => i === 0 ? ` ${accent("◆")} ${line}` : ` ${line}`),
|
|
39
|
+
""
|
|
40
|
+
].join("\n"));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
function systemctl(...args) {
|
|
44
|
+
return spawnSync("systemctl", ["--user", ...args], { encoding: "utf8" });
|
|
45
|
+
}
|
|
46
|
+
function unitFile() {
|
|
47
|
+
const config = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
|
|
48
|
+
return join(config, "systemd", "user", `${NAME}.service`);
|
|
49
|
+
}
|
|
50
|
+
function requireSystemd() {
|
|
51
|
+
if (process.platform !== "linux") fail("Setting Kiteline up to run in the background works on Linux so far.", `Here, keep ${bold("kiteline")} running in a terminal window.`);
|
|
52
|
+
if (systemctl("show-environment").status !== 0) fail("This computer doesn't run systemd's user services, which the background service needs.", `Keep ${bold("kiteline")} running in a terminal window instead.`);
|
|
53
|
+
}
|
|
54
|
+
/** systemd reads % and, in commands, $ as its own; a quoted value keeps spaces. */
|
|
55
|
+
function quote(value, { command = false } = {}) {
|
|
56
|
+
let out = value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("%", "%%");
|
|
57
|
+
if (command) out = out.replaceAll("$", () => "$$");
|
|
58
|
+
return `"${out}"`;
|
|
59
|
+
}
|
|
60
|
+
/** The folders Claude Code's Bash tool should find tools in: the ones this terminal has, less throwaways. */
|
|
61
|
+
function shellPath() {
|
|
62
|
+
const kept = (process.env.PATH ?? "").split(delimiter).filter(Boolean).filter((folder) => !/[\\/]_npx[\\/]|node_modules[\\/]\.bin/.test(folder));
|
|
63
|
+
return [...new Set(kept)].join(delimiter) || "/usr/local/bin:/usr/bin:/bin";
|
|
64
|
+
}
|
|
65
|
+
function unitText(node, script) {
|
|
66
|
+
const settings = KEPT.flatMap((key) => {
|
|
67
|
+
const value = process.env[key]?.trim();
|
|
68
|
+
return value ? [`Environment=${quote(`${key}=${value}`)}`] : [];
|
|
69
|
+
});
|
|
70
|
+
return `${MARK}
|
|
71
|
+
[Unit]
|
|
72
|
+
Description=Kiteline: drive Claude Code from your phone
|
|
73
|
+
Documentation=https://kiteline.seefun.dev/docs/#always-on
|
|
74
|
+
After=network-online.target
|
|
75
|
+
Wants=network-online.target
|
|
76
|
+
|
|
77
|
+
[Service]
|
|
78
|
+
Type=simple
|
|
79
|
+
ExecStart=${quote(node, { command: true })} ${quote(script, { command: true })}
|
|
80
|
+
${settings.length ? `${settings.join("\n")}\n` : ""}# Claude Code's Bash tool runs with this shell and finds tools in these folders, as in your terminal.
|
|
81
|
+
Environment=${quote(`SHELL=${process.env.SHELL || "/bin/sh"}`)}
|
|
82
|
+
Environment=${quote(`PATH=${shellPath()}`)}
|
|
83
|
+
Restart=always
|
|
84
|
+
RestartSec=3
|
|
85
|
+
TimeoutStopSec=15
|
|
86
|
+
|
|
87
|
+
[Install]
|
|
88
|
+
WantedBy=default.target
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
/** Where the service would answer, to check it came up (or that something else holds the port). */
|
|
92
|
+
function localAddress(port, host) {
|
|
93
|
+
return `http://${[
|
|
94
|
+
"0.0.0.0",
|
|
95
|
+
"::",
|
|
96
|
+
"127.0.0.1",
|
|
97
|
+
"localhost",
|
|
98
|
+
""
|
|
99
|
+
].includes(host) ? "127.0.0.1" : host.includes(":") ? `[${host}]` : host}:${port}`;
|
|
100
|
+
}
|
|
101
|
+
async function answers(url) {
|
|
102
|
+
return fetch(`${url}/auth/status`, { signal: AbortSignal.timeout(1500) }).then((r) => r.ok).catch(() => false);
|
|
103
|
+
}
|
|
104
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
105
|
+
async function install({ force }) {
|
|
106
|
+
requireSystemd();
|
|
107
|
+
const script = realpathSync(process.argv[1] ?? "");
|
|
108
|
+
if (/[\\/]_npx[\\/]|[\\/]dlx[\\/]|[\\/]bunx-/.test(script)) fail("This copy of Kiteline came from npx, which may clear it out later, and a service needs one that stays.", "Install it, then set up the service with that copy:", "", ` ${accent("npm install -g kiteline")}`, ` ${accent("kiteline service install")}`);
|
|
109
|
+
let settings;
|
|
110
|
+
try {
|
|
111
|
+
settings = readSettings();
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (!(error instanceof SettingsError)) throw error;
|
|
114
|
+
fail(error.message);
|
|
115
|
+
}
|
|
116
|
+
if (process.env.KITELINE_TOKEN?.trim()) say(dim("KITELINE_TOKEN stays out of the service file, where it could be read; the service makes its own."));
|
|
117
|
+
const file = unitFile();
|
|
118
|
+
const existing = existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
119
|
+
if (existing !== null && !existing.includes(MARK) && !force) fail(`There's already a ${NAME} service, set up by hand:`, dim(file), `Run ${bold("kiteline service install --force")} to replace it; the old file is kept beside it as .bak.`);
|
|
120
|
+
const url = localAddress(settings.port, settings.host);
|
|
121
|
+
if (!(systemctl("is-active", NAME).stdout.trim() === "active") && await answers(url)) fail(`Something already answers on port ${settings.port}, perhaps Kiteline in another terminal.`, `Stop it first (Ctrl C in its window), then run ${bold("kiteline service install")} again.`);
|
|
122
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
123
|
+
if (existing !== null && !existing.includes(MARK)) copyFileSync(file, `${file}.bak`);
|
|
124
|
+
writeFileSync(file, unitText(process.execPath, script));
|
|
125
|
+
const pairingFile = join(kitelineHome(settings.home), "pairing.json");
|
|
126
|
+
const before = existsSync(pairingFile) ? statSync(pairingFile).mtimeMs : 0;
|
|
127
|
+
for (const step of [
|
|
128
|
+
["daemon-reload"],
|
|
129
|
+
["enable", NAME],
|
|
130
|
+
["restart", NAME]
|
|
131
|
+
]) {
|
|
132
|
+
const result = systemctl(...step);
|
|
133
|
+
if (result.status !== 0) fail(`systemctl --user ${step.join(" ")} failed:`, result.stderr.trim());
|
|
134
|
+
}
|
|
135
|
+
const user = userInfo().username;
|
|
136
|
+
const linger = spawnSync("loginctl", [
|
|
137
|
+
"show-user",
|
|
138
|
+
user,
|
|
139
|
+
"--property=Linger",
|
|
140
|
+
"--value"
|
|
141
|
+
], { encoding: "utf8" });
|
|
142
|
+
let lingerNote = "";
|
|
143
|
+
if (linger.stdout.trim() !== "yes") {
|
|
144
|
+
if (spawnSync("loginctl", ["enable-linger", user], { stdio: [
|
|
145
|
+
"inherit",
|
|
146
|
+
"ignore",
|
|
147
|
+
"pipe"
|
|
148
|
+
] }).status !== 0) lingerNote = `To start it at boot, before anyone logs in, run once: ${accent(`sudo loginctl enable-linger ${user}`)}`;
|
|
149
|
+
}
|
|
150
|
+
let up = false;
|
|
151
|
+
for (let i = 0; i < 40 && !up; i++) {
|
|
152
|
+
await sleep(250);
|
|
153
|
+
up = existsSync(pairingFile) && statSync(pairingFile).mtimeMs > before && await answers(url);
|
|
154
|
+
}
|
|
155
|
+
if (!up) fail("The service is set up, but Kiteline didn't come up. See what it said with:", "", ` ${accent(`journalctl --user -u ${NAME} -n 40`)}`);
|
|
156
|
+
await showPairing();
|
|
157
|
+
say(`${bold("Kiteline runs in the background now.")} It starts with your computer and restarts if it stops.`, "", row("See what it's doing", `journalctl --user -u ${NAME} -f`), row("Show this code again", "kiteline pair"), row("Change its settings", "kiteline service install, with the new options"), row("Stop running it", "kiteline service uninstall"), ...lingerNote ? ["", lingerNote] : []);
|
|
158
|
+
}
|
|
159
|
+
function uninstall({ force }) {
|
|
160
|
+
requireSystemd();
|
|
161
|
+
const file = unitFile();
|
|
162
|
+
if (!existsSync(file)) {
|
|
163
|
+
say(`Kiteline isn't set up to run in the background, so there's nothing to take away.`);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (!readFileSync(file, "utf8").includes(MARK) && !force) fail(`The ${NAME} service was set up by hand:`, dim(file), `Run ${bold("kiteline service uninstall --force")} to remove it anyway.`);
|
|
167
|
+
systemctl("disable", "--now", NAME);
|
|
168
|
+
rmSync(file);
|
|
169
|
+
systemctl("daemon-reload");
|
|
170
|
+
say(`${bold("Kiteline no longer runs in the background.")} Paired phones stay paired.`, `Start it in a terminal with ${accent("kiteline")} whenever you like.`);
|
|
171
|
+
}
|
|
172
|
+
function status() {
|
|
173
|
+
requireSystemd();
|
|
174
|
+
const file = unitFile();
|
|
175
|
+
if (!existsSync(file)) {
|
|
176
|
+
say("Kiteline isn't set up to run in the background.", `Set it up with ${accent("kiteline service install")}: it starts with your computer and keeps going.`);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const state = systemctl("is-active", NAME).stdout.trim();
|
|
180
|
+
say(state === "active" ? `${bold("Kiteline is running in the background.")}` : `${bold(`The ${NAME} service is set up, but it's ${state || "not running"}.`)}`, dim(file), "", row("See what it's doing", `journalctl --user -u ${NAME} -f`), row("Show the pairing code", "kiteline pair"), row("Stop running it", "kiteline service uninstall"));
|
|
181
|
+
}
|
|
182
|
+
async function service(action, options) {
|
|
183
|
+
switch (action) {
|
|
184
|
+
case "install": return install(options);
|
|
185
|
+
case "uninstall":
|
|
186
|
+
case "remove": return uninstall(options);
|
|
187
|
+
case void 0:
|
|
188
|
+
case "status": return status();
|
|
189
|
+
default: fail(`"kiteline service ${action}" isn't a thing. Try install, uninstall or status.`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export { service };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { d as loadOwnEnvFile, m as renderSVG, o as printBanner, u as command } from "./banner-DJdyE8-G.mjs";
|
|
2
|
+
import { i as kitelineHome } from "./auth-YhkfTv6K.mjs";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
// src/show-pairing.ts
|
|
6
|
+
/** The pairing code of the Kiteline that's running, read from what it saved when it started. */
|
|
7
|
+
async function showPairing() {
|
|
8
|
+
loadOwnEnvFile();
|
|
9
|
+
const home = kitelineHome(process.env.KITELINE_HOME?.trim() || void 0);
|
|
10
|
+
let saved;
|
|
11
|
+
try {
|
|
12
|
+
saved = JSON.parse(readFileSync(join(home, "pairing.json"), "utf8"));
|
|
13
|
+
} catch {
|
|
14
|
+
console.error(`\n Kiteline hasn't run yet on this computer. Start it with \`${command("start")}\` first.\n`);
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const local = saved.urls[saved.urls.length - 1] ?? "http://localhost:4545";
|
|
19
|
+
const running = await fetch(`${local}/auth/status`, { signal: AbortSignal.timeout(2e3) }).then((r) => r.ok).catch(() => false);
|
|
20
|
+
printBanner({
|
|
21
|
+
url: saved.url,
|
|
22
|
+
urls: saved.urls,
|
|
23
|
+
svg: renderSVG(saved.url)
|
|
24
|
+
}, {
|
|
25
|
+
version: saved.version,
|
|
26
|
+
dev: false
|
|
27
|
+
});
|
|
28
|
+
if (!running) console.log(" Kiteline isn't running right now, so this link won't open until it starts again.\n");
|
|
29
|
+
}
|
|
30
|
+
export { showPairing as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as showPairing } from "./show-pairing-jhFEXWi7.mjs";
|