agenticmail 0.3.15 → 0.3.17
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/dist/cli.js +55 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4375,11 +4375,23 @@ async function registerWithOpenClaw(config) {
|
|
|
4375
4375
|
try {
|
|
4376
4376
|
const raw = readFileSync2(openclawConfigPath, "utf-8");
|
|
4377
4377
|
const existing = JSON5.parse(raw);
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4378
|
+
const existingEntry = existing.plugins?.entries?.agenticmail;
|
|
4379
|
+
if (existingEntry?.config?.apiKey) {
|
|
4380
|
+
const existingPaths = existing.plugins?.load?.paths ?? [];
|
|
4381
|
+
const pluginFound = existingPaths.some(
|
|
4382
|
+
(p) => existsSync2(join(p, "openclaw.plugin.json"))
|
|
4383
|
+
);
|
|
4384
|
+
if (pluginFound) {
|
|
4385
|
+
ok2(`OpenClaw integration already configured`);
|
|
4386
|
+
return;
|
|
4387
|
+
}
|
|
4381
4388
|
}
|
|
4382
4389
|
const pluginDir = resolveOpenClawPluginDir();
|
|
4390
|
+
if (!pluginDir) {
|
|
4391
|
+
info2(`Install the OpenClaw plugin first: ${c2.green("npm i @agenticmail/openclaw")}`);
|
|
4392
|
+
info2(`Then run: ${c2.green("agenticmail openclaw")}`);
|
|
4393
|
+
return;
|
|
4394
|
+
}
|
|
4383
4395
|
let agentApiKey;
|
|
4384
4396
|
try {
|
|
4385
4397
|
const base = `http://${config.api.host}:${config.api.port}`;
|
|
@@ -4745,25 +4757,58 @@ async function setupDomain(config) {
|
|
|
4745
4757
|
}
|
|
4746
4758
|
}
|
|
4747
4759
|
function resolveOpenClawPluginDir() {
|
|
4760
|
+
const pluginMarker = "openclaw.plugin.json";
|
|
4761
|
+
const pkgPath = join("node_modules", "@agenticmail", "openclaw");
|
|
4748
4762
|
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
4749
4763
|
let dir = thisDir;
|
|
4750
4764
|
for (let i = 0; i < 10; i++) {
|
|
4751
|
-
const candidate = join(dir,
|
|
4752
|
-
if (existsSync2(join(candidate,
|
|
4765
|
+
const candidate = join(dir, pkgPath);
|
|
4766
|
+
if (existsSync2(join(candidate, pluginMarker))) return realpathSync(candidate);
|
|
4753
4767
|
const parent = dirname(dir);
|
|
4754
4768
|
if (parent === dir) break;
|
|
4755
4769
|
dir = parent;
|
|
4756
4770
|
}
|
|
4757
|
-
const
|
|
4771
|
+
const monorepo = [
|
|
4758
4772
|
join(thisDir, "..", "..", "packages", "openclaw"),
|
|
4759
4773
|
join(thisDir, "..", "packages", "openclaw")
|
|
4760
4774
|
];
|
|
4761
|
-
for (const p of
|
|
4762
|
-
if (existsSync2(join(p,
|
|
4775
|
+
for (const p of monorepo) {
|
|
4776
|
+
if (existsSync2(join(p, pluginMarker))) return p;
|
|
4777
|
+
}
|
|
4778
|
+
const userDirs = [
|
|
4779
|
+
join(process.cwd(), pkgPath),
|
|
4780
|
+
join(homedir(), pkgPath)
|
|
4781
|
+
];
|
|
4782
|
+
for (const p of userDirs) {
|
|
4783
|
+
if (existsSync2(join(p, pluginMarker))) {
|
|
4784
|
+
try {
|
|
4785
|
+
return realpathSync(p);
|
|
4786
|
+
} catch {
|
|
4787
|
+
return p;
|
|
4788
|
+
}
|
|
4789
|
+
}
|
|
4790
|
+
}
|
|
4791
|
+
try {
|
|
4792
|
+
const cp = createRequire(import.meta.url)("node:child_process");
|
|
4793
|
+
const prefix = cp.execSync("npm prefix -g", { timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).toString().trim();
|
|
4794
|
+
const globalCandidates = [
|
|
4795
|
+
join(prefix, "lib", pkgPath),
|
|
4796
|
+
join(prefix, pkgPath)
|
|
4797
|
+
];
|
|
4798
|
+
for (const p of globalCandidates) {
|
|
4799
|
+
if (existsSync2(join(p, pluginMarker))) {
|
|
4800
|
+
try {
|
|
4801
|
+
return realpathSync(p);
|
|
4802
|
+
} catch {
|
|
4803
|
+
return p;
|
|
4804
|
+
}
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
} catch {
|
|
4763
4808
|
}
|
|
4764
4809
|
try {
|
|
4765
|
-
const
|
|
4766
|
-
const resolved =
|
|
4810
|
+
const req = createRequire(import.meta.url);
|
|
4811
|
+
const resolved = req.resolve("@agenticmail/openclaw/openclaw.plugin.json");
|
|
4767
4812
|
return dirname(resolved);
|
|
4768
4813
|
} catch {
|
|
4769
4814
|
}
|