clawai-relay-client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/install.d.ts +4 -0
- package/dist/commands/install.js +105 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/pair.d.ts +6 -0
- package/dist/commands/pair.js +60 -0
- package/dist/commands/pair.js.map +1 -0
- package/dist/commands/run.d.ts +1 -0
- package/dist/commands/run.js +27 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +56 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/config/config.d.ts +22 -0
- package/dist/config/config.js +53 -0
- package/dist/config/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/relay/gateway-client.d.ts +34 -0
- package/dist/relay/gateway-client.js +268 -0
- package/dist/relay/gateway-client.js.map +1 -0
- package/dist/relay/reconnect.d.ts +14 -0
- package/dist/relay/reconnect.js +27 -0
- package/dist/relay/reconnect.js.map +1 -0
- package/dist/relay/relay-manager.d.ts +19 -0
- package/dist/relay/relay-manager.js +99 -0
- package/dist/relay/relay-manager.js.map +1 -0
- package/dist/relay/session-proxy.d.ts +18 -0
- package/dist/relay/session-proxy.js +75 -0
- package/dist/relay/session-proxy.js.map +1 -0
- package/package.json +26 -0
- package/run-relay.sh +24 -0
- package/src/commands/install.ts +110 -0
- package/src/commands/pair.ts +84 -0
- package/src/commands/run.ts +33 -0
- package/src/commands/status.ts +58 -0
- package/src/config/config.ts +67 -0
- package/src/index.ts +70 -0
- package/src/relay/gateway-client.ts +333 -0
- package/src/relay/reconnect.ts +37 -0
- package/src/relay/relay-manager.ts +146 -0
- package/test-chat.mjs +64 -0
- package/test-direct.mjs +171 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { writeFileSync, mkdirSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
const PLIST_LABEL = "com.rethinkingstudio.clawpilot";
|
|
6
|
+
const PLIST_LABEL_OLD = "com.rethinkingstudio.clawai"; // legacy, cleaned up by stop
|
|
7
|
+
const LAUNCH_AGENTS_DIR = join(homedir(), "Library", "LaunchAgents");
|
|
8
|
+
const PLIST_PATH = join(LAUNCH_AGENTS_DIR, `${PLIST_LABEL}.plist`);
|
|
9
|
+
const PLIST_PATH_OLD = join(LAUNCH_AGENTS_DIR, `${PLIST_LABEL_OLD}.plist`);
|
|
10
|
+
export function installCommand() {
|
|
11
|
+
const nodeBin = process.execPath;
|
|
12
|
+
const scriptPath = process.argv[1];
|
|
13
|
+
// Bundled binary (pkg): execPath === argv[1], use it directly.
|
|
14
|
+
// Node script: need both node binary and script path.
|
|
15
|
+
const programArgs = nodeBin === scriptPath
|
|
16
|
+
? [scriptPath, "run"]
|
|
17
|
+
: [nodeBin, scriptPath, "run"];
|
|
18
|
+
const argsXml = programArgs.map(a => ` <string>${a}</string>`).join("\n");
|
|
19
|
+
const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
20
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
|
21
|
+
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
22
|
+
<plist version="1.0">
|
|
23
|
+
<dict>
|
|
24
|
+
<key>Label</key>
|
|
25
|
+
<string>${PLIST_LABEL}</string>
|
|
26
|
+
<key>ProgramArguments</key>
|
|
27
|
+
<array>
|
|
28
|
+
${argsXml}
|
|
29
|
+
</array>
|
|
30
|
+
<key>RunAtLoad</key>
|
|
31
|
+
<true/>
|
|
32
|
+
<key>KeepAlive</key>
|
|
33
|
+
<true/>
|
|
34
|
+
<key>StandardOutPath</key>
|
|
35
|
+
<string>${join(homedir(), ".clawai", "clawpilot.log")}</string>
|
|
36
|
+
<key>StandardErrorPath</key>
|
|
37
|
+
<string>${join(homedir(), ".clawai", "clawpilot-error.log")}</string>
|
|
38
|
+
</dict>
|
|
39
|
+
</plist>`;
|
|
40
|
+
mkdirSync(LAUNCH_AGENTS_DIR, { recursive: true });
|
|
41
|
+
mkdirSync(join(homedir(), ".clawai"), { recursive: true });
|
|
42
|
+
writeFileSync(PLIST_PATH, plistContent, "utf-8");
|
|
43
|
+
try {
|
|
44
|
+
execSync(`launchctl load -w "${PLIST_PATH}"`, { stdio: "inherit" });
|
|
45
|
+
console.log(`Service installed and started: ${PLIST_LABEL}`);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
console.error("Failed to load launchd service:", err);
|
|
49
|
+
console.log(`Plist written to: ${PLIST_PATH}`);
|
|
50
|
+
console.log(`Run manually: launchctl load -w "${PLIST_PATH}"`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function uninstallCommand() {
|
|
54
|
+
try {
|
|
55
|
+
execSync(`launchctl unload -w "${PLIST_PATH}"`, { stdio: "inherit" });
|
|
56
|
+
console.log(`Service stopped: ${PLIST_LABEL}`);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// May fail if not loaded
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
execSync(`rm -f "${PLIST_PATH}"`, { stdio: "inherit" });
|
|
63
|
+
console.log(`Plist removed: ${PLIST_PATH}`);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
console.error("Failed to remove plist:", err);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Stop relay client and remove from launchd (also cleans up legacy clawai service). */
|
|
70
|
+
export function stopCommand() {
|
|
71
|
+
let stopped = false;
|
|
72
|
+
// Stop + remove new label
|
|
73
|
+
try {
|
|
74
|
+
execSync(`launchctl unload -w "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
75
|
+
console.log(`Stopped: ${PLIST_LABEL}`);
|
|
76
|
+
stopped = true;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Not loaded — that's fine
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
execSync(`rm -f "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
83
|
+
}
|
|
84
|
+
catch { /* ignore */ }
|
|
85
|
+
// Stop + remove legacy clawai label
|
|
86
|
+
try {
|
|
87
|
+
execSync(`launchctl unload -w "${PLIST_PATH_OLD}"`, { stdio: "pipe" });
|
|
88
|
+
console.log(`Stopped: ${PLIST_LABEL_OLD}`);
|
|
89
|
+
stopped = true;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// Not loaded — that's fine
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
execSync(`rm -f "${PLIST_PATH_OLD}"`, { stdio: "pipe" });
|
|
96
|
+
}
|
|
97
|
+
catch { /* ignore */ }
|
|
98
|
+
if (stopped) {
|
|
99
|
+
console.log("Relay client stopped and removed from launchd.");
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
console.log("No running relay service found.");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,WAAW,GAAO,gCAAgC,CAAC;AACzD,MAAM,eAAe,GAAG,6BAA6B,CAAC,CAAG,6BAA6B;AACtF,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AACrE,MAAM,UAAU,GAAO,IAAI,CAAC,iBA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M,CAAC,CAAC,YAAY,CAAC,CAAC;IAExB,oCAAoC;IACpC,IAAI,CAAC;QACH,QAAQ,CAAC,wBAAwB,cAAc,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACvE,OAAO,CAAC,GAAG,CAAC,YAAY,eAAe,EAAE,CAAC,CAAC;QAC3C,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,2BAA2B;IAC7B,CAAC;IACD,IAAI,CAAC;QACH,QAAQ,CAAC,UAAU,cAAc,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAExB,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAChE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { configExists, readConfig, writeConfig } from "../config/config.js";
|
|
2
|
+
import qrcodeTerminal from "qrcode-terminal";
|
|
3
|
+
const DEFAULT_RELAY_SERVER = "https://relay.example.com";
|
|
4
|
+
export async function pairCommand(opts) {
|
|
5
|
+
const relayServerUrl = opts.server ?? DEFAULT_RELAY_SERVER;
|
|
6
|
+
const httpBase = relayServerUrl.replace(/^wss?/, "http");
|
|
7
|
+
let gatewayId;
|
|
8
|
+
let relaySecret;
|
|
9
|
+
let accessCode;
|
|
10
|
+
let displayName;
|
|
11
|
+
if (configExists()) {
|
|
12
|
+
const config = readConfig();
|
|
13
|
+
gatewayId = config.gatewayId;
|
|
14
|
+
relaySecret = config.relaySecret;
|
|
15
|
+
displayName = opts.name ?? config.displayName;
|
|
16
|
+
console.log(`Gateway already registered (id=${gatewayId}). Refreshing access code…`);
|
|
17
|
+
const res = await fetch(`${httpBase}/api/relay/accesscode`, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: { "Content-Type": "application/json" },
|
|
20
|
+
body: JSON.stringify({ gatewayId, relaySecret }),
|
|
21
|
+
});
|
|
22
|
+
if (!res.ok) {
|
|
23
|
+
const body = await res.text();
|
|
24
|
+
throw new Error(`Failed to refresh access code: ${res.status} ${body}`);
|
|
25
|
+
}
|
|
26
|
+
const data = (await res.json());
|
|
27
|
+
accessCode = data.accessCode;
|
|
28
|
+
writeConfig({ ...config, relayServerUrl, displayName });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
displayName = opts.name ?? "My Mac";
|
|
32
|
+
console.log("Registering with relay server…");
|
|
33
|
+
const res = await fetch(`${httpBase}/api/relay/register`, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers: { "Content-Type": "application/json" },
|
|
36
|
+
body: JSON.stringify({ displayName }),
|
|
37
|
+
});
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
const body = await res.text();
|
|
40
|
+
throw new Error(`Registration failed: ${res.status} ${body}`);
|
|
41
|
+
}
|
|
42
|
+
const data = (await res.json());
|
|
43
|
+
gatewayId = data.gatewayId;
|
|
44
|
+
relaySecret = data.relaySecret;
|
|
45
|
+
accessCode = data.accessCode;
|
|
46
|
+
writeConfig({ relayServerUrl, gatewayId, relaySecret, displayName });
|
|
47
|
+
console.log(`Registered! Gateway ID: ${gatewayId}`);
|
|
48
|
+
}
|
|
49
|
+
const qrPayload = JSON.stringify({
|
|
50
|
+
version: 1,
|
|
51
|
+
server: httpBase,
|
|
52
|
+
gatewayId,
|
|
53
|
+
accessCode,
|
|
54
|
+
displayName,
|
|
55
|
+
});
|
|
56
|
+
console.log("\nScan this QR code with the Clawai iOS app:\n");
|
|
57
|
+
qrcodeTerminal.generate(qrPayload, { small: true });
|
|
58
|
+
console.log("\nAccess code (one-time use):", accessCode);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=pair.js.map
|
|
@@ -0,0 +1 @@
|
|
|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AAC;QACV,MAAM,EAAE,QAAQ;QAChB,SAAS;QACT,UAAU;QACV,WAAW;KACZ,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAC9D,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,UAAU,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCommand(): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { readConfig, readGatewayUrl, readGatewayAuth } from "../config/config.js";
|
|
2
|
+
import { runRelayManager } from "../relay/relay-manager.js";
|
|
3
|
+
import { withReconnect } from "../relay/reconnect.js";
|
|
4
|
+
export async function runCommand() {
|
|
5
|
+
const config = readConfig();
|
|
6
|
+
const gatewayUrl = readGatewayUrl();
|
|
7
|
+
const gatewayAuth = readGatewayAuth(config);
|
|
8
|
+
console.log(`Starting ClawAI relay client…`);
|
|
9
|
+
console.log(` Gateway ID: ${config.gatewayId}`);
|
|
10
|
+
console.log(` Relay Server: ${config.relayServerUrl}`);
|
|
11
|
+
console.log(` Gateway URL: ${gatewayUrl}`);
|
|
12
|
+
await withReconnect(() => runRelayManager({
|
|
13
|
+
relayServerUrl: config.relayServerUrl,
|
|
14
|
+
gatewayId: config.gatewayId,
|
|
15
|
+
relaySecret: config.relaySecret,
|
|
16
|
+
gatewayUrl,
|
|
17
|
+
gatewayToken: gatewayAuth.token,
|
|
18
|
+
gatewayPassword: gatewayAuth.password,
|
|
19
|
+
onConnected: () => console.log("Relay connected."),
|
|
20
|
+
onDisconnected: () => console.log("Relay disconnected. Reconnecting…"),
|
|
21
|
+
}), {
|
|
22
|
+
onRetry: (attempt, delayMs) => {
|
|
23
|
+
console.log(`Retry attempt ${attempt}, waiting ${delayMs}ms…`);
|
|
24
|
+
},
|
|
25
|
+
});
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;YAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,OAAO,aAAa,OAAO,KAAK,CAAC,CAAC;QACjE,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function statusCommand(): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import { configExists, readConfig, readGatewayUrl } from "../config/config.js";
|
|
6
|
+
const PLIST_LABEL = "com.rethinkingstudio.clawpilot";
|
|
7
|
+
const PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
|
|
8
|
+
const LOG_PATH = join(homedir(), ".clawai", "clawpilot.log");
|
|
9
|
+
function isServiceRunning() {
|
|
10
|
+
try {
|
|
11
|
+
execSync(`launchctl list ${PLIST_LABEL}`, { stdio: "pipe" });
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function statusCommand() {
|
|
19
|
+
console.log("── ClawPilot Relay Client Status ──\n");
|
|
20
|
+
// Pairing config
|
|
21
|
+
if (!configExists()) {
|
|
22
|
+
console.log("Config: ✗ Not paired — run 'clawpilot pair' first");
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
try {
|
|
26
|
+
const config = readConfig();
|
|
27
|
+
console.log("Config: ✓ Paired");
|
|
28
|
+
console.log(` Display name : ${config.displayName}`);
|
|
29
|
+
console.log(` Gateway ID : ${config.gatewayId}`);
|
|
30
|
+
console.log(` Relay server : ${config.relayServerUrl}`);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
console.log("Config: ✗ File exists but is corrupted");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Local gateway
|
|
37
|
+
const gatewayUrl = readGatewayUrl();
|
|
38
|
+
console.log(`\nGateway: ${gatewayUrl}`);
|
|
39
|
+
// launchd service
|
|
40
|
+
const plistExists = existsSync(PLIST_PATH);
|
|
41
|
+
const running = isServiceRunning();
|
|
42
|
+
if (!plistExists) {
|
|
43
|
+
console.log("\nService: ✗ Not installed — run 'clawpilot install'");
|
|
44
|
+
}
|
|
45
|
+
else if (running) {
|
|
46
|
+
console.log("\nService: ✓ Running (launchd)");
|
|
47
|
+
console.log(` Log : ${LOG_PATH}`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.log("\nService: ⚠ Installed but not running");
|
|
51
|
+
console.log(` Plist : ${PLIST_PATH}`);
|
|
52
|
+
console.log(" Start : launchctl start " + PLIST_LABEL);
|
|
53
|
+
}
|
|
54
|
+
console.log("");
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,WAAW,GAAG,gCAAgC,CAAC;AACrD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,WAAW,QAAQ,CAAC,CAAC;AACtF,MAAM,QAAQ,GAAK,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAE/D,SAAS,gBAAgB;IACvB,IAAI,CAAC;QACH,QAAQ,CAAC,kBAAkB,WAAW,EAAE,EAAE,E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AAQ,EAAE,CAAC,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,aAAa,UAAU,EAAE,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,WAAW,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ClawaiConfig {
|
|
2
|
+
relayServerUrl: string;
|
|
3
|
+
gatewayId: string;
|
|
4
|
+
relaySecret: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
/** Shared token for the local OpenClaw Gateway (gateway.auth.token in openclaw config). */
|
|
7
|
+
gatewayToken?: string;
|
|
8
|
+
/** Password for the local OpenClaw Gateway (used when auth mode is "password"). */
|
|
9
|
+
gatewayPassword?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function configExists(): boolean;
|
|
12
|
+
export declare function readConfig(): ClawaiConfig;
|
|
13
|
+
export declare function writeConfig(config: ClawaiConfig): void;
|
|
14
|
+
export declare function readGatewayUrl(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Reads the gateway token or password from the clawai config first,
|
|
17
|
+
* then falls back to reading directly from the OpenClaw config file.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readGatewayAuth(cfg: ClawaiConfig): {
|
|
20
|
+
token?: string;
|
|
21
|
+
password?: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
const CONFIG_DIR = join(homedir(), ".clawai");
|
|
5
|
+
const CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
6
|
+
const OPENCLAW_CONFIG_PATH = join(homedir(), ".openclaw", "openclaw.json");
|
|
7
|
+
export function configExists() {
|
|
8
|
+
return existsSync(CONFIG_PATH);
|
|
9
|
+
}
|
|
10
|
+
export function readConfig() {
|
|
11
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
12
|
+
throw new Error(`Config not found at ${CONFIG_PATH}. Run 'clawai pair' first.`);
|
|
13
|
+
}
|
|
14
|
+
const raw = readFileSync(CONFIG_PATH, "utf-8");
|
|
15
|
+
return JSON.parse(raw);
|
|
16
|
+
}
|
|
17
|
+
export function writeConfig(config) {
|
|
18
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
19
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
20
|
+
}
|
|
21
|
+
export function readGatewayUrl() {
|
|
22
|
+
try {
|
|
23
|
+
const raw = readFileSync(OPENCLAW_CONFIG_PATH, "utf-8");
|
|
24
|
+
const json = JSON.parse(raw);
|
|
25
|
+
const port = json?.gateway?.port ?? 18789;
|
|
26
|
+
return `ws://localhost:${port}`;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return "ws://localhost:18789";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reads the gateway token or password from the clawai config first,
|
|
34
|
+
* then falls back to reading directly from the OpenClaw config file.
|
|
35
|
+
*/
|
|
36
|
+
export function readGatewayAuth(cfg) {
|
|
37
|
+
if (cfg.gatewayToken || cfg.gatewayPassword) {
|
|
38
|
+
return { token: cfg.gatewayToken, password: cfg.gatewayPassword };
|
|
39
|
+
}
|
|
40
|
+
// Try to read the token from OpenClaw's own config
|
|
41
|
+
try {
|
|
42
|
+
const raw = readFileSync(OPENCLAW_CONFIG_PATH, "utf-8");
|
|
43
|
+
const json = JSON.parse(raw);
|
|
44
|
+
return {
|
|
45
|
+
token: json?.gateway?.token ?? json?.gateway?.auth?.token ?? undefined,
|
|
46
|
+
password: json?.gateway?.password ?? json?.gateway?.auth?.password ?? undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AACpD,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;AAa3E,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,uBAAuB,WAAW,4BAA4B,CAAC,CAAC;IAClF,CAAC;IACD,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAiB,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAoB;IAC9C,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAoC,CAAC;QAChE,MAAM,IAAI,GAAG,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,KAAK,CAAC;QAC1C,OAAO,kBAAkB,IAAI,EAAE,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,sBAAsB,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAiB;IAC/C,IAAI,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,eAAe,EAAE,CAAC;QAC5C,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,GAAG,CAAC,eAAe,EAAE,CAAC;IACpE,CAAC;IACD,mDAAmD;IACnD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAsG,CAAC;QAClI,OAAO;YACL,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,IAAI,SAAS;YACtE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,SAAS;SAChF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { pairCommand } from "./commands/pair.js";
|
|
4
|
+
import { runCommand } from "./commands/run.js";
|
|
5
|
+
import { installCommand, uninstallCommand, stopCommand } from "./commands/install.js";
|
|
6
|
+
import { statusCommand } from "./commands/status.js";
|
|
7
|
+
const program = new Command();
|
|
8
|
+
program
|
|
9
|
+
.name("clawpilot")
|
|
10
|
+
.description("ClawPilot relay client — connects Mac mini to the cloud relay server")
|
|
11
|
+
.version("1.0.0");
|
|
12
|
+
program
|
|
13
|
+
.command("pair")
|
|
14
|
+
.description("Register with relay server and display QR code for iOS pairing")
|
|
15
|
+
.option("-s, --server <url>", "Relay server URL", "https://relay.example.com")
|
|
16
|
+
.option("-n, --name <name>", "Display name for this Mac", "My Mac")
|
|
17
|
+
.action(async (opts) => {
|
|
18
|
+
try {
|
|
19
|
+
await pairCommand(opts);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
console.error("Error:", err instanceof Error ? err.message : err);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
program
|
|
27
|
+
.command("run")
|
|
28
|
+
.description("Start the relay client (connects to cloud relay server)")
|
|
29
|
+
.action(async () => {
|
|
30
|
+
try {
|
|
31
|
+
await runCommand();
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
console.error("Error:", err instanceof Error ? err.message : err);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
program
|
|
39
|
+
.command("stop")
|
|
40
|
+
.description("Stop relay client and remove launchd service")
|
|
41
|
+
.action(() => {
|
|
42
|
+
stopCommand();
|
|
43
|
+
});
|
|
44
|
+
program
|
|
45
|
+
.command("status")
|
|
46
|
+
.description("Show pairing config, gateway URL, and launchd service status")
|
|
47
|
+
.action(() => {
|
|
48
|
+
statusCommand();
|
|
49
|
+
});
|
|
50
|
+
program
|
|
51
|
+
.command("install")
|
|
52
|
+
.description("Register as a launchd service (auto-start on login)")
|
|
53
|
+
.action(() => {
|
|
54
|
+
installCommand();
|
|
55
|
+
});
|
|
56
|
+
program
|
|
57
|
+
.command("uninstall")
|
|
58
|
+
.description("Remove launchd service")
|
|
59
|
+
.action(() => {
|
|
60
|
+
uninstallCommand();
|
|
61
|
+
});
|
|
62
|
+
program.parse(process.argv);
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,sEAAsE,CAAC;KACnF,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,gEAAgE,CAAC;KAC7E,MAAM,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,2BAA2B,CAAC;KAC7E,MAAM,CAAC,mBAAmB,EAAE,2BAA2B,EAAE,QAAQ,CAAC;KAClE,MAAM,CAAC,KAAK,EAAE,IAAsC,EAAE,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,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4
|
+
password?: string;
|
|
5
|
+
onConnected: () => void;
|
|
6
|
+
onEvent: (eventName: string, payload: unknown) => void;
|
|
7
|
+
onDisconnected: (reason: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class OpenClawGatewayClient {
|
|
10
|
+
private readonly opts;
|
|
11
|
+
private ws;
|
|
12
|
+
private pending;
|
|
13
|
+
private backoffMs;
|
|
14
|
+
private stopped;
|
|
15
|
+
private connectNonce;
|
|
16
|
+
private connectSent;
|
|
17
|
+
private storedDeviceToken;
|
|
18
|
+
private connectTimer;
|
|
19
|
+
private tickTimer;
|
|
20
|
+
private lastTick;
|
|
21
|
+
private tickIntervalMs;
|
|
22
|
+
private readonly identity;
|
|
23
|
+
constructor(opts: GatewayClientOptions);
|
|
24
|
+
start(): void;
|
|
25
|
+
stop(): void;
|
|
26
|
+
send(method: string, params?: unknown): void;
|
|
27
|
+
request<T = unknown>(method: string, params?: unknown): Promise<T>;
|
|
28
|
+
private sendConnect;
|
|
29
|
+
private handleMessage;
|
|
30
|
+
private startTickWatch;
|
|
31
|
+
private scheduleReconnect;
|
|
32
|
+
private teardown;
|
|
33
|
+
private flushPending;
|
|
34
|
+
}
|