openclaw-sync-assistant 0.0.3 → 0.0.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.
package/index.js CHANGED
@@ -14,17 +14,18 @@ module.exports = {
14
14
  * @param {object} context - OpenClaw 提供的上下文对象,包含 api 等
15
15
  */
16
16
  async activate(context) {
17
- // 仅在明确启用 DEBUG 的情况下输出激活日志
18
17
  if (process.env.DEBUG === "openclaw:sync") {
19
18
  console.log("✅ openclaw-sync-assistant 插件已激活!");
20
19
  }
21
20
 
22
- // OpenClaw 插件 API 中注册 CLI 命令
23
- if (context.registerCommand) {
24
- context.registerCommand({
25
- command: "sync.setup",
26
- description: "Initialize OpenClaw Sync Assistant configuration",
27
- action: async () => {
21
+ // 安全地注册命令,避免 .trim() 报错
22
+ try {
23
+ if (
24
+ context.api &&
25
+ context.api.commands &&
26
+ typeof context.api.commands.registerCommand === "function"
27
+ ) {
28
+ context.api.commands.registerCommand("sync.setup", async () => {
28
29
  console.log("\n");
29
30
  intro(pc.bgCyan(pc.black(" OpenClaw Sync Assistant Setup ")));
30
31
 
@@ -90,7 +91,6 @@ module.exports = {
90
91
  `正在初始化 [${syncMethod.toUpperCase()} - ${syncMode}] 同步服务...`,
91
92
  );
92
93
 
93
- // 模拟保存配置 (实际应使用 context.api.config.update 等方法)
94
94
  if (context.api.config && context.api.config.update) {
95
95
  await context.api.config.update(
96
96
  "openclaw-sync-assistant.syncMethod",
@@ -116,7 +116,6 @@ module.exports = {
116
116
  );
117
117
  }
118
118
 
119
- // 模拟启动相关服务等耗时操作
120
119
  await new Promise((resolve) => setTimeout(resolve, 1500));
121
120
 
122
121
  s.stop("配置已保存!");
@@ -126,19 +125,13 @@ module.exports = {
126
125
  `✔ 配置完成!同步助手后台服务已按 [${syncMethod.toUpperCase()} - ${syncMode}] 接管状态同步。`,
127
126
  ),
128
127
  );
129
- },
130
- });
131
- } else if (process.env.DEBUG === "openclaw:sync") {
132
- console.log(
133
- pc.yellow(
134
- "提示: 可以在配置文件中设置 syncMethod, syncMode, syncSecret 和 githubRepo 来启动同步。",
135
- ),
136
- );
128
+ });
129
+ }
130
+ } catch (e) {
131
+ if (process.env.DEBUG === "openclaw:sync") {
132
+ console.error("❌ 注册命令失败:", e);
133
+ }
137
134
  }
138
-
139
- // 根据模式启动后台服务的逻辑占位
140
- // if (config.syncMethod === 'p2p') startP2PService(context);
141
- // else if (config.syncMethod === 'github') startGitSyncService(context);
142
135
  },
143
136
 
144
137
  /**
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "id": "openclaw-sync-assistant",
3
3
  "name": "openclaw-sync-assistant",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "description": "OpenClaw Sync Assistant Plugin",
6
+ "commands": [
7
+ {
8
+ "id": "sync.setup",
9
+ "title": "OpenClaw Sync: Setup",
10
+ "description": "Initialize OpenClaw Sync Assistant configuration"
11
+ }
12
+ ],
6
13
  "configSchema": {
7
14
  "type": "object",
8
15
  "properties": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-sync-assistant",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "An OpenClaw plugin for P2P file and data synchronization using Hyperswarm and Hyperdrive ecosystem.",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",