Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled

Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11),
free to diverge. Tree copied sans upstream .git; upstream remote added for
future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19.
Preserves docs/ARCHITECTURE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
2026-07-05 09:36:54 +00:00
parent 3216769225
commit bedb527145
21108 changed files with 6010766 additions and 0 deletions

View File

@@ -0,0 +1,489 @@
// Telegram tests cover status plugin behavior.
import type { ChannelAccountSnapshot } from "openclaw/plugin-sdk/channel-contract";
import { DEFAULT_EMOJIS } from "openclaw/plugin-sdk/channel-feedback";
import { describe, expect, it } from "vitest";
import type { TelegramChatDetails, TelegramGetChat } from "./bot/types.js";
import { collectTelegramStatusIssues } from "./status-issues.js";
import {
buildTelegramStatusReactionVariants,
extractTelegramAllowedEmojiReactions,
isTelegramSupportedReactionEmoji,
resolveTelegramAllowedEmojiReactions,
resolveTelegramReactionVariant,
resolveTelegramStatusReactionEmojis,
} from "./status-reaction-variants.js";
type StatusIssue = ReturnType<typeof collectTelegramStatusIssues>[number];
function expectIssueFields(issue: StatusIssue | undefined, expected: Partial<StatusIssue>): void {
if (!issue) {
throw new Error("expected status issue");
}
for (const [key, value] of Object.entries(expected)) {
expect(issue[key as keyof StatusIssue]).toBe(value);
}
}
function expectIssueListContainsFields(
issues: StatusIssue[],
expected: Partial<StatusIssue>,
): void {
const match = issues.find((issue) =>
Object.entries(expected).every(([key, value]) => issue[key as keyof StatusIssue] === value),
);
expectIssueFields(match, expected);
}
function expectIssueMessageContains(issues: StatusIssue[], text: string): void {
expect(issues.map((issue) => issue.message).join("\n")).toContain(text);
}
describe("collectTelegramStatusIssues", () => {
it("reports privacy-mode and wildcard unmentioned-group configuration risks", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
allowUnmentionedGroups: true,
audit: {
hasWildcardUnmentionedGroups: true,
unresolvedGroups: 2,
},
} as ChannelAccountSnapshot,
]);
expectIssueListContainsFields(issues, {
channel: "telegram",
accountId: "main",
kind: "config",
});
expectIssueMessageContains(issues, "privacy mode");
expectIssueMessageContains(issues, 'uses "*"');
expectIssueMessageContains(issues, "unresolvedGroups=2");
});
it("reports unreachable groups with match metadata", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
audit: {
groups: [
{
chatId: "-100123",
ok: false,
status: "left",
error: "403",
matchKey: "alerts",
matchSource: "channels.telegram.groups",
},
],
},
} as ChannelAccountSnapshot,
]);
expect(issues).toHaveLength(1);
expectIssueFields(issues[0], {
channel: "telegram",
accountId: "main",
kind: "runtime",
});
expect(issues[0]?.message).toContain("Group -100123 not reachable");
expect(issues[0]?.message).toContain("alerts");
expect(issues[0]?.message).toContain("channels.telegram.groups");
});
it("reports polling runtime state that never completed getUpdates after startup grace", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "polling",
connected: false,
lastStartAt: Date.now() - 121_000,
lastError: "network timeout",
} as ChannelAccountSnapshot,
]);
expect(issues).toHaveLength(1);
expectIssueFields(issues[0], {
channel: "telegram",
accountId: "main",
kind: "runtime",
});
expect(issues[0]?.message).toContain("has not completed a successful getUpdates call");
expect(issues[0]?.message).toContain("network timeout");
expect(issues[0]?.fix).toContain("channels status --probe");
});
it("reports isolated polling spool backlog stalls distinctly from startup failures", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "polling",
connected: false,
lastStartAt: Date.now() - 121_000,
lastError:
"Telegram isolated polling spool backlog stalled behind update 42 on lane telegram:123 for 1500100ms; marking polling unhealthy until the backlog drains.",
} as ChannelAccountSnapshot,
]);
expect(issues).toHaveLength(1);
expectIssueFields(issues[0], {
channel: "telegram",
accountId: "main",
kind: "runtime",
});
expect(issues[0]?.message).toContain("spool backlog is stalled");
expect(issues[0]?.message).not.toContain("has not completed a successful getUpdates call");
});
it("reports isolated polling spool handler timeouts distinctly from startup failures", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "polling",
connected: false,
lastStartAt: Date.now() - 121_000,
lastError:
"Telegram isolated polling spool handler timed out behind update 42 on lane telegram:123 after 1500100ms; marking the update failed and restarting isolated ingress so later updates can drain.",
} as ChannelAccountSnapshot,
]);
expect(issues).toHaveLength(1);
expectIssueFields(issues[0], {
channel: "telegram",
accountId: "main",
kind: "runtime",
});
expect(issues[0]?.message).toContain("spool backlog is stalled");
expect(issues[0]?.message).not.toContain("has not completed a successful getUpdates call");
});
it("does not report polling startup before the connect grace expires", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "polling",
connected: false,
lastStartAt: Date.now() - 60_000,
} as ChannelAccountSnapshot,
]);
expect(issues).toStrictEqual([]);
});
it("reports stale polling transport activity after successful getUpdates stops refreshing", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "polling",
connected: true,
lastStartAt: Date.now() - 60 * 60_000,
lastTransportActivityAt: Date.now() - 31 * 60_000,
} as ChannelAccountSnapshot,
]);
expect(issues).toHaveLength(1);
expectIssueFields(issues[0], {
channel: "telegram",
accountId: "main",
kind: "runtime",
});
expect(issues[0]?.message).toContain("polling transport is stale");
});
it("does not report inherited stale transport activity during a fresh polling lifecycle", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "polling",
connected: true,
lastStartAt: Date.now() - 60_000,
lastTransportActivityAt: Date.now() - 2 * 60 * 60_000,
} as ChannelAccountSnapshot,
]);
expect(issues).toStrictEqual([]);
});
it("reports webhook runtime state that never completed setWebhook after startup grace", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "webhook",
connected: false,
lastStartAt: Date.now() - 10 * 60_000,
lastError: "fetch failed",
} as ChannelAccountSnapshot,
]);
expect(issues).toHaveLength(1);
expectIssueFields(issues[0], {
channel: "telegram",
accountId: "main",
kind: "runtime",
});
expect(issues[0]?.message).toContain("setWebhook has not completed");
expect(issues[0]?.message).toContain("fetch failed");
expect(issues[0]?.fix).toContain("webhook URL");
});
it("does not report webhook startup before the connect grace expires", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "webhook",
connected: false,
lastStartAt: Date.now() - 60_000,
} as ChannelAccountSnapshot,
]);
expect(issues).toStrictEqual([]);
});
it("does not report an advertised webhook just because no user updates arrived", () => {
const issues = collectTelegramStatusIssues([
{
accountId: "main",
enabled: true,
configured: true,
running: true,
mode: "webhook",
connected: true,
lastStartAt: Date.now() - 60 * 60_000,
} as ChannelAccountSnapshot,
]);
expect(issues).toStrictEqual([]);
});
it("ignores accounts that are not both enabled and configured", () => {
expect(
collectTelegramStatusIssues([
{
accountId: "main",
enabled: false,
configured: true,
} as ChannelAccountSnapshot,
]),
).toStrictEqual([]);
});
});
describe("resolveTelegramStatusReactionEmojis", () => {
it("falls back to Telegram-safe defaults for empty overrides", () => {
const result = resolveTelegramStatusReactionEmojis({
initialEmoji: "👀",
overrides: {
thinking: " ",
done: "\n",
},
});
expect(result.queued).toBe("👀");
expect(result.thinking).toBe(DEFAULT_EMOJIS.thinking);
expect(result.done).toBe(DEFAULT_EMOJIS.done);
});
it("preserves explicit non-empty overrides", () => {
const result = resolveTelegramStatusReactionEmojis({
initialEmoji: "👀",
overrides: {
thinking: "🫡",
done: "🎉",
},
});
expect(result.thinking).toBe("🫡");
expect(result.done).toBe("🎉");
});
});
describe("buildTelegramStatusReactionVariants", () => {
it("puts requested emoji first and appends Telegram fallbacks", () => {
const variants = buildTelegramStatusReactionVariants({
...DEFAULT_EMOJIS,
coding: "🛠️",
});
expect(variants.get("🛠️")).toEqual(["🛠️", "👨‍💻", "🔥", "⚡"]);
});
});
describe("isTelegramSupportedReactionEmoji", () => {
it("accepts Telegram-supported reaction emojis", () => {
expect(isTelegramSupportedReactionEmoji("👀")).toBe(true);
expect(isTelegramSupportedReactionEmoji("👨‍💻")).toBe(true);
});
it("rejects unsupported emojis", () => {
expect(isTelegramSupportedReactionEmoji("🫠")).toBe(false);
});
});
describe("extractTelegramAllowedEmojiReactions", () => {
it("returns undefined when chat does not include available_reactions", () => {
const result = extractTelegramAllowedEmojiReactions({ id: 1 } satisfies TelegramChatDetails);
expect(result).toBeUndefined();
});
it("returns null when available_reactions is omitted/null", () => {
const result = extractTelegramAllowedEmojiReactions({
available_reactions: null,
} satisfies TelegramChatDetails);
expect(result).toBeNull();
});
it("extracts emoji reactions only", () => {
const result = extractTelegramAllowedEmojiReactions({
available_reactions: [
{ type: "emoji", emoji: "👍" },
{ type: "custom_emoji", custom_emoji_id: "abc" },
{ type: "emoji", emoji: "🔥" },
],
} satisfies TelegramChatDetails);
expect(result ? Array.from(result).toSorted() : null).toEqual(["👍", "🔥"]);
});
it("treats malformed available_reactions payloads as an empty allowlist instead of throwing", () => {
expect(
extractTelegramAllowedEmojiReactions({
available_reactions: { type: "emoji", emoji: "👍" },
} as never),
).toEqual(new Set<string>());
});
});
describe("resolveTelegramAllowedEmojiReactions", () => {
it("uses getChat lookup when message chat does not include available_reactions", async () => {
const getChat: TelegramGetChat = async () => ({
available_reactions: [{ type: "emoji", emoji: "👍" }],
});
const result = await resolveTelegramAllowedEmojiReactions({
chat: { id: 1 } satisfies TelegramChatDetails,
chatId: 1,
getChat,
});
expect(result ? Array.from(result) : null).toEqual(["👍"]);
});
it("falls back to unrestricted reactions when getChat lookup fails", async () => {
const getChat = async () => {
throw new Error("lookup failed");
};
const result = await resolveTelegramAllowedEmojiReactions({
chat: { id: 1 } satisfies TelegramChatDetails,
chatId: 1,
getChat,
});
expect(result).toBeNull();
});
});
describe("resolveTelegramReactionVariant", () => {
it("returns requested emoji when already Telegram-supported", () => {
const variantsByEmoji = buildTelegramStatusReactionVariants({
...DEFAULT_EMOJIS,
coding: "👨‍💻",
});
const result = resolveTelegramReactionVariant({
requestedEmoji: "👨‍💻",
variantsByRequestedEmoji: variantsByEmoji,
});
expect(result).toBe("👨‍💻");
});
it("returns first Telegram-supported fallback for unsupported requested emoji", () => {
const variantsByEmoji = buildTelegramStatusReactionVariants({
...DEFAULT_EMOJIS,
coding: "🛠️",
});
const result = resolveTelegramReactionVariant({
requestedEmoji: "🛠️",
variantsByRequestedEmoji: variantsByEmoji,
});
expect(result).toBe("👨‍💻");
});
it("uses generic Telegram fallbacks for unknown emojis", () => {
const result = resolveTelegramReactionVariant({
requestedEmoji: "🫠",
variantsByRequestedEmoji: new Map(),
});
expect(result).toBe("👍");
});
it("respects chat allowed reactions", () => {
const variantsByEmoji = buildTelegramStatusReactionVariants({
...DEFAULT_EMOJIS,
coding: "👨‍💻",
});
const result = resolveTelegramReactionVariant({
requestedEmoji: "👨‍💻",
variantsByRequestedEmoji: variantsByEmoji,
allowedEmojiReactions: new Set(["👍"]),
});
expect(result).toBe("👍");
});
it("returns undefined when no candidate is chat-allowed", () => {
const variantsByEmoji = buildTelegramStatusReactionVariants({
...DEFAULT_EMOJIS,
coding: "👨‍💻",
});
const result = resolveTelegramReactionVariant({
requestedEmoji: "👨‍💻",
variantsByRequestedEmoji: variantsByEmoji,
allowedEmojiReactions: new Set(["🎉"]),
});
expect(result).toBeUndefined();
});
it("returns undefined for empty requested emoji", () => {
const result = resolveTelegramReactionVariant({
requestedEmoji: " ",
variantsByRequestedEmoji: new Map(),
});
expect(result).toBeUndefined();
});
});