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,6 +1,6 @@
type CustomEntryLike = { type?: unknown; customType?: unknown; data?: unknown };
export const CACHE_TTL_CUSTOM_TYPE = "moltbot.cache-ttl";
export const CACHE_TTL_CUSTOM_TYPE = "openclaw.cache-ttl";
export type CacheTtlEntryData = {
timestamp: number;

View File

@@ -12,7 +12,7 @@ import { resolveHeartbeatPrompt } from "../../auto-reply/heartbeat.js";
import type { ReasoningLevel, ThinkLevel } from "../../auto-reply/thinking.js";
import { listChannelSupportedActions, resolveChannelMessageToolHints } from "../channel-tools.js";
import { resolveChannelCapabilities } from "../../config/channel-capabilities.js";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { getMachineDisplayName } from "../../infra/machine-name.js";
import { resolveTelegramInlineButtonsScope } from "../../telegram/inline-buttons.js";
import { resolveTelegramReactionLevel } from "../../telegram/reaction-level.js";
@@ -22,14 +22,14 @@ import { normalizeMessageChannel } from "../../utils/message-channel.js";
import { isSubagentSessionKey } from "../../routing/session-key.js";
import { isReasoningTagProvider } from "../../utils/provider-utils.js";
import { resolveUserPath } from "../../utils.js";
import { resolveMoltbotAgentDir } from "../agent-paths.js";
import { resolveOpenClawAgentDir } from "../agent-paths.js";
import { resolveSessionAgentIds } from "../agent-scope.js";
import { makeBootstrapWarn, resolveBootstrapContextForRun } from "../bootstrap-files.js";
import { resolveMoltbotDocsPath } from "../docs-path.js";
import { resolveOpenClawDocsPath } from "../docs-path.js";
import type { ExecElevatedDefaults } from "../bash-tools.js";
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../defaults.js";
import { getApiKeyForModel, resolveModelAuthMode } from "../model-auth.js";
import { ensureMoltbotModelsJson } from "../models-config.js";
import { ensureOpenClawModelsJson } from "../models-config.js";
import {
ensureSessionHeader,
validateAnthropicTurns,
@@ -39,7 +39,7 @@ import {
ensurePiCompactionReserveTokens,
resolveCompactionReserveTokensFloor,
} from "../pi-settings.js";
import { createMoltbotCodingTools } from "../pi-tools.js";
import { createOpenClawCodingTools } from "../pi-tools.js";
import { resolveSandboxContext } from "../sandbox.js";
import { guardSessionManager } from "../session-tool-result-guard-wrapper.js";
import { resolveTranscriptPolicy } from "../transcript-policy.js";
@@ -88,7 +88,7 @@ export type CompactEmbeddedPiSessionParams = {
sessionFile: string;
workspaceDir: string;
agentDir?: string;
config?: MoltbotConfig;
config?: OpenClawConfig;
skillsSnapshot?: SkillSnapshot;
provider?: string;
model?: string;
@@ -114,8 +114,8 @@ export async function compactEmbeddedPiSessionDirect(
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
const agentDir = params.agentDir ?? resolveMoltbotAgentDir();
await ensureMoltbotModelsJson(params.config, agentDir);
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
await ensureOpenClawModelsJson(params.config, agentDir);
const { model, error, authStorage, modelRegistry } = resolveModel(
provider,
modelId,
@@ -211,7 +211,7 @@ export async function compactEmbeddedPiSessionDirect(
warn: makeBootstrapWarn({ sessionLabel, warn: (message) => log.warn(message) }),
});
const runAbortController = new AbortController();
const toolsRaw = createMoltbotCodingTools({
const toolsRaw = createOpenClawCodingTools({
exec: {
...resolveExecToolDefaults(params.config),
elevated: params.bashElevated,
@@ -315,7 +315,7 @@ export async function compactEmbeddedPiSessionDirect(
});
const isDefaultAgent = sessionAgentId === defaultAgentId;
const promptMode = isSubagentSessionKey(params.sessionKey) ? "minimal" : "full";
const docsPath = await resolveMoltbotDocsPath({
const docsPath = await resolveOpenClawDocsPath({
workspaceDir: effectiveWorkspace,
argv1: process.argv[1],
cwd: process.cwd(),

View File

@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
import type { Api, Model } from "@mariozechner/pi-ai";
import type { SessionManager } from "@mariozechner/pi-coding-agent";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { resolveContextWindowInfo } from "../context-window-guard.js";
import { DEFAULT_CONTEXT_TOKENS } from "../defaults.js";
import { setCompactionSafeguardRuntime } from "../pi-extensions/compaction-safeguard-runtime.js";
@@ -23,7 +23,7 @@ function resolvePiExtensionPath(id: string): string {
}
function resolveContextWindowTokens(params: {
cfg: MoltbotConfig | undefined;
cfg: OpenClawConfig | undefined;
provider: string;
modelId: string;
model: Model<Api> | undefined;
@@ -38,7 +38,7 @@ function resolveContextWindowTokens(params: {
}
function buildContextPruningExtension(params: {
cfg: MoltbotConfig | undefined;
cfg: OpenClawConfig | undefined;
sessionManager: SessionManager;
provider: string;
modelId: string;
@@ -63,12 +63,12 @@ function buildContextPruningExtension(params: {
};
}
function resolveCompactionMode(cfg?: MoltbotConfig): "default" | "safeguard" {
function resolveCompactionMode(cfg?: OpenClawConfig): "default" | "safeguard" {
return cfg?.agents?.defaults?.compaction?.mode === "safeguard" ? "safeguard" : "default";
}
export function buildEmbeddedExtensionPaths(params: {
cfg: MoltbotConfig | undefined;
cfg: OpenClawConfig | undefined;
sessionManager: SessionManager;
provider: string;
modelId: string;

View File

@@ -2,7 +2,7 @@ import type { StreamFn } from "@mariozechner/pi-agent-core";
import type { Api, Model, SimpleStreamOptions } from "@mariozechner/pi-ai";
import { streamSimple } from "@mariozechner/pi-ai";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { log } from "./logger.js";
/**
@@ -12,7 +12,7 @@ import { log } from "./logger.js";
* @internal Exported for testing only
*/
export function resolveExtraParams(params: {
cfg: MoltbotConfig | undefined;
cfg: OpenClawConfig | undefined;
provider: string;
modelId: string;
}): Record<string, unknown> | undefined {
@@ -80,7 +80,7 @@ function createStreamFnWithExtraParams(
*/
export function applyExtraParamsToAgent(
agent: { streamFn?: StreamFn },
cfg: MoltbotConfig | undefined,
cfg: OpenClawConfig | undefined,
provider: string,
modelId: string,
extraParamsOverride?: Record<string, unknown>,

View File

@@ -1,6 +1,6 @@
import type { AgentMessage } from "@mariozechner/pi-agent-core";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
const THREAD_SUFFIX_REGEX = /^(.*)(?::(?:thread|topic):\d+)$/i;
@@ -40,7 +40,7 @@ export function limitHistoryTurns(
*/
export function getDmHistoryLimitFromSessionKey(
sessionKey: string | undefined,
config: MoltbotConfig | undefined,
config: OpenClawConfig | undefined,
): number | undefined {
if (!sessionKey || !config) return undefined;
@@ -71,7 +71,7 @@ export function getDmHistoryLimitFromSessionKey(
};
const resolveProviderConfig = (
cfg: MoltbotConfig | undefined,
cfg: OpenClawConfig | undefined,
providerId: string,
): { dmHistoryLimit?: number; dms?: Record<string, { historyLimit?: number }> } | undefined => {
const channels = cfg?.channels;

View File

@@ -5,7 +5,7 @@ vi.mock("@mariozechner/pi-coding-agent", () => ({
discoverModels: vi.fn(() => ({ find: vi.fn(() => null) })),
}));
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { buildInlineProviderModels, resolveModel } from "./model.js";
const makeModel = (id: string) => ({
@@ -119,7 +119,7 @@ describe("resolveModel", () => {
},
},
},
} as MoltbotConfig;
} as OpenClawConfig;
const result = resolveModel("custom", "missing-model", "/tmp/agent", cfg);

View File

@@ -1,9 +1,9 @@
import type { Api, Model } from "@mariozechner/pi-ai";
import { discoverAuthStorage, discoverModels } from "@mariozechner/pi-coding-agent";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import type { ModelDefinitionConfig } from "../../config/types.js";
import { resolveMoltbotAgentDir } from "../agent-paths.js";
import { resolveOpenClawAgentDir } from "../agent-paths.js";
import { DEFAULT_CONTEXT_TOKENS } from "../defaults.js";
import { normalizeModelCompat } from "../model-compat.js";
import { normalizeProviderId } from "../model-selection.js";
@@ -30,7 +30,7 @@ export function buildInlineProviderModels(
});
}
export function buildModelAliasLines(cfg?: MoltbotConfig) {
export function buildModelAliasLines(cfg?: OpenClawConfig) {
const models = cfg?.agents?.defaults?.models ?? {};
const entries: Array<{ alias: string; model: string }> = [];
for (const [keyRaw, entryRaw] of Object.entries(models)) {
@@ -49,14 +49,14 @@ export function resolveModel(
provider: string,
modelId: string,
agentDir?: string,
cfg?: MoltbotConfig,
cfg?: OpenClawConfig,
): {
model?: Model<Api>;
error?: string;
authStorage: ReturnType<typeof discoverAuthStorage>;
modelRegistry: ReturnType<typeof discoverModels>;
} {
const resolvedAgentDir = agentDir ?? resolveMoltbotAgentDir();
const resolvedAgentDir = agentDir ?? resolveOpenClawAgentDir();
const authStorage = discoverAuthStorage(resolvedAgentDir);
const modelRegistry = discoverModels(authStorage, resolvedAgentDir);
const model = modelRegistry.find(provider, modelId) as Model<Api> | null;

View File

@@ -35,7 +35,7 @@ vi.mock("../model-auth.js", () => ({
}));
vi.mock("../models-config.js", () => ({
ensureMoltbotModelsJson: vi.fn(async () => {}),
ensureOpenClawModelsJson: vi.fn(async () => {}),
}));
vi.mock("../context-window-guard.js", () => ({
@@ -66,7 +66,7 @@ vi.mock("../../utils/message-channel.js", () => ({
}));
vi.mock("../agent-paths.js", () => ({
resolveMoltbotAgentDir: vi.fn(() => "/tmp/agent-dir"),
resolveOpenClawAgentDir: vi.fn(() => "/tmp/agent-dir"),
}));
vi.mock("../auth-profiles.js", () => ({

View File

@@ -3,7 +3,7 @@ import type { ThinkLevel } from "../../auto-reply/thinking.js";
import { enqueueCommandInLane } from "../../process/command-queue.js";
import { resolveUserPath } from "../../utils.js";
import { isMarkdownCapableMessageChannel } from "../../utils/message-channel.js";
import { resolveMoltbotAgentDir } from "../agent-paths.js";
import { resolveOpenClawAgentDir } from "../agent-paths.js";
import {
isProfileInCooldown,
markAuthProfileFailure,
@@ -25,7 +25,7 @@ import {
type ResolvedProviderAuth,
} from "../model-auth.js";
import { normalizeProviderId } from "../model-selection.js";
import { ensureMoltbotModelsJson } from "../models-config.js";
import { ensureOpenClawModelsJson } from "../models-config.js";
import {
classifyFailoverReason,
formatAssistantErrorText,
@@ -94,10 +94,10 @@ export async function runEmbeddedPiAgent(
const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
const agentDir = params.agentDir ?? resolveMoltbotAgentDir();
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
const fallbackConfigured =
(params.config?.agents?.defaults?.model?.fallbacks?.length ?? 0) > 0;
await ensureMoltbotModelsJson(params.config, agentDir);
await ensureOpenClawModelsJson(params.config, agentDir);
const { model, error, authStorage, modelRegistry } = resolveModel(
provider,

View File

@@ -22,10 +22,10 @@ import { isSubagentSessionKey } from "../../../routing/session-key.js";
import { resolveUserPath } from "../../../utils.js";
import { createCacheTrace } from "../../cache-trace.js";
import { createAnthropicPayloadLogger } from "../../anthropic-payload-log.js";
import { resolveMoltbotAgentDir } from "../../agent-paths.js";
import { resolveOpenClawAgentDir } from "../../agent-paths.js";
import { resolveSessionAgentIds } from "../../agent-scope.js";
import { makeBootstrapWarn, resolveBootstrapContextForRun } from "../../bootstrap-files.js";
import { resolveMoltbotDocsPath } from "../../docs-path.js";
import { resolveOpenClawDocsPath } from "../../docs-path.js";
import { resolveModelAuthMode } from "../../model-auth.js";
import {
isCloudCodeAssistFormatError,
@@ -38,7 +38,7 @@ import {
ensurePiCompactionReserveTokens,
resolveCompactionReserveTokensFloor,
} from "../../pi-settings.js";
import { createMoltbotCodingTools } from "../../pi-tools.js";
import { createOpenClawCodingTools } from "../../pi-tools.js";
import { resolveSandboxContext } from "../../sandbox.js";
import { guardSessionManager } from "../../session-tool-result-guard-wrapper.js";
import { resolveTranscriptPolicy } from "../../transcript-policy.js";
@@ -195,13 +195,13 @@ export async function runEmbeddedAttempt(
? ["Reminder: commit your changes in this workspace after edits."]
: undefined;
const agentDir = params.agentDir ?? resolveMoltbotAgentDir();
const agentDir = params.agentDir ?? resolveOpenClawAgentDir();
// Check if the model supports native image input
const modelHasVision = params.model.input?.includes("image") ?? false;
const toolsRaw = params.disableTools
? []
: createMoltbotCodingTools({
: createOpenClawCodingTools({
exec: {
...params.execOverrides,
elevated: params.bashElevated,
@@ -326,7 +326,7 @@ export async function runEmbeddedAttempt(
});
const isDefaultAgent = sessionAgentId === defaultAgentId;
const promptMode = isSubagentSessionKey(params.sessionKey) ? "minimal" : "full";
const docsPath = await resolveMoltbotDocsPath({
const docsPath = await resolveOpenClawDocsPath({
workspaceDir: effectiveWorkspace,
argv1: process.argv[1],
cwd: process.cwd(),

View File

@@ -125,8 +125,8 @@ describe("detectImageReferences", () => {
it("detects multiple images in [media attached: ...] format", () => {
// Multi-file format uses separate brackets on separate lines
const prompt = `[media attached: 2 files]
[media attached 1/2: /Users/tyleryust/.clawdbot/media/IMG_6430.jpeg (image/jpeg)]
[media attached 2/2: /Users/tyleryust/.clawdbot/media/IMG_6431.jpeg (image/jpeg)]
[media attached 1/2: /Users/tyleryust/.openclaw/media/IMG_6430.jpeg (image/jpeg)]
[media attached 2/2: /Users/tyleryust/.openclaw/media/IMG_6431.jpeg (image/jpeg)]
what about these images?`;
const refs = detectImageReferences(prompt);
@@ -165,7 +165,7 @@ what is this?`;
it("handles paths with spaces in filename", () => {
// URL after | is https, not a local path, so only the local path should be detected
const prompt = `[media attached: /Users/test/.clawdbot/media/ChatGPT Image Apr 21, 2025.png (image/png) | https://example.com/same.png]
const prompt = `[media attached: /Users/test/.openclaw/media/ChatGPT Image Apr 21, 2025.png (image/png) | https://example.com/same.png]
what is this?`;
const refs = detectImageReferences(prompt);

View File

@@ -1,6 +1,6 @@
import type { ImageContent } from "@mariozechner/pi-ai";
import type { ReasoningLevel, ThinkLevel, VerboseLevel } from "../../../auto-reply/thinking.js";
import type { MoltbotConfig } from "../../../config/config.js";
import type { OpenClawConfig } from "../../../config/config.js";
import type { AgentStreamParams } from "../../../commands/agent/types.js";
import type { enqueueCommand } from "../../../process/command-queue.js";
import type { ExecElevatedDefaults, ExecToolDefaults } from "../../bash-tools.js";
@@ -50,7 +50,7 @@ export type RunEmbeddedPiAgentParams = {
sessionFile: string;
workspaceDir: string;
agentDir?: string;
config?: MoltbotConfig;
config?: OpenClawConfig;
skillsSnapshot?: SkillSnapshot;
prompt: string;
images?: ImageContent[];

View File

@@ -3,7 +3,7 @@ import { parseReplyDirectives } from "../../../auto-reply/reply/reply-directives
import type { ReasoningLevel, VerboseLevel } from "../../../auto-reply/thinking.js";
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../../../auto-reply/tokens.js";
import { formatToolAggregate } from "../../../auto-reply/tool-meta.js";
import type { MoltbotConfig } from "../../../config/config.js";
import type { OpenClawConfig } from "../../../config/config.js";
import {
formatAssistantErrorText,
formatRawAssistantErrorForUi,
@@ -25,7 +25,7 @@ export function buildEmbeddedRunPayloads(params: {
toolMetas: ToolMetaEntry[];
lastAssistant: AssistantMessage | undefined;
lastToolError?: { toolName: string; meta?: string; error?: string };
config?: MoltbotConfig;
config?: OpenClawConfig;
sessionKey: string;
verboseLevel?: VerboseLevel;
reasoningLevel?: ReasoningLevel;

View File

@@ -3,7 +3,7 @@ import type { Api, AssistantMessage, ImageContent, Model } from "@mariozechner/p
import type { discoverAuthStorage, discoverModels } from "@mariozechner/pi-coding-agent";
import type { ReasoningLevel, ThinkLevel, VerboseLevel } from "../../../auto-reply/thinking.js";
import type { MoltbotConfig } from "../../../config/config.js";
import type { OpenClawConfig } from "../../../config/config.js";
import type { AgentStreamParams } from "../../../commands/agent/types.js";
import type { ExecElevatedDefaults, ExecToolDefaults } from "../../bash-tools.js";
import type { MessagingToolSend } from "../../pi-embedded-messaging.js";
@@ -42,7 +42,7 @@ export type EmbeddedRunAttemptParams = {
sessionFile: string;
workspaceDir: string;
agentDir?: string;
config?: MoltbotConfig;
config?: OpenClawConfig;
skillsSnapshot?: SkillSnapshot;
prompt: string;
images?: ImageContent[];

View File

@@ -13,7 +13,7 @@ const DEFAULT_SESSION_MANAGER_TTL_MS = 45_000; // 45 seconds
function getSessionManagerTtl(): number {
return resolveCacheTtlMs({
envValue: process.env.CLAWDBOT_SESSION_MANAGER_CACHE_TTL_MS,
envValue: process.env.OPENCLAW_SESSION_MANAGER_CACHE_TTL_MS,
defaultTtlMs: DEFAULT_SESSION_MANAGER_TTL_MS,
});
}

View File

@@ -1,15 +1,15 @@
import type { ThinkingLevel } from "@mariozechner/pi-agent-core";
import type { ReasoningLevel, ThinkLevel } from "../../auto-reply/thinking.js";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import type { ExecToolDefaults } from "../bash-tools.js";
export function mapThinkingLevel(level?: ThinkLevel): ThinkingLevel {
// pi-agent-core supports "xhigh"; Moltbot enables it for specific models.
// pi-agent-core supports "xhigh"; OpenClaw enables it for specific models.
if (!level) return "off";
return level;
}
export function resolveExecToolDefaults(config?: MoltbotConfig): ExecToolDefaults | undefined {
export function resolveExecToolDefaults(config?: OpenClawConfig): ExecToolDefaults | undefined {
const tools = config?.tools;
if (!tools?.exec) return undefined;
return tools.exec;