openclaw-elys 1.4.1 → 1.4.3

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 CHANGED
@@ -7,7 +7,7 @@ Elys App 的 OpenClaw 频道插件 — 将本地 OpenClaw 智能体连接到 Ely
7
7
  ## Install / 安装
8
8
 
9
9
  ```bash
10
- openclaw plugins install openclaw-elys
10
+ openclaw plugins install openclaw-elys@latest
11
11
  # Installs the latest version by default / 默认安装最新版本
12
12
  ```
13
13
 
@@ -18,19 +18,19 @@ Get a one-time register token from the Elys App, then run:
18
18
  从 Elys App 获取一次性注册令牌,然后执行:
19
19
 
20
20
  ```bash
21
- npx openclaw-elys setup <gateway_url> <register_token>
21
+ npx openclaw-elys@latest setup <gateway_url> <register_token>
22
22
  ```
23
23
 
24
24
  Example / 示例:
25
25
 
26
26
  ```bash
27
- npx openclaw-elys setup https://your-gateway.com reg_abc123def456
27
+ npx openclaw-elys@latest setup https://your-gateway.com reg_abc123def456
28
28
  # Device registered successfully!
29
29
  # Device ID: d_xxxxxxxxxxxx
30
30
  # Credentials saved to ~/.elys/config.json
31
31
  # OpenClaw config updated: channels.elys.gatewayUrl = https://your-gateway.com
32
32
  #
33
- # Restart OpenClaw gateway to activate: openclaw gateway restart
33
+ # OpenClaw will auto-detect the config change. You're all set!
34
34
  ```
35
35
 
36
36
  The setup command automatically configures `channels.elys` in `~/.openclaw/openclaw.json`. OpenClaw will auto-detect the config change — no restart needed.
@@ -45,19 +45,13 @@ npx openclaw-elys status
45
45
 
46
46
  ## Uninstall / 卸载
47
47
 
48
- Revoke device credentials and remove local config:
49
-
50
- 撤销设备凭证并删除本地配置:
48
+ **Important: run these two commands in order. / 重要:请按顺序执行以下两条命令。**
51
49
 
52
50
  ```bash
51
+ # Step 1: Revoke device and remove channel config / 第一步:撤销设备并清除频道配置
53
52
  npx openclaw-elys uninstall
54
- ```
55
-
56
- Then remove the plugin:
57
53
 
58
- 然后卸载插件:
59
-
60
- ```bash
54
+ # Step 2: Remove the plugin / 第二步:卸载插件
61
55
  openclaw plugins uninstall openclaw-elys
62
56
  ```
63
57
 
package/dist/src/cli.js CHANGED
@@ -2,29 +2,45 @@
2
2
  import fs from "fs";
3
3
  import os from "os";
4
4
  import path from "path";
5
+ import { execSync } from "child_process";
5
6
  import { registerDevice } from "./register.js";
6
7
  import { loadCredentials, loadGatewayUrl, deleteCredentials, } from "./config.js";
7
8
  const OPENCLAW_CONFIG = path.join(os.homedir(), ".openclaw", "openclaw.json");
8
9
  /**
9
10
  * Auto-configure channels.elys in ~/.openclaw/openclaw.json
11
+ * Retries if OpenClaw's file watcher overwrites the change.
10
12
  */
11
13
  function configureOpenClawChannel(gatewayUrl) {
12
- try {
13
- if (!fs.existsSync(OPENCLAW_CONFIG))
14
+ const maxAttempts = 3;
15
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
16
+ try {
17
+ if (!fs.existsSync(OPENCLAW_CONFIG))
18
+ return false;
19
+ const raw = fs.readFileSync(OPENCLAW_CONFIG, "utf-8");
20
+ const cfg = JSON.parse(raw);
21
+ if (!cfg.channels)
22
+ cfg.channels = {};
23
+ cfg.channels.elys = { gatewayUrl };
24
+ fs.writeFileSync(OPENCLAW_CONFIG, JSON.stringify(cfg, null, 2), "utf-8");
25
+ // Wait and verify the write wasn't overwritten
26
+ if (attempt < maxAttempts - 1) {
27
+ const delay = (attempt + 1) * 1000;
28
+ const start = Date.now();
29
+ while (Date.now() - start < delay) { /* busy wait */ }
30
+ const verify = JSON.parse(fs.readFileSync(OPENCLAW_CONFIG, "utf-8"));
31
+ if (verify.channels?.elys?.gatewayUrl === gatewayUrl) {
32
+ return true;
33
+ }
34
+ // Was overwritten, retry
35
+ continue;
36
+ }
37
+ return true;
38
+ }
39
+ catch {
14
40
  return false;
15
- const raw = fs.readFileSync(OPENCLAW_CONFIG, "utf-8");
16
- const cfg = JSON.parse(raw);
17
- if (!cfg.channels)
18
- cfg.channels = {};
19
- cfg.channels.elys = {
20
- gatewayUrl,
21
- };
22
- fs.writeFileSync(OPENCLAW_CONFIG, JSON.stringify(cfg, null, 2), "utf-8");
23
- return true;
24
- }
25
- catch {
26
- return false;
41
+ }
27
42
  }
43
+ return false;
28
44
  }
29
45
  /**
30
46
  * Remove channels.elys from ~/.openclaw/openclaw.json
@@ -114,11 +130,23 @@ else if (command === "uninstall") {
114
130
  console.warn("Proceeding with local cleanup anyway.");
115
131
  })
116
132
  .finally(() => {
117
- deleteCredentials();
133
+ // 1. Remove channel config BEFORE plugin uninstall to avoid validation error
118
134
  if (removeOpenClawChannel()) {
119
135
  console.log("OpenClaw channel config removed.");
120
136
  }
137
+ // 2. Delete local credentials
138
+ deleteCredentials();
121
139
  console.log("Local credentials removed.");
140
+ // 3. Uninstall the plugin from OpenClaw
141
+ try {
142
+ console.log("Removing plugin from OpenClaw...");
143
+ execSync("openclaw plugins uninstall openclaw-elys --force", {
144
+ stdio: "inherit",
145
+ });
146
+ }
147
+ catch {
148
+ console.log("Could not auto-remove plugin. Run manually: openclaw plugins uninstall openclaw-elys");
149
+ }
122
150
  });
123
151
  }
124
152
  else if (command === "status") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-elys",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "OpenClaw Elys channel plugin — connects to Elys App",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",