@a2hmarket/a2hmarket 0.6.4 → 0.6.6

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.
@@ -6,20 +6,7 @@
6
6
  "skills": ["./skills"],
7
7
  "configSchema": {
8
8
  "type": "object",
9
- "properties": {
10
- "agentId": { "type": "string", "description": "A2H Market agent ID" },
11
- "agentKey": { "type": "string", "description": "A2H Market agent key (HMAC signing)" },
12
- "apiUrl": { "type": "string", "description": "A2H Market API base URL" },
13
- "mqttUrl": { "type": "string", "description": "MQTT broker URL for A2A messaging" },
14
- "tempoPrivateKey": { "type": "string", "description": "Solana private key for Tempo payments" },
15
- "notify": {
16
- "type": "object",
17
- "properties": {
18
- "channel": { "type": "string", "description": "Notification channel (feishu, discord, etc.)" },
19
- "target": { "type": "string", "description": "Target ID for notifications" }
20
- }
21
- }
22
- },
9
+ "properties": {},
23
10
  "additionalProperties": false
24
11
  }
25
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2hmarket/a2hmarket",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "index.ts",
@@ -308,8 +308,19 @@ async function runUpdate() {
308
308
  process.exit(0);
309
309
  }
310
310
 
311
- // 3. Update plugin
311
+ // 3. Backup credentials before uninstall
312
312
  logStep(3, "更新插件");
313
+ let savedCreds = null;
314
+ try {
315
+ if (existsSync(CREDS_FILE)) {
316
+ savedCreds = JSON.parse(readFileSync(CREDS_FILE, "utf-8"));
317
+ log(` ${CHECK} 凭证已备份`);
318
+ }
319
+ } catch {}
320
+ if (!savedCreds) {
321
+ log(` ${WARN} 未找到凭证备份,更新后可能需要重新安装`);
322
+ }
323
+
313
324
  try {
314
325
  log(` 卸载旧版本...`);
315
326
  execSync('echo y | openclaw plugins uninstall a2hmarket 2>&1', { encoding: "utf-8", stdio: "pipe" });
@@ -321,6 +332,20 @@ async function runUpdate() {
321
332
  process.exit(1);
322
333
  }
323
334
 
335
+ // Restore credentials file
336
+ if (savedCreds) {
337
+ mkdirSync(DATA_DIR, { recursive: true });
338
+ const fileData = {
339
+ agent_id: savedCreds.agentId ?? savedCreds.agent_id,
340
+ agent_key: savedCreds.agentKey ?? savedCreds.agent_key,
341
+ api_url: savedCreds.apiUrl ?? savedCreds.api_url ?? "https://api.a2hmarket.ai",
342
+ mqtt_url: savedCreds.mqttUrl ?? savedCreds.mqtt_url ?? "mqtts://post-cn-e4k4o78q702.mqtt.aliyuncs.com:8883",
343
+ };
344
+ if (savedCreds.notify) fileData.notify = savedCreds.notify;
345
+ writeFileSync(CREDS_FILE, JSON.stringify(fileData, null, 2) + "\n");
346
+ log(` ${CHECK} 凭证已恢复`);
347
+ }
348
+
324
349
  // 4. Re-link openclaw module
325
350
  log(` 配置模块依赖...`);
326
351
  try {
@@ -711,36 +736,15 @@ async function main() {
711
736
  log(` ${DIM}未检测到可用渠道,跳过通知配置${RESET}`);
712
737
  }
713
738
 
714
- // Save credentials file (fallback for dev mode)
739
+ // Save credentials to ~/.openclaw/a2hmarket/credentials.json
715
740
  writeFileSync(CREDS_FILE, JSON.stringify(credsData, null, 2) + "\n");
716
- log(` ${CHECK} 凭证文件已保存`);
741
+ log(` ${CHECK} 凭证已保存`);
717
742
 
718
- // Write credentials into openclaw.json plugins.entries.a2hmarket
719
- // This is the primary config path — api.pluginConfig reads from here
720
- log(` 写入 openclaw.json...`);
743
+ // Ensure a2h tools in alsoAllow (if whitelist mode is active)
721
744
  try {
722
745
  const configPath = join(OPENCLAW_DIR, "openclaw.json");
723
746
  const cfg = JSON.parse(readFileSync(configPath, "utf-8"));
724
-
725
- // Ensure plugins.entries.a2hmarket exists
726
- if (!cfg.plugins) cfg.plugins = {};
727
- if (!cfg.plugins.entries) cfg.plugins.entries = {};
728
- const entry = cfg.plugins.entries.a2hmarket ?? {};
729
-
730
- // Write credentials into plugin entry
731
- entry.enabled = true;
732
- entry.agentId = agentId;
733
- entry.agentKey = agentKey;
734
- entry.apiUrl = apiUrl;
735
- entry.mqttUrl = mqttUrl;
736
- if (credsData.notify) {
737
- entry.notify = credsData.notify;
738
- }
739
- cfg.plugins.entries.a2hmarket = entry;
740
-
741
- // Ensure a2h tools in alsoAllow (if whitelist mode is active)
742
- if (!cfg.tools) cfg.tools = {};
743
- if (Array.isArray(cfg.tools.alsoAllow)) {
747
+ if (Array.isArray(cfg?.tools?.alsoAllow)) {
744
748
  const a2hTools = [
745
749
  "a2h_status", "a2h_profile_get", "a2h_profile_upload_qrcode",
746
750
  "a2h_profile_delete_qrcode", "a2h_file_upload",
@@ -759,15 +763,24 @@ async function main() {
759
763
  added++;
760
764
  }
761
765
  }
762
- if (added > 0) log(` ${CHECK} ${added} 个工具已添加到白名单`);
766
+ if (added > 0) {
767
+ writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
768
+ log(` ${CHECK} ${added} 个工具已添加到白名单`);
769
+ }
763
770
  }
771
+ } catch {}
764
772
 
765
- writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
766
- log(` ${CHECK} openclaw.json 已更新`);
767
- } catch (err) {
768
- log(` ${WARN} openclaw.json 写入失败: ${err.message}`);
769
- log(` ${DIM}插件将使用凭证文件作为回退${RESET}`);
770
- }
773
+ // Clean any stale credentials from plugins.entries (OpenClaw doesn't allow custom keys there)
774
+ try {
775
+ const configPath = join(OPENCLAW_DIR, "openclaw.json");
776
+ const cfg = JSON.parse(readFileSync(configPath, "utf-8"));
777
+ const entry = cfg?.plugins?.entries?.a2hmarket;
778
+ if (entry && (entry.agentId || entry.agentKey)) {
779
+ cfg.plugins.entries.a2hmarket = { enabled: true };
780
+ writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
781
+ log(` ${CHECK} 清理 openclaw.json 中的旧凭证`);
782
+ }
783
+ } catch {}
771
784
 
772
785
  // ── Step 5: Restart gateway ────────────────────────────────────
773
786
  logStep(5, "启动服务");