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 @@
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
import { normalizeChatChannelId } from "../channels/registry.js";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { AgentBinding } from "../config/types.agents.js";
import { normalizeAccountId, normalizeAgentId } from "./session-key.js";
@@ -11,11 +11,11 @@ function normalizeBindingChannelId(raw?: string | null): string | null {
return fallback || null;
}
export function listBindings(cfg: MoltbotConfig): AgentBinding[] {
export function listBindings(cfg: OpenClawConfig): AgentBinding[] {
return Array.isArray(cfg.bindings) ? cfg.bindings : [];
}
export function listBoundAccountIds(cfg: MoltbotConfig, channelId: string): string[] {
export function listBoundAccountIds(cfg: OpenClawConfig, channelId: string): string[] {
const normalizedChannel = normalizeBindingChannelId(channelId);
if (!normalizedChannel) return [];
const ids = new Set<string>();
@@ -33,7 +33,7 @@ export function listBoundAccountIds(cfg: MoltbotConfig, channelId: string): stri
}
export function resolveDefaultAgentBoundAccountId(
cfg: MoltbotConfig,
cfg: OpenClawConfig,
channelId: string,
): string | null {
const normalizedChannel = normalizeBindingChannelId(channelId);
@@ -53,7 +53,7 @@ export function resolveDefaultAgentBoundAccountId(
return null;
}
export function buildChannelAccountBindings(cfg: MoltbotConfig) {
export function buildChannelAccountBindings(cfg: OpenClawConfig) {
const map = new Map<string, Map<string, string[]>>();
for (const binding of listBindings(cfg)) {
if (!binding || typeof binding !== "object") continue;

View File

@@ -1,11 +1,11 @@
import { describe, expect, test } from "vitest";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveAgentRoute } from "./resolve-route.js";
describe("resolveAgentRoute", () => {
test("defaults to main/default when no bindings exist", () => {
const cfg: MoltbotConfig = {};
const cfg: OpenClawConfig = {};
const route = resolveAgentRoute({
cfg,
channel: "whatsapp",
@@ -19,7 +19,7 @@ describe("resolveAgentRoute", () => {
});
test("dmScope=per-peer isolates DM sessions by sender id", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
session: { dmScope: "per-peer" },
};
const route = resolveAgentRoute({
@@ -32,7 +32,7 @@ describe("resolveAgentRoute", () => {
});
test("dmScope=per-channel-peer isolates DM sessions per channel and sender", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
session: { dmScope: "per-channel-peer" },
};
const route = resolveAgentRoute({
@@ -45,7 +45,7 @@ describe("resolveAgentRoute", () => {
});
test("identityLinks collapses per-peer DM sessions across providers", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
session: {
dmScope: "per-peer",
identityLinks: {
@@ -63,7 +63,7 @@ describe("resolveAgentRoute", () => {
});
test("identityLinks applies to per-channel-peer DM sessions", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
session: {
dmScope: "per-channel-peer",
identityLinks: {
@@ -81,7 +81,7 @@ describe("resolveAgentRoute", () => {
});
test("peer binding wins over account binding", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
bindings: [
{
agentId: "a",
@@ -109,7 +109,7 @@ describe("resolveAgentRoute", () => {
});
test("discord channel peer binding wins over guild binding", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
bindings: [
{
agentId: "chan",
@@ -142,7 +142,7 @@ describe("resolveAgentRoute", () => {
});
test("guild binding wins over account binding when peer not bound", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
bindings: [
{
agentId: "guild",
@@ -170,7 +170,7 @@ describe("resolveAgentRoute", () => {
});
test("missing accountId in binding matches default account only", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
bindings: [{ agentId: "defaultAcct", match: { channel: "whatsapp" } }],
};
@@ -193,7 +193,7 @@ describe("resolveAgentRoute", () => {
});
test("accountId=* matches any account as a channel fallback", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
bindings: [
{
agentId: "any",
@@ -212,9 +212,9 @@ describe("resolveAgentRoute", () => {
});
test("defaultAgentId is used when no binding matches", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
agents: {
list: [{ id: "home", default: true, workspace: "~/clawd-home" }],
list: [{ id: "home", default: true, workspace: "~/openclaw-home" }],
},
};
const route = resolveAgentRoute({
@@ -229,7 +229,7 @@ describe("resolveAgentRoute", () => {
});
test("dmScope=per-account-channel-peer isolates DM sessions per account, channel and sender", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
session: { dmScope: "per-account-channel-peer" },
};
const route = resolveAgentRoute({
@@ -242,7 +242,7 @@ test("dmScope=per-account-channel-peer isolates DM sessions per account, channel
});
test("dmScope=per-account-channel-peer uses default accountId when not provided", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
session: { dmScope: "per-account-channel-peer" },
};
const route = resolveAgentRoute({

View File

@@ -1,5 +1,5 @@
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { listBindings } from "./bindings.js";
import {
buildAgentMainSessionKey,
@@ -18,7 +18,7 @@ export type RoutePeer = {
};
export type ResolveAgentRouteInput = {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
channel: string;
accountId?: string | null;
peer?: RoutePeer | null;
@@ -89,12 +89,12 @@ export function buildAgentSessionKey(params: {
});
}
function listAgents(cfg: MoltbotConfig) {
function listAgents(cfg: OpenClawConfig) {
const agents = cfg.agents?.list;
return Array.isArray(agents) ? agents : [];
}
function pickFirstExistingAgentId(cfg: MoltbotConfig, agentId: string): string {
function pickFirstExistingAgentId(cfg: OpenClawConfig, agentId: string): string {
const trimmed = (agentId ?? "").trim();
if (!trimmed) return sanitizeAgentId(resolveDefaultAgentId(cfg));
const normalized = normalizeAgentId(trimmed);