ofiere-openclaw-plugin 3.5.3 → 3.5.5

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/src/tools.ts +34 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofiere-openclaw-plugin",
3
- "version": "3.5.3",
3
+ "version": "3.5.5",
4
4
  "type": "module",
5
5
  "description": "OpenClaw plugin for Ofiere PM - 10 meta-tools covering tasks, agents, projects, scheduling, knowledge, workflows, notifications, memory, prompts, and constellation agent architecture",
6
6
  "keywords": ["openclaw", "ofiere", "project-management", "agents", "plugin"],
package/src/tools.ts CHANGED
@@ -1697,7 +1697,7 @@ function registerConstellationOps(
1697
1697
  // Resolve the OpenClaw data directory — the plugin runs inside the gateway process
1698
1698
  const fs = require("fs");
1699
1699
  const path = require("path");
1700
- const { execSync } = require("child_process");
1700
+ const { spawnSync } = require("child_process");
1701
1701
 
1702
1702
  // OpenClaw stores data at /data/.openclaw/ inside the Docker container
1703
1703
  // Fallback: check HOME/.openclaw/ for local dev
@@ -1967,20 +1967,27 @@ function registerConstellationOps(
1967
1967
 
1968
1968
  function tryRegisterAgent(agentName: string): { success: boolean; message: string } {
1969
1969
  const wsPath = getWorkspacePath(agentName);
1970
- try {
1971
- const cmd = `${OPENCLAW_CLI} agents add ${agentName} --workspace ${wsPath} --non-interactive 2>&1`;
1972
- const output = execSync(cmd, { encoding: "utf8", timeout: 15000 });
1973
- api.logger?.info?.(`[ofiere] Auto-registered agent "${agentName}": ${output.slice(0, 200)}`);
1970
+ // Use spawnSync instead of execSync: spawnSync never throws on non-zero
1971
+ // exit codes, giving us clean access to stdout/stderr/status regardless
1972
+ // of CLI config warnings that cause non-zero exits.
1973
+ const result = spawnSync(OPENCLAW_CLI, [
1974
+ "agents", "add", agentName, "--workspace", wsPath, "--non-interactive",
1975
+ ], { encoding: "utf8", timeout: 15000 });
1976
+
1977
+ const stdout = result.stdout || "";
1978
+ const stderr = result.stderr || "";
1979
+ const combined = stdout + "\n" + stderr;
1980
+
1981
+ // Success indicators: JSON with agentId, agent name present, or zero exit
1982
+ if (result.status === 0 || combined.includes('"agentId"') || combined.includes(`"${agentName}"`)) {
1983
+ api.logger?.info?.(`[ofiere] Auto-registered agent "${agentName}": ${stdout.slice(0, 200)}`);
1974
1984
  return { success: true, message: `Agent "${agentName}" registered in OpenClaw` };
1975
- } catch (e: any) {
1976
- const msg = e?.stderr || e?.stdout || String(e);
1977
- // Check if already registered
1978
- if (msg.includes("already exists") || msg.includes("duplicate")) {
1979
- return { success: true, message: `Agent "${agentName}" was already registered` };
1980
- }
1981
- api.logger?.warn?.(`[ofiere] Auto-registration failed for "${agentName}": ${msg.slice(0, 300)}`);
1982
- return { success: false, message: `Auto-registration failed: ${msg.slice(0, 200)}. CLI path: ${OPENCLAW_CLI}` };
1983
1985
  }
1986
+ if (combined.includes("already exists") || combined.includes("duplicate")) {
1987
+ return { success: true, message: `Agent "${agentName}" was already registered` };
1988
+ }
1989
+ api.logger?.warn?.(`[ofiere] Auto-registration failed for "${agentName}": ${combined.slice(0, 300)}`);
1990
+ return { success: false, message: `Auto-registration failed: ${combined.slice(0, 200)}` };
1984
1991
  }
1985
1992
 
1986
1993
  // ── Register the tool ──
@@ -2296,14 +2303,20 @@ function registerConstellationOps(
2296
2303
  }
2297
2304
 
2298
2305
  // Unregister from OpenClaw (best-effort)
2299
- let unregResult = { success: false, message: "" };
2300
- try {
2301
- const cmd = `${OPENCLAW_CLI} agents delete ${agentName} --force 2>&1`;
2302
- const output = execSync(cmd, { encoding: "utf8", timeout: 15000 });
2303
- unregResult = { success: true, message: output.slice(0, 200) };
2304
- } catch (e: any) {
2305
- const emsg = e?.stderr || e?.stdout || String(e);
2306
- unregResult = { success: false, message: `Unregistration failed: ${emsg.slice(0, 200)}. CLI path: ${OPENCLAW_CLI}` };
2306
+ // Use spawnSync: never throws, gives clean stdout/stderr/status
2307
+ const unregCmd = spawnSync(OPENCLAW_CLI, [
2308
+ "agents", "delete", agentName, "--force",
2309
+ ], { encoding: "utf8", timeout: 15000 });
2310
+
2311
+ const unregStdout = unregCmd.stdout || "";
2312
+ const unregStderr = unregCmd.stderr || "";
2313
+ const unregCombined = unregStdout + "\n" + unregStderr;
2314
+
2315
+ let unregResult: { success: boolean; message: string };
2316
+ if (unregCmd.status === 0 || unregCombined.includes('"agentId"') || unregCombined.includes(`"${agentName}"`)) {
2317
+ unregResult = { success: true, message: `Agent "${agentName}" unregistered from OpenClaw` };
2318
+ } else {
2319
+ unregResult = { success: false, message: `Unregistration may have failed: ${unregCombined.slice(0, 200)}` };
2307
2320
  }
2308
2321
 
2309
2322
  api.logger?.info?.(`[ofiere] Deleted agent "${agentName}" — ${deletedFiles.length} files removed`);