mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 23:21:23 +00:00
refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -96,7 +96,7 @@ export async function ensureSandboxBrowser(params: {
|
||||
name: containerName,
|
||||
cfg: params.cfg.docker,
|
||||
scopeKey: params.scopeKey,
|
||||
labels: { "clawdbot.sandboxBrowser": "1" },
|
||||
labels: { "moltbot.sandboxBrowser": "1" },
|
||||
});
|
||||
const mainMountSuffix =
|
||||
params.cfg.workspaceAccess === "ro" && params.workspaceDir === params.agentWorkspaceDir
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import { resolveAgentConfig } from "../agent-scope.js";
|
||||
import {
|
||||
DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS,
|
||||
@@ -121,10 +121,7 @@ export function resolveSandboxPruneConfig(params: {
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveSandboxConfigForAgent(
|
||||
cfg?: ClawdbotConfig,
|
||||
agentId?: string,
|
||||
): SandboxConfig {
|
||||
export function resolveSandboxConfigForAgent(cfg?: MoltbotConfig, agentId?: string): SandboxConfig {
|
||||
const agent = cfg?.agents?.defaults?.sandbox;
|
||||
|
||||
// Agent-specific sandbox config overrides global
|
||||
|
||||
@@ -2,12 +2,12 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { CHANNEL_IDS } from "../../channels/registry.js";
|
||||
import { STATE_DIR_CLAWDBOT } from "../../config/config.js";
|
||||
import { STATE_DIR } from "../../config/config.js";
|
||||
|
||||
export const DEFAULT_SANDBOX_WORKSPACE_ROOT = path.join(os.homedir(), ".clawdbot", "sandboxes");
|
||||
|
||||
export const DEFAULT_SANDBOX_IMAGE = "clawdbot-sandbox:bookworm-slim";
|
||||
export const DEFAULT_SANDBOX_CONTAINER_PREFIX = "clawdbot-sbx-";
|
||||
export const DEFAULT_SANDBOX_IMAGE = "moltbot-sandbox:bookworm-slim";
|
||||
export const DEFAULT_SANDBOX_CONTAINER_PREFIX = "moltbot-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 = "clawdbot-sandbox-browser:bookworm-slim";
|
||||
export const DEFAULT_SANDBOX_COMMON_IMAGE = "clawdbot-sandbox-common:bookworm-slim";
|
||||
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_PREFIX = "clawdbot-sbx-browser-";
|
||||
export const DEFAULT_SANDBOX_BROWSER_PREFIX = "moltbot-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_CLAWDBOT ?? path.join(os.homedir(), ".clawdbot");
|
||||
const resolvedSandboxStateDir = STATE_DIR ?? path.join(os.homedir(), ".clawdbot");
|
||||
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");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from "node:fs/promises";
|
||||
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import type { MoltbotConfig } 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?: ClawdbotConfig;
|
||||
config?: MoltbotConfig;
|
||||
sessionKey?: string;
|
||||
workspaceDir?: string;
|
||||
}): Promise<SandboxContext | null> {
|
||||
@@ -96,7 +96,7 @@ export async function resolveSandboxContext(params: {
|
||||
}
|
||||
|
||||
export async function ensureSandboxWorkspaceForSession(params: {
|
||||
config?: ClawdbotConfig;
|
||||
config?: MoltbotConfig;
|
||||
sessionKey?: string;
|
||||
workspaceDir?: string;
|
||||
}): Promise<SandboxWorkspaceInfo | null> {
|
||||
|
||||
@@ -113,11 +113,11 @@ export function buildSandboxCreateArgs(params: {
|
||||
}) {
|
||||
const createdAtMs = params.createdAtMs ?? Date.now();
|
||||
const args = ["create", "--name", params.name];
|
||||
args.push("--label", "clawdbot.sandbox=1");
|
||||
args.push("--label", `clawdbot.sessionKey=${params.scopeKey}`);
|
||||
args.push("--label", `clawdbot.createdAtMs=${createdAtMs}`);
|
||||
args.push("--label", "moltbot.sandbox=1");
|
||||
args.push("--label", `moltbot.sessionKey=${params.scopeKey}`);
|
||||
args.push("--label", `moltbot.createdAtMs=${createdAtMs}`);
|
||||
if (params.configHash) {
|
||||
args.push("--label", `clawdbot.configHash=${params.configHash}`);
|
||||
args.push("--label", `moltbot.configHash=${params.configHash}`);
|
||||
}
|
||||
for (const [key, value] of Object.entries(params.labels ?? {})) {
|
||||
if (key && value) args.push("--label", `${key}=${value}`);
|
||||
@@ -209,7 +209,7 @@ async function createSandboxContainer(params: {
|
||||
|
||||
async function readContainerConfigHash(containerName: string): Promise<string | null> {
|
||||
const result = await execDocker(
|
||||
["inspect", "-f", '{{ index .Config.Labels "clawdbot.configHash" }}', containerName],
|
||||
["inspect", "-f", '{{ index .Config.Labels "moltbot.configHash" }}', containerName],
|
||||
{ allowFailure: true },
|
||||
);
|
||||
if (result.code !== 0) return null;
|
||||
@@ -220,13 +220,13 @@ async function readContainerConfigHash(containerName: string): Promise<string |
|
||||
|
||||
function formatSandboxRecreateHint(params: { scope: SandboxConfig["scope"]; sessionKey: string }) {
|
||||
if (params.scope === "session") {
|
||||
return formatCliCommand(`clawdbot sandbox recreate --session ${params.sessionKey}`);
|
||||
return formatCliCommand(`moltbot sandbox recreate --session ${params.sessionKey}`);
|
||||
}
|
||||
if (params.scope === "agent") {
|
||||
const agentId = resolveSandboxAgentId(params.sessionKey) ?? "main";
|
||||
return formatCliCommand(`clawdbot sandbox recreate --agent ${agentId}`);
|
||||
return formatCliCommand(`moltbot sandbox recreate --agent ${agentId}`);
|
||||
}
|
||||
return formatCliCommand("clawdbot sandbox recreate --all");
|
||||
return formatCliCommand("moltbot sandbox recreate --all");
|
||||
}
|
||||
|
||||
export async function ensureSandboxContainer(params: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import { canonicalizeMainSessionAlias, resolveAgentMainSessionKey } from "../../config/sessions.js";
|
||||
import { resolveSessionAgentId } from "../agent-scope.js";
|
||||
import { expandToolGroups } from "../tool-policy.js";
|
||||
@@ -13,10 +13,7 @@ function shouldSandboxSession(cfg: SandboxConfig, sessionKey: string, mainSessio
|
||||
return sessionKey.trim() !== mainSessionKey.trim();
|
||||
}
|
||||
|
||||
function resolveMainSessionKeyForSandbox(params: {
|
||||
cfg?: ClawdbotConfig;
|
||||
agentId: string;
|
||||
}): string {
|
||||
function resolveMainSessionKeyForSandbox(params: { cfg?: MoltbotConfig; agentId: string }): string {
|
||||
if (params.cfg?.session?.scope === "global") return "global";
|
||||
return resolveAgentMainSessionKey({
|
||||
cfg: params.cfg,
|
||||
@@ -25,7 +22,7 @@ function resolveMainSessionKeyForSandbox(params: {
|
||||
}
|
||||
|
||||
function resolveComparableSessionKeyForSandbox(params: {
|
||||
cfg?: ClawdbotConfig;
|
||||
cfg?: MoltbotConfig;
|
||||
agentId: string;
|
||||
sessionKey: string;
|
||||
}): string {
|
||||
@@ -36,10 +33,7 @@ function resolveComparableSessionKeyForSandbox(params: {
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveSandboxRuntimeStatus(params: {
|
||||
cfg?: ClawdbotConfig;
|
||||
sessionKey?: string;
|
||||
}): {
|
||||
export function resolveSandboxRuntimeStatus(params: { cfg?: MoltbotConfig; sessionKey?: string }): {
|
||||
agentId: string;
|
||||
sessionKey: string;
|
||||
mainSessionKey: string;
|
||||
@@ -73,7 +67,7 @@ export function resolveSandboxRuntimeStatus(params: {
|
||||
}
|
||||
|
||||
export function formatSandboxToolPolicyBlockedMessage(params: {
|
||||
cfg?: ClawdbotConfig;
|
||||
cfg?: MoltbotConfig;
|
||||
sessionKey?: string;
|
||||
toolName: string;
|
||||
}): string | undefined {
|
||||
@@ -117,7 +111,7 @@ export function formatSandboxToolPolicyBlockedMessage(params: {
|
||||
lines.push(`- Use main session key (direct): ${runtime.mainSessionKey}`);
|
||||
}
|
||||
lines.push(
|
||||
`- See: ${formatCliCommand(`clawdbot sandbox explain --session ${runtime.sessionKey}`)}`,
|
||||
`- See: ${formatCliCommand(`moltbot sandbox explain --session ${runtime.sessionKey}`)}`,
|
||||
);
|
||||
|
||||
return lines.join("\n");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import type { MoltbotConfig } 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?: ClawdbotConfig,
|
||||
cfg?: MoltbotConfig,
|
||||
agentId?: string,
|
||||
): SandboxToolPolicyResolved {
|
||||
const agentConfig = cfg && agentId ? resolveAgentConfig(cfg, agentId) : undefined;
|
||||
|
||||
Reference in New Issue
Block a user