@a2hmarket/a2hmarket 0.6.5 → 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.5",
3
+ "version": "0.6.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "index.ts",
@@ -311,24 +311,12 @@ async function runUpdate() {
311
311
  // 3. Backup credentials before uninstall
312
312
  logStep(3, "更新插件");
313
313
  let savedCreds = null;
314
- // Try openclaw.json plugin config first
315
314
  try {
316
- const cfg = JSON.parse(readFileSync(join(OPENCLAW_DIR, "openclaw.json"), "utf-8"));
317
- const entry = cfg?.plugins?.entries?.a2hmarket;
318
- if (entry?.agentId && entry?.agentKey) {
319
- savedCreds = entry;
320
- log(` ${CHECK} 凭证已备份 (openclaw.json)`);
315
+ if (existsSync(CREDS_FILE)) {
316
+ savedCreds = JSON.parse(readFileSync(CREDS_FILE, "utf-8"));
317
+ log(` ${CHECK} 凭证已备份`);
321
318
  }
322
319
  } catch {}
323
- // Fallback to credentials file
324
- if (!savedCreds) {
325
- try {
326
- if (existsSync(CREDS_FILE)) {
327
- savedCreds = JSON.parse(readFileSync(CREDS_FILE, "utf-8"));
328
- log(` ${CHECK} 凭证已备份 (credentials.json)`);
329
- }
330
- } catch {}
331
- }
332
320
  if (!savedCreds) {
333
321
  log(` ${WARN} 未找到凭证备份,更新后可能需要重新安装`);
334
322
  }
@@ -344,9 +332,8 @@ async function runUpdate() {
344
332
  process.exit(1);
345
333
  }
346
334
 
347
- // Restore credentials to both locations
335
+ // Restore credentials file
348
336
  if (savedCreds) {
349
- // Restore credentials file
350
337
  mkdirSync(DATA_DIR, { recursive: true });
351
338
  const fileData = {
352
339
  agent_id: savedCreds.agentId ?? savedCreds.agent_id,
@@ -356,23 +343,6 @@ async function runUpdate() {
356
343
  };
357
344
  if (savedCreds.notify) fileData.notify = savedCreds.notify;
358
345
  writeFileSync(CREDS_FILE, JSON.stringify(fileData, null, 2) + "\n");
359
-
360
- // Restore openclaw.json plugin entry
361
- try {
362
- const configPath = join(OPENCLAW_DIR, "openclaw.json");
363
- const cfg = JSON.parse(readFileSync(configPath, "utf-8"));
364
- if (!cfg.plugins) cfg.plugins = {};
365
- if (!cfg.plugins.entries) cfg.plugins.entries = {};
366
- cfg.plugins.entries.a2hmarket = {
367
- enabled: true,
368
- agentId: fileData.agent_id,
369
- agentKey: fileData.agent_key,
370
- apiUrl: fileData.api_url,
371
- mqttUrl: fileData.mqtt_url,
372
- ...(fileData.notify ? { notify: fileData.notify } : {}),
373
- };
374
- writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
375
- } catch {}
376
346
  log(` ${CHECK} 凭证已恢复`);
377
347
  }
378
348
 
@@ -766,36 +736,15 @@ async function main() {
766
736
  log(` ${DIM}未检测到可用渠道,跳过通知配置${RESET}`);
767
737
  }
768
738
 
769
- // Save credentials file (fallback for dev mode)
739
+ // Save credentials to ~/.openclaw/a2hmarket/credentials.json
770
740
  writeFileSync(CREDS_FILE, JSON.stringify(credsData, null, 2) + "\n");
771
- log(` ${CHECK} 凭证文件已保存`);
741
+ log(` ${CHECK} 凭证已保存`);
772
742
 
773
- // Write credentials into openclaw.json plugins.entries.a2hmarket
774
- // This is the primary config path — api.pluginConfig reads from here
775
- log(` 写入 openclaw.json...`);
743
+ // Ensure a2h tools in alsoAllow (if whitelist mode is active)
776
744
  try {
777
745
  const configPath = join(OPENCLAW_DIR, "openclaw.json");
778
746
  const cfg = JSON.parse(readFileSync(configPath, "utf-8"));
779
-
780
- // Ensure plugins.entries.a2hmarket exists
781
- if (!cfg.plugins) cfg.plugins = {};
782
- if (!cfg.plugins.entries) cfg.plugins.entries = {};
783
- const entry = cfg.plugins.entries.a2hmarket ?? {};
784
-
785
- // Write credentials into plugin entry
786
- entry.enabled = true;
787
- entry.agentId = agentId;
788
- entry.agentKey = agentKey;
789
- entry.apiUrl = apiUrl;
790
- entry.mqttUrl = mqttUrl;
791
- if (credsData.notify) {
792
- entry.notify = credsData.notify;
793
- }
794
- cfg.plugins.entries.a2hmarket = entry;
795
-
796
- // Ensure a2h tools in alsoAllow (if whitelist mode is active)
797
- if (!cfg.tools) cfg.tools = {};
798
- if (Array.isArray(cfg.tools.alsoAllow)) {
747
+ if (Array.isArray(cfg?.tools?.alsoAllow)) {
799
748
  const a2hTools = [
800
749
  "a2h_status", "a2h_profile_get", "a2h_profile_upload_qrcode",
801
750
  "a2h_profile_delete_qrcode", "a2h_file_upload",
@@ -814,15 +763,24 @@ async function main() {
814
763
  added++;
815
764
  }
816
765
  }
817
- if (added > 0) log(` ${CHECK} ${added} 个工具已添加到白名单`);
766
+ if (added > 0) {
767
+ writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
768
+ log(` ${CHECK} ${added} 个工具已添加到白名单`);
769
+ }
818
770
  }
771
+ } catch {}
819
772
 
820
- writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
821
- log(` ${CHECK} openclaw.json 已更新`);
822
- } catch (err) {
823
- log(` ${WARN} openclaw.json 写入失败: ${err.message}`);
824
- log(` ${DIM}插件将使用凭证文件作为回退${RESET}`);
825
- }
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 {}
826
784
 
827
785
  // ── Step 5: Restart gateway ────────────────────────────────────
828
786
  logStep(5, "启动服务");