@a2hmarket/a2hmarket 1.0.8 → 1.0.10

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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "id": "a2hmarket",
3
3
  "name": "A2H Market",
4
- "description": "A2H Market \u2014 AI agent marketplace with self-managed A2A messaging via MQTT.",
5
- "version": "1.0.8",
4
+ "description": "A2H Market AI agent marketplace with self-managed A2A messaging via MQTT.",
5
+ "version": "1.0.10",
6
6
  "hosts": [
7
7
  "openclaw"
8
8
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2hmarket/a2hmarket",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "index.ts",
@@ -9,7 +9,7 @@
9
9
  "skills/",
10
10
  "src/"
11
11
  ],
12
- "description": "A2H Market OpenClaw plugin \u2014 AI agent marketplace with A2A messaging via MQTT.",
12
+ "description": "A2H Market OpenClaw plugin AI agent marketplace with A2A messaging via MQTT.",
13
13
  "license": "MIT-0",
14
14
  "main": "index.ts",
15
15
  "bin": {
@@ -9,12 +9,12 @@
9
9
  * 2. User opens URL in browser to authorize
10
10
  * 3. Poll GET /findu-user/api/v1/public/user/agent/auth?code=xxx
11
11
  * 4. Server returns agent_id + secret after user authorizes
12
- * 5. Save credentials to ~/.openclaw/a2hmarket/credentials.json
12
+ * 5. Save credentials to openclaw.json config + ~/.openclaw/credentials/a2h_credentials.json
13
13
  */
14
14
 
15
15
  import { execSync } from "node:child_process";
16
16
  import { createInterface } from "node:readline";
17
- import { existsSync, mkdirSync, writeFileSync, readFileSync } from "node:fs";
17
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, unlinkSync } from "node:fs";
18
18
  import { join } from "node:path";
19
19
  import { homedir } from "node:os";
20
20
  import { createHash, createHmac, randomBytes } from "node:crypto";
@@ -23,7 +23,7 @@ import { networkInterfaces } from "node:os";
23
23
  const OPENCLAW_DIR = join(homedir(), ".openclaw");
24
24
  const OPENCLAW_CONFIG = join(OPENCLAW_DIR, "openclaw.json");
25
25
  const CREDS_DIR = join(OPENCLAW_DIR, "credentials");
26
- const CREDS_FILE = join(CREDS_DIR, "credentials.json");
26
+ const CREDS_FILE = join(CREDS_DIR, "a2h_credentials.json");
27
27
  const A2H_STORE_DIR = join(homedir(), ".a2h_store");
28
28
  const A2H_CONFIG_DIR = join(A2H_STORE_DIR, "a2h_config");
29
29
  const A2H_DATA_DIR = join(A2H_STORE_DIR, "a2h_data");
@@ -512,14 +512,22 @@ async function runUninstall() {
512
512
  }
513
513
 
514
514
  // 2. Remove runtime data
