mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 21:54:32 +00:00
refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -7,7 +7,7 @@ import path from "node:path";
|
||||
import type { Api, Model } from "@mariozechner/pi-ai";
|
||||
import { discoverAuthStorage, discoverModels } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, it } from "vitest";
|
||||
import { resolveClawdbotAgentDir } from "../agents/agent-paths.js";
|
||||
import { resolveMoltbotAgentDir } from "../agents/agent-paths.js";
|
||||
import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js";
|
||||
import {
|
||||
type AuthProfileStore,
|
||||
@@ -21,9 +21,9 @@ import {
|
||||
} from "../agents/live-auth-keys.js";
|
||||
import { isModernModelRef } from "../agents/live-model-filter.js";
|
||||
import { getApiKeyForModel } from "../agents/model-auth.js";
|
||||
import { ensureClawdbotModelsJson } from "../agents/models-config.js";
|
||||
import { ensureMoltbotModelsJson } from "../agents/models-config.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import type { ClawdbotConfig, ModelProviderConfig } from "../config/types.js";
|
||||
import type { MoltbotConfig, ModelProviderConfig } from "../config/types.js";
|
||||
import { isTruthyEnvValue } from "../infra/env.js";
|
||||
import { DEFAULT_AGENT_ID } from "../routing/session-key.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
@@ -331,7 +331,7 @@ async function connectClient(params: { url: string; token: string }) {
|
||||
|
||||
type GatewayModelSuiteParams = {
|
||||
label: string;
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
candidates: Array<Model<Api>>;
|
||||
extraToolProbes: boolean;
|
||||
extraImageProbes: boolean;
|
||||
@@ -340,10 +340,10 @@ type GatewayModelSuiteParams = {
|
||||
};
|
||||
|
||||
function buildLiveGatewayConfig(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
candidates: Array<Model<Api>>;
|
||||
providerOverrides?: Record<string, ModelProviderConfig>;
|
||||
}): ClawdbotConfig {
|
||||
}): MoltbotConfig {
|
||||
const providerOverrides = params.providerOverrides ?? {};
|
||||
const lmstudioProvider = params.cfg.models?.providers?.lmstudio;
|
||||
const baseProviders = params.cfg.models?.providers ?? {};
|
||||
@@ -382,16 +382,16 @@ function buildLiveGatewayConfig(params: {
|
||||
}
|
||||
|
||||
function sanitizeAuthConfig(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
agentDir: string;
|
||||
}): ClawdbotConfig["auth"] | undefined {
|
||||
}): MoltbotConfig["auth"] | undefined {
|
||||
const auth = params.cfg.auth;
|
||||
if (!auth) return auth;
|
||||
const store = ensureAuthProfileStore(params.agentDir, {
|
||||
allowKeychainPrompt: false,
|
||||
});
|
||||
|
||||
let profiles: NonNullable<ClawdbotConfig["auth"]>["profiles"] | undefined;
|
||||
let profiles: NonNullable<MoltbotConfig["auth"]>["profiles"] | undefined;
|
||||
if (auth.profiles) {
|
||||
profiles = {};
|
||||
for (const [profileId, profile] of Object.entries(auth.profiles)) {
|
||||
@@ -421,7 +421,7 @@ function sanitizeAuthConfig(params: {
|
||||
}
|
||||
|
||||
function buildMinimaxProviderOverride(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
api: "openai-completions" | "anthropic-messages";
|
||||
baseUrl: string;
|
||||
}): ModelProviderConfig | null {
|
||||
@@ -458,7 +458,7 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
|
||||
process.env.CLAWDBOT_GATEWAY_TOKEN = token;
|
||||
const agentId = "dev";
|
||||
|
||||
const hostAgentDir = resolveClawdbotAgentDir();
|
||||
const hostAgentDir = resolveMoltbotAgentDir();
|
||||
const hostStore = ensureAuthProfileStore(hostAgentDir, {
|
||||
allowKeychainPrompt: false,
|
||||
});
|
||||
@@ -471,7 +471,7 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
|
||||
lastGood: hostStore.lastGood ? { ...hostStore.lastGood } : undefined,
|
||||
usageStats: hostStore.usageStats ? { ...hostStore.usageStats } : undefined,
|
||||
};
|
||||
tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-live-state-"));
|
||||
tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-live-state-"));
|
||||
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
||||
tempAgentDir = path.join(tempStateDir, "agents", DEFAULT_AGENT_ID, "agent");
|
||||
saveAuthProfileStore(sanitizedStore, tempAgentDir);
|
||||
@@ -489,8 +489,8 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
|
||||
const toolProbePath = path.join(workspaceDir, `.clawdbot-live-tool-probe.${nonceA}.txt`);
|
||||
await fs.writeFile(toolProbePath, `nonceA=${nonceA}\nnonceB=${nonceB}\n`);
|
||||
|
||||
const agentDir = resolveClawdbotAgentDir();
|
||||
const sanitizedCfg: ClawdbotConfig = {
|
||||
const agentDir = resolveMoltbotAgentDir();
|
||||
const sanitizedCfg: MoltbotConfig = {
|
||||
...params.cfg,
|
||||
auth: sanitizeAuthConfig({ cfg: params.cfg, agentDir }),
|
||||
};
|
||||
@@ -499,12 +499,12 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
|
||||
candidates: params.candidates,
|
||||
providerOverrides: params.providerOverrides,
|
||||
});
|
||||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-live-"));
|
||||
const tempConfigPath = path.join(tempDir, "clawdbot.json");
|
||||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-live-"));
|
||||
const tempConfigPath = path.join(tempDir, "moltbot.json");
|
||||
await fs.writeFile(tempConfigPath, `${JSON.stringify(nextCfg, null, 2)}\n`);
|
||||
process.env.CLAWDBOT_CONFIG_PATH = tempConfigPath;
|
||||
|
||||
await ensureClawdbotModelsJson(nextCfg);
|
||||
await ensureMoltbotModelsJson(nextCfg);
|
||||
|
||||
const port = await getFreeGatewayPort();
|
||||
const server = await startGatewayServer(port, {
|
||||
@@ -636,7 +636,7 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
|
||||
sessionKey,
|
||||
idempotencyKey: `idem-${runIdTool}-tool`,
|
||||
message:
|
||||
"Clawdbot live tool probe (local, safe): " +
|
||||
"Moltbot live tool probe (local, safe): " +
|
||||
`use the tool named \`read\` (or \`Read\`) with JSON arguments {"path":"${toolProbePath}"}. ` +
|
||||
"Then reply with the two nonce values you read (include both).",
|
||||
thinking: params.thinkingLevel,
|
||||
@@ -676,7 +676,7 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
|
||||
sessionKey,
|
||||
idempotencyKey: `idem-${runIdTool}-exec-read`,
|
||||
message:
|
||||
"Clawdbot live tool probe (local, safe): " +
|
||||
"Moltbot live tool probe (local, safe): " +
|
||||
"use the tool named `exec` (or `Exec`) to run this command: " +
|
||||
`mkdir -p "${tempDir}" && printf '%s' '${nonceC}' > "${toolWritePath}". ` +
|
||||
`Then use the tool named \`read\` (or \`Read\`) with JSON arguments {"path":"${toolWritePath}"}. ` +
|
||||
@@ -957,9 +957,9 @@ describeLive("gateway live (dev agent, profile keys)", () => {
|
||||
"runs meaningful prompts across models with available keys",
|
||||
async () => {
|
||||
const cfg = loadConfig();
|
||||
await ensureClawdbotModelsJson(cfg);
|
||||
await ensureMoltbotModelsJson(cfg);
|
||||
|
||||
const agentDir = resolveClawdbotAgentDir();
|
||||
const agentDir = resolveMoltbotAgentDir();
|
||||
const authStore = ensureAuthProfileStore(agentDir, {
|
||||
allowKeychainPrompt: false,
|
||||
});
|
||||
@@ -1061,9 +1061,9 @@ describeLive("gateway live (dev agent, profile keys)", () => {
|
||||
process.env.CLAWDBOT_GATEWAY_TOKEN = token;
|
||||
|
||||
const cfg = loadConfig();
|
||||
await ensureClawdbotModelsJson(cfg);
|
||||
await ensureMoltbotModelsJson(cfg);
|
||||
|
||||
const agentDir = resolveClawdbotAgentDir();
|
||||
const agentDir = resolveMoltbotAgentDir();
|
||||
const authStorage = discoverAuthStorage(agentDir);
|
||||
const modelRegistry = discoverModels(authStorage, agentDir);
|
||||
const anthropic = modelRegistry.find("anthropic", "claude-opus-4-5") as Model<Api> | null;
|
||||
|
||||
Reference in New Issue
Block a user