@rethinkingstudio/clawpilot 1.1.10 → 1.1.11
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/README.md +38 -8
- package/dist/commands/install.d.ts +0 -2
- package/dist/commands/install.js +66 -97
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/pair.d.ts +1 -0
- package/dist/commands/pair.js +12 -3
- package/dist/commands/pair.js.map +1 -1
- package/dist/commands/status.js +19 -29
- package/dist/commands/status.js.map +1 -1
- package/dist/i18n/index.js +30 -24
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/platform/service-manager.d.ts +25 -0
- package/dist/platform/service-manager.js +426 -0
- package/dist/platform/service-manager.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/install.ts +73 -100
- package/src/commands/pair.ts +12 -3
- package/src/commands/status.ts +20 -30
- package/src/i18n/index.ts +30 -24
- package/src/index.ts +10 -10
- package/src/platform/service-manager.ts +464 -0
package/src/commands/install.ts
CHANGED
|
@@ -1,135 +1,97 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync, unlinkSync } from "fs";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { homedir } from "os";
|
|
4
|
-
import { execSync } from "child_process";
|
|
5
4
|
import { t } from "../i18n/index.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
import {
|
|
6
|
+
getServicePlatform,
|
|
7
|
+
getServiceStatus,
|
|
8
|
+
installService,
|
|
9
|
+
restartService,
|
|
10
|
+
stopService,
|
|
11
|
+
uninstallService,
|
|
12
|
+
servicePaths,
|
|
13
|
+
} from "../platform/service-manager.js";
|
|
12
14
|
|
|
13
15
|
export function isInstalled(): boolean {
|
|
14
|
-
|
|
16
|
+
const platform = getServicePlatform();
|
|
17
|
+
if (platform === "macos") return existsSync(servicePaths.macPlistPath);
|
|
18
|
+
if (platform === "linux") {
|
|
19
|
+
return existsSync(servicePaths.linuxServicePath) || existsSync(servicePaths.linuxNohupStartScriptPath);
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
export function installCommand(): void {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
? [scriptPath, "run"]
|
|
25
|
-
: [nodeBin, scriptPath, "run"];
|
|
26
|
-
|
|
27
|
-
const argsXml = programArgs.map(a => ` <string>${a}</string>`).join("\n");
|
|
28
|
-
|
|
29
|
-
const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
30
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
|
31
|
-
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
32
|
-
<plist version="1.0">
|
|
33
|
-
<dict>
|
|
34
|
-
<key>Label</key>
|
|
35
|
-
<string>${PLIST_LABEL}</string>
|
|
36
|
-
<key>ProgramArguments</key>
|
|
37
|
-
<array>
|
|
38
|
-
${argsXml}
|
|
39
|
-
</array>
|
|
40
|
-
<key>RunAtLoad</key>
|
|
41
|
-
<true/>
|
|
42
|
-
<key>KeepAlive</key>
|
|
43
|
-
<true/>
|
|
44
|
-
<key>StandardOutPath</key>
|
|
45
|
-
<string>${join(homedir(), ".clawai", "clawpilot.log")}</string>
|
|
46
|
-
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${join(homedir(), ".clawai", "clawpilot-error.log")}</string>
|
|
48
|
-
</dict>
|
|
49
|
-
</plist>`;
|
|
50
|
-
|
|
51
|
-
mkdirSync(LAUNCH_AGENTS_DIR, { recursive: true });
|
|
52
|
-
mkdirSync(join(homedir(), ".clawai"), { recursive: true });
|
|
53
|
-
|
|
54
|
-
// Unload existing service first (ignore errors if not loaded)
|
|
55
|
-
try {
|
|
56
|
-
execSync(`launchctl unload -w "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
57
|
-
} catch { /* not loaded, that's fine */ }
|
|
25
|
+
const platform = getServicePlatform();
|
|
26
|
+
if (platform === "unsupported") {
|
|
27
|
+
console.log(t("install.unsupported", process.platform));
|
|
28
|
+
console.log(t("install.runForeground"));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
58
31
|
|
|
59
|
-
|
|
32
|
+
const started = installService();
|
|
33
|
+
if (started) {
|
|
34
|
+
const service = getServiceStatus();
|
|
35
|
+
console.log(t("install.serviceStarted", service.manager));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
60
38
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
console.log(t("install.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.log(t("install.
|
|
67
|
-
console.log(t("install.
|
|
39
|
+
console.log(t("install.installFailed", platformName(platform)));
|
|
40
|
+
if (platform === "macos") {
|
|
41
|
+
console.log(t("install.serviceFileWritten", servicePaths.macPlistPath));
|
|
42
|
+
console.log(t("install.startManually", `launchctl load -w "${servicePaths.macPlistPath}"`));
|
|
43
|
+
} else if (platform === "linux") {
|
|
44
|
+
console.log(t("install.serviceFileWritten", servicePaths.linuxServicePath));
|
|
45
|
+
console.log(t("install.startManually", "systemctl --user daemon-reload && systemctl --user enable --now clawpilot.service"));
|
|
46
|
+
console.log(t("install.startManually", `bash "${servicePaths.linuxNohupStartScriptPath}"`));
|
|
68
47
|
}
|
|
69
48
|
}
|
|
70
49
|
|
|
71
50
|
export function restartCommand(): void {
|
|
72
51
|
console.log(t("install.restarting"));
|
|
73
|
-
|
|
52
|
+
const platform = getServicePlatform();
|
|
53
|
+
if (platform === "unsupported") {
|
|
54
|
+
console.log(t("install.unsupported", process.platform));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (restartService()) {
|
|
58
|
+
console.log(t("install.serviceRestarted", platformName(platform)));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
console.log(t("install.restartFailed", platformName(platform)));
|
|
74
62
|
}
|
|
75
63
|
|
|
76
64
|
export function uninstallCommand(): void {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
console.log(t("install.
|
|
80
|
-
|
|
81
|
-
// May fail if not loaded
|
|
65
|
+
const platform = getServicePlatform();
|
|
66
|
+
if (platform === "unsupported") {
|
|
67
|
+
console.log(t("install.unsupported", process.platform));
|
|
68
|
+
return;
|
|
82
69
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
console.error(t("install.removePlistFailed"), err);
|
|
70
|
+
const changed = uninstallService();
|
|
71
|
+
if (changed) {
|
|
72
|
+
console.log(t("install.stoppedAndRemoved", platformName(platform)));
|
|
73
|
+
} else {
|
|
74
|
+
console.log(t("install.noService"));
|
|
89
75
|
}
|
|
90
76
|
}
|
|
91
77
|
|
|
92
|
-
/** Stop relay client and remove from launchd (also cleans up legacy clawai service). */
|
|
93
78
|
export function stopCommand(): void {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
execSync(`launchctl unload -w "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
99
|
-
console.log(t("install.stopped", PLIST_LABEL));
|
|
100
|
-
stopped = true;
|
|
101
|
-
} catch {
|
|
102
|
-
// Not loaded — that's fine
|
|
103
|
-
}
|
|
104
|
-
try {
|
|
105
|
-
execSync(`rm -f "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
106
|
-
} catch { /* ignore */ }
|
|
107
|
-
|
|
108
|
-
// Stop + remove legacy clawai label
|
|
109
|
-
try {
|
|
110
|
-
execSync(`launchctl unload -w "${PLIST_PATH_OLD}"`, { stdio: "pipe" });
|
|
111
|
-
console.log(t("install.stopped", PLIST_LABEL_OLD));
|
|
112
|
-
stopped = true;
|
|
113
|
-
} catch {
|
|
114
|
-
// Not loaded — that's fine
|
|
79
|
+
const platform = getServicePlatform();
|
|
80
|
+
if (platform === "unsupported") {
|
|
81
|
+
console.log(t("install.unsupported", process.platform));
|
|
82
|
+
return;
|
|
115
83
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (stopped) {
|
|
121
|
-
console.log(t("install.stoppedAndRemoved"));
|
|
84
|
+
const changed = stopService();
|
|
85
|
+
if (changed) {
|
|
86
|
+
console.log(t("install.stopped", platformName(platform)));
|
|
122
87
|
} else {
|
|
123
88
|
console.log(t("install.noService"));
|
|
124
89
|
}
|
|
125
90
|
}
|
|
126
91
|
|
|
127
|
-
/** Clear saved config and stop the service — use this when switching servers or on auth errors. */
|
|
128
92
|
export function resetCommand(): void {
|
|
129
|
-
// Stop the service first
|
|
130
93
|
stopCommand();
|
|
131
94
|
|
|
132
|
-
// Remove config file
|
|
133
95
|
const configPath = join(homedir(), ".clawai", "config.json");
|
|
134
96
|
if (existsSync(configPath)) {
|
|
135
97
|
try {
|
|
@@ -144,3 +106,14 @@ export function resetCommand(): void {
|
|
|
144
106
|
|
|
145
107
|
console.log(t("install.resetComplete"));
|
|
146
108
|
}
|
|
109
|
+
|
|
110
|
+
function platformName(platform: ReturnType<typeof getServicePlatform>): string {
|
|
111
|
+
switch (platform) {
|
|
112
|
+
case "macos":
|
|
113
|
+
return "launchd";
|
|
114
|
+
case "linux":
|
|
115
|
+
return "systemd/nohup";
|
|
116
|
+
default:
|
|
117
|
+
return process.platform;
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/commands/pair.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { hostname } from "os";
|
|
2
2
|
import { execSync } from "child_process";
|
|
3
|
+
import { getServicePlatform } from "../platform/service-manager.js";
|
|
3
4
|
|
|
4
5
|
function sanitizeDisplayName(name: string): string {
|
|
5
6
|
// Replace smart quotes and other problematic characters with regular ones
|
|
@@ -11,6 +12,9 @@ function sanitizeDisplayName(name: string): string {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
function getDisplayName(): string {
|
|
15
|
+
if (getServicePlatform() !== "macos") {
|
|
16
|
+
return hostname();
|
|
17
|
+
}
|
|
14
18
|
try {
|
|
15
19
|
const raw = execSync("scutil --get ComputerName", { encoding: "utf8" }).trim();
|
|
16
20
|
return sanitizeDisplayName(raw);
|
|
@@ -28,6 +32,7 @@ const DEFAULT_RELAY_SERVER = "https://clawpilot.codeaddict.cn";
|
|
|
28
32
|
interface PairOptions {
|
|
29
33
|
server?: string;
|
|
30
34
|
name?: string;
|
|
35
|
+
codeOnly?: boolean;
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
export async function pairCommand(opts: PairOptions): Promise<void> {
|
|
@@ -103,9 +108,13 @@ export async function pairCommand(opts: PairOptions): Promise<void> {
|
|
|
103
108
|
displayName,
|
|
104
109
|
});
|
|
105
110
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
if (opts.codeOnly) {
|
|
112
|
+
console.log(accessCode);
|
|
113
|
+
} else {
|
|
114
|
+
console.log(t("pair.scanQR"));
|
|
115
|
+
qrcodeTerminal.generate(qrPayload, { small: true });
|
|
116
|
+
console.log(t("pair.accessCode", accessCode));
|
|
117
|
+
}
|
|
109
118
|
|
|
110
119
|
console.log(t("pair.installingService"));
|
|
111
120
|
installCommand();
|
package/src/commands/status.ts
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
import { existsSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { homedir } from "os";
|
|
4
|
-
import { execSync } from "child_process";
|
|
5
1
|
import { configExists, readConfig, readGatewayUrl } from "../config/config.js";
|
|
6
2
|
import { t } from "../i18n/index.js";
|
|
7
|
-
|
|
8
|
-
const PLIST_LABEL = "com.rethinkingstudio.clawpilot";
|
|
9
|
-
const PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
|
|
10
|
-
const LOG_PATH = join(homedir(), ".clawai", "clawpilot.log");
|
|
11
|
-
|
|
12
|
-
function isServiceRunning(): boolean {
|
|
13
|
-
try {
|
|
14
|
-
execSync(`launchctl list ${PLIST_LABEL}`, { stdio: "pipe" });
|
|
15
|
-
return true;
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
3
|
+
import { getServiceStatus } from "../platform/service-manager.js";
|
|
20
4
|
|
|
21
5
|
export function statusCommand(): void {
|
|
22
6
|
console.log(t("status.title"));
|
|
23
7
|
|
|
24
|
-
// Pairing config
|
|
25
8
|
if (!configExists()) {
|
|
26
9
|
console.log(t("status.notPaired"));
|
|
27
10
|
} else {
|
|
@@ -36,23 +19,30 @@ export function statusCommand(): void {
|
|
|
36
19
|
}
|
|
37
20
|
}
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
const gatewayUrl = readGatewayUrl();
|
|
41
|
-
console.log(t("status.gateway", gatewayUrl));
|
|
22
|
+
console.log(t("status.gateway", readGatewayUrl()));
|
|
42
23
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
const service = getServiceStatus();
|
|
25
|
+
if (service.platform === "unsupported") {
|
|
26
|
+
console.log(t("status.serviceUnsupported", process.platform));
|
|
27
|
+
console.log("");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log(t("status.servicePlatform", service.manager));
|
|
46
32
|
|
|
47
|
-
if (!
|
|
33
|
+
if (!service.installed) {
|
|
48
34
|
console.log(t("status.serviceNotInstalled"));
|
|
49
|
-
} else if (running) {
|
|
50
|
-
console.log(t("status.serviceRunning"));
|
|
51
|
-
console.log(t("status.serviceLog",
|
|
35
|
+
} else if (service.running) {
|
|
36
|
+
console.log(t("status.serviceRunning", service.manager));
|
|
37
|
+
console.log(t("status.serviceLog", service.logPath));
|
|
52
38
|
} else {
|
|
53
39
|
console.log(t("status.serviceNotRunning"));
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
if (service.servicePath) {
|
|
41
|
+
console.log(t("status.serviceFile", service.servicePath));
|
|
42
|
+
}
|
|
43
|
+
if (service.startHint) {
|
|
44
|
+
console.log(t("status.serviceStart", service.startHint));
|
|
45
|
+
}
|
|
56
46
|
}
|
|
57
47
|
|
|
58
48
|
console.log("");
|
package/src/i18n/index.ts
CHANGED
|
@@ -24,17 +24,18 @@ const en: Record<string, MsgValue> = {
|
|
|
24
24
|
"run.retry": (attempt, delay) => `Retry attempt ${attempt}, waiting ${delay}ms…`,
|
|
25
25
|
|
|
26
26
|
// install
|
|
27
|
-
"install.serviceStarted": (
|
|
28
|
-
"install.
|
|
29
|
-
"install.
|
|
30
|
-
"install.
|
|
27
|
+
"install.serviceStarted": (manager) => `Service installed and started via ${manager}.`,
|
|
28
|
+
"install.installFailed": (manager) => `Failed to activate service via ${manager}.`,
|
|
29
|
+
"install.serviceFileWritten": (path) => `Service file written to: ${path}`,
|
|
30
|
+
"install.startManually": (command) => `Start manually: ${command}`,
|
|
31
31
|
"install.restarting": "Restarting relay service…",
|
|
32
|
-
"install.
|
|
33
|
-
"install.
|
|
34
|
-
"install.
|
|
35
|
-
"install.
|
|
36
|
-
"install.stoppedAndRemoved": "Relay client stopped and removed from launchd.",
|
|
32
|
+
"install.serviceRestarted": (manager) => `Service restarted via ${manager}.`,
|
|
33
|
+
"install.restartFailed": (manager) => `Failed to restart service via ${manager}.`,
|
|
34
|
+
"install.stopped": (manager) => `Relay client stopped via ${manager}.`,
|
|
35
|
+
"install.stoppedAndRemoved": (manager) => `Relay client stopped and removed from ${manager}.`,
|
|
37
36
|
"install.noService": "No running relay service found.",
|
|
37
|
+
"install.unsupported": (platform) => `Background service management is not supported on platform: ${platform}`,
|
|
38
|
+
"install.runForeground": "Run `clawpilot run` manually in the foreground instead.",
|
|
38
39
|
"install.configRemoved": (path) => `Config removed: ${path}`,
|
|
39
40
|
"install.removeConfigFailed": "Failed to remove config:",
|
|
40
41
|
"install.noConfig": "No config file found.",
|
|
@@ -49,12 +50,14 @@ const en: Record<string, MsgValue> = {
|
|
|
49
50
|
"status.relayServer": (url) => ` Relay server : ${url}`,
|
|
50
51
|
"status.configCorrupted": "Config: ✗ File exists but is corrupted",
|
|
51
52
|
"status.gateway": (url) => `\nGateway: ${url}`,
|
|
53
|
+
"status.servicePlatform": (manager) => `\nService Manager: ${manager}`,
|
|
52
54
|
"status.serviceNotInstalled": "\nService: ✗ Not installed — run 'clawpilot install'",
|
|
53
|
-
"status.serviceRunning":
|
|
55
|
+
"status.serviceRunning": (manager) => `\nService: ✓ Running (${manager})`,
|
|
54
56
|
"status.serviceLog": (path) => ` Log : ${path}`,
|
|
55
57
|
"status.serviceNotRunning": "\nService: ⚠ Installed but not running",
|
|
56
|
-
"status.
|
|
57
|
-
"status.serviceStart": (
|
|
58
|
+
"status.serviceFile": (path) => ` Service file : ${path}`,
|
|
59
|
+
"status.serviceStart": (command) => ` Start : ${command}`,
|
|
60
|
+
"status.serviceUnsupported": (platform) => `\nService: - Unsupported on platform ${platform}`,
|
|
58
61
|
|
|
59
62
|
// set-token
|
|
60
63
|
"setToken.noPairing": "No pairing config found. Run 'clawpilot pair' first.",
|
|
@@ -91,17 +94,18 @@ const zh: Record<string, MsgValue> = {
|
|
|
91
94
|
"run.retry": (attempt, delay) => `第 ${attempt} 次重试,等待 ${delay}ms…`,
|
|
92
95
|
|
|
93
96
|
// install
|
|
94
|
-
"install.serviceStarted": (
|
|
95
|
-
"install.
|
|
96
|
-
"install.
|
|
97
|
-
"install.
|
|
97
|
+
"install.serviceStarted": (manager) => `服务已通过 ${manager} 安装并启动。`,
|
|
98
|
+
"install.installFailed": (manager) => `通过 ${manager} 启动服务失败。`,
|
|
99
|
+
"install.serviceFileWritten": (path) => `服务文件已写入:${path}`,
|
|
100
|
+
"install.startManually": (command) => `请手动运行:${command}`,
|
|
98
101
|
"install.restarting": "正在重启中继服务…",
|
|
99
|
-
"install.
|
|
100
|
-
"install.
|
|
101
|
-
"install.
|
|
102
|
-
"install.
|
|
103
|
-
"install.stoppedAndRemoved": "中继客户端已停止并从 launchd 移除。",
|
|
102
|
+
"install.serviceRestarted": (manager) => `服务已通过 ${manager} 重启。`,
|
|
103
|
+
"install.restartFailed": (manager) => `通过 ${manager} 重启服务失败。`,
|
|
104
|
+
"install.stopped": (manager) => `已通过 ${manager} 停止中继客户端。`,
|
|
105
|
+
"install.stoppedAndRemoved": (manager) => `中继客户端已停止并从 ${manager} 移除。`,
|
|
104
106
|
"install.noService": "未找到正在运行的中继服务。",
|
|
107
|
+
"install.unsupported": (platform) => `当前平台 ${platform} 暂不支持后台服务管理`,
|
|
108
|
+
"install.runForeground": "请改用 `clawpilot run` 前台运行。",
|
|
105
109
|
"install.configRemoved": (path) => `配置文件已删除:${path}`,
|
|
106
110
|
"install.removeConfigFailed": "删除配置文件失败:",
|
|
107
111
|
"install.noConfig": "未找到配置文件。",
|
|
@@ -116,12 +120,14 @@ const zh: Record<string, MsgValue> = {
|
|
|
116
120
|
"status.relayServer": (url) => ` 中继服务器:${url}`,
|
|
117
121
|
"status.configCorrupted": "配置:✗ 文件存在但已损坏",
|
|
118
122
|
"status.gateway": (url) => `\n网关地址:${url}`,
|
|
123
|
+
"status.servicePlatform": (manager) => `\n服务管理器:${manager}`,
|
|
119
124
|
"status.serviceNotInstalled": "\n服务:✗ 未安装 — 请运行 'clawpilot install'",
|
|
120
|
-
"status.serviceRunning":
|
|
125
|
+
"status.serviceRunning": (manager) => `\n服务:✓ 运行中 (${manager})`,
|
|
121
126
|
"status.serviceLog": (path) => ` 日志:${path}`,
|
|
122
127
|
"status.serviceNotRunning": "\n服务:⚠ 已安装但未运行",
|
|
123
|
-
"status.
|
|
124
|
-
"status.serviceStart": (
|
|
128
|
+
"status.serviceFile": (path) => ` 服务文件:${path}`,
|
|
129
|
+
"status.serviceStart": (command) => ` 启动命令:${command}`,
|
|
130
|
+
"status.serviceUnsupported": (platform) => `\n服务:- 平台 ${platform} 暂不支持`,
|
|
125
131
|
|
|
126
132
|
// set-token
|
|
127
133
|
"setToken.noPairing": "未找到配对配置,请先运行 'clawpilot pair'。",
|
package/src/index.ts
CHANGED
|
@@ -14,15 +14,16 @@ const program = new Command();
|
|
|
14
14
|
|
|
15
15
|
program
|
|
16
16
|
.name("clawpilot")
|
|
17
|
-
.description("ClawPilot relay client — connects
|
|
17
|
+
.description("ClawPilot relay client — connects OpenClaw gateway hosts to the cloud relay server")
|
|
18
18
|
.version(version);
|
|
19
19
|
|
|
20
20
|
program
|
|
21
21
|
.command("pair")
|
|
22
22
|
.description("Register with relay server and display QR code for iOS pairing")
|
|
23
23
|
.option("-s, --server <url>", "Relay server URL", "https://clawpilot.codeaddict.cn")
|
|
24
|
-
.option("-n, --name <name>", "Display name for this
|
|
25
|
-
.
|
|
24
|
+
.option("-n, --name <name>", "Display name for this host")
|
|
25
|
+
.option("--code-only", "Print only the access code and skip QR code output", false)
|
|
26
|
+
.action(async (opts: { server: string; name: string; codeOnly?: boolean }) => {
|
|
26
27
|
try {
|
|
27
28
|
await pairCommand(opts);
|
|
28
29
|
} catch (err) {
|
|
@@ -33,7 +34,7 @@ program
|
|
|
33
34
|
|
|
34
35
|
program
|
|
35
36
|
.command("run")
|
|
36
|
-
.description("Run relay client in foreground (used by
|
|
37
|
+
.description("Run relay client in foreground (used by the background service manager)")
|
|
37
38
|
.action(async () => {
|
|
38
39
|
try {
|
|
39
40
|
await runCommand();
|
|
@@ -45,35 +46,35 @@ program
|
|
|
45
46
|
|
|
46
47
|
program
|
|
47
48
|
.command("stop")
|
|
48
|
-
.description("Stop relay client
|
|
49
|
+
.description("Stop relay client background service")
|
|
49
50
|
.action(() => {
|
|
50
51
|
stopCommand();
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
program
|
|
54
55
|
.command("status")
|
|
55
|
-
.description("Show pairing config, gateway URL, and
|
|
56
|
+
.description("Show pairing config, gateway URL, and background service status")
|
|
56
57
|
.action(() => {
|
|
57
58
|
statusCommand();
|
|
58
59
|
});
|
|
59
60
|
|
|
60
61
|
program
|
|
61
62
|
.command("install")
|
|
62
|
-
.description("Register as a
|
|
63
|
+
.description("Register as a background service (launchd on macOS, systemd --user on Linux)")
|
|
63
64
|
.action(() => {
|
|
64
65
|
installCommand();
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
program
|
|
68
69
|
.command("restart")
|
|
69
|
-
.description("Restart the relay
|
|
70
|
+
.description("Restart the relay background service")
|
|
70
71
|
.action(() => {
|
|
71
72
|
restartCommand();
|
|
72
73
|
});
|
|
73
74
|
|
|
74
75
|
program
|
|
75
76
|
.command("uninstall")
|
|
76
|
-
.description("Remove
|
|
77
|
+
.description("Remove background service")
|
|
77
78
|
.action(() => {
|
|
78
79
|
uninstallCommand();
|
|
79
80
|
});
|
|
@@ -98,4 +99,3 @@ program
|
|
|
98
99
|
});
|
|
99
100
|
|
|
100
101
|
program.parse(process.argv);
|
|
101
|
-
|