feat(openclaw): add workerHost config for Docker deployments

When the OpenClaw gateway runs in Docker and the claude-mem worker runs
on the host, localhost:37777 is unreachable from inside the container.

Add a workerHost config option (default: 127.0.0.1) so users can set it
to host.docker.internal for Docker-based deployments.

Changes:
- Add workerHost to ClaudeMemPluginConfig interface
- Read workerHost from plugin config in plugin entry point
- Update workerBaseUrl to use configurable host
- Add workerHost to openclaw.plugin.json config schema
- Update startup log to show configured host
This commit is contained in:
zengyuzhi
2026-03-25 14:40:33 +08:00
parent e2a230286d
commit fe8c65a8cd
2 changed files with 12 additions and 2 deletions
+5
View File
@@ -27,6 +27,11 @@
"default": 37777, "default": 37777,
"description": "Port for Claude-Mem worker service" "description": "Port for Claude-Mem worker service"
}, },
"workerHost": {
"type": "string",
"default": "127.0.0.1",
"description": "Hostname for Claude-Mem worker service. Set to host.docker.internal when the gateway runs in Docker and the worker runs on the host."
},
"project": { "project": {
"type": "string", "type": "string",
"default": "openclaw", "default": "openclaw",
+7 -2
View File
@@ -183,6 +183,7 @@ interface ClaudeMemPluginConfig {
syncMemoryFileExclude?: string[]; syncMemoryFileExclude?: string[];
project?: string; project?: string;
workerPort?: number; workerPort?: number;
workerHost?: string;
observationFeed?: { observationFeed?: {
enabled?: boolean; enabled?: boolean;
channel?: string; channel?: string;
@@ -198,6 +199,7 @@ interface ClaudeMemPluginConfig {
const MAX_SSE_BUFFER_SIZE = 1024 * 1024; // 1MB const MAX_SSE_BUFFER_SIZE = 1024 * 1024; // 1MB
const DEFAULT_WORKER_PORT = 37777; const DEFAULT_WORKER_PORT = 37777;
const DEFAULT_WORKER_HOST = "127.0.0.1";
// Emoji pool for deterministic auto-assignment to unknown agents. // Emoji pool for deterministic auto-assignment to unknown agents.
// Uses a hash of the agentId to pick a consistent emoji — no persistent state needed. // Uses a hash of the agentId to pick a consistent emoji — no persistent state needed.
@@ -256,8 +258,10 @@ function buildGetSourceLabel(
// Worker HTTP Client // Worker HTTP Client
// ============================================================================ // ============================================================================
let _workerHost = DEFAULT_WORKER_HOST;
function workerBaseUrl(port: number): string { function workerBaseUrl(port: number): string {
return `http://127.0.0.1:${port}`; return `http://${_workerHost}:${port}`;
} }
async function workerPost( async function workerPost(
@@ -533,6 +537,7 @@ async function connectToSSEStream(
export default function claudeMemPlugin(api: OpenClawPluginApi): void { export default function claudeMemPlugin(api: OpenClawPluginApi): void {
const userConfig = (api.pluginConfig || {}) as ClaudeMemPluginConfig; const userConfig = (api.pluginConfig || {}) as ClaudeMemPluginConfig;
const workerPort = userConfig.workerPort || DEFAULT_WORKER_PORT; const workerPort = userConfig.workerPort || DEFAULT_WORKER_PORT;
_workerHost = userConfig.workerHost || DEFAULT_WORKER_HOST;
const baseProjectName = userConfig.project || "openclaw"; const baseProjectName = userConfig.project || "openclaw";
const getSourceLabel = buildGetSourceLabel(userConfig.observationFeed?.emojis); const getSourceLabel = buildGetSourceLabel(userConfig.observationFeed?.emojis);
@@ -1047,5 +1052,5 @@ export default function claudeMemPlugin(api: OpenClawPluginApi): void {
}, },
}); });
api.logger.info(`[claude-mem] OpenClaw plugin loaded — v1.0.0 (worker: 127.0.0.1:${workerPort})`); api.logger.info(`[claude-mem] OpenClaw plugin loaded — v1.0.0 (worker: ${_workerHost}:${workerPort})`);
} }