openclaw/extensions/memory-claudemem/config.ts
Alex Newman 346cef2488 feat(memory-claudemem): scaffold plugin structure
Create extensions/memory-claudemem with:
- package.json with workspace references
- clawdbot.plugin.json manifest
- types.ts, config.ts, client.ts (stubs), index.ts

Part of claude-mem integration (Phase 2/7).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 14:04:28 -05:00

50 lines
1.4 KiB
TypeScript

export type ClaudeMemConfig = {
workerUrl: string;
workerTimeout: number;
};
const DEFAULT_WORKER_URL = "http://localhost:37777";
const DEFAULT_TIMEOUT = 10000;
function assertAllowedKeys(
value: Record<string, unknown>,
allowed: string[],
label: string,
) {
const unknown = Object.keys(value).filter((key) => !allowed.includes(key));
if (unknown.length === 0) return;
throw new Error(`${label} has unknown keys: ${unknown.join(", ")}`);
}
export const claudeMemConfigSchema = {
parse(value: unknown): ClaudeMemConfig {
if (!value || typeof value !== "object" || Array.isArray(value)) {
// Return defaults if no config provided
return {
workerUrl: DEFAULT_WORKER_URL,
workerTimeout: DEFAULT_TIMEOUT,
};
}
const cfg = value as Record<string, unknown>;
assertAllowedKeys(cfg, ["workerUrl", "workerTimeout"], "claude-mem config");
return {
workerUrl: typeof cfg.workerUrl === "string" ? cfg.workerUrl : DEFAULT_WORKER_URL,
workerTimeout: typeof cfg.workerTimeout === "number" ? cfg.workerTimeout : DEFAULT_TIMEOUT,
};
},
uiHints: {
workerUrl: {
label: "Worker URL",
placeholder: DEFAULT_WORKER_URL,
help: "URL of the claude-mem worker",
},
workerTimeout: {
label: "Timeout (ms)",
placeholder: String(DEFAULT_TIMEOUT),
advanced: true,
help: "Request timeout in milliseconds",
},
},
};