refactor: rename to openclaw

This commit is contained in:
Peter Steinberger
2026-01-30 03:15:10 +01:00
parent 4583f88626
commit 9a7160786a
2357 changed files with 16688 additions and 16788 deletions

View File

@@ -1,7 +1,7 @@
import os from "node:os";
import path from "node:path";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveStateDir } from "../config/paths.js";
import {
DEFAULT_AGENT_ID,
@@ -13,7 +13,7 @@ import { DEFAULT_AGENT_WORKSPACE_DIR } from "./workspace.js";
export { resolveAgentIdFromSessionKey } from "../routing/session-key.js";
type AgentEntry = NonNullable<NonNullable<MoltbotConfig["agents"]>["list"]>[number];
type AgentEntry = NonNullable<NonNullable<OpenClawConfig["agents"]>["list"]>[number];
type ResolvedAgentConfig = {
name?: string;
@@ -32,13 +32,13 @@ type ResolvedAgentConfig = {
let defaultAgentWarned = false;
function listAgents(cfg: MoltbotConfig): AgentEntry[] {
function listAgents(cfg: OpenClawConfig): AgentEntry[] {
const list = cfg.agents?.list;
if (!Array.isArray(list)) return [];
return list.filter((entry): entry is AgentEntry => Boolean(entry && typeof entry === "object"));
}
export function listAgentIds(cfg: MoltbotConfig): string[] {
export function listAgentIds(cfg: OpenClawConfig): string[] {
const agents = listAgents(cfg);
if (agents.length === 0) return [DEFAULT_AGENT_ID];
const seen = new Set<string>();
@@ -52,7 +52,7 @@ export function listAgentIds(cfg: MoltbotConfig): string[] {
return ids.length > 0 ? ids : [DEFAULT_AGENT_ID];
}
export function resolveDefaultAgentId(cfg: MoltbotConfig): string {
export function resolveDefaultAgentId(cfg: OpenClawConfig): string {
const agents = listAgents(cfg);
if (agents.length === 0) return DEFAULT_AGENT_ID;
const defaults = agents.filter((agent) => agent?.default);
@@ -64,7 +64,7 @@ export function resolveDefaultAgentId(cfg: MoltbotConfig): string {
return normalizeAgentId(chosen || DEFAULT_AGENT_ID);
}
export function resolveSessionAgentIds(params: { sessionKey?: string; config?: MoltbotConfig }): {
export function resolveSessionAgentIds(params: { sessionKey?: string; config?: OpenClawConfig }): {
defaultAgentId: string;
sessionAgentId: string;
} {
@@ -78,18 +78,18 @@ export function resolveSessionAgentIds(params: { sessionKey?: string; config?: M
export function resolveSessionAgentId(params: {
sessionKey?: string;
config?: MoltbotConfig;
config?: OpenClawConfig;
}): string {
return resolveSessionAgentIds(params).sessionAgentId;
}
function resolveAgentEntry(cfg: MoltbotConfig, agentId: string): AgentEntry | undefined {
function resolveAgentEntry(cfg: OpenClawConfig, agentId: string): AgentEntry | undefined {
const id = normalizeAgentId(agentId);
return listAgents(cfg).find((entry) => normalizeAgentId(entry.id) === id);
}
export function resolveAgentConfig(
cfg: MoltbotConfig,
cfg: OpenClawConfig,
agentId: string,
): ResolvedAgentConfig | undefined {
const id = normalizeAgentId(agentId);
@@ -114,7 +114,7 @@ export function resolveAgentConfig(
};
}
export function resolveAgentModelPrimary(cfg: MoltbotConfig, agentId: string): string | undefined {
export function resolveAgentModelPrimary(cfg: OpenClawConfig, agentId: string): string | undefined {
const raw = resolveAgentConfig(cfg, agentId)?.model;
if (!raw) return undefined;
if (typeof raw === "string") return raw.trim() || undefined;
@@ -123,7 +123,7 @@ export function resolveAgentModelPrimary(cfg: MoltbotConfig, agentId: string): s
}
export function resolveAgentModelFallbacksOverride(
cfg: MoltbotConfig,
cfg: OpenClawConfig,
agentId: string,
): string[] | undefined {
const raw = resolveAgentConfig(cfg, agentId)?.model;
@@ -133,7 +133,7 @@ export function resolveAgentModelFallbacksOverride(
return Array.isArray(raw.fallbacks) ? raw.fallbacks : undefined;
}
export function resolveAgentWorkspaceDir(cfg: MoltbotConfig, agentId: string) {
export function resolveAgentWorkspaceDir(cfg: OpenClawConfig, agentId: string) {
const id = normalizeAgentId(agentId);
const configured = resolveAgentConfig(cfg, id)?.workspace?.trim();
if (configured) return resolveUserPath(configured);
@@ -143,10 +143,10 @@ export function resolveAgentWorkspaceDir(cfg: MoltbotConfig, agentId: string) {
if (fallback) return resolveUserPath(fallback);
return DEFAULT_AGENT_WORKSPACE_DIR;
}
return path.join(os.homedir(), `clawd-${id}`);
return path.join(os.homedir(), ".openclaw", `workspace-${id}`);
}
export function resolveAgentDir(cfg: MoltbotConfig, agentId: string) {
export function resolveAgentDir(cfg: OpenClawConfig, agentId: string) {
const id = normalizeAgentId(agentId);
const configured = resolveAgentConfig(cfg, id)?.agentDir?.trim();
if (configured) return resolveUserPath(configured);