openclaw-sync-assistant 0.0.3 → 0.0.4

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
@@ -19,126 +19,118 @@ module.exports = {
19
19
  console.log("✅ openclaw-sync-assistant 插件已激活!");
20
20
  }
21
21
 
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 () => {
28
- console.log("\n");
29
- intro(pc.bgCyan(pc.black(" OpenClaw Sync Assistant Setup ")));
22
+ // 根据模式启动后台服务的逻辑占位
23
+ // if (config.syncMethod === 'p2p') startP2PService(context);
24
+ // else if (config.syncMethod === 'github') startGitSyncService(context);
25
+ },
30
26
 
31
- const syncMethod = await select({
32
- message: "请选择同步方式 (Sync Method):",
33
- options: [
34
- { value: "p2p", label: "点对点直连 (P2P - 基于 Hyperswarm)" },
35
- { value: "github", label: "GitHub 托管 (基于 Git 仓库)" },
36
- ],
37
- });
27
+ /**
28
+ * 注册命令处理函数
29
+ */
30
+ async executeCommand(command, context) {
31
+ if (command === "sync.setup") {
32
+ console.log("\n");
33
+ intro(pc.bgCyan(pc.black(" OpenClaw Sync Assistant Setup ")));
38
34
 
39
- const syncMode = await select({
40
- message: "请选择同步模式 (Sync Mode):",
41
- options: [
42
- {
43
- value: "decentralized",
44
- label:
45
- "去中心模式 (Decentralized - 适合多设备对等同步,随时随地拉取)",
46
- },
47
- {
48
- value: "centralized",
49
- label:
50
- "中心模式 (Centralized - 适合以某台设备或仓库为主的主从同步)",
51
- },
52
- ],
53
- });
35
+ const syncMethod = await select({
36
+ message: "请选择同步方式 (Sync Method):",
37
+ options: [
38
+ { value: "p2p", label: "点对点直连 (P2P - 基于 Hyperswarm)" },
39
+ { value: "github", label: "GitHub 托管 (基于 Git 仓库)" },
40
+ ],
41
+ });
54
42
 
55
- let syncSecret = "";
56
- let githubRepo = "";
43
+ const syncMode = await select({
44
+ message: "请选择同步模式 (Sync Mode):",
45
+ options: [
46
+ {
47
+ value: "decentralized",
48
+ label:
49
+ "去中心模式 (Decentralized - 适合多设备对等同步,随时随地拉取)",
50
+ },
51
+ {
52
+ value: "centralized",
53
+ label:
54
+ "中心模式 (Centralized - 适合以某台设备或仓库为主的主从同步)",
55
+ },
56
+ ],
57
+ });
57
58
 
58
- if (syncMethod === "p2p") {
59
- syncSecret = await text({
60
- message:
61
- "请输入您的同步密钥 (Sync Secret, 用于生成 P2P 发现的 Topic 和加密数据):",
62
- placeholder: "例如: my-super-secret-key",
63
- validate(value) {
64
- if (value.length === 0) return "同步密钥不能为空!";
65
- },
66
- });
67
- } else if (syncMethod === "github") {
68
- githubRepo = await text({
69
- message: "请输入用于同步的 GitHub 仓库地址:",
70
- placeholder: "例如: https://github.com/your-name/sync-repo.git",
71
- validate(value) {
72
- if (value.length === 0) return "GitHub 仓库地址不能为空!";
73
- },
74
- });
75
- }
59
+ let syncSecret = "";
60
+ let githubRepo = "";
76
61
 
77
- const syncItems = await multiselect({
78
- message: "请选择要同步的内容:",
79
- options: [
80
- { value: "Config", label: "Config", hint: "OpenClaw 核心配置" },
81
- { value: "Auth", label: "Auth", hint: "认证信息" },
82
- { value: "Sessions", label: "Sessions", hint: "会话记录" },
83
- { value: "Workspace", label: "Workspace", hint: "工作区状态" },
84
- ],
85
- required: true,
86
- });
62
+ if (syncMethod === "p2p") {
63
+ syncSecret = await text({
64
+ message:
65
+ "请输入您的同步密钥 (Sync Secret, 用于生成 P2P 发现的 Topic 和加密数据):",
66
+ placeholder: "例如: my-super-secret-key",
67
+ validate(value) {
68
+ if (value.length === 0) return "同步密钥不能为空!";
69
+ },
70
+ });
71
+ } else if (syncMethod === "github") {
72
+ githubRepo = await text({
73
+ message: "请输入用于同步的 GitHub 仓库地址:",
74
+ placeholder: "例如: https://github.com/your-name/sync-repo.git",
75
+ validate(value) {
76
+ if (value.length === 0) return "GitHub 仓库地址不能为空!";
77
+ },
78
+ });
79
+ }
87
80
 
88
- const s = spinner();
89
- s.start(
90
- `正在初始化 [${syncMethod.toUpperCase()} - ${syncMode}] 同步服务...`,
91
- );
81
+ const syncItems = await multiselect({
82
+ message: "请选择要同步的内容:",
83
+ options: [
84
+ { value: "Config", label: "Config", hint: "OpenClaw 核心配置" },
85
+ { value: "Auth", label: "Auth", hint: "认证信息" },
86
+ { value: "Sessions", label: "Sessions", hint: "会话记录" },
87
+ { value: "Workspace", label: "Workspace", hint: "工作区状态" },
88
+ ],
89
+ required: true,
90
+ });
92
91
 
93
- // 模拟保存配置 (实际应使用 context.api.config.update 等方法)
94
- if (context.api.config && context.api.config.update) {
95
- await context.api.config.update(
96
- "openclaw-sync-assistant.syncMethod",
97
- syncMethod,
98
- );
99
- await context.api.config.update(
100
- "openclaw-sync-assistant.syncMode",
101
- syncMode,
102
- );
103
- if (syncSecret)
104
- await context.api.config.update(
105
- "openclaw-sync-assistant.syncSecret",
106
- syncSecret,
107
- );
108
- if (githubRepo)
109
- await context.api.config.update(
110
- "openclaw-sync-assistant.githubRepo",
111
- githubRepo,
112
- );
113
- await context.api.config.update(
114
- "openclaw-sync-assistant.syncItems",
115
- syncItems,
116
- );
117
- }
92
+ const s = spinner();
93
+ s.start(
94
+ `正在初始化 [${syncMethod.toUpperCase()} - ${syncMode}] 同步服务...`,
95
+ );
118
96
 
119
- // 模拟启动相关服务等耗时操作
120
- await new Promise((resolve) => setTimeout(resolve, 1500));
97
+ // 模拟保存配置 (实际应使用 context.api.config.update 等方法)
98
+ if (context.api && context.api.config && context.api.config.update) {
99
+ await context.api.config.update(
100
+ "openclaw-sync-assistant.syncMethod",
101
+ syncMethod,
102
+ );
103
+ await context.api.config.update(
104
+ "openclaw-sync-assistant.syncMode",
105
+ syncMode,
106
+ );
107
+ if (syncSecret)
108
+ await context.api.config.update(
109
+ "openclaw-sync-assistant.syncSecret",
110
+ syncSecret,
111
+ );
112
+ if (githubRepo)
113
+ await context.api.config.update(
114
+ "openclaw-sync-assistant.githubRepo",
115
+ githubRepo,
116
+ );
117
+ await context.api.config.update(
118
+ "openclaw-sync-assistant.syncItems",
119
+ syncItems,
120
+ );
121
+ }
121
122
 
122
- s.stop("配置已保存!");
123
+ // 模拟启动相关服务等耗时操作
124
+ await new Promise((resolve) => setTimeout(resolve, 1500));
123
125
 
124
- outro(
125
- pc.green(
126
- `✔ 配置完成!同步助手后台服务已按 [${syncMethod.toUpperCase()} - ${syncMode}] 接管状态同步。`,
127
- ),
128
- );
129
- },
130
- });
131
- } else if (process.env.DEBUG === "openclaw:sync") {
132
- console.log(
133
- pc.yellow(
134
- "提示: 可以在配置文件中设置 syncMethod, syncMode, syncSecret 和 githubRepo 来启动同步。",
126
+ s.stop("配置已保存!");
127
+
128
+ outro(
129
+ pc.green(
130
+ `✔ 配置完成!同步助手后台服务已按 [${syncMethod.toUpperCase()} - ${syncMode}] 接管状态同步。`,
135
131
  ),
136
132
  );
137
133
  }
138
-
139
- // 根据模式启动后台服务的逻辑占位
140
- // if (config.syncMethod === 'p2p') startP2PService(context);
141
- // else if (config.syncMethod === 'github') startGitSyncService(context);
142
134
  },
143
135
 
144
136
  /**
@@ -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.4",
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.4",
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",