@a2hmarket/a2hmarket 0.3.1 → 0.3.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/install.mjs +25 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2hmarket/a2hmarket",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "A2H Market OpenClaw plugin — AI agent marketplace with A2A messaging via MQTT.",
6
6
  "license": "MIT-0",
@@ -302,30 +302,35 @@ async function main() {
302
302
  try {
303
303
  const pluginDir = join(OPENCLAW_DIR, "extensions", "a2hmarket");
304
304
  if (existsSync(pluginDir)) {
305
- // Find openclaw package in multiple possible locations
305
+ // Find openclaw package resolve from the actual binary location
306
306
  let openclawPkg = null;
307
- const candidates = [];
308
307
  try {
309
- // 1. npm root -g (most reliable)
310
- const npmRoot = execSync("npm root -g 2>/dev/null", { encoding: "utf-8" }).trim();
311
- if (npmRoot) candidates.push(join(npmRoot, "openclaw"));
312
- } catch {}
313
- try {
314
- // 2. Relative to `which openclaw` binary
315
- const binDir = execSync("dirname $(which openclaw) 2>/dev/null", { encoding: "utf-8" }).trim();
316
- if (binDir) {
317
- candidates.push(join(binDir, "..", "lib", "node_modules", "openclaw"));
318
- candidates.push(join(binDir, "..", "node_modules", "openclaw"));
308
+ // Follow symlinks to find the real openclaw.mjs, then derive the package root
309
+ const realBin = execSync("realpath $(which openclaw) 2>/dev/null || readlink -f $(which openclaw) 2>/dev/null", { encoding: "utf-8" }).trim();
310
+ if (realBin) {
311
+ // openclaw.mjs is at {pkg}/openclaw.mjs or {pkg}/dist/cli/...
312
+ // Walk up until we find package.json with name "openclaw"
313
+ let dir = realBin;
314
+ for (let i = 0; i < 5; i++) {
315
+ dir = join(dir, "..");
316
+ const pj = join(dir, "package.json");
317
+ if (existsSync(pj)) {
318
+ try {
319
+ const pkg = JSON.parse(readFileSync(pj, "utf-8"));
320
+ if (pkg.name === "openclaw") { openclawPkg = dir; break; }
321
+ } catch {}
322
+ }
323
+ }
319
324
  }
320
325
  } catch {}
321
- // 3. Common global paths
322
- candidates.push("/opt/homebrew/lib/node_modules/openclaw");
323
- candidates.push("/usr/local/lib/node_modules/openclaw");
324
-
325
- for (const p of candidates) {
326
- if (existsSync(join(p, "package.json"))) {
327
- openclawPkg = p;
328
- break;
326
+
327
+ // Fallback: try common paths
328
+ if (!openclawPkg) {
329
+ for (const p of [
330
+ "/opt/homebrew/lib/node_modules/openclaw",
331
+ "/usr/local/lib/node_modules/openclaw",
332
+ ]) {
333
+ if (existsSync(join(p, "package.json"))) { openclawPkg = p; break; }
329
334
  }
330
335
  }
331
336