mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 19:21:08 +00:00
fix(cycles): use loaded channel prompt hints
This commit is contained in:
@@ -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 <url|label>.",
|
||||
"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<string, unknown> {
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user