515
- for (const dir of [CREDS_DIR, A2H_STORE_DIR]) {
516
- if (existsSync(dir)) {
517
- try {
518
- execSync(`rm -rf "${dir}"`, { stdio: "pipe" });
519
- log(` ${CHECK} Removed: ${dir}`);
520
- } catch {
521
- log(` ${WARN} Failed to remove: ${dir}`);
522
- }
515
+ // Only remove a2h_credentials.json from shared credentials dir (other plugins use this dir)
516
+ if (existsSync(CREDS_FILE)) {
517
+ try {
518
+ unlinkSync(CREDS_FILE);
519
+ log(` ${CHECK} Removed: ${CREDS_FILE}`);
520
+ } catch {
521
+ log(` ${WARN} Failed to remove: ${CREDS_FILE}`);
522
+ }
523
+ }
524
+ // Remove a2h_store dir entirely (a2hmarket-exclusive)
525
+ if (existsSync(A2H_STORE_DIR)) {
526
+ try {
527
+ execSync(`rm -rf "${A2H_STORE_DIR}"`, { stdio: "pipe" });
528
+ log(` ${CHECK} Removed: ${A2H_STORE_DIR}`);
529
+ } catch {
530
+ log(` ${WARN} Failed to remove: ${A2H_STORE_DIR}`);
523
531
  }
524
532
  }
525
533
 
@@ -531,6 +539,10 @@ async function runUninstall() {
531
539
  if (entry) {
532
540
  // Reset to minimal — keep enabled:false so openclaw knows it was uninstalled
533
541
  cfg.plugins.entries.a2hmarket = { enabled: false };
542
+ // Remove from allowlist
543
+ if (Array.isArray(cfg.plugins?.allow)) {
544
+ cfg.plugins.allow = cfg.plugins.allow.filter(p => p !== "a2hmarket");
545
+ }
534
546
  writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
535
547
  log(` ${CHECK} openclaw.json cleaned`);
536
548
  }
@@ -860,13 +872,19 @@ async function main() {
860
872
  if (credsData.notify) {
861
873
  cfg.plugins.entries.a2hmarket.config.notify = credsData.notify;
862
874
  }
875
+ // Ensure plugin is in allowlist and enabled
876
+ if (!cfg.plugins.allow) cfg.plugins.allow = [];
877
+ if (!cfg.plugins.allow.includes("a2hmarket")) {
878
+ cfg.plugins.allow.push("a2hmarket");
879
+ }
880
+ cfg.plugins.entries.a2hmarket.enabled = true;
863
881
  writeFileSync(OPENCLAW_CONFIG, JSON.stringify(cfg, null, 2) + "\n");
864
882
  log(` ${CHECK} Credentials saved to openclaw.json`);
865
883
  } catch (err) {
866
884
  log(` ${WARN} Could not write to openclaw.json: ${err.message}`);
867
885
  }
868
886
 
869
- // Also save fallback file to ~/.openclaw/credentials/credentials.json
887
+ // Also save fallback file to ~/.openclaw/credentials/a2h_credentials.json
870
888
  writeFileSync(CREDS_FILE, JSON.stringify(credsData, null, 2) + "\n");
871
889
  log(` ${CHECK} Fallback credentials saved to ${CREDS_DIR}`);
872
890
 
@@ -905,7 +923,9 @@ async function main() {
905
923
  const cfg = JSON.parse(readFileSync(configPath, "utf-8"));
906
924
  const entry = cfg?.plugins?.entries?.a2hmarket;
907
925
  if (entry && (entry.agentId || entry.agentKey)) {
926
+ const existingConfig = entry.config;
908
927
  cfg.plugins.entries.a2hmarket = { enabled: true };
928
+ if (existingConfig) cfg.plugins.entries.a2hmarket.config = existingConfig;
909
929
  writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
910
930
  log(` ${CHECK} Cleaned stale credentials from openclaw.json`);
911
931
  }
@@ -22,7 +22,7 @@ import { createInterface } from 'readline';
22
22
 
23
23
  const KEYCHAIN_SERVICE = 'a2hmarket-tempo';
24
24
  // Try new path first, fallback to legacy
25
- const CREDS_NEW = join(homedir(), '.openclaw', 'credentials', 'credentials.json');
25
+ const CREDS_NEW = join(homedir(), '.openclaw', 'credentials', 'a2h_credentials.json');
26
26
  const CREDS_LEGACY = join(homedir(), '.openclaw', 'a2hmarket', 'credentials.json');
27
27
  const CREDS_PATH = existsSync(CREDS_NEW) ? CREDS_NEW : CREDS_LEGACY;
28
28
 
@@ -54,7 +54,8 @@ export function loadCredentialsFromConfig(
54
54
  const PLUGIN_DIR = join(dirname(fileURLToPath(import.meta.url)), "..");
55
55
  const OPENCLAW_CREDS_DIR = join(homedir(), ".openclaw", "credentials");
56
56
  const LEGACY_CREDS_DIR = join(homedir(), ".openclaw", "a2hmarket");
57
- const CREDENTIALS_FILE = "credentials.json";
57
+ const A2H_CREDENTIALS_FILE = "a2h_credentials.json";
58
+ const LEGACY_CREDENTIALS_FILE = "credentials.json";
58
59
 
59
60
  interface RawCredentials {
60
61
  agent_id?: string;
@@ -70,23 +71,24 @@ interface RawCredentials {
70
71
  }
71
72
 
72
73
  export function loadCredentialsFromFile(configDir?: string): A2HCredentials {
73
- let dir: string;
74
+ let filePath: string;
74
75
  if (configDir) {
75
- dir = configDir;
76
+ // configDir provided: try a2h_credentials.json first, fall back to credentials.json
77
+ const a2hPath = join(configDir, A2H_CREDENTIALS_FILE);
78
+ filePath = existsSync(a2hPath) ? a2hPath : join(configDir, LEGACY_CREDENTIALS_FILE);
76
79
  } else {
77
- // Priority: ~/.openclaw/credentials/ > ~/.openclaw/a2hmarket/ (legacy) > plugin dir
78
- const credsPath = join(OPENCLAW_CREDS_DIR, CREDENTIALS_FILE);
79
- const legacyPath = join(LEGACY_CREDS_DIR, CREDENTIALS_FILE);
80
- const pluginPath = join(PLUGIN_DIR, CREDENTIALS_FILE);
81
- dir = existsSync(credsPath)
82
- ? OPENCLAW_CREDS_DIR
80
+ // Priority: ~/.openclaw/credentials/a2h_credentials.json > ~/.openclaw/a2hmarket/credentials.json (legacy) > plugin dir credentials.json
81
+ const credsPath = join(OPENCLAW_CREDS_DIR, A2H_CREDENTIALS_FILE);
82
+ const legacyPath = join(LEGACY_CREDS_DIR, LEGACY_CREDENTIALS_FILE);
83
+ const pluginPath = join(PLUGIN_DIR, LEGACY_CREDENTIALS_FILE);
84
+ filePath = existsSync(credsPath)
85
+ ? credsPath
83
86
  : existsSync(legacyPath)
84
- ? LEGACY_CREDS_DIR
87
+ ? legacyPath
85
88
  : existsSync(pluginPath)
86
- ? PLUGIN_DIR
87
- : OPENCLAW_CREDS_DIR; // default to standard path
89
+ ? pluginPath
90
+ : credsPath; // default: will throw with helpful error
88
91
  }
89
- const filePath = join(dir, CREDENTIALS_FILE);
90
92
 
91
93
  let raw: RawCredentials;
92
94
  try {