From 53fde90dc2bb0a114ce91533508bf5c4fbc522ad Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 11 Apr 2026 22:32:43 +0100 Subject: [PATCH] fix(cycles): use loaded channel prompt hints --- src/auto-reply/reply/inbound-meta.test.ts | 26 ++++++----------------- src/auto-reply/reply/inbound-meta.ts | 12 +++++------ 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/auto-reply/reply/inbound-meta.test.ts b/src/auto-reply/reply/inbound-meta.test.ts index 9d60a4c87e8..1adb323fe98 100644 --- a/src/auto-reply/reply/inbound-meta.test.ts +++ b/src/auto-reply/reply/inbound-meta.test.ts @@ -5,8 +5,8 @@ import { withEnv } from "../../test-utils/env.js"; import type { TemplateContext } from "../templating.js"; import { buildInboundMetaSystemPrompt, buildInboundUserContextPrefix } from "./inbound-meta.js"; -vi.mock("../../channels/plugins/index.js", () => ({ - getChannelPlugin: (channelId: string) => +vi.mock("../../channels/plugins/registry-loaded.js", () => ({ + getLoadedChannelPluginById: (channelId: string) => channelId === "slack" ? { agentPrompt: { @@ -23,24 +23,10 @@ vi.mock("../../channels/plugins/index.js", () => ({ }, } : undefined, - getLoadedChannelPlugin: (channelId: string) => - channelId === "slack" - ? { - agentPrompt: { - inboundFormattingHints: () => ({ - text_markup: "slack_mrkdwn", - rules: [ - "Use Slack mrkdwn, not standard Markdown.", - "Bold uses *single asterisks*.", - "Links use .", - "Code blocks use triple backticks without a language identifier.", - "Do not use markdown headings or pipe tables.", - ], - }), - }, - } - : undefined, - normalizeChannelId: (channelId?: string) => channelId?.trim().toLowerCase(), +})); + +vi.mock("../../channels/registry.js", () => ({ + normalizeAnyChannelId: (channelId?: string) => channelId?.trim().toLowerCase(), })); function parseInboundMetaPayload(text: string): Record { diff --git a/src/auto-reply/reply/inbound-meta.ts b/src/auto-reply/reply/inbound-meta.ts index cf2718deb1f..f09059af960 100644 --- a/src/auto-reply/reply/inbound-meta.ts +++ b/src/auto-reply/reply/inbound-meta.ts @@ -1,6 +1,7 @@ import { normalizeChatType } from "../../channels/chat-type.js"; -import { getBundledChannelPlugin } from "../../channels/plugins/bundled.js"; -import { getLoadedChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; +import { getLoadedChannelPluginById } from "../../channels/plugins/registry-loaded.js"; +import type { ChannelPlugin } from "../../channels/plugins/types.plugin.js"; +import { normalizeAnyChannelId } from "../../channels/registry.js"; import { resolveSenderLabel } from "../../channels/sender-label.js"; import { normalizeOptionalString } from "../../shared/string-coerce.js"; import type { EnvelopeFormatOptions } from "../envelope.js"; @@ -39,10 +40,9 @@ function resolveInboundFormattingHints(ctx: TemplateContext): if (!channelValue) { return undefined; } - const normalizedChannel = normalizeChannelId(channelValue) ?? channelValue; - const agentPrompt = - getLoadedChannelPlugin(normalizedChannel)?.agentPrompt ?? - getBundledChannelPlugin(normalizedChannel)?.agentPrompt; + const normalizedChannel = normalizeAnyChannelId(channelValue) ?? channelValue; + const agentPrompt = (getLoadedChannelPluginById(normalizedChannel) as ChannelPlugin | undefined) + ?.agentPrompt; return agentPrompt?.inboundFormattingHints?.({ accountId: normalizeOptionalString(ctx.AccountId) ?? undefined, });