@rethinkingstudio/clawpilot 1.0.0 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rethinkingstudio/clawpilot",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "ClawAI relay client for Mac mini",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,4 @@
1
- import { writeFileSync, mkdirSync } from "fs";
1
+ import { writeFileSync, mkdirSync, existsSync } from "fs";
2
2
  import { join } from "path";
3
3
  import { homedir } from "os";
4
4
  import { execSync } from "child_process";
@@ -9,6 +9,10 @@ const LAUNCH_AGENTS_DIR = join(homedir(), "Library", "LaunchAgents");
9
9
  const PLIST_PATH = join(LAUNCH_AGENTS_DIR, `${PLIST_LABEL}.plist`);
10
10
  const PLIST_PATH_OLD = join(LAUNCH_AGENTS_DIR, `${PLIST_LABEL_OLD}.plist`);
11
11
 
12
+ export function isInstalled(): boolean {
13
+ return existsSync(PLIST_PATH);
14
+ }
15
+
12
16
  export function installCommand(): void {
13
17
  const nodeBin = process.execPath;
14
18
  const scriptPath = process.argv[1];
@@ -1,4 +1,15 @@
1
+ import { hostname } from "os";
2
+ import { execSync } from "child_process";
3
+
4
+ function getDisplayName(): string {
5
+ try {
6
+ return execSync("scutil --get ComputerName", { encoding: "utf8" }).trim();
7
+ } catch {
8
+ return hostname();
9
+ }
10
+ }
1
11
  import { configExists, readConfig, writeConfig } from "../config/config.js";
12
+ import { installCommand, isInstalled } from "./install.js";
2
13
  import qrcodeTerminal from "qrcode-terminal";
3
14
 
4
15
  const DEFAULT_RELAY_SERVER = "http://8.140.58.48";
@@ -41,7 +52,7 @@ export async function pairCommand(opts: PairOptions): Promise<void> {
41
52
 
42
53
  writeConfig({ ...config, relayServerUrl, displayName });
43
54
  } else {
44
- displayName = opts.name ?? "My Mac";
55
+ displayName = opts.name ?? getDisplayName();
45
56
  console.log("Registering with relay server…");
46
57
 
47
58
  const res = await fetch(`${httpBase}/api/relay/register`, {
@@ -81,4 +92,11 @@ export async function pairCommand(opts: PairOptions): Promise<void> {
81
92
  console.log("\nScan this QR code with the Clawai iOS app:\n");
82
93
  qrcodeTerminal.generate(qrPayload, { small: true });
83
94
  console.log("\nAccess code (one-time use):", accessCode);
95
+
96
+ if (isInstalled()) {
97
+ console.log("\nRelay service already installed — skipping.");
98
+ } else {
99
+ console.log("\nInstalling relay as a background service (auto-start on login)…");
100
+ installCommand();
101
+ }
84
102
  }
package/src/index.ts CHANGED
@@ -1,22 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
+ import { createRequire } from "module";
3
4
  import { pairCommand } from "./commands/pair.js";
4
5
  import { runCommand } from "./commands/run.js";
5
6
  import { installCommand, uninstallCommand, stopCommand } from "./commands/install.js";
6
7
  import { statusCommand } from "./commands/status.js";
7
8
 
9
+ const require = createRequire(import.meta.url);
10
+ const { version } = require("../../package.json");
11
+
8
12
  const program = new Command();
9
13
 
10
14
  program
11
15
  .name("clawpilot")
12
16
  .description("ClawPilot relay client — connects Mac mini to the cloud relay server")
13
- .version("1.0.0");
17
+ .version(version);
14
18
 
15
19
  program
16
20
  .command("pair")
17
21
  .description("Register with relay server and display QR code for iOS pairing")
18
22
  .option("-s, --server <url>", "Relay server URL", "http://8.140.58.48")
19
- .option("-n, --name <name>", "Display name for this Mac", "My Mac")
23
+ .option("-n, --name <name>", "Display name for this Mac")
20
24
  .action(async (opts: { server: string; name: string }) => {
21
25
  try {
22
26
  await pairCommand(opts);