fix(plugins): clean second channel lint batch

This commit is contained in:
Vincent Koc
2026-04-06 14:29:51 +01:00
parent c3edcfd46e
commit 98f222a661
7 changed files with 11 additions and 57 deletions

View File

@@ -17,11 +17,7 @@ import {
createRuntimeDirectoryLiveAdapter,
} from "openclaw/plugin-sdk/directory-runtime";
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
import {
createRuntimeOutboundDelegates,
resolveOutboundSendDep,
} from "openclaw/plugin-sdk/outbound-runtime";
import { normalizeMessageChannel } from "openclaw/plugin-sdk/routing";
import { resolveOutboundSendDep } from "openclaw/plugin-sdk/outbound-runtime";
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
import {
createComputedAccountStatusAdapter,
@@ -39,7 +35,6 @@ import {
buildTokenChannelStatusSummary,
type ChannelPlugin,
DEFAULT_ACCOUNT_ID,
getChatChannelMeta,
PAIRING_APPROVED_MESSAGE,
projectCredentialSnapshotFields,
resolveConfiguredFromCredentialStatuses,
@@ -129,9 +124,6 @@ function loadDiscordCarbonModule() {
return discordCarbonModuleCache;
}
const meta = {
...getChatChannelMeta("discord"),
};
const REQUIRED_DISCORD_PERMISSIONS = ["ViewChannel", "SendMessages"] as const;
const DISCORD_ACCOUNT_STARTUP_STAGGER_MS = 10_000;
const DISCORD_VIDEO_MEDIA_EXTENSIONS = new Set([".avi", ".m4v", ".mkv", ".mov", ".mp4", ".webm"]);
@@ -605,7 +597,7 @@ export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount, DiscordProbe>
maxAgeMs,
}).map(toConversationLifecycleBinding),
},
status: createComputedAccountStatusAdapter<ResolvedDiscordAccount, DiscordProbe, unknown>({
status: createComputedAccountStatusAdapter<ResolvedDiscordAccount, DiscordProbe>({
defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID, {
connected: false,
reconnectAttempts: 0,
@@ -634,7 +626,7 @@ export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount, DiscordProbe>
}
return lines;
},
buildCapabilitiesDiagnostics: async ({ account, timeoutMs, target }) => {
buildCapabilitiesDiagnostics: async ({ account, target }) => {
if (!target?.trim()) {
return undefined;
}

View File

@@ -30,7 +30,7 @@ function ensureNestedRecord(owner: Record<string, unknown>, key: string): Record
}
function sanitizeForLog(value: string): string {
return value.replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
return value.replace(/\p{Cc}+/gu, " ").trim();
}
function isDiscordMutableAllowEntry(raw: string): boolean {
@@ -457,14 +457,14 @@ export function collectDiscordNumericIdWarnings(params: {
const lines: string[] = [];
if (repairableHits.length > 0) {
const sample = repairableHits[0]!;
const sample = repairableHits[0];
lines.push(
`- Discord allowlists contain ${repairableHits.length} numeric ${repairableHits.length === 1 ? "entry" : "entries"} (e.g. ${sanitizeForLog(sample.path)}=${sanitizeForLog(String(sample.entry))}).`,
`- Discord IDs must be strings; run "${params.doctorFixCommand}" to convert numeric IDs to quoted strings.`,
);
}
if (blockedHits.length > 0) {
const sample = blockedHits[0]!;
const sample = blockedHits[0];
lines.push(
`- Discord allowlists contain ${blockedHits.length} numeric ${blockedHits.length === 1 ? "entry" : "entries"} in lists that cannot be auto-repaired (e.g. ${sanitizeForLog(sample.path)}).`,
`- These lists include invalid or precision-losing numeric IDs; manually quote the original values in your config file, then rerun "${params.doctorFixCommand}".`,

View File

@@ -672,31 +672,3 @@ export function resolveDiscordReplyDeliveryPlan(params: {
});
return { deliverTarget, replyTarget, replyReference };
}
/**
* Extract text from forwarded message snapshots for thread starter resolution.
* Discord forwarded messages have empty `content` and store the original text
* in `message_snapshots[0].message.content`.
*/
function resolveStarterForwardedText(
snapshots?: Array<{
message?: {
content?: string | null;
attachments?: unknown[];
embeds?: Array<{ title?: string | null; description?: string | null }>;
sticker_items?: unknown[];
};
}>,
): string {
if (!Array.isArray(snapshots) || snapshots.length === 0) {
return "";
}
const blocks: string[] = [];
for (const snapshot of snapshots) {
const msg = snapshot.message;
if (!msg) continue;
const text = msg.content?.trim() || resolveDiscordEmbedText(msg.embeds?.[0]) || "";
if (text) blocks.push(`[Forwarded message]\n${text}`);
}
return blocks.join("\n\n");
}

View File

@@ -9,8 +9,6 @@ import {
type LineConfig,
} from "./setup-runtime-api.js";
const channel = "line" as const;
export function patchLineAccountConfig(params: {
cfg: OpenClawConfig;
accountId: string;
@@ -41,7 +39,7 @@ export function patchLineAccountConfig(params: {
}
const nextAccount = {
...(lineConfig.accounts?.[accountId] ?? {}),
...lineConfig.accounts?.[accountId],
} as Record<string, unknown>;
for (const field of clearFields) {
delete nextAccount[field];

View File

@@ -16,10 +16,7 @@ import {
} from "openclaw/plugin-sdk/directory-runtime";
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
import {
createRuntimeOutboundDelegates,
resolveOutboundSendDep,
} from "openclaw/plugin-sdk/outbound-runtime";
import { resolveOutboundSendDep } from "openclaw/plugin-sdk/outbound-runtime";
import {
buildOutboundBaseSessionKey,
normalizeOutboundThreadId,
@@ -32,7 +29,6 @@ import {
} from "openclaw/plugin-sdk/status-helpers";
import { resolveTargetsWithOptionalToken } from "openclaw/plugin-sdk/target-resolver-runtime";
import {
listEnabledSlackAccounts,
resolveDefaultSlackAccountId,
resolveSlackAccount,
resolveSlackReplyToMode,
@@ -573,7 +569,7 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount, SlackProbe> = crea
return await slackOutbound.sendPayload!({
...ctx,
deps: {
...(ctx.deps ?? {}),
...ctx.deps,
slack: async (
to: Parameters<SlackSendFn>[0],
text: Parameters<SlackSendFn>[1],

View File

@@ -23,7 +23,7 @@ function ensureNestedRecord(owner: Record<string, unknown>, key: string): Record
}
function sanitizeForLog(value: string): string {
return value.replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
return value.replace(/\p{Cc}+/gu, " ").trim();
}
function normalizeSlackDmAliases(params: {

View File

@@ -1,10 +1,6 @@
import { truncateSlackText } from "../../truncate.js";
import type { SlackMonitorContext } from "../context.js";
import {
registerSlackBlockActionHandler,
summarizeAction,
type InteractionSummary,
} from "./interactions.block-actions.js";
import { registerSlackBlockActionHandler, summarizeAction } from "./interactions.block-actions.js";
import {
registerModalLifecycleHandler,
type ModalInputSummary,