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

@@ -2,7 +2,8 @@ import { startBrowserBridgeServer, stopBrowserBridgeServer } from "../../browser
import { type ResolvedBrowserConfig, resolveProfile } from "../../browser/config.js";
import {
DEFAULT_BROWSER_EVALUATE_ENABLED,
DEFAULT_CLAWD_BROWSER_COLOR,
DEFAULT_OPENCLAW_BROWSER_COLOR,
DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME,
} from "../../browser/constants.js";
import { BROWSER_BRIDGES } from "./browser-bridges.js";
import { DEFAULT_SANDBOX_BROWSER_IMAGE, SANDBOX_AGENT_WORKSPACE_MOUNT } from "./constants.js";
@@ -54,14 +55,17 @@ function buildSandboxBrowserResolvedConfig(params: {
cdpIsLoopback: true,
remoteCdpTimeoutMs: 1500,
remoteCdpHandshakeTimeoutMs: 3000,
color: DEFAULT_CLAWD_BROWSER_COLOR,
color: DEFAULT_OPENCLAW_BROWSER_COLOR,
executablePath: undefined,
headless: params.headless,
noSandbox: false,
attachOnly: true,
defaultProfile: "clawd",
defaultProfile: DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME,
profiles: {
clawd: { cdpPort: params.cdpPort, color: DEFAULT_CLAWD_BROWSER_COLOR },
[DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME]: {
cdpPort: params.cdpPort,
color: DEFAULT_OPENCLAW_BROWSER_COLOR,
},
},
};
}
@@ -96,7 +100,7 @@ export async function ensureSandboxBrowser(params: {
name: containerName,
cfg: params.cfg.docker,
scopeKey: params.scopeKey,
labels: { "moltbot.sandboxBrowser": "1" },
labels: { "openclaw.sandboxBrowser": "1" },
});
const mainMountSuffix =
params.cfg.workspaceAccess === "ro" && params.workspaceDir === params.agentWorkspaceDir
@@ -114,11 +118,11 @@ export async function ensureSandboxBrowser(params: {
if (params.cfg.browser.enableNoVnc && !params.cfg.browser.headless) {
args.push("-p", `127.0.0.1::${params.cfg.browser.noVncPort}`);
}
args.push("-e", `CLAWDBOT_BROWSER_HEADLESS=${params.cfg.browser.headless ? "1" : "0"}`);
args.push("-e", `CLAWDBOT_BROWSER_ENABLE_NOVNC=${params.cfg.browser.enableNoVnc ? "1" : "0"}`);
args.push("-e", `CLAWDBOT_BROWSER_CDP_PORT=${params.cfg.browser.cdpPort}`);
args.push("-e", `CLAWDBOT_BROWSER_VNC_PORT=${params.cfg.browser.vncPort}`);
args.push("-e", `CLAWDBOT_BROWSER_NOVNC_PORT=${params.cfg.browser.noVncPort}`);
args.push("-e", `OPENCLAW_BROWSER_HEADLESS=${params.cfg.browser.headless ? "1" : "0"}`);
args.push("-e", `OPENCLAW_BROWSER_ENABLE_NOVNC=${params.cfg.browser.enableNoVnc ? "1" : "0"}`);
args.push("-e", `OPENCLAW_BROWSER_CDP_PORT=${params.cfg.browser.cdpPort}`);
args.push("-e", `OPENCLAW_BROWSER_VNC_PORT=${params.cfg.browser.vncPort}`);
args.push("-e", `OPENCLAW_BROWSER_NOVNC_PORT=${params.cfg.browser.noVncPort}`);
args.push(params.cfg.browser.image);
await execDocker(args);
await execDocker(["start", containerName]);
@@ -137,7 +141,9 @@ export async function ensureSandboxBrowser(params: {
: null;
const existing = BROWSER_BRIDGES.get(params.scopeKey);
const existingProfile = existing ? resolveProfile(existing.bridge.state.resolved, "clawd") : null;
const existingProfile = existing
? resolveProfile(existing.bridge.state.resolved, DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME)
: null;
const shouldReuse =
existing && existing.containerName === containerName && existingProfile?.cdpPort === mappedCdp;
if (existing && !shouldReuse) {

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { resolveAgentConfig } from "../agent-scope.js";
import {
DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS,
@@ -121,7 +121,10 @@ export function resolveSandboxPruneConfig(params: {
};
}
export function resolveSandboxConfigForAgent(cfg?: MoltbotConfig, agentId?: string): SandboxConfig {
export function resolveSandboxConfigForAgent(
cfg?: OpenClawConfig,
agentId?: string,
): SandboxConfig {
const agent = cfg?.agents?.defaults?.sandbox;
// Agent-specific sandbox config overrides global

View File

@@ -4,10 +4,10 @@ import path from "node:path";
import { CHANNEL_IDS } from "../../channels/registry.js";
import { STATE_DIR } from "../../config/config.js";
export const DEFAULT_SANDBOX_WORKSPACE_ROOT = path.join(os.homedir(), ".clawdbot", "sandboxes");
export const DEFAULT_SANDBOX_WORKSPACE_ROOT = path.join(os.homedir(), ".openclaw", "sandboxes");
export const DEFAULT_SANDBOX_IMAGE = "moltbot-sandbox:bookworm-slim";
export const DEFAULT_SANDBOX_CONTAINER_PREFIX = "moltbot-sbx-";
export const DEFAULT_SANDBOX_IMAGE = "openclaw-sandbox:bookworm-slim";
export const DEFAULT_SANDBOX_CONTAINER_PREFIX = "openclaw-sbx-";
export const DEFAULT_SANDBOX_WORKDIR = "/workspace";
export const DEFAULT_SANDBOX_IDLE_HOURS = 24;
export const DEFAULT_SANDBOX_MAX_AGE_DAYS = 7;
@@ -37,10 +37,10 @@ export const DEFAULT_TOOL_DENY = [
...CHANNEL_IDS,
] as const;
export const DEFAULT_SANDBOX_BROWSER_IMAGE = "moltbot-sandbox-browser:bookworm-slim";
export const DEFAULT_SANDBOX_COMMON_IMAGE = "moltbot-sandbox-common:bookworm-slim";
export const DEFAULT_SANDBOX_BROWSER_IMAGE = "openclaw-sandbox-browser:bookworm-slim";
export const DEFAULT_SANDBOX_COMMON_IMAGE = "openclaw-sandbox-common:bookworm-slim";
export const DEFAULT_SANDBOX_BROWSER_PREFIX = "moltbot-sbx-browser-";
export const DEFAULT_SANDBOX_BROWSER_PREFIX = "openclaw-sbx-browser-";
export const DEFAULT_SANDBOX_BROWSER_CDP_PORT = 9222;
export const DEFAULT_SANDBOX_BROWSER_VNC_PORT = 5900;
export const DEFAULT_SANDBOX_BROWSER_NOVNC_PORT = 6080;
@@ -48,7 +48,7 @@ export const DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS = 12_000;
export const SANDBOX_AGENT_WORKSPACE_MOUNT = "/agent";
const resolvedSandboxStateDir = STATE_DIR ?? path.join(os.homedir(), ".clawdbot");
const resolvedSandboxStateDir = STATE_DIR ?? path.join(os.homedir(), ".openclaw");
export const SANDBOX_STATE_DIR = path.join(resolvedSandboxStateDir, "sandbox");
export const SANDBOX_REGISTRY_PATH = path.join(SANDBOX_STATE_DIR, "containers.json");
export const SANDBOX_BROWSER_REGISTRY_PATH = path.join(SANDBOX_STATE_DIR, "browsers.json");

View File

@@ -1,6 +1,6 @@
import fs from "node:fs/promises";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { defaultRuntime } from "../../runtime.js";
import { resolveUserPath } from "../../utils.js";
import { DEFAULT_BROWSER_EVALUATE_ENABLED } from "../../browser/constants.js";
@@ -16,7 +16,7 @@ import type { SandboxContext, SandboxWorkspaceInfo } from "./types.js";
import { ensureSandboxWorkspace } from "./workspace.js";
export async function resolveSandboxContext(params: {
config?: MoltbotConfig;
config?: OpenClawConfig;
sessionKey?: string;
workspaceDir?: string;
}): Promise<SandboxContext | null> {
@@ -96,7 +96,7 @@ export async function resolveSandboxContext(params: {
}
export async function ensureSandboxWorkspaceForSession(params: {
config?: MoltbotConfig;
config?: OpenClawConfig;
sessionKey?: string;
workspaceDir?: string;
}): Promise<SandboxWorkspaceInfo | null> {

View File

@@ -113,11 +113,11 @@ export function buildSandboxCreateArgs(params: {
}) {
const createdAtMs = params.createdAtMs ?? Date.now();
const args = ["create", "--name", params.name];
args.push("--label", "moltbot.sandbox=1");
args.push("--label", `moltbot.sessionKey=${params.scopeKey}`);
args.push("--label", `moltbot.createdAtMs=${createdAtMs}`);
args.push("--label", "openclaw.sandbox=1");
args.push("--label", `openclaw.sessionKey=${params.scopeKey}`);
args.push("--label", `openclaw.createdAtMs=${createdAtMs}`);
if (params.configHash) {
args.push("--label", `moltbot.configHash=${params.configHash}`);
args.push("--label", `openclaw.configHash=${params.configHash}`);
}
for (const [key, value] of Object.entries(params.labels ?? {})) {
if (key && value) args.push("--label", `${key}=${value}`);
@@ -208,25 +208,28 @@ async function createSandboxContainer(params: {
}
async function readContainerConfigHash(containerName: string): Promise<string | null> {
const result = await execDocker(
["inspect", "-f", '{{ index .Config.Labels "moltbot.configHash" }}', containerName],
{ allowFailure: true },
);
if (result.code !== 0) return null;
const raw = result.stdout.trim();
if (!raw || raw === "<no value>") return null;
return raw;
const readLabel = async (label: string) => {
const result = await execDocker(
["inspect", "-f", `{{ index .Config.Labels "${label}" }}`, containerName],
{ allowFailure: true },
);
if (result.code !== 0) return null;
const raw = result.stdout.trim();
if (!raw || raw === "<no value>") return null;
return raw;
};
return await readLabel("openclaw.configHash");
}
function formatSandboxRecreateHint(params: { scope: SandboxConfig["scope"]; sessionKey: string }) {
if (params.scope === "session") {
return formatCliCommand(`moltbot sandbox recreate --session ${params.sessionKey}`);
return formatCliCommand(`openclaw sandbox recreate --session ${params.sessionKey}`);
}
if (params.scope === "agent") {
const agentId = resolveSandboxAgentId(params.sessionKey) ?? "main";
return formatCliCommand(`moltbot sandbox recreate --agent ${agentId}`);
return formatCliCommand(`openclaw sandbox recreate --agent ${agentId}`);
}
return formatCliCommand("moltbot sandbox recreate --all");
return formatCliCommand("openclaw sandbox recreate --all");
}
export async function ensureSandboxContainer(params: {

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { canonicalizeMainSessionAlias, resolveAgentMainSessionKey } from "../../config/sessions.js";
import { resolveSessionAgentId } from "../agent-scope.js";
import { expandToolGroups } from "../tool-policy.js";
@@ -13,7 +13,10 @@ function shouldSandboxSession(cfg: SandboxConfig, sessionKey: string, mainSessio
return sessionKey.trim() !== mainSessionKey.trim();
}
function resolveMainSessionKeyForSandbox(params: { cfg?: MoltbotConfig; agentId: string }): string {
function resolveMainSessionKeyForSandbox(params: {
cfg?: OpenClawConfig;
agentId: string;
}): string {
if (params.cfg?.session?.scope === "global") return "global";
return resolveAgentMainSessionKey({
cfg: params.cfg,
@@ -22,7 +25,7 @@ function resolveMainSessionKeyForSandbox(params: { cfg?: MoltbotConfig; agentId:
}
function resolveComparableSessionKeyForSandbox(params: {
cfg?: MoltbotConfig;
cfg?: OpenClawConfig;
agentId: string;
sessionKey: string;
}): string {
@@ -33,7 +36,10 @@ function resolveComparableSessionKeyForSandbox(params: {
});
}
export function resolveSandboxRuntimeStatus(params: { cfg?: MoltbotConfig; sessionKey?: string }): {
export function resolveSandboxRuntimeStatus(params: {
cfg?: OpenClawConfig;
sessionKey?: string;
}): {
agentId: string;
sessionKey: string;
mainSessionKey: string;
@@ -67,7 +73,7 @@ export function resolveSandboxRuntimeStatus(params: { cfg?: MoltbotConfig; sessi
}
export function formatSandboxToolPolicyBlockedMessage(params: {
cfg?: MoltbotConfig;
cfg?: OpenClawConfig;
sessionKey?: string;
toolName: string;
}): string | undefined {
@@ -111,7 +117,7 @@ export function formatSandboxToolPolicyBlockedMessage(params: {
lines.push(`- Use main session key (direct): ${runtime.mainSessionKey}`);
}
lines.push(
`- See: ${formatCliCommand(`moltbot sandbox explain --session ${runtime.sessionKey}`)}`,
`- See: ${formatCliCommand(`openclaw sandbox explain --session ${runtime.sessionKey}`)}`,
);
return lines.join("\n");

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { resolveAgentConfig } from "../agent-scope.js";
import { expandToolGroups } from "../tool-policy.js";
import { DEFAULT_TOOL_ALLOW, DEFAULT_TOOL_DENY } from "./constants.js";
@@ -51,7 +51,7 @@ export function isToolAllowed(policy: SandboxToolPolicy, name: string) {
}
export function resolveSandboxToolPolicyForAgent(
cfg?: MoltbotConfig,
cfg?: OpenClawConfig,
agentId?: string,
): SandboxToolPolicyResolved {
const agentConfig = cfg && agentId ? resolveAgentConfig(cfg, agentId) : undefined;