diff --git a/src/acp/client.test.ts b/src/acp/client.test.ts index 78292b4e3ed..def03c7e8ce 100644 --- a/src/acp/client.test.ts +++ b/src/acp/client.test.ts @@ -145,8 +145,8 @@ describe("acp event mapper", () => { it("extracts text and resource blocks into prompt text", () => { const text = extractTextFromPrompt([ { type: "text", text: "Hello" }, - { type: "resource", resource: { text: "File contents" } }, - { type: "resource_link", uri: "https://example.com", title: "Spec" }, + { type: "resource", resource: { uri: "file:///tmp/spec.txt", text: "File contents" } }, + { type: "resource_link", uri: "https://example.com", name: "Spec", title: "Spec" }, { type: "image", data: "abc", mimeType: "image/png" }, ]); diff --git a/src/channels/channel-config.test.ts b/src/channels/channel-config.test.ts index 807a254e62b..5fa81b0b955 100644 --- a/src/channels/channel-config.test.ts +++ b/src/channels/channel-config.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import type { MsgContext } from "../auto-reply/templating.js"; import { + type ChannelMatchSource, buildChannelKeyCandidates, normalizeChannelSlug, resolveChannelEntryMatch, @@ -95,10 +96,8 @@ describe("resolveChannelEntryMatchWithFallback", () => { describe("applyChannelMatchMeta", () => { it("copies match metadata onto resolved configs", () => { - const resolved = applyChannelMatchMeta( - { allowed: true }, - { matchKey: "general", matchSource: "direct" }, - ); + const base: { matchKey?: string; matchSource?: ChannelMatchSource } = {}; + const resolved = applyChannelMatchMeta(base, { matchKey: "general", matchSource: "direct" }); expect(resolved.matchKey).toBe("general"); expect(resolved.matchSource).toBe("direct"); }); @@ -106,14 +105,20 @@ describe("applyChannelMatchMeta", () => { describe("resolveChannelMatchConfig", () => { it("returns null when no entry is matched", () => { - const resolved = resolveChannelMatchConfig({ matchKey: "x" }, () => ({ allowed: true })); + const resolved = resolveChannelMatchConfig({ matchKey: "x" }, () => { + const out: { matchKey?: string; matchSource?: ChannelMatchSource } = {}; + return out; + }); expect(resolved).toBeNull(); }); it("resolves entry and applies match metadata", () => { const resolved = resolveChannelMatchConfig( { entry: { allow: true }, matchKey: "*", matchSource: "wildcard" }, - () => ({ allowed: true }), + () => { + const out: { matchKey?: string; matchSource?: ChannelMatchSource } = {}; + return out; + }, ); expect(resolved?.matchKey).toBe("*"); expect(resolved?.matchSource).toBe("wildcard"); diff --git a/src/channels/plugins/actions/actions.test.ts b/src/channels/plugins/actions/actions.test.ts index dd5081e339e..25726718e92 100644 --- a/src/channels/plugins/actions/actions.test.ts +++ b/src/channels/plugins/actions/actions.test.ts @@ -436,9 +436,13 @@ describe("telegramMessageActions", () => { it("rejects non-integer messageId for edit before reaching telegram-actions", async () => { const cfg = { channels: { telegram: { botToken: "tok" } } } as OpenClawConfig; + const handleAction = telegramMessageActions.handleAction; + if (!handleAction) { + throw new Error("telegram handleAction unavailable"); + } await expect( - telegramMessageActions.handleAction({ + handleAction({ channel: "telegram", action: "edit", params: { @@ -595,9 +599,13 @@ describe("signalMessageActions", () => { const cfg = { channels: { signal: { account: "+15550001111", actions: { reactions: false } } }, } as OpenClawConfig; + const handleAction = signalMessageActions.handleAction; + if (!handleAction) { + throw new Error("signal handleAction unavailable"); + } await expect( - signalMessageActions.handleAction({ + handleAction({ channel: "signal", action: "react", params: { to: "+15550001111", messageId: "123", emoji: "✅" }, @@ -661,9 +669,13 @@ describe("signalMessageActions", () => { const cfg = { channels: { signal: { account: "+15550001111" } }, } as OpenClawConfig; + const handleAction = signalMessageActions.handleAction; + if (!handleAction) { + throw new Error("signal handleAction unavailable"); + } await expect( - signalMessageActions.handleAction({ + handleAction({ channel: "signal", action: "react", params: { to: "signal:group:group-id", messageId: "123", emoji: "✅" }, diff --git a/src/channels/plugins/plugins-core.test.ts b/src/channels/plugins/plugins-core.test.ts index a1c505fb113..9e10f65d2d1 100644 --- a/src/channels/plugins/plugins-core.test.ts +++ b/src/channels/plugins/plugins-core.test.ts @@ -121,6 +121,9 @@ describe("channel plugin catalog", () => { const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({ plugins: [], tools: [], + hooks: [], + typedHooks: [], + commands: [], channels, providers: [], gatewayHandlers: {}, diff --git a/src/config/channel-capabilities.test.ts b/src/config/channel-capabilities.test.ts index 896be0fab3e..564b420e5f4 100644 --- a/src/config/channel-capabilities.test.ts +++ b/src/config/channel-capabilities.test.ts @@ -130,6 +130,9 @@ describe("resolveChannelCapabilities", () => { const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({ plugins: [], tools: [], + hooks: [], + typedHooks: [], + commands: [], channels, providers: [], gatewayHandlers: {}, diff --git a/src/config/config.legacy-config-detection.accepts-imessage-dmpolicy.e2e.test.ts b/src/config/config.legacy-config-detection.accepts-imessage-dmpolicy.e2e.test.ts index c809527e494..e685f326f6b 100644 --- a/src/config/config.legacy-config-detection.accepts-imessage-dmpolicy.e2e.test.ts +++ b/src/config/config.legacy-config-detection.accepts-imessage-dmpolicy.e2e.test.ts @@ -187,7 +187,9 @@ describe("legacy config detection", () => { 'Moved telegram.requireMention → channels.telegram.groups."*".requireMention.', ); expect(res.config?.channels?.telegram?.groups?.["*"]?.requireMention).toBe(false); - expect(res.config?.channels?.telegram?.requireMention).toBeUndefined(); + expect( + (res.config?.channels?.telegram as { requireMention?: boolean } | undefined)?.requireMention, + ).toBeUndefined(); }); it("migrates messages.tts.enabled to messages.tts.auto", async () => { const res = migrateLegacyConfig({ @@ -219,7 +221,7 @@ describe("legacy config detection", () => { alias: "Opus", }); expect(res.config?.agents?.defaults?.models?.["openai/gpt-4.1-mini"]).toBeTruthy(); - expect(res.config?.agent).toBeUndefined(); + expect((res.config as { agent?: unknown } | undefined)?.agent).toBeUndefined(); }); it("flags legacy config in snapshot", async () => { await withTempHome(async (home) => { diff --git a/src/discord/gateway-logging.test.ts b/src/discord/gateway-logging.test.ts index ef95aff6313..762cf5d160b 100644 --- a/src/discord/gateway-logging.test.ts +++ b/src/discord/gateway-logging.test.ts @@ -10,6 +10,8 @@ import { attachDiscordGatewayLogging } from "./gateway-logging.js"; const makeRuntime = () => ({ log: vi.fn(), + error: vi.fn(), + exit: vi.fn(), }); describe("attachDiscordGatewayLogging", () => { diff --git a/src/discord/monitor.tool-result.sends-status-replies-responseprefix.test.ts b/src/discord/monitor.tool-result.sends-status-replies-responseprefix.test.ts index 983252058a2..69d7d8fd0fc 100644 --- a/src/discord/monitor.tool-result.sends-status-replies-responseprefix.test.ts +++ b/src/discord/monitor.tool-result.sends-status-replies-responseprefix.test.ts @@ -46,7 +46,6 @@ const CATEGORY_GUILD_CFG = { }, }, }, - routing: { allowFrom: [] }, } satisfies Config; async function createDmHandler(opts: { cfg: Config; runtimeError?: (err: unknown) => void }) { diff --git a/src/discord/monitor/message-handler.process.test.ts b/src/discord/monitor/message-handler.process.test.ts index 0a88aa08328..75cf28e5175 100644 --- a/src/discord/monitor/message-handler.process.test.ts +++ b/src/discord/monitor/message-handler.process.test.ts @@ -3,7 +3,13 @@ import { createBaseDiscordMessageContext } from "./message-handler.test-harness. const reactMessageDiscord = vi.fn(async () => {}); const removeReactionDiscord = vi.fn(async () => {}); -const dispatchInboundMessage = vi.fn(async () => ({ +type DispatchInboundParams = { + replyOptions?: { + onReasoningStream?: () => Promise | void; + onToolStart?: (payload: { name?: string }) => Promise | void; + }; +}; +const dispatchInboundMessage = vi.fn(async (_params?: DispatchInboundParams) => ({ queuedFinal: false, counts: { final: 0, tool: 0, block: 0 }, })); @@ -114,18 +120,11 @@ describe("processDiscordMessage ack reactions", () => { }); it("debounces intermediate phase reactions and jumps to done for short runs", async () => { - dispatchInboundMessage.mockImplementationOnce( - async (params: { - replyOptions?: { - onReasoningStream?: () => Promise | void; - onToolStart?: (payload: { name?: string }) => Promise | void; - }; - }) => { - await params.replyOptions?.onReasoningStream?.(); - await params.replyOptions?.onToolStart?.({ name: "exec" }); - return { queuedFinal: false, counts: { final: 0, tool: 0, block: 0 } }; - }, - ); + dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => { + await params?.replyOptions?.onReasoningStream?.(); + await params?.replyOptions?.onToolStart?.({ name: "exec" }); + return { queuedFinal: false, counts: { final: 0, tool: 0, block: 0 } }; + }); const ctx = await createBaseContext(); diff --git a/src/discord/monitor/monitor.test.ts b/src/discord/monitor/monitor.test.ts index 8ee2cc21843..670a2a0a81f 100644 --- a/src/discord/monitor/monitor.test.ts +++ b/src/discord/monitor/monitor.test.ts @@ -324,7 +324,10 @@ describe("discord component interactions", () => { await button.run(interaction, { cid: "btn_1" } as ComponentData); const { interaction: secondInteraction } = createComponentButtonInteraction({ - rawData: { channel_id: "dm-channel", id: "interaction-2" }, + rawData: { + channel_id: "dm-channel", + id: "interaction-2", + } as unknown as ButtonInteraction["rawData"], }); await button.run(secondInteraction, { cid: "btn_1" } as ComponentData); diff --git a/src/discord/monitor/threading.auto-thread.test.ts b/src/discord/monitor/threading.auto-thread.test.ts index 630524d68c1..4cdb36319ff 100644 --- a/src/discord/monitor/threading.auto-thread.test.ts +++ b/src/discord/monitor/threading.auto-thread.test.ts @@ -19,7 +19,7 @@ describe("maybeCreateDiscordAutoThread", () => { message: mockMessage, messageChannelId: "forum1", isGuildMessage: true, - channelConfig: { autoThread: true }, + channelConfig: { allowed: true, autoThread: true }, channelType: ChannelType.GuildForum, baseText: "test", combinedBody: "test", @@ -34,7 +34,7 @@ describe("maybeCreateDiscordAutoThread", () => { message: mockMessage, messageChannelId: "media1", isGuildMessage: true, - channelConfig: { autoThread: true }, + channelConfig: { allowed: true, autoThread: true }, channelType: ChannelType.GuildMedia, baseText: "test", combinedBody: "test", @@ -50,7 +50,7 @@ describe("maybeCreateDiscordAutoThread", () => { message: mockMessage, messageChannelId: "text1", isGuildMessage: true, - channelConfig: { autoThread: true }, + channelConfig: { allowed: true, autoThread: true }, channelType: ChannelType.GuildText, baseText: "test", combinedBody: "test",