mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 04:31:10 +00:00
chore: enable consistent-return
This commit is contained in:
@@ -1496,7 +1496,7 @@ export default definePluginEntry({
|
||||
agentId: effectiveAgentId,
|
||||
sessionKey: resolvedSessionKey,
|
||||
});
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (!isEnabledForAgent(config, effectiveAgentId)) {
|
||||
await persistPluginStatusLines({
|
||||
@@ -1504,7 +1504,7 @@ export default definePluginEntry({
|
||||
agentId: effectiveAgentId,
|
||||
sessionKey: resolvedSessionKey,
|
||||
});
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (!isEligibleInteractiveSession(ctx)) {
|
||||
await persistPluginStatusLines({
|
||||
@@ -1512,7 +1512,7 @@ export default definePluginEntry({
|
||||
agentId: effectiveAgentId,
|
||||
sessionKey: resolvedSessionKey,
|
||||
});
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (
|
||||
!isAllowedChatType(config, {
|
||||
@@ -1526,7 +1526,7 @@ export default definePluginEntry({
|
||||
agentId: effectiveAgentId,
|
||||
sessionKey: resolvedSessionKey,
|
||||
});
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const query = buildQuery({
|
||||
latestUserMessage: event.prompt,
|
||||
@@ -1544,11 +1544,11 @@ export default definePluginEntry({
|
||||
currentModelId: ctx.modelId,
|
||||
});
|
||||
if (!result.summary) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const metadata = buildMetadata(result.summary);
|
||||
if (!metadata) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
prependSystemContext: ACTIVE_MEMORY_PLUGIN_GUIDANCE,
|
||||
|
||||
@@ -318,4 +318,5 @@ export function normalizeActRequest(
|
||||
};
|
||||
}
|
||||
}
|
||||
throw new Error("Unsupported browser act kind");
|
||||
}
|
||||
|
||||
@@ -307,6 +307,7 @@ function getExistingSessionUnsupportedMessage(action: BrowserActRequest): string
|
||||
case "close":
|
||||
return null;
|
||||
}
|
||||
throw new Error("Unsupported browser act kind");
|
||||
}
|
||||
|
||||
export function registerBrowserAgentActRoutes(
|
||||
|
||||
@@ -21,7 +21,7 @@ export function createBrowserProgram(params?: { withGatewayUrl?: boolean }): {
|
||||
if (params?.withGatewayUrl) {
|
||||
browser.option("--url <url>", "Gateway WebSocket URL");
|
||||
}
|
||||
const parentOpts = (cmd: Command) => cmd.parent?.opts?.() as BrowserParentOpts;
|
||||
const parentOpts = (cmd: Command): BrowserParentOpts => cmd.parent?.opts?.() as BrowserParentOpts;
|
||||
return { program, browser, parentOpts };
|
||||
}
|
||||
|
||||
|
||||
@@ -128,4 +128,5 @@ export async function handleDiscordModerationAction(
|
||||
return jsonResult({ ok: true });
|
||||
}
|
||||
}
|
||||
throw new Error("Unsupported Discord moderation action");
|
||||
}
|
||||
|
||||
@@ -52,6 +52,22 @@ type DiscordSubagentDeliveryTargetEvent = {
|
||||
};
|
||||
};
|
||||
|
||||
type DiscordSubagentSpawningResult =
|
||||
| { status: "ok"; threadBindingReady?: boolean }
|
||||
| { status: "error"; error: string }
|
||||
| undefined;
|
||||
|
||||
type DiscordSubagentDeliveryTargetResult =
|
||||
| {
|
||||
origin: {
|
||||
channel: "discord";
|
||||
accountId?: string;
|
||||
to: string;
|
||||
threadId?: string | number;
|
||||
};
|
||||
}
|
||||
| undefined;
|
||||
|
||||
function normalizeThreadBindingTargetKind(raw?: string): ThreadBindingTargetKind | undefined {
|
||||
const normalized = normalizeOptionalLowercaseString(raw);
|
||||
if (normalized === "subagent" || normalized === "acp") {
|
||||
@@ -84,13 +100,13 @@ function resolveThreadBindingFlags(api: OpenClawPluginApi, accountId?: string) {
|
||||
export async function handleDiscordSubagentSpawning(
|
||||
api: OpenClawPluginApi,
|
||||
event: DiscordSubagentSpawningEvent,
|
||||
) {
|
||||
): Promise<DiscordSubagentSpawningResult> {
|
||||
if (!event.threadRequested) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const channel = normalizeOptionalLowercaseString(event.requester?.channel);
|
||||
if (channel !== "discord") {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const threadBindingFlags = resolveThreadBindingFlags(api, event.requester?.accountId);
|
||||
if (!threadBindingFlags.enabled) {
|
||||
@@ -145,13 +161,15 @@ export function handleDiscordSubagentEnded(event: DiscordSubagentEndedEvent) {
|
||||
});
|
||||
}
|
||||
|
||||
export function handleDiscordSubagentDeliveryTarget(event: DiscordSubagentDeliveryTargetEvent) {
|
||||
export function handleDiscordSubagentDeliveryTarget(
|
||||
event: DiscordSubagentDeliveryTargetEvent,
|
||||
): DiscordSubagentDeliveryTargetResult {
|
||||
if (!event.expectsCompletionMessage) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const requesterChannel = normalizeOptionalLowercaseString(event.requesterOrigin?.channel);
|
||||
if (requesterChannel !== "discord") {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const requesterAccountId = event.requesterOrigin?.accountId?.trim();
|
||||
const requesterThreadId =
|
||||
@@ -164,7 +182,7 @@ export function handleDiscordSubagentDeliveryTarget(event: DiscordSubagentDelive
|
||||
targetKind: "subagent",
|
||||
});
|
||||
if (bindings.length === 0) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let binding: (typeof bindings)[number] | undefined;
|
||||
@@ -183,7 +201,7 @@ export function handleDiscordSubagentDeliveryTarget(event: DiscordSubagentDelive
|
||||
binding = bindings[0];
|
||||
}
|
||||
if (!binding) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
origin: {
|
||||
|
||||
@@ -270,16 +270,32 @@ type FeishuSubagentEndedEvent = {
|
||||
targetSessionKey: string;
|
||||
};
|
||||
|
||||
type FeishuSubagentSpawningResult =
|
||||
| { status: "ok"; threadBindingReady?: boolean }
|
||||
| { status: "error"; error: string }
|
||||
| undefined;
|
||||
|
||||
type FeishuSubagentDeliveryTargetResult =
|
||||
| {
|
||||
origin: {
|
||||
channel: "feishu";
|
||||
accountId?: string;
|
||||
to?: string;
|
||||
threadId?: string | number;
|
||||
};
|
||||
}
|
||||
| undefined;
|
||||
|
||||
export async function handleFeishuSubagentSpawning(
|
||||
event: FeishuSubagentSpawningEvent,
|
||||
ctx: FeishuSubagentContext,
|
||||
) {
|
||||
): Promise<FeishuSubagentSpawningResult> {
|
||||
if (!event.threadRequested) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const requesterChannel = normalizeOptionalLowercaseString(event.requester?.channel);
|
||||
if (requesterChannel !== "feishu") {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const manager = getFeishuThreadBindingManager(event.requester?.accountId);
|
||||
@@ -341,13 +357,15 @@ export async function handleFeishuSubagentSpawning(
|
||||
}
|
||||
}
|
||||
|
||||
export function handleFeishuSubagentDeliveryTarget(event: FeishuSubagentDeliveryTargetEvent) {
|
||||
export function handleFeishuSubagentDeliveryTarget(
|
||||
event: FeishuSubagentDeliveryTargetEvent,
|
||||
): FeishuSubagentDeliveryTargetResult {
|
||||
if (!event.expectsCompletionMessage) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const requesterChannel = normalizeOptionalLowercaseString(event.requesterOrigin?.channel);
|
||||
if (requesterChannel !== "feishu") {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const binding = resolveMatchingChildBinding({
|
||||
@@ -360,7 +378,7 @@ export function handleFeishuSubagentDeliveryTarget(event: FeishuSubagentDelivery
|
||||
},
|
||||
});
|
||||
if (!binding) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -456,18 +456,18 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
const readIngressPrefix = async () => {
|
||||
const selfUserId = await client.getUserId();
|
||||
if (senderId === selfUserId) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (dropPreStartupMessages) {
|
||||
if (typeof eventTs === "number" && eventTs < startupMs - startupGraceMs) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (
|
||||
typeof eventTs !== "number" &&
|
||||
typeof eventAge === "number" &&
|
||||
eventAge > startupGraceMs
|
||||
) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
})
|
||||
) {
|
||||
logVerboseMessage(`matrix: skip verification/system room message room=${roomId}`);
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const locationPayload: MatrixLocationPayload | null = resolveMatrixLocation({
|
||||
@@ -491,13 +491,13 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
|
||||
const relates = content["m.relates_to"];
|
||||
if (relates && "rel_type" in relates && relates.rel_type === RelationType.Replace) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (eventId && inboundDeduper) {
|
||||
claimedInboundEvent = inboundDeduper.claimEvent({ roomId, eventId });
|
||||
if (!claimedInboundEvent) {
|
||||
logVerboseMessage(`matrix: skip duplicate inbound event room=${roomId} id=${eventId}`);
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
const { locationPayload, selfUserId } = params;
|
||||
if (isRoom && groupPolicy === "disabled") {
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const roomInfoForConfig =
|
||||
@@ -553,24 +553,24 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
`matrix: drop configured bot sender=${senderId} (allowBots=false${isDirectMessage ? "" : `, ${roomMatchMeta}`})`,
|
||||
);
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (isRoom && roomConfig && !roomConfigInfo?.allowed) {
|
||||
logVerboseMessage(`matrix: room disabled room=${roomId} (${roomMatchMeta})`);
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (isRoom && groupPolicy === "allowlist") {
|
||||
if (!roomConfigInfo?.allowlistConfigured) {
|
||||
logVerboseMessage(`matrix: drop room message (no allowlist, ${roomMatchMeta})`);
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (!roomConfig) {
|
||||
logVerboseMessage(`matrix: drop room message (not in allowlist, ${roomMatchMeta})`);
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
if (isDirectMessage) {
|
||||
if (!dmEnabled || dmPolicy === "disabled") {
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (dmPolicy !== "open") {
|
||||
const allowMatchMeta = formatAllowlistMatchMeta(directAllowMatch);
|
||||
@@ -643,7 +643,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
logVerboseMessage(
|
||||
`matrix pairing reply failed for ${senderId}: ${String(err)}`,
|
||||
);
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
logVerboseMessage(
|
||||
@@ -658,7 +658,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
);
|
||||
await commitInboundEventIfClaimed();
|
||||
}
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -670,7 +670,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
)})`,
|
||||
);
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (
|
||||
isRoom &&
|
||||
@@ -686,7 +686,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
)})`,
|
||||
);
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (isRoom) {
|
||||
logVerboseMessage(`matrix: allow room ${roomId} (${roomMatchMeta})`);
|
||||
@@ -708,7 +708,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
logVerboseMessage,
|
||||
});
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let pollSnapshotPromise: Promise<MatrixPollSnapshot | null> | null = null;
|
||||
@@ -748,7 +748,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
: "";
|
||||
if (!mentionPrecheckText && !mediaUrl && !isPollEvent) {
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const _messageId = event.event_id ?? "";
|
||||
@@ -797,7 +797,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
`matrix: drop configured bot sender=${senderId} (allowBots=mentions, missing mention, ${roomMatchMeta})`,
|
||||
);
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const allowTextCommands = core.channel.commands.shouldHandleTextCommands({
|
||||
cfg,
|
||||
@@ -823,7 +823,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
target: senderId,
|
||||
});
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const shouldRequireMention = isRoom
|
||||
? roomConfig?.autoReply === true
|
||||
@@ -856,13 +856,13 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
}
|
||||
logger.info("skipping room message", { roomId, reason: "no-mention" });
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (isPollEvent) {
|
||||
const pollSnapshot = await getPollSnapshot();
|
||||
if (!pollSnapshot) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
content = {
|
||||
msgtype: "m.text",
|
||||
@@ -935,7 +935,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
});
|
||||
if (!bodyText) {
|
||||
await commitInboundEventIfClaimed();
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const senderName = await getSenderName();
|
||||
if (_configuredBinding) {
|
||||
@@ -950,7 +950,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
reason: "configured ACP binding unavailable",
|
||||
target: _configuredBinding.spec.conversationId,
|
||||
});
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
if (_runtimeBindingId) {
|
||||
@@ -997,7 +997,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
? await runRoomIngress(roomId, async () => {
|
||||
const prefix = await readIngressPrefix();
|
||||
if (!prefix) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (prefix.isDirectMessage) {
|
||||
return { deferredPrefix: prefix } as const;
|
||||
@@ -1013,7 +1013,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
: await (async () => {
|
||||
const prefix = await readIngressPrefix();
|
||||
if (!prefix) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
return await continueIngress(prefix);
|
||||
})();
|
||||
|
||||
@@ -40,6 +40,8 @@ type MemorySearchResult = {
|
||||
score: number;
|
||||
};
|
||||
|
||||
type LegacyBeforeAgentStartContext = { prependContext: string } | undefined;
|
||||
|
||||
// ============================================================================
|
||||
// LanceDB Provider
|
||||
// ============================================================================
|
||||
@@ -536,9 +538,9 @@ export default definePluginEntry({
|
||||
|
||||
// Auto-recall: inject relevant memories before agent starts
|
||||
if (cfg.autoRecall) {
|
||||
api.on("before_agent_start", async (event) => {
|
||||
api.on("before_agent_start", async (event): Promise<LegacyBeforeAgentStartContext> => {
|
||||
if (!event.prompt || event.prompt.length < 5) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -546,7 +548,7 @@ export default definePluginEntry({
|
||||
const results = await db.search(vector, 3, 0.3);
|
||||
|
||||
if (results.length === 0) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
api.logger.info?.(`memory-lancedb: injecting ${results.length} memories into context`);
|
||||
@@ -559,6 +561,7 @@ export default definePluginEntry({
|
||||
} catch (err) {
|
||||
api.logger.warn(`memory-lancedb: recall failed: ${String(err)}`);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -289,6 +289,7 @@ function formatFreshnessLabel(freshness: WikiFreshness): string {
|
||||
case "unknown":
|
||||
return freshness.reason;
|
||||
}
|
||||
throw new Error("Unsupported wiki freshness level");
|
||||
}
|
||||
|
||||
function formatClaimIdentity(claim: WikiClaimHealth): string {
|
||||
@@ -761,6 +762,7 @@ function rankFreshnessLevel(level: WikiFreshnessLevel): number {
|
||||
case "unknown":
|
||||
return 0;
|
||||
}
|
||||
throw new Error("Unsupported wiki freshness level");
|
||||
}
|
||||
|
||||
function sortClaims(page: WikiPageSummary): WikiClaim[] {
|
||||
|
||||
@@ -64,7 +64,7 @@ export const nextcloudTalkSetupWizard: ChannelSetupWizard = {
|
||||
initialValue: hasApiCredentials,
|
||||
});
|
||||
if (!configureApiCredentials) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
credentialValues: {
|
||||
|
||||
@@ -73,6 +73,7 @@ export function cloneEvent(event: QaBusEvent): QaBusEvent {
|
||||
case "thread-created":
|
||||
return { ...event, thread: { ...event.thread } };
|
||||
}
|
||||
throw new Error("Unsupported QA bus event kind");
|
||||
}
|
||||
|
||||
export function buildQaBusSnapshot(params: {
|
||||
|
||||
@@ -501,6 +501,7 @@ async function sendQQBotTextChunk(params: {
|
||||
if (event.channelId) {
|
||||
return await sendChannelMessage(token, event.channelId, text, event.messageId);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function sendTextChunks(
|
||||
|
||||
@@ -42,7 +42,7 @@ export const signalSetupWizard: ChannelSetupWizard = {
|
||||
}),
|
||||
prepare: async ({ cfg, accountId, credentialValues, runtime, prompter, options }) => {
|
||||
if (!options?.allowSignalInstall) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const currentCliPath =
|
||||
(typeof credentialValues.cliPath === "string" ? credentialValues.cliPath : undefined) ??
|
||||
@@ -56,7 +56,7 @@ export const signalSetupWizard: ChannelSetupWizard = {
|
||||
initialValue: !cliDetected,
|
||||
});
|
||||
if (!wantsInstall) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
const result = await installSignalCli(runtime);
|
||||
@@ -74,6 +74,7 @@ export const signalSetupWizard: ChannelSetupWizard = {
|
||||
} catch (error) {
|
||||
await prompter.note(`signal-cli install failed: ${String(error)}`, "Signal");
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
credentials: [],
|
||||
textInputs: [
|
||||
|
||||
@@ -257,7 +257,7 @@ export function createSlackSetupWizardBase(handlers: {
|
||||
}),
|
||||
finalize: async ({ cfg, accountId, options, prompter }) => {
|
||||
if (hasSlackInteractiveRepliesConfig(cfg, accountId)) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (options?.quickstartDefaults) {
|
||||
return {
|
||||
|
||||
@@ -13,6 +13,7 @@ type ThreadOwnershipConfig = {
|
||||
};
|
||||
|
||||
type AgentEntry = NonNullable<NonNullable<OpenClawConfig["agents"]>["list"]>[number];
|
||||
type ThreadOwnershipMessageSendingResult = { cancel: true } | undefined;
|
||||
|
||||
// In-memory set of {channel}:{thread} keys where this agent was @-mentioned.
|
||||
// Entries expire after 5 minutes.
|
||||
@@ -86,23 +87,23 @@ export default definePluginEntry({
|
||||
}
|
||||
});
|
||||
|
||||
api.on("message_sending", async (event, ctx) => {
|
||||
api.on("message_sending", async (event, ctx): Promise<ThreadOwnershipMessageSendingResult> => {
|
||||
if (ctx.channelId !== "slack") {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const threadTs = (event.metadata?.threadTs as string) ?? "";
|
||||
const channelId = (event.metadata?.channelId as string) ?? event.to;
|
||||
if (!threadTs) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (abTestChannels.size > 0 && !abTestChannels.has(channelId)) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
cleanExpiredMentions();
|
||||
if (mentionedThreads.has(`${channelId}:${threadTs}`)) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -122,7 +123,7 @@ export default definePluginEntry({
|
||||
|
||||
try {
|
||||
if (resp.ok) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (resp.status === 409) {
|
||||
const body = (await resp.json()) as { owner?: string };
|
||||
@@ -140,6 +141,7 @@ export default definePluginEntry({
|
||||
`thread-ownership: ownership check failed (${String(err)}), allowing send`,
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -352,6 +352,7 @@ export function createTlonApprovalRuntime(params: {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw new Error("Unsupported Tlon admin command");
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -92,6 +92,7 @@ export function formatApprovalRequest(approval: PendingApproval): string {
|
||||
`(ID: ${approval.id})`
|
||||
);
|
||||
}
|
||||
throw new Error("Unsupported approval type");
|
||||
}
|
||||
|
||||
export type ApprovalResponse = {
|
||||
@@ -211,6 +212,7 @@ export function formatApprovalConfirmation(
|
||||
}
|
||||
return `${actionText} group invite from ${approval.requestingShip} to ${approval.groupFlag}.`;
|
||||
}
|
||||
throw new Error("Unsupported approval type");
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@@ -658,6 +658,7 @@ async function executeWebhookAction(params: {
|
||||
};
|
||||
}
|
||||
}
|
||||
throw new Error("Unsupported webhook action");
|
||||
}
|
||||
|
||||
export function createTaskFlowWebhookRequestHandler(params: {
|
||||
|
||||
@@ -173,9 +173,9 @@ function startPollingLoop(params: ZaloPollingLoopParams) {
|
||||
|
||||
runtime.log?.(`[${account.accountId}] Zalo polling loop started timeout=${String(pollTimeout)}s`);
|
||||
|
||||
const poll = async () => {
|
||||
const poll = async (): Promise<void> => {
|
||||
if (isStopped() || abortSignal.aborted) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -209,7 +209,7 @@ async function processUpdate(params: ZaloUpdateProcessingParams): Promise<void>
|
||||
const { event_name, message } = update;
|
||||
const sharedContext = { token, account, config, runtime, core, statusSink, fetcher };
|
||||
if (!message) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
switch (event_name) {
|
||||
@@ -245,7 +245,7 @@ async function handleTextMessage(
|
||||
const { message } = params;
|
||||
const { text } = message;
|
||||
if (!text?.trim()) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
await processMessageWithPipeline({
|
||||
@@ -350,7 +350,7 @@ async function authorizeZaloMessage(
|
||||
} else if (groupAccess.reason === "sender_not_allowlisted") {
|
||||
logVerbose(core, runtime, `zalo: drop group sender ${senderId} (groupPolicy=allowlist)`);
|
||||
}
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ async function authorizeZaloMessage(
|
||||
});
|
||||
if (directDmOutcome === "disabled") {
|
||||
logVerbose(core, runtime, `Blocked zalo DM from ${senderId} (dmPolicy=disabled)`);
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
if (directDmOutcome === "unauthorized") {
|
||||
if (dmPolicy === "pairing") {
|
||||
@@ -409,7 +409,7 @@ async function authorizeZaloMessage(
|
||||
`Blocked unauthorized zalo sender ${senderId} (dmPolicy=${dmPolicy})`,
|
||||
);
|
||||
}
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user