clawdock 0.2.3 → 0.2.5

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 (2) hide show
  1. package/dist/index.js +35 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,6 +6,9 @@ import * as fs from "fs";
6
6
  import * as path from "path";
7
7
  import * as os from "os";
8
8
  import * as tar from "tar";
9
+ import { createRequire } from "module";
10
+ var require2 = createRequire(import.meta.url);
11
+ var PKG_VERSION = require2("../package.json").version;
9
12
  var CONFIG_DIR = path.join(os.homedir(), ".clawdock");
10
13
  var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
11
14
  var DEFAULT_REGISTRY = "https://clawhub-one.vercel.app";
@@ -44,7 +47,7 @@ async function apiRequest(method, endpoint, body, isForm) {
44
47
  return res.json();
45
48
  }
46
49
  var program = new Command();
47
- program.name("clawdock").description("ClawDock \u2014 the agent registry").version("0.1.0");
50
+ program.name("clawdock").description("ClawDock \u2014 the agent registry").version(PKG_VERSION, "-v, -V, --version");
48
51
  program.command("login").description("Authenticate with ClawDock").option("--api-key <key>", "API key").option("--registry <url>", "Registry URL").action(async (opts) => {
49
52
  const config = loadConfig();
50
53
  if (opts.apiKey) {
@@ -401,13 +404,16 @@ program.command("run <bundle>").description("Pull and run an agent locally").opt
401
404
  if (resolvedModel) console.log(` Model: ${resolvedModel}`);
402
405
  console.log();
403
406
  if (runtimeName === "openclaw") {
407
+ let needsRegister = true;
404
408
  try {
405
409
  const list = execSync(`openclaw agents list --json ${devNull}`, { encoding: "utf-8", shell: isWindows ? "cmd.exe" : void 0 });
406
410
  const agents = JSON.parse(list);
407
- if (!agents.find((a) => a.name === agentName)) {
408
- throw new Error("not found");
411
+ if (agents.find((a) => a.name === agentName)) {
412
+ needsRegister = false;
409
413
  }
410
414
  } catch {
415
+ }
416
+ if (needsRegister) {
411
417
  console.log(` Registering agent "${agentName}"...`);
412
418
  try {
413
419
  const modelFlag = resolvedModel ? ` --model ${resolvedModel}` : "";
@@ -416,8 +422,12 @@ program.command("run <bundle>").description("Pull and run an agent locally").opt
416
422
  { stdio: "inherit" }
417
423
  );
418
424
  } catch (err) {
419
- console.error(`\u274C Failed to register agent: ${err.message}`);
420
- process.exit(1);
425
+ if (err.message?.includes("already exists") || err.stderr?.includes("already exists")) {
426
+ console.log(` Agent "${agentName}" already registered.`);
427
+ } else {
428
+ console.error(`\u274C Failed to register agent: ${err.message}`);
429
+ process.exit(1);
430
+ }
421
431
  }
422
432
  }
423
433
  if (provider && apiKey) {
@@ -480,4 +490,24 @@ program.command("run <bundle>").description("Pull and run an agent locally").opt
480
490
  process.on("SIGTERM", () => child.kill("SIGTERM"));
481
491
  }
482
492
  });
493
+ program.command("update").description("Update clawdock CLI to the latest version").action(async () => {
494
+ const { execSync } = await import("child_process");
495
+ console.log(`Current version: ${PKG_VERSION}`);
496
+ console.log("\u{1F504} Checking for updates...");
497
+ try {
498
+ const latest = execSync("npm view clawdock version", { encoding: "utf-8" }).trim();
499
+ if (latest === PKG_VERSION) {
500
+ console.log(`\u2705 Already on latest version (${PKG_VERSION})`);
501
+ return;
502
+ }
503
+ console.log(` New version available: ${latest}`);
504
+ console.log(" Installing...");
505
+ execSync("npm install -g clawdock@latest", { stdio: "inherit" });
506
+ console.log(`\u2705 Updated to clawdock@${latest}`);
507
+ } catch (err) {
508
+ console.error(`\u274C Update failed: ${err.message}`);
509
+ console.error(" Try manually: npm install -g clawdock@latest");
510
+ process.exit(1);
511
+ }
512
+ });
483
513
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawdock",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "CLI for ClawDock — the agent registry",
5
5
  "bin": {
6
6
  "clawdock": "./dist/index.js"