fix(telegram): restore account reply mode on beta.1

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-08-08 19:36:23 -07:00
committed by GitHub
parent 2965190344
commit da4e341b07
3 changed files with 64 additions and 3 deletions
+3 -1
View File
@@ -90,6 +90,7 @@ import {
createTelegramPluginBase,
findTelegramTokenOwnerAccountId,
formatDuplicateTelegramTokenReason,
resolveTelegramConfigAccessorAccount,
telegramConfigAdapter,
} from "./shared.js";
import { withTelegramStartupProbeSlot } from "./startup-probe-limiter.js";
@@ -1246,7 +1247,8 @@ export const telegramPlugin = createChatChannelPlugin({
},
security: telegramSecurityAdapter,
threading: {
topLevelReplyToMode: "telegram",
resolveReplyToMode: ({ cfg, accountId }) =>
resolveTelegramConfigAccessorAccount({ cfg, accountId }).config.replyToMode ?? "off",
buildToolContext: (params) => buildTelegramThreadingToolContext(params),
resolveAutoThreadId: ({ to, toolContext }) => resolveTelegramAutoThreadId({ to, toolContext }),
resolveCurrentChannelId: ({ to, threadId }) => {
+1 -1
View File
@@ -104,7 +104,7 @@ function isBlockedByMultiBotGuard(cfg: OpenClawConfig, accountId: string): boole
return !resolveNormalizedAccountEntry(accounts, accountId, normalizeAccountId);
}
function resolveTelegramConfigAccessorAccount(params: {
export function resolveTelegramConfigAccessorAccount(params: {
cfg: OpenClawConfig;
accountId?: string | null;
}): TelegramConfigAccessorAccount {
@@ -1,8 +1,67 @@
// Telegram tests cover threading tool context plugin behavior.
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { telegramPlugin } from "./channel.js";
import { buildTelegramThreadingToolContext } from "./threading-tool-context.js";
const tryReadSecretFileSyncMock = vi.hoisted(() =>
vi.fn(() => {
throw new Error("reply mode must not read Telegram credentials");
}),
);
vi.mock("openclaw/plugin-sdk/secret-file-runtime", async (importOriginal) => ({
...(await importOriginal<typeof import("openclaw/plugin-sdk/secret-file-runtime")>()),
tryReadSecretFileSync: tryReadSecretFileSyncMock,
}));
describe("telegramPlugin reply threading", () => {
it.each([
{
name: "uses an account override",
telegram: {
accounts: {
sut: {
tokenFile: "/tmp/openclaw-telegram-reply-mode-must-not-read",
replyToMode: "first" as const,
},
},
},
expected: "first",
},
{
name: "inherits the top-level mode",
telegram: {
replyToMode: "all" as const,
accounts: {
sut: {
botToken: { source: "file", provider: "telegram_token", id: "value" },
},
},
},
expected: "all",
},
{
name: "allows an account to disable replies",
telegram: {
replyToMode: "all" as const,
accounts: { sut: { replyToMode: "off" as const } },
},
expected: "off",
},
])("$name", ({ telegram, expected }) => {
tryReadSecretFileSyncMock.mockClear();
const resolveReplyToMode = telegramPlugin.threading?.resolveReplyToMode;
if (!resolveReplyToMode) {
throw new Error("Telegram reply mode resolver is unavailable");
}
const cfg = { channels: { telegram } } as unknown as OpenClawConfig;
expect(resolveReplyToMode({ cfg, accountId: "sut" })).toBe(expected);
expect(tryReadSecretFileSyncMock).not.toHaveBeenCalled();
});
});
describe("buildTelegramThreadingToolContext", () => {
it("keeps topic thread state in plugin-owned tool context", () => {
const hasRepliedRef = { value: false };