mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 05:37:41 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -12,7 +12,7 @@ vi.mock("./targets.js", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { resolveAgentDeliveryPlan, resolveAgentOutboundTarget } from "./agent-delivery.js";
|
||||
|
||||
describe("agent delivery helpers", () => {
|
||||
@@ -45,7 +45,7 @@ describe("agent delivery helpers", () => {
|
||||
});
|
||||
|
||||
const resolved = resolveAgentOutboundTarget({
|
||||
cfg: {} as MoltbotConfig,
|
||||
cfg: {} as OpenClawConfig,
|
||||
plan,
|
||||
targetMode: "implicit",
|
||||
});
|
||||
@@ -68,7 +68,7 @@ describe("agent delivery helpers", () => {
|
||||
|
||||
mocks.resolveOutboundTarget.mockClear();
|
||||
const resolved = resolveAgentOutboundTarget({
|
||||
cfg: {} as MoltbotConfig,
|
||||
cfg: {} as OpenClawConfig,
|
||||
plan,
|
||||
targetMode: "explicit",
|
||||
validateExplicitTarget: false,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
resolveSessionDeliveryTarget,
|
||||
type SessionDeliveryTarget,
|
||||
} from "./targets.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { OutboundTargetResolution } from "./targets.js";
|
||||
|
||||
export type AgentDeliveryPlan = {
|
||||
@@ -98,7 +98,7 @@ export function resolveAgentDeliveryPlan(params: {
|
||||
}
|
||||
|
||||
export function resolveAgentOutboundTarget(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
plan: AgentDeliveryPlan;
|
||||
targetMode?: ChannelOutboundTargetMode;
|
||||
validateExplicitTarget?: boolean;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { listChannelPlugins } from "../../channels/plugins/index.js";
|
||||
import type { ChannelPlugin } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import {
|
||||
listDeliverableMessageChannels,
|
||||
type DeliverableMessageChannel,
|
||||
@@ -21,7 +21,7 @@ function isAccountEnabled(account: unknown): boolean {
|
||||
return enabled !== false;
|
||||
}
|
||||
|
||||
async function isPluginConfigured(plugin: ChannelPlugin, cfg: MoltbotConfig): Promise<boolean> {
|
||||
async function isPluginConfigured(plugin: ChannelPlugin, cfg: OpenClawConfig): Promise<boolean> {
|
||||
const accountIds = plugin.config.listAccountIds(cfg);
|
||||
if (accountIds.length === 0) return false;
|
||||
|
||||
@@ -40,7 +40,7 @@ async function isPluginConfigured(plugin: ChannelPlugin, cfg: MoltbotConfig): Pr
|
||||
}
|
||||
|
||||
export async function listConfiguredMessageChannels(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
): Promise<MessageChannelId[]> {
|
||||
const channels: MessageChannelId[] = [];
|
||||
for (const plugin of listChannelPlugins()) {
|
||||
@@ -53,7 +53,7 @@ export async function listConfiguredMessageChannels(
|
||||
}
|
||||
|
||||
export async function resolveMessageChannelSelection(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel?: string | null;
|
||||
}): Promise<{ channel: MessageChannelId; configured: MessageChannelId[] }> {
|
||||
const normalized = normalizeMessageChannel(params.channel);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { signalOutbound } from "../../channels/plugins/outbound/signal.js";
|
||||
import { telegramOutbound } from "../../channels/plugins/outbound/telegram.js";
|
||||
import { whatsappOutbound } from "../../channels/plugins/outbound/whatsapp.js";
|
||||
@@ -38,7 +38,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
});
|
||||
it("chunks telegram markdown and passes through accountId", async () => {
|
||||
const sendTelegram = vi.fn().mockResolvedValue({ messageId: "m1", chatId: "c1" });
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { telegram: { botToken: "tok-1", textChunkLimit: 2 } },
|
||||
};
|
||||
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
|
||||
@@ -71,7 +71,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
|
||||
it("passes explicit accountId to sendTelegram", async () => {
|
||||
const sendTelegram = vi.fn().mockResolvedValue({ messageId: "m1", chatId: "c1" });
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { telegram: { botToken: "tok-1", textChunkLimit: 2 } },
|
||||
};
|
||||
|
||||
@@ -93,7 +93,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
|
||||
it("uses signal media maxBytes from config", async () => {
|
||||
const sendSignal = vi.fn().mockResolvedValue({ messageId: "s1", timestamp: 123 });
|
||||
const cfg: MoltbotConfig = { channels: { signal: { mediaMaxMb: 2 } } };
|
||||
const cfg: OpenClawConfig = { channels: { signal: { mediaMaxMb: 2 } } };
|
||||
|
||||
const results = await deliverOutboundPayloads({
|
||||
cfg,
|
||||
@@ -118,7 +118,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
|
||||
it("chunks Signal markdown using the format-first chunker", async () => {
|
||||
const sendSignal = vi.fn().mockResolvedValue({ messageId: "s1", timestamp: 123 });
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { signal: { textChunkLimit: 20 } },
|
||||
};
|
||||
const text = `Intro\\n\\n\`\`\`\`md\\n${"y".repeat(60)}\\n\`\`\`\\n\\nOutro`;
|
||||
@@ -152,7 +152,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
.fn()
|
||||
.mockResolvedValueOnce({ messageId: "w1", toJid: "jid" })
|
||||
.mockResolvedValueOnce({ messageId: "w2", toJid: "jid" });
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { whatsapp: { textChunkLimit: 2 } },
|
||||
};
|
||||
|
||||
@@ -170,7 +170,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
|
||||
it("respects newline chunk mode for WhatsApp", async () => {
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({ messageId: "w1", toJid: "jid" });
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { whatsapp: { textChunkLimit: 4000, chunkMode: "newline" } },
|
||||
};
|
||||
|
||||
@@ -229,7 +229,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
]),
|
||||
);
|
||||
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { matrix: { textChunkLimit: 4000, chunkMode: "newline" } },
|
||||
};
|
||||
const text = "```js\nconst a = 1;\nconst b = 2;\n```\nAfter";
|
||||
@@ -256,7 +256,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
},
|
||||
]),
|
||||
);
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: { defaults: { mediaMaxMb: 3 } },
|
||||
};
|
||||
|
||||
@@ -293,7 +293,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
.mockRejectedValueOnce(new Error("fail"))
|
||||
.mockResolvedValueOnce({ messageId: "w2", toJid: "jid" });
|
||||
const onError = vi.fn();
|
||||
const cfg: MoltbotConfig = {};
|
||||
const cfg: OpenClawConfig = {};
|
||||
|
||||
const results = await deliverOutboundPayloads({
|
||||
cfg,
|
||||
@@ -313,7 +313,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
it("passes normalized payload to onError", async () => {
|
||||
const sendWhatsApp = vi.fn().mockRejectedValue(new Error("boom"));
|
||||
const onError = vi.fn();
|
||||
const cfg: MoltbotConfig = {};
|
||||
const cfg: OpenClawConfig = {};
|
||||
|
||||
await deliverOutboundPayloads({
|
||||
cfg,
|
||||
@@ -334,7 +334,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
|
||||
it("mirrors delivered output when mirror options are provided", async () => {
|
||||
const sendTelegram = vi.fn().mockResolvedValue({ messageId: "m1", chatId: "c1" });
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { telegram: { botToken: "tok-1", textChunkLimit: 2 } },
|
||||
};
|
||||
mocks.appendAssistantMessageToSessionTranscript.mockClear();
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { ReplyPayload } from "../../auto-reply/types.js";
|
||||
import { resolveChannelMediaMaxBytes } from "../../channels/plugins/media-limits.js";
|
||||
import { loadChannelOutboundAdapter } from "../../channels/plugins/outbound/load.js";
|
||||
import type { ChannelOutboundAdapter } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { resolveMarkdownTableMode } from "../../config/markdown-tables.js";
|
||||
import type { sendMessageDiscord } from "../../discord/send.js";
|
||||
import type { sendMessageIMessage } from "../../imessage/send.js";
|
||||
@@ -82,7 +82,7 @@ function throwIfAborted(abortSignal?: AbortSignal): void {
|
||||
|
||||
// Channel docking: outbound delivery delegates to plugin.outbound adapters.
|
||||
async function createChannelHandler(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: Exclude<OutboundChannel, "none">;
|
||||
to: string;
|
||||
accountId?: string;
|
||||
@@ -114,7 +114,7 @@ async function createChannelHandler(params: {
|
||||
|
||||
function createPluginHandler(params: {
|
||||
outbound?: ChannelOutboundAdapter;
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: Exclude<OutboundChannel, "none">;
|
||||
to: string;
|
||||
accountId?: string;
|
||||
@@ -175,7 +175,7 @@ function createPluginHandler(params: {
|
||||
}
|
||||
|
||||
export async function deliverOutboundPayloads(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: Exclude<OutboundChannel, "none">;
|
||||
to: string;
|
||||
accountId?: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ChannelDirectoryEntryKind, ChannelId } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
|
||||
type CacheEntry<T> = {
|
||||
value: T;
|
||||
@@ -21,11 +21,11 @@ export function buildDirectoryCacheKey(key: DirectoryCacheKey): string {
|
||||
|
||||
export class DirectoryCache<T> {
|
||||
private readonly cache = new Map<string, CacheEntry<T>>();
|
||||
private lastConfigRef: MoltbotConfig | null = null;
|
||||
private lastConfigRef: OpenClawConfig | null = null;
|
||||
|
||||
constructor(private readonly ttlMs: number) {}
|
||||
|
||||
get(key: string, cfg: MoltbotConfig): T | undefined {
|
||||
get(key: string, cfg: OpenClawConfig): T | undefined {
|
||||
this.resetIfConfigChanged(cfg);
|
||||
const entry = this.cache.get(key);
|
||||
if (!entry) return undefined;
|
||||
@@ -36,7 +36,7 @@ export class DirectoryCache<T> {
|
||||
return entry.value;
|
||||
}
|
||||
|
||||
set(key: string, value: T, cfg: MoltbotConfig): void {
|
||||
set(key: string, value: T, cfg: OpenClawConfig): void {
|
||||
this.resetIfConfigChanged(cfg);
|
||||
this.cache.set(key, { value, fetchedAt: Date.now() });
|
||||
}
|
||||
@@ -47,12 +47,12 @@ export class DirectoryCache<T> {
|
||||
}
|
||||
}
|
||||
|
||||
clear(cfg?: MoltbotConfig): void {
|
||||
clear(cfg?: OpenClawConfig): void {
|
||||
this.cache.clear();
|
||||
if (cfg) this.lastConfigRef = cfg;
|
||||
}
|
||||
|
||||
private resetIfConfigChanged(cfg: MoltbotConfig): void {
|
||||
private resetIfConfigChanged(cfg: OpenClawConfig): void {
|
||||
if (this.lastConfigRef && this.lastConfigRef !== cfg) {
|
||||
this.cache.clear();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import { createIMessageTestPlugin, createTestRegistry } from "../../test-utils/channel-plugins.js";
|
||||
import { slackPlugin } from "../../../extensions/slack/src/channel.js";
|
||||
@@ -26,7 +26,7 @@ const slackConfig = {
|
||||
appToken: "xapp-test",
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
const whatsappConfig = {
|
||||
channels: {
|
||||
@@ -34,7 +34,7 @@ const whatsappConfig = {
|
||||
allowFrom: ["*"],
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
describe("runMessageAction context isolation", () => {
|
||||
beforeEach(async () => {
|
||||
@@ -263,7 +263,7 @@ describe("runMessageAction context isolation", () => {
|
||||
token: "tg-test",
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
const result = await runMessageAction({
|
||||
cfg: multiConfig,
|
||||
@@ -305,7 +305,7 @@ describe("runMessageAction context isolation", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
await expect(
|
||||
runMessageAction({
|
||||
@@ -423,7 +423,7 @@ describe("runMessageAction sendAttachment hydration", () => {
|
||||
password: "test-password",
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
const result = await runMessageAction({
|
||||
cfg,
|
||||
@@ -491,7 +491,7 @@ describe("runMessageAction accountId defaults", () => {
|
||||
|
||||
it("propagates defaultAccountId into params", async () => {
|
||||
await runMessageAction({
|
||||
cfg: {} as MoltbotConfig,
|
||||
cfg: {} as OpenClawConfig,
|
||||
action: "send",
|
||||
params: {
|
||||
channel: "discord",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import { createTestRegistry } from "../../test-utils/channel-plugins.js";
|
||||
import { slackPlugin } from "../../../extensions/slack/src/channel.js";
|
||||
@@ -39,7 +39,7 @@ const slackConfig = {
|
||||
appToken: "xapp-test",
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
describe("runMessageAction Slack threading", () => {
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -15,7 +15,7 @@ import type {
|
||||
ChannelMessageActionName,
|
||||
ChannelThreadingToolContext,
|
||||
} from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import {
|
||||
isDeliverableMessageChannel,
|
||||
normalizeMessageChannel,
|
||||
@@ -54,7 +54,7 @@ export type MessageActionRunnerGateway = {
|
||||
};
|
||||
|
||||
export type RunMessageActionParams = {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
action: ChannelMessageActionName;
|
||||
params: Record<string, unknown>;
|
||||
defaultAccountId?: string;
|
||||
@@ -168,7 +168,7 @@ function applyCrossContextMessageDecoration({
|
||||
}
|
||||
|
||||
async function maybeApplyCrossContextMarker(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
action: ChannelMessageActionName;
|
||||
target: string;
|
||||
@@ -224,7 +224,7 @@ function resolveSlackAutoThreadId(params: {
|
||||
}
|
||||
|
||||
function resolveAttachmentMaxBytes(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
accountId?: string | null;
|
||||
}): number | undefined {
|
||||
@@ -298,7 +298,7 @@ function normalizeBase64Payload(params: { base64?: string; contentType?: string
|
||||
}
|
||||
|
||||
async function hydrateSetGroupIconParams(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
accountId?: string | null;
|
||||
args: Record<string, unknown>;
|
||||
@@ -355,7 +355,7 @@ async function hydrateSetGroupIconParams(params: {
|
||||
}
|
||||
|
||||
async function hydrateSendAttachmentParams(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
accountId?: string | null;
|
||||
args: Record<string, unknown>;
|
||||
@@ -444,7 +444,7 @@ function parseCardParam(params: Record<string, unknown>): void {
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveChannel(cfg: MoltbotConfig, params: Record<string, unknown>) {
|
||||
async function resolveChannel(cfg: OpenClawConfig, params: Record<string, unknown>) {
|
||||
const channelHint = readStringParam(params, "channel");
|
||||
const selection = await resolveMessageChannelSelection({
|
||||
cfg,
|
||||
@@ -454,7 +454,7 @@ async function resolveChannel(cfg: MoltbotConfig, params: Record<string, unknown
|
||||
}
|
||||
|
||||
async function resolveActionTarget(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
action: ChannelMessageActionName;
|
||||
args: Record<string, unknown>;
|
||||
@@ -499,7 +499,7 @@ async function resolveActionTarget(params: {
|
||||
}
|
||||
|
||||
type ResolvedActionContext = {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
params: Record<string, unknown>;
|
||||
channel: ChannelId;
|
||||
accountId?: string | null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
|
||||
import type { ChannelId } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import { callGateway, randomIdempotencyKey } from "../../gateway/call.js";
|
||||
import type { PollInput } from "../../polls.js";
|
||||
@@ -41,7 +41,7 @@ type MessageSendParams = {
|
||||
dryRun?: boolean;
|
||||
bestEffort?: boolean;
|
||||
deps?: OutboundSendDeps;
|
||||
cfg?: MoltbotConfig;
|
||||
cfg?: OpenClawConfig;
|
||||
gateway?: MessageGatewayOptions;
|
||||
idempotencyKey?: string;
|
||||
mirror?: {
|
||||
@@ -71,7 +71,7 @@ type MessagePollParams = {
|
||||
durationHours?: number;
|
||||
channel?: string;
|
||||
dryRun?: boolean;
|
||||
cfg?: MoltbotConfig;
|
||||
cfg?: OpenClawConfig;
|
||||
gateway?: MessageGatewayOptions;
|
||||
idempotencyKey?: string;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import {
|
||||
applyCrossContextDecoration,
|
||||
buildCrossContextDecoration,
|
||||
@@ -14,13 +14,13 @@ const slackConfig = {
|
||||
appToken: "xapp-test",
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
const discordConfig = {
|
||||
channels: {
|
||||
discord: {},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
describe("outbound policy", () => {
|
||||
it("blocks cross-provider sends by default", () => {
|
||||
@@ -41,7 +41,7 @@ describe("outbound policy", () => {
|
||||
tools: {
|
||||
message: { crossContext: { allowAcrossProviders: true } },
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(() =>
|
||||
enforceCrossContextPolicy({
|
||||
@@ -58,7 +58,7 @@ describe("outbound policy", () => {
|
||||
const cfg = {
|
||||
...slackConfig,
|
||||
tools: { message: { crossContext: { allowWithinProvider: false } } },
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(() =>
|
||||
enforceCrossContextPolicy({
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
ChannelMessageActionName,
|
||||
ChannelThreadingToolContext,
|
||||
} from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { getChannelMessageAdapter } from "./channel-adapters.js";
|
||||
import { formatTargetDisplay, lookupDirectoryDisplay } from "./target-resolver.js";
|
||||
|
||||
@@ -74,7 +74,7 @@ export function enforceCrossContextPolicy(params: {
|
||||
action: ChannelMessageActionName;
|
||||
args: Record<string, unknown>;
|
||||
toolContext?: ChannelThreadingToolContext;
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
}): void {
|
||||
const currentTarget = params.toolContext?.currentChannelId?.trim();
|
||||
if (!currentTarget) return;
|
||||
@@ -112,7 +112,7 @@ export function enforceCrossContextPolicy(params: {
|
||||
}
|
||||
|
||||
export async function buildCrossContextDecoration(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
target: string;
|
||||
toolContext?: ChannelThreadingToolContext;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { dispatchChannelMessageAction } from "../../channels/plugins/message-actions.js";
|
||||
import type { ChannelId, ChannelThreadingToolContext } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { appendAssistantMessageToSessionTranscript } from "../../config/sessions.js";
|
||||
import type { GatewayClientMode, GatewayClientName } from "../../utils/message-channel.js";
|
||||
import type { OutboundSendDeps } from "./deliver.js";
|
||||
@@ -18,7 +18,7 @@ export type OutboundGatewayContext = {
|
||||
};
|
||||
|
||||
export type OutboundSendContext = {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
params: Record<string, unknown>;
|
||||
accountId?: string | null;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { resolveOutboundSessionRoute } from "./outbound-session.js";
|
||||
|
||||
const baseConfig = {} as MoltbotConfig;
|
||||
const baseConfig = {} as OpenClawConfig;
|
||||
|
||||
describe("resolveOutboundSessionRoute", () => {
|
||||
it("builds Slack thread session keys", async () => {
|
||||
@@ -36,7 +36,7 @@ describe("resolveOutboundSessionRoute", () => {
|
||||
});
|
||||
|
||||
it("treats Telegram usernames as DMs when unresolved", async () => {
|
||||
const cfg = { session: { dmScope: "per-channel-peer" } } as MoltbotConfig;
|
||||
const cfg = { session: { dmScope: "per-channel-peer" } } as OpenClawConfig;
|
||||
const route = await resolveOutboundSessionRoute({
|
||||
cfg,
|
||||
channel: "telegram",
|
||||
@@ -56,7 +56,7 @@ describe("resolveOutboundSessionRoute", () => {
|
||||
alice: ["discord:123"],
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
const route = await resolveOutboundSessionRoute({
|
||||
cfg,
|
||||
@@ -81,7 +81,7 @@ describe("resolveOutboundSessionRoute", () => {
|
||||
});
|
||||
|
||||
it("treats Zalo Personal DM targets as direct sessions", async () => {
|
||||
const cfg = { session: { dmScope: "per-channel-peer" } } as MoltbotConfig;
|
||||
const cfg = { session: { dmScope: "per-channel-peer" } } as OpenClawConfig;
|
||||
const route = await resolveOutboundSessionRoute({
|
||||
cfg,
|
||||
channel: "zalouser",
|
||||
@@ -102,7 +102,7 @@ describe("resolveOutboundSessionRoute", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
const route = await resolveOutboundSessionRoute({
|
||||
cfg,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { MsgContext } from "../../auto-reply/templating.js";
|
||||
import { getChannelPlugin } from "../../channels/plugins/index.js";
|
||||
import type { ChannelId } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { recordSessionMetaFromInbound, resolveStorePath } from "../../config/sessions.js";
|
||||
import { parseDiscordTarget } from "../../discord/targets.js";
|
||||
import { parseIMessageTarget, normalizeIMessageHandle } from "../../imessage/targets.js";
|
||||
@@ -37,7 +37,7 @@ export type OutboundSessionRoute = {
|
||||
};
|
||||
|
||||
export type ResolveOutboundSessionRouteParams = {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
agentId: string;
|
||||
accountId?: string | null;
|
||||
@@ -100,7 +100,7 @@ function inferPeerKind(params: {
|
||||
}
|
||||
|
||||
function buildBaseSessionKey(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
agentId: string;
|
||||
channel: ChannelId;
|
||||
accountId?: string | null;
|
||||
@@ -118,7 +118,7 @@ function buildBaseSessionKey(params: {
|
||||
|
||||
// Best-effort mpim detection: allowlist/config, then Slack API (if token available).
|
||||
async function resolveSlackChannelType(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
channelId: string;
|
||||
}): Promise<"channel" | "group" | "dm" | "unknown"> {
|
||||
@@ -824,7 +824,7 @@ export async function resolveOutboundSessionRoute(
|
||||
}
|
||||
|
||||
export async function ensureOutboundSessionEntry(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
agentId: string;
|
||||
channel: ChannelId;
|
||||
accountId?: string | null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { ChannelDirectoryEntry } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { resetDirectoryCache, resolveMessagingTarget } from "./target-resolver.js";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
@@ -16,7 +16,7 @@ vi.mock("../../channels/plugins/index.js", () => ({
|
||||
}));
|
||||
|
||||
describe("resolveMessagingTarget (directory fallback)", () => {
|
||||
const cfg = {} as MoltbotConfig;
|
||||
const cfg = {} as OpenClawConfig;
|
||||
|
||||
beforeEach(() => {
|
||||
mocks.listGroups.mockReset();
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
ChannelDirectoryEntryKind,
|
||||
ChannelId,
|
||||
} from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
|
||||
import { buildDirectoryCacheKey, DirectoryCache } from "./directory-cache.js";
|
||||
import {
|
||||
@@ -30,7 +30,7 @@ export type ResolveMessagingTargetResult =
|
||||
| { ok: false; error: Error; candidates?: ChannelDirectoryEntry[] };
|
||||
|
||||
export async function resolveChannelTarget(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
input: string;
|
||||
accountId?: string | null;
|
||||
@@ -177,7 +177,7 @@ function resolveMatch(params: {
|
||||
}
|
||||
|
||||
async function listDirectoryEntries(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
accountId?: string | null;
|
||||
kind: ChannelDirectoryEntryKind;
|
||||
@@ -213,7 +213,7 @@ async function listDirectoryEntries(params: {
|
||||
}
|
||||
|
||||
async function getDirectoryEntries(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
accountId?: string | null;
|
||||
kind: ChannelDirectoryEntryKind;
|
||||
@@ -281,7 +281,7 @@ function pickAmbiguousMatch(
|
||||
}
|
||||
|
||||
export async function resolveMessagingTarget(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
input: string;
|
||||
accountId?: string | null;
|
||||
@@ -397,7 +397,7 @@ export async function resolveMessagingTarget(params: {
|
||||
}
|
||||
|
||||
export async function lookupDirectoryDisplay(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
channel: ChannelId;
|
||||
targetId: string;
|
||||
accountId?: string | null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
|
||||
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import { createTestRegistry } from "../../test-utils/channel-plugins.js";
|
||||
@@ -18,7 +18,7 @@ describe("resolveOutboundTarget", () => {
|
||||
});
|
||||
|
||||
it("falls back to whatsapp allowFrom via config", () => {
|
||||
const cfg: MoltbotConfig = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { whatsapp: { allowFrom: ["+1555"] } },
|
||||
};
|
||||
const res = resolveOutboundTarget({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
|
||||
import { formatCliCommand } from "../../cli/command-format.js";
|
||||
import type { ChannelId, ChannelOutboundTargetMode } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { SessionEntry } from "../../config/sessions.js";
|
||||
import type { AgentDefaultsConfig } from "../../config/types.agent-defaults.js";
|
||||
import { deliveryContextFromSession } from "../../utils/delivery-context.js";
|
||||
@@ -119,7 +119,7 @@ export function resolveOutboundTarget(params: {
|
||||
channel: GatewayMessageChannel;
|
||||
to?: string;
|
||||
allowFrom?: string[];
|
||||
cfg?: MoltbotConfig;
|
||||
cfg?: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
mode?: ChannelOutboundTargetMode;
|
||||
}): OutboundTargetResolution {
|
||||
@@ -127,7 +127,7 @@ export function resolveOutboundTarget(params: {
|
||||
return {
|
||||
ok: false,
|
||||
error: new Error(
|
||||
`Delivering to WebChat is not supported via \`${formatCliCommand("moltbot agent")}\`; use WhatsApp/Telegram or run with --deliver=false.`,
|
||||
`Delivering to WebChat is not supported via \`${formatCliCommand("openclaw agent")}\`; use WhatsApp/Telegram or run with --deliver=false.`,
|
||||
),
|
||||
};
|
||||
}
|
||||
@@ -172,7 +172,7 @@ export function resolveOutboundTarget(params: {
|
||||
}
|
||||
|
||||
export function resolveHeartbeatDeliveryTarget(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
entry?: SessionEntry;
|
||||
heartbeat?: AgentDefaultsConfig["heartbeat"];
|
||||
}): OutboundTarget {
|
||||
@@ -289,7 +289,7 @@ function resolveHeartbeatSenderId(params: {
|
||||
}
|
||||
|
||||
export function resolveHeartbeatSenderContext(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
entry?: SessionEntry;
|
||||
delivery: OutboundTarget;
|
||||
}): HeartbeatSenderContext {
|
||||
|
||||
Reference in New Issue
Block a user