openclaw-elys 1.4.1 → 1.4.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/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,13 +18,13 @@ 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
package/dist/src/cli.js CHANGED
@@ -7,24 +7,39 @@ import { loadCredentials, loadGatewayUrl, deleteCredentials, } from "./config.js
7
7
  const OPENCLAW_CONFIG = path.join(os.homedir(), ".openclaw", "openclaw.json");
8
8
  /**
9
9
  * Auto-configure channels.elys in ~/.openclaw/openclaw.json
10
+ * Retries if OpenClaw's file watcher overwrites the change.
10
11
  */
11
12
  function configureOpenClawChannel(gatewayUrl) {
12
- try {
13
- if (!fs.existsSync(OPENCLAW_CONFIG))
13
+ const maxAttempts = 3;
14
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
15
+ try {
16
+ if (!fs.existsSync(OPENCLAW_CONFIG))
17
+ return false;
18
+ const raw = fs.readFileSync(OPENCLAW_CONFIG, "utf-8");
19
+ const cfg = JSON.parse(raw);
20
+ if (!cfg.channels)
21
+ cfg.channels = {};
22
+ cfg.channels.elys = { gatewayUrl };
23
+ fs.writeFileSync(OPENCLAW_CONFIG, JSON.stringify(cfg, null, 2), "utf-8");
24
+ // Wait and verify the write wasn't overwritten
25
+ if (attempt < maxAttempts - 1) {
26
+ const delay = (attempt + 1) * 1000;
27
+ const start = Date.now();
28
+ while (Date.now() - start < delay) { /* busy wait */ }
29
+ const verify = JSON.parse(fs.readFileSync(OPENCLAW_CONFIG, "utf-8"));
30
+ if (verify.channels?.elys?.gatewayUrl === gatewayUrl) {
31
+ return true;
32
+ }
33
+ // Was overwritten, retry
34
+ continue;
35
+ }
36
+ return true;
37
+ }
38
+ catch {
14
39
  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;
40
+ }
27
41
  }
42
+ return false;
28
43
  }
29
44
  /**
30
45
  * Remove channels.elys from ~/.openclaw/openclaw.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-elys",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "OpenClaw Elys channel plugin — connects to Elys App",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",