mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 21:01:43 +03:00
refactor: rename to openclaw
This commit is contained in:
@@ -26,9 +26,21 @@ function resolveMode(input: string): "off" | "serve" | "funnel" {
|
||||
}
|
||||
|
||||
function resolveDefaultStorePath(config: VoiceCallConfig): string {
|
||||
const base =
|
||||
config.store?.trim() || path.join(os.homedir(), "clawd", "voice-calls");
|
||||
return path.join(resolveUserPath(base), "calls.jsonl");
|
||||
const preferred = path.join(os.homedir(), ".openclaw", "voice-calls");
|
||||
const resolvedPreferred = resolveUserPath(preferred);
|
||||
const existing =
|
||||
[resolvedPreferred].find((dir) => {
|
||||
try {
|
||||
return (
|
||||
fs.existsSync(path.join(dir, "calls.jsonl")) ||
|
||||
fs.existsSync(dir)
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}) ?? resolvedPreferred;
|
||||
const base = config.store?.trim() ? resolveUserPath(config.store) : existing;
|
||||
return path.join(base, "calls.jsonl");
|
||||
}
|
||||
|
||||
function sleep(ms: number): Promise<void> {
|
||||
@@ -45,7 +57,7 @@ export function registerVoiceCallCli(params: {
|
||||
const root = program
|
||||
.command("voicecall")
|
||||
.description("Voice call utilities")
|
||||
.addHelpText("after", () => `\nDocs: https://docs.molt.bot/cli/voicecall\n`);
|
||||
.addHelpText("after", () => `\nDocs: https://docs.openclaw.ai/cli/voicecall\n`);
|
||||
|
||||
root
|
||||
.command("call")
|
||||
|
||||
@@ -86,9 +86,9 @@ function findPackageRoot(startDir: string, name: string): string | null {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveMoltbotRoot(): string {
|
||||
function resolveOpenClawRoot(): string {
|
||||
if (coreRootCache) return coreRootCache;
|
||||
const override = process.env.MOLTBOT_ROOT?.trim() || process.env.CLAWDBOT_ROOT?.trim();
|
||||
const override = process.env.OPENCLAW_ROOT?.trim();
|
||||
if (override) {
|
||||
coreRootCache = override;
|
||||
return override;
|
||||
@@ -107,7 +107,7 @@ function resolveMoltbotRoot(): string {
|
||||
}
|
||||
|
||||
for (const start of candidates) {
|
||||
for (const name of ["moltbot", "moltbot"]) {
|
||||
for (const name of ["openclaw"]) {
|
||||
const found = findPackageRoot(start, name);
|
||||
if (found) {
|
||||
coreRootCache = found;
|
||||
@@ -117,12 +117,12 @@ function resolveMoltbotRoot(): string {
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Unable to resolve core root. Set MOLTBOT_ROOT (or legacy CLAWDBOT_ROOT) to the package root.",
|
||||
"Unable to resolve core root. Set OPENCLAW_ROOT to the package root.",
|
||||
);
|
||||
}
|
||||
|
||||
async function importCoreModule<T>(relativePath: string): Promise<T> {
|
||||
const root = resolveMoltbotRoot();
|
||||
const root = resolveOpenClawRoot();
|
||||
const distPath = path.join(root, "dist", relativePath);
|
||||
if (!fs.existsSync(distPath)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -47,7 +47,7 @@ describe("CallManager", () => {
|
||||
fromNumber: "+15550000000",
|
||||
});
|
||||
|
||||
const storePath = path.join(os.tmpdir(), `moltbot-voice-call-test-${Date.now()}`);
|
||||
const storePath = path.join(os.tmpdir(), `openclaw-voice-call-test-${Date.now()}`);
|
||||
const manager = new CallManager(config, storePath);
|
||||
manager.initialize(new FakeProvider(), "https://example.com/voice/webhook");
|
||||
|
||||
@@ -80,7 +80,7 @@ describe("CallManager", () => {
|
||||
fromNumber: "+15550000000",
|
||||
});
|
||||
|
||||
const storePath = path.join(os.tmpdir(), `moltbot-voice-call-test-${Date.now()}`);
|
||||
const storePath = path.join(os.tmpdir(), `openclaw-voice-call-test-${Date.now()}`);
|
||||
const provider = new FakeProvider();
|
||||
const manager = new CallManager(config, storePath);
|
||||
manager.initialize(provider, "https://example.com/voice/webhook");
|
||||
|
||||
@@ -19,6 +19,22 @@ import {
|
||||
} from "./types.js";
|
||||
import { escapeXml, mapVoiceToPolly } from "./voice-mapping.js";
|
||||
|
||||
function resolveDefaultStoreBase(config: VoiceCallConfig, storePath?: string): string {
|
||||
const rawOverride = storePath?.trim() || config.store?.trim();
|
||||
if (rawOverride) return resolveUserPath(rawOverride);
|
||||
const preferred = path.join(os.homedir(), ".openclaw", "voice-calls");
|
||||
const candidates = [preferred].map((dir) => resolveUserPath(dir));
|
||||
const existing =
|
||||
candidates.find((dir) => {
|
||||
try {
|
||||
return fs.existsSync(path.join(dir, "calls.jsonl")) || fs.existsSync(dir);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}) ?? resolveUserPath(preferred);
|
||||
return existing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages voice calls: state machine, persistence, and provider coordination.
|
||||
*/
|
||||
@@ -44,11 +60,7 @@ export class CallManager {
|
||||
constructor(config: VoiceCallConfig, storePath?: string) {
|
||||
this.config = config;
|
||||
// Resolve store path with tilde expansion (like other config values)
|
||||
const rawPath =
|
||||
storePath ||
|
||||
config.store ||
|
||||
path.join(os.homedir(), "clawd", "voice-calls");
|
||||
this.storePath = resolveUserPath(rawPath);
|
||||
this.storePath = resolveDefaultStoreBase(config, storePath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { VoiceCallConfig } from "./config.js";
|
||||
export type VoiceResponseParams = {
|
||||
/** Voice call config */
|
||||
voiceConfig: VoiceCallConfig;
|
||||
/** Core Moltbot config */
|
||||
/** Core OpenClaw config */
|
||||
coreConfig: CoreConfig;
|
||||
/** Call ID for session tracking */
|
||||
callId: string;
|
||||
|
||||
Reference in New Issue
Block a user