mirror of
https://github.com/dtzp555-max/ocp.git
synced 2026-07-21 21:15:09 +00:00
fix: use neutral service names to avoid OpenClaw gateway detection
OpenClaw's gateway scans LaunchAgent plists and systemd units for "openclaw" markers and flags them as conflicting gateway-like services. Renamed service identifiers to avoid false positives: - macOS: ai.openclaw.proxy → dev.ocp.proxy - Linux: openclaw-proxy.service → ocp-proxy.service - Logs: ~/.openclaw/logs/ → ~/.ocp/logs/ Setup auto-removes legacy service names on upgrade. Uninstall handles both old and new names. Also bumps version to 3.1.0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
python3 -c "
|
|
||||||
import json, glob, os
|
|
||||||
for sf in glob.glob(os.path.expanduser('~/.openclaw/agents/*/sessions/sessions.json')):
|
|
||||||
d=json.load(open(sf))
|
|
||||||
keys=[k for k in d if 'slash' in k]
|
|
||||||
if keys:
|
|
||||||
for k in keys: del d[k]
|
|
||||||
json.dump(d, open(sf,'w'), indent=2)
|
|
||||||
"
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"id": "ocp",
|
"id": "ocp",
|
||||||
"name": "OCP Commands",
|
"name": "OCP Commands",
|
||||||
"description": "Slash commands for the OpenClaw Proxy — /ocp usage, /ocp settings, /ocp health, etc.",
|
"description": "Slash commands for the OpenClaw Proxy — /ocp usage, /ocp settings, /ocp health, etc.",
|
||||||
"version": "1.0.0",
|
"version": "3.1.0",
|
||||||
"configSchema": {
|
"configSchema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ocp",
|
"name": "ocp",
|
||||||
"version": "1.0.0",
|
"version": "3.1.0",
|
||||||
"description": "Slash commands for the OpenClaw Proxy",
|
"description": "Slash commands for the OpenClaw Proxy",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openclaw-claude-proxy",
|
"name": "openclaw-claude-proxy",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"description": "OCP (Open Claude Proxy) — use your Claude Pro/Max subscription as an OpenAI-compatible API for any IDE. Works with Cline, OpenCode, Aider, Continue.dev, OpenClaw, and more.",
|
"description": "OCP (Open Claude Proxy) — use your Claude Pro/Max subscription as an OpenAI-compatible API for any IDE. Works with Cline, OpenCode, Aider, Continue.dev, OpenClaw, and more.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
* 4. Creates start.sh for easy launch
|
* 4. Creates start.sh for easy launch
|
||||||
* 5. Optionally starts the proxy
|
* 5. Optionally starts the proxy
|
||||||
*/
|
*/
|
||||||
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
|
import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from "node:fs";
|
||||||
import { execSync } from "node:child_process";
|
import { execSync } from "node:child_process";
|
||||||
import { join, dirname } from "node:path";
|
import { join, dirname } from "node:path";
|
||||||
import { homedir } from "node:os";
|
import { homedir } from "node:os";
|
||||||
@@ -291,20 +291,47 @@ if (!DRY_RUN) {
|
|||||||
const logsDir = join(OPENCLAW_DIR, "logs");
|
const logsDir = join(OPENCLAW_DIR, "logs");
|
||||||
if (!existsSync(logsDir)) mkdirSync(logsDir, { recursive: true });
|
if (!existsSync(logsDir)) mkdirSync(logsDir, { recursive: true });
|
||||||
|
|
||||||
|
// Use neutral service names to avoid OpenClaw gateway's extra-service detection.
|
||||||
|
// OpenClaw scans LaunchAgent plists and systemd units for "openclaw" / "clawdbot"
|
||||||
|
// markers and flags them as conflicting gateway-like services. Using "dev.ocp.*"
|
||||||
|
// and "ocp-proxy" keeps the proxy invisible to that heuristic.
|
||||||
|
const OCP_HOME = join(HOME, ".ocp");
|
||||||
|
const ocpLogsDir = join(OCP_HOME, "logs");
|
||||||
|
if (!existsSync(ocpLogsDir)) mkdirSync(ocpLogsDir, { recursive: true });
|
||||||
|
|
||||||
|
// Uninstall legacy service names if present (upgrade path)
|
||||||
|
if (platform === "darwin") {
|
||||||
|
const legacyPlist = join(HOME, "Library", "LaunchAgents", "ai.openclaw.proxy.plist");
|
||||||
|
if (existsSync(legacyPlist)) {
|
||||||
|
try { execSync(`launchctl bootout gui/$(id -u) "${legacyPlist}" 2>/dev/null`); } catch { /* ignore */ }
|
||||||
|
try { unlinkSync(legacyPlist); } catch { /* ignore */ }
|
||||||
|
log(`Removed legacy plist: ai.openclaw.proxy`);
|
||||||
|
}
|
||||||
|
} else if (platform === "linux") {
|
||||||
|
const legacyService = join(HOME, ".config", "systemd", "user", "openclaw-proxy.service");
|
||||||
|
if (existsSync(legacyService)) {
|
||||||
|
try { execSync(`systemctl --user stop openclaw-proxy 2>/dev/null`); } catch { /* ignore */ }
|
||||||
|
try { execSync(`systemctl --user disable openclaw-proxy 2>/dev/null`); } catch { /* ignore */ }
|
||||||
|
try { unlinkSync(legacyService); } catch { /* ignore */ }
|
||||||
|
try { execSync(`systemctl --user daemon-reload`); } catch { /* ignore */ }
|
||||||
|
log(`Removed legacy systemd service: openclaw-proxy`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (platform === "darwin") {
|
if (platform === "darwin") {
|
||||||
// macOS: launchd
|
// macOS: launchd
|
||||||
const plistDir = join(HOME, "Library", "LaunchAgents");
|
const plistDir = join(HOME, "Library", "LaunchAgents");
|
||||||
if (!existsSync(plistDir)) mkdirSync(plistDir, { recursive: true });
|
if (!existsSync(plistDir)) mkdirSync(plistDir, { recursive: true });
|
||||||
|
|
||||||
const plistPath = join(plistDir, "ai.openclaw.proxy.plist");
|
const plistPath = join(plistDir, "dev.ocp.proxy.plist");
|
||||||
const logPath = join(logsDir, "proxy.log");
|
const logPath = join(ocpLogsDir, "proxy.log");
|
||||||
|
|
||||||
const plistXml = `<?xml version="1.0" encoding="UTF-8"?>
|
const plistXml = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>ai.openclaw.proxy</string>
|
<string>dev.ocp.proxy</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>${nodeBin}</string>
|
<string>${nodeBin}</string>
|
||||||
@@ -330,27 +357,28 @@ if (!DRY_RUN) {
|
|||||||
writeFileSync(plistPath, plistXml);
|
writeFileSync(plistPath, plistXml);
|
||||||
log(`Plist written: ${plistPath}`);
|
log(`Plist written: ${plistPath}`);
|
||||||
|
|
||||||
// Unload first (in case it was already loaded) then load
|
// Bootout first (in case it was already loaded) then bootstrap
|
||||||
try { execSync(`launchctl unload "${plistPath}" 2>/dev/null`); } catch { /* ignore */ }
|
try { execSync(`launchctl bootout gui/$(id -u) "${plistPath}" 2>/dev/null`); } catch { /* ignore */ }
|
||||||
execSync(`launchctl load "${plistPath}"`);
|
execSync(`launchctl bootstrap gui/$(id -u) "${plistPath}"`);
|
||||||
log(`launchctl loaded ai.openclaw.proxy`);
|
log(`launchctl loaded dev.ocp.proxy`);
|
||||||
|
|
||||||
} else if (platform === "linux") {
|
} else if (platform === "linux") {
|
||||||
// Linux: systemd user service
|
// Linux: systemd user service
|
||||||
const systemdDir = join(HOME, ".config", "systemd", "user");
|
const systemdDir = join(HOME, ".config", "systemd", "user");
|
||||||
if (!existsSync(systemdDir)) mkdirSync(systemdDir, { recursive: true });
|
if (!existsSync(systemdDir)) mkdirSync(systemdDir, { recursive: true });
|
||||||
|
|
||||||
const servicePath = join(systemdDir, "openclaw-proxy.service");
|
const servicePath = join(systemdDir, "ocp-proxy.service");
|
||||||
const logPath = join(logsDir, "proxy.log");
|
const logPath = join(ocpLogsDir, "proxy.log");
|
||||||
|
|
||||||
const serviceUnit = `[Unit]
|
const serviceUnit = `[Unit]
|
||||||
Description=OpenClaw Claude Proxy
|
Description=OCP — Open Claude Proxy
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=${nodeBin} ${serverPath}
|
ExecStart=${nodeBin} ${serverPath}
|
||||||
Environment=CLAUDE_PROXY_PORT=${PORT}
|
Environment=CLAUDE_PROXY_PORT=${PORT}
|
||||||
Restart=always
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
StandardOutput=append:${logPath}
|
StandardOutput=append:${logPath}
|
||||||
StandardError=append:${logPath}
|
StandardError=append:${logPath}
|
||||||
|
|
||||||
@@ -362,8 +390,8 @@ WantedBy=default.target
|
|||||||
log(`Service file written: ${servicePath}`);
|
log(`Service file written: ${servicePath}`);
|
||||||
|
|
||||||
execSync(`systemctl --user daemon-reload`);
|
execSync(`systemctl --user daemon-reload`);
|
||||||
execSync(`systemctl --user enable openclaw-proxy`);
|
execSync(`systemctl --user enable ocp-proxy`);
|
||||||
execSync(`systemctl --user start openclaw-proxy`);
|
execSync(`systemctl --user start ocp-proxy`);
|
||||||
log(`systemd user service enabled and started`);
|
log(`systemd user service enabled and started`);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+35
-23
@@ -3,6 +3,9 @@
|
|||||||
* openclaw-claude-proxy uninstaller
|
* openclaw-claude-proxy uninstaller
|
||||||
*
|
*
|
||||||
* Stops and removes the launchd (macOS) or systemd (Linux) auto-start entry.
|
* Stops and removes the launchd (macOS) or systemd (Linux) auto-start entry.
|
||||||
|
* Handles both legacy (ai.openclaw.proxy / openclaw-proxy) and current
|
||||||
|
* (dev.ocp.proxy / ocp-proxy) service names.
|
||||||
|
*
|
||||||
* Run: node uninstall.mjs
|
* Run: node uninstall.mjs
|
||||||
*/
|
*/
|
||||||
import { existsSync, unlinkSync } from "node:fs";
|
import { existsSync, unlinkSync } from "node:fs";
|
||||||
@@ -15,43 +18,52 @@ const HOME = homedir();
|
|||||||
function log(msg) { console.log(` ✓ ${msg}`); }
|
function log(msg) { console.log(` ✓ ${msg}`); }
|
||||||
function warn(msg) { console.log(` ⚠ ${msg}`); }
|
function warn(msg) { console.log(` ⚠ ${msg}`); }
|
||||||
|
|
||||||
console.log("\n🗑 Uninstalling openclaw-claude-proxy auto-start...\n");
|
console.log("\n🗑 Uninstalling OCP auto-start...\n");
|
||||||
|
|
||||||
const platform = process.platform;
|
const platform = process.platform;
|
||||||
|
|
||||||
if (platform === "darwin") {
|
if (platform === "darwin") {
|
||||||
const plistPath = join(HOME, "Library", "LaunchAgents", "ai.openclaw.proxy.plist");
|
// Remove current service
|
||||||
|
const plistPath = join(HOME, "Library", "LaunchAgents", "dev.ocp.proxy.plist");
|
||||||
if (existsSync(plistPath)) {
|
if (existsSync(plistPath)) {
|
||||||
try {
|
try { execSync(`launchctl bootout gui/$(id -u) "${plistPath}" 2>/dev/null`); } catch { /* ignore */ }
|
||||||
execSync(`launchctl unload "${plistPath}" 2>/dev/null`);
|
|
||||||
log("launchd service stopped and unloaded");
|
|
||||||
} catch {
|
|
||||||
warn("launchctl unload failed (service may not have been running)");
|
|
||||||
}
|
|
||||||
unlinkSync(plistPath);
|
unlinkSync(plistPath);
|
||||||
log(`Plist removed: ${plistPath}`);
|
log(`Removed: ${plistPath}`);
|
||||||
} else {
|
}
|
||||||
warn(`Plist not found: ${plistPath}`);
|
|
||||||
|
// Remove legacy service
|
||||||
|
const legacyPath = join(HOME, "Library", "LaunchAgents", "ai.openclaw.proxy.plist");
|
||||||
|
if (existsSync(legacyPath)) {
|
||||||
|
try { execSync(`launchctl bootout gui/$(id -u) "${legacyPath}" 2>/dev/null`); } catch { /* ignore */ }
|
||||||
|
unlinkSync(legacyPath);
|
||||||
|
log(`Removed legacy: ${legacyPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!existsSync(plistPath) && !existsSync(legacyPath)) {
|
||||||
|
warn("No plist found (service may not have been installed)");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (platform === "linux") {
|
} else if (platform === "linux") {
|
||||||
const servicePath = join(HOME, ".config", "systemd", "user", "openclaw-proxy.service");
|
// Remove current service
|
||||||
|
const servicePath = join(HOME, ".config", "systemd", "user", "ocp-proxy.service");
|
||||||
try { execSync(`systemctl --user stop openclaw-proxy 2>/dev/null`); } catch { /* ignore */ }
|
try { execSync(`systemctl --user stop ocp-proxy 2>/dev/null`); } catch { /* ignore */ }
|
||||||
log("systemd service stopped");
|
try { execSync(`systemctl --user disable ocp-proxy 2>/dev/null`); } catch { /* ignore */ }
|
||||||
|
|
||||||
try { execSync(`systemctl --user disable openclaw-proxy 2>/dev/null`); } catch { /* ignore */ }
|
|
||||||
log("systemd service disabled");
|
|
||||||
|
|
||||||
if (existsSync(servicePath)) {
|
if (existsSync(servicePath)) {
|
||||||
unlinkSync(servicePath);
|
unlinkSync(servicePath);
|
||||||
log(`Service file removed: ${servicePath}`);
|
log(`Removed: ${servicePath}`);
|
||||||
} else {
|
}
|
||||||
warn(`Service file not found: ${servicePath}`);
|
|
||||||
|
// Remove legacy service
|
||||||
|
const legacyPath = join(HOME, ".config", "systemd", "user", "openclaw-proxy.service");
|
||||||
|
try { execSync(`systemctl --user stop openclaw-proxy 2>/dev/null`); } catch { /* ignore */ }
|
||||||
|
try { execSync(`systemctl --user disable openclaw-proxy 2>/dev/null`); } catch { /* ignore */ }
|
||||||
|
if (existsSync(legacyPath)) {
|
||||||
|
unlinkSync(legacyPath);
|
||||||
|
log(`Removed legacy: ${legacyPath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
try { execSync(`systemctl --user daemon-reload`); } catch { /* ignore */ }
|
try { execSync(`systemctl --user daemon-reload`); } catch { /* ignore */ }
|
||||||
|
log("systemd daemon reloaded");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
warn(`Auto-start not supported on ${platform} — nothing to remove`);
|
warn(`Auto-start not supported on ${platform} — nothing to remove`);
|
||||||
|
|||||||
Reference in New Issue
Block a user