From 1d310e2ab0db9513268aab646eae6f8840ddc09e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 10 Apr 2026 09:20:54 +0100 Subject: [PATCH] fix: restore main verification gates --- extensions/imessage/runtime-api.ts | 7 +++- extensions/whatsapp/src/outbound-base.test.ts | 8 +++-- .../whatsapp/src/outbound-test-support.ts | 17 ---------- .../run.overflow-compaction.harness.ts | 1 + src/image-generation/runtime.live.test.ts | 11 ++----- src/infra/dotenv.test.ts | 6 ++-- src/utils/delivery-context.ts | 33 +++++++++---------- .../bundled-provider-builders.ts | 12 ++++++- 8 files changed, 44 insertions(+), 51 deletions(-) diff --git a/extensions/imessage/runtime-api.ts b/extensions/imessage/runtime-api.ts index 53d50b07a28..88c3187d924 100644 --- a/extensions/imessage/runtime-api.ts +++ b/extensions/imessage/runtime-api.ts @@ -1,3 +1,5 @@ +import type { OpenClawConfig as RuntimeApiOpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; + export { DEFAULT_ACCOUNT_ID, getChatChannelMeta, @@ -29,4 +31,7 @@ export type { IMessageProbe } from "./src/probe.js"; export { sendMessageIMessage } from "./src/send.js"; export { setIMessageRuntime } from "./src/runtime.js"; export { chunkTextForOutbound } from "./src/channel-api.js"; -export type { IMessageAccountConfig } from "./src/account-types.js"; +export type IMessageAccountConfig = Omit< + NonNullable["imessage"]>, + "accounts" | "defaultAccount" +>; diff --git a/extensions/whatsapp/src/outbound-base.test.ts b/extensions/whatsapp/src/outbound-base.test.ts index dd940236e8a..0509e88412a 100644 --- a/extensions/whatsapp/src/outbound-base.test.ts +++ b/extensions/whatsapp/src/outbound-base.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; import { createWhatsAppOutboundBase } from "./outbound-base.js"; -import { createWhatsAppPollFixture, expectWhatsAppPollSent } from "./outbound-test-support.js"; +import { createWhatsAppPollFixture } from "./outbound-test-support.js"; describe("createWhatsAppOutboundBase", () => { it("exposes the provided chunker", () => { @@ -75,7 +75,11 @@ describe("createWhatsAppOutboundBase", () => { accountId, }); - expectWhatsAppPollSent(sendPollWhatsApp, { cfg, poll, to, accountId }); + expect(sendPollWhatsApp).toHaveBeenCalledWith(to, poll, { + verbose: false, + accountId, + cfg, + }); expect(result).toEqual({ channel: "whatsapp", messageId: "wa-poll-1", diff --git a/extensions/whatsapp/src/outbound-test-support.ts b/extensions/whatsapp/src/outbound-test-support.ts index 19e12f37108..94dd78f9aca 100644 --- a/extensions/whatsapp/src/outbound-test-support.ts +++ b/extensions/whatsapp/src/outbound-test-support.ts @@ -1,5 +1,4 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; -import { expect, type MockInstance } from "vitest"; export function createWhatsAppPollFixture() { const cfg = { marker: "resolved-cfg" } as OpenClawConfig; @@ -15,19 +14,3 @@ export function createWhatsAppPollFixture() { accountId: "work", }; } - -export function expectWhatsAppPollSent( - sendPollWhatsApp: MockInstance, - params: { - cfg: OpenClawConfig; - poll: { question: string; options: string[]; maxSelections: number }; - to?: string; - accountId?: string; - }, -) { - expect(sendPollWhatsApp).toHaveBeenCalledWith(params.to ?? "+1555", params.poll, { - verbose: false, - accountId: params.accountId ?? "work", - cfg: params.cfg, - }); -} diff --git a/src/agents/pi-embedded-runner/run.overflow-compaction.harness.ts b/src/agents/pi-embedded-runner/run.overflow-compaction.harness.ts index 9c39b15eed4..e0099644b70 100644 --- a/src/agents/pi-embedded-runner/run.overflow-compaction.harness.ts +++ b/src/agents/pi-embedded-runner/run.overflow-compaction.harness.ts @@ -392,6 +392,7 @@ export async function loadRunOverflowCompactionHarness(): Promise<{ isRateLimitAssistantError: mockedIsRateLimitAssistantError, isTimeoutErrorMessage: mockedIsTimeoutErrorMessage, pickFallbackThinkingLevel: mockedPickFallbackThinkingLevel, + sanitizeUserFacingText: vi.fn((text: unknown) => (typeof text === "string" ? text : "")), })); vi.doMock("./run/attempt.js", () => ({ diff --git a/src/image-generation/runtime.live.test.ts b/src/image-generation/runtime.live.test.ts index b547cf3072f..5c1879c477e 100644 --- a/src/image-generation/runtime.live.test.ts +++ b/src/image-generation/runtime.live.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; +import { loadBundledProviderPlugin as loadBundledProviderPluginFromTestHelper } from "../../test/helpers/media-generation/bundled-provider-builders.js"; import { registerProviderPlugin, requireRegisteredProvider, @@ -12,7 +13,6 @@ import { isTruthyEnvValue } from "../infra/env.js"; import { getShellEnvAppliedKeys, loadShellEnvFallback } from "../infra/shell-env.js"; import { encodePngRgba, fillPixel } from "../media/png-encode.js"; import { getProviderEnvVars } from "../secrets/provider-env-vars.js"; -import { loadBundledPluginPublicSurfaceSync } from "../test-utils/bundled-plugin-public-surface.js"; import { DEFAULT_LIVE_IMAGE_MODELS, parseCaseFilter, @@ -38,10 +38,6 @@ type LiveProviderCase = { providerId: string; }; -type BundledProviderEntryModule = { - default: LiveProviderCase["plugin"]; -}; - type LiveImageCase = { id: string; providerId: string; @@ -53,10 +49,7 @@ type LiveImageCase = { }; function loadBundledProviderPlugin(pluginId: string): LiveProviderCase["plugin"] { - return loadBundledPluginPublicSurfaceSync({ - pluginId, - artifactBasename: "index.js", - }).default; + return loadBundledProviderPluginFromTestHelper(pluginId); } const PROVIDER_CASES: LiveProviderCase[] = [ diff --git a/src/infra/dotenv.test.ts b/src/infra/dotenv.test.ts index 92e75525a30..ca60457927a 100644 --- a/src/infra/dotenv.test.ts +++ b/src/infra/dotenv.test.ts @@ -686,17 +686,17 @@ describe("workspace .env blocklist completeness", () => { await withDotEnvFixture(async ({ cwdDir }) => { await writeEnvFile( path.join(cwdDir, ".env"), - "MY_APP_KEY=user-value\nGITHUB_TOKEN=ghp_test123\nDATABASE_URL_CUSTOM=pg://localhost\n", + "MY_APP_KEY=user-value\nAPP_GITHUB_REPO=openclaw/openclaw\nDATABASE_URL_CUSTOM=pg://localhost\n", ); delete process.env.MY_APP_KEY; - delete process.env.GITHUB_TOKEN; + delete process.env.APP_GITHUB_REPO; delete process.env.DATABASE_URL_CUSTOM; loadWorkspaceDotEnvFile(path.join(cwdDir, ".env"), { quiet: true }); expect(process.env.MY_APP_KEY).toBe("user-value"); - expect(process.env.GITHUB_TOKEN).toBe("ghp_test123"); + expect(process.env.APP_GITHUB_REPO).toBe("openclaw/openclaw"); expect(process.env.DATABASE_URL_CUSTOM).toBe("pg://localhost"); }); }); diff --git a/src/utils/delivery-context.ts b/src/utils/delivery-context.ts index 7c712cd1d4c..d4a0f9dfe08 100644 --- a/src/utils/delivery-context.ts +++ b/src/utils/delivery-context.ts @@ -113,6 +113,21 @@ export function resolveConversationDeliveryTarget(params: { : typeof params.parentConversationId === "string" ? normalizeOptionalString(params.parentConversationId) : undefined; + const isThreadChild = + conversationId && parentConversationId && parentConversationId !== conversationId; + if (channel && isThreadChild) { + if ( + channel === "matrix" || + channel === "slack" || + channel === "mattermost" || + channel === "telegram" + ) { + return { + to: `channel:${parentConversationId}`, + threadId: conversationId, + }; + } + } const pluginTarget = channel && conversationId ? getChannelPlugin( @@ -128,24 +143,6 @@ export function resolveConversationDeliveryTarget(params: { ...(pluginTarget.threadId?.trim() ? { threadId: pluginTarget.threadId.trim() } : {}), }; } - const isThreadChild = - conversationId && parentConversationId && parentConversationId !== conversationId; - if (channel && isThreadChild) { - if ( - channel === "matrix" || - channel === "slack" || - channel === "mattermost" || - channel === "telegram" - ) { - return { - to: formatConversationTarget({ - channel, - conversationId: parentConversationId, - }), - threadId: conversationId, - }; - } - } const to = formatConversationTarget(params); return { to }; } diff --git a/test/helpers/media-generation/bundled-provider-builders.ts b/test/helpers/media-generation/bundled-provider-builders.ts index 65b388de7ab..03f0914c2bd 100644 --- a/test/helpers/media-generation/bundled-provider-builders.ts +++ b/test/helpers/media-generation/bundled-provider-builders.ts @@ -1,4 +1,5 @@ import type { + ImageGenerationProviderPlugin, MusicGenerationProviderPlugin, OpenClawPluginApi, VideoGenerationProviderPlugin, @@ -22,6 +23,11 @@ export type BundledMusicProviderEntry = { provider: MusicGenerationProviderPlugin; }; +export type BundledImageProviderEntry = { + pluginId: string; + provider: ImageGenerationProviderPlugin; +}; + const BUNDLED_VIDEO_PROVIDER_PLUGIN_IDS = [ "alibaba", "byteplus", @@ -46,8 +52,12 @@ function loadBundledPluginEntry(pluginId: string): BundledPluginEntryModule { }); } +export function loadBundledProviderPlugin(pluginId: string): BundledPluginEntryModule["default"] { + return loadBundledPluginEntry(pluginId).default; +} + async function registerBundledMediaPlugin(pluginId: string) { - const { default: plugin } = loadBundledPluginEntry(pluginId); + const plugin = loadBundledProviderPlugin(pluginId); return await registerProviderPlugin({ plugin, id: pluginId,