mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:40:44 +00:00
refactor: trim slack helper exports
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import type { SlackAccountConfig } from "./runtime-api.js";
|
||||
|
||||
export type SlackReplyToMode = "off" | "first" | "all" | "batched";
|
||||
type SlackReplyToMode = "off" | "first" | "all" | "batched";
|
||||
|
||||
export type SlackReplyToModeAccount = {
|
||||
type SlackReplyToModeAccount = {
|
||||
replyToMode?: SlackReplyToMode;
|
||||
replyToModeByChatType?: SlackAccountConfig["replyToModeByChatType"];
|
||||
dm?: { replyToMode?: SlackReplyToMode };
|
||||
|
||||
@@ -44,7 +44,7 @@ const { listAccountIds, resolveDefaultAccountId } = createAccountListHelpers("sl
|
||||
export const listSlackAccountIds = listAccountIds;
|
||||
export const resolveDefaultSlackAccountId = resolveDefaultAccountId;
|
||||
|
||||
export function resolveSlackAccountConfig(
|
||||
function resolveSlackAccountConfig(
|
||||
cfg: OpenClawConfig,
|
||||
accountId: string,
|
||||
): SlackAccountConfig | undefined {
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import { resolveSlackAccount, resolveSlackAccountAllowFrom } from "./accounts.js";
|
||||
import { normalizeSlackApproverId } from "./exec-approvals.js";
|
||||
|
||||
export function getSlackApprovalApprovers(params: {
|
||||
function getSlackApprovalApprovers(params: {
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
}): string[] {
|
||||
|
||||
@@ -21,7 +21,7 @@ const SLACK_ACTION_BLOCK_ELEMENTS_MAX = 25;
|
||||
|
||||
export type SlackBlock = Block | KnownBlock;
|
||||
|
||||
export type SlackInteractiveBlockRenderOptions = {
|
||||
type SlackInteractiveBlockRenderOptions = {
|
||||
buttonIndexOffset?: number;
|
||||
selectIndexOffset?: number;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ type SlackChannels = Record<string, SlackChannelConfig>;
|
||||
|
||||
type MigrationScope = "account" | "global";
|
||||
|
||||
export type SlackChannelMigrationResult = {
|
||||
type SlackChannelMigrationResult = {
|
||||
migrated: boolean;
|
||||
skippedExisting: boolean;
|
||||
scopes: MigrationScope[];
|
||||
|
||||
@@ -12,7 +12,7 @@ function asObjectRecord(value: unknown): Record<string, unknown> | null {
|
||||
: null;
|
||||
}
|
||||
|
||||
export const collectSlackMutableAllowlistWarnings =
|
||||
const collectSlackMutableAllowlistWarnings =
|
||||
createDangerousNameMatchingMutableAllowlistWarningCollector({
|
||||
channel: "slack",
|
||||
detector: isSlackMutableAllowEntry,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { sendMessageSlack } from "./send.js";
|
||||
|
||||
const DEFAULT_THROTTLE_MS = 1000;
|
||||
|
||||
export type SlackDraftStream = {
|
||||
type SlackDraftStream = {
|
||||
update: (text: string) => void;
|
||||
flush: () => Promise<void>;
|
||||
clear: () => Promise<void>;
|
||||
|
||||
@@ -55,7 +55,7 @@ export type SlackInteractiveHandlerRegistration = PluginInteractiveRegistration<
|
||||
"slack"
|
||||
>;
|
||||
|
||||
export type SlackInteractiveDispatchContext = Omit<
|
||||
type SlackInteractiveDispatchContext = Omit<
|
||||
SlackInteractiveHandlerContext,
|
||||
| "interaction"
|
||||
| "respond"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
|
||||
export type SlackModalPrivateMetadata = {
|
||||
type SlackModalPrivateMetadata = {
|
||||
sessionKey?: string;
|
||||
channelId?: string;
|
||||
channelType?: string;
|
||||
|
||||
@@ -694,7 +694,7 @@ describe("monitorSlackProvider tool results", () => {
|
||||
await runMentionGatedChannelMessageAndFlush();
|
||||
|
||||
expect(sendMock).not.toHaveBeenCalled();
|
||||
expectReactionNames(["eyes", "scream", "eyes", "eyes", "scream"]);
|
||||
expectReactionNames(["eyes", "scream", "scream"]);
|
||||
});
|
||||
|
||||
it("replies with pairing code when dmPolicy is pairing and no allowFrom is set", async () => {
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
type ChannelMatchSource,
|
||||
} from "openclaw/plugin-sdk/channel-targets";
|
||||
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
||||
import type { SlackMessageEvent } from "../types.js";
|
||||
import { normalizeSlackSlug } from "./allow-list.js";
|
||||
|
||||
export type SlackChannelConfigResolved = {
|
||||
@@ -19,7 +18,7 @@ export type SlackChannelConfigResolved = {
|
||||
matchSource?: ChannelMatchSource;
|
||||
};
|
||||
|
||||
export type SlackChannelConfigEntry = {
|
||||
type SlackChannelConfigEntry = {
|
||||
enabled?: boolean;
|
||||
requireMention?: boolean;
|
||||
allowBots?: boolean;
|
||||
@@ -117,5 +116,3 @@ export function resolveSlackChannelConfig(params: {
|
||||
};
|
||||
return applyChannelMatchMeta(result, match);
|
||||
}
|
||||
|
||||
export type { SlackMessageEvent };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/text-runtime";
|
||||
import type { SlackMessageEvent } from "../types.js";
|
||||
|
||||
export type SlackChatType = "direct" | "group" | "channel";
|
||||
type SlackChatType = "direct" | "group" | "channel";
|
||||
|
||||
export function inferSlackChannelType(
|
||||
channelId?: string | null,
|
||||
|
||||
@@ -12,7 +12,7 @@ export function stripSlackMentionsForCommandDetection(text: string): string {
|
||||
.trim();
|
||||
}
|
||||
|
||||
export function normalizeSlackSlashCommandName(raw: string) {
|
||||
function normalizeSlackSlashCommandName(raw: string) {
|
||||
return raw.replace(/^\/+/, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export type ModalInputSummary = {
|
||||
richTextPreview?: string;
|
||||
};
|
||||
|
||||
export type SlackModalBody = {
|
||||
type SlackModalBody = {
|
||||
user?: { id?: string };
|
||||
team?: { id?: string };
|
||||
view?: {
|
||||
@@ -65,8 +65,8 @@ type SlackModalEventBase = {
|
||||
};
|
||||
};
|
||||
|
||||
export type SlackModalInteractionKind = "view_submission" | "view_closed";
|
||||
export type SlackModalEventHandlerArgs = { ack: () => Promise<void>; body: unknown };
|
||||
type SlackModalInteractionKind = "view_submission" | "view_closed";
|
||||
type SlackModalEventHandlerArgs = { ack: () => Promise<void>; body: unknown };
|
||||
export type RegisterSlackModalHandler = (
|
||||
matcher: RegExp,
|
||||
handler: (args: SlackModalEventHandlerArgs) => Promise<void>,
|
||||
@@ -169,7 +169,7 @@ function resolveSlackModalEventBase(params: {
|
||||
};
|
||||
}
|
||||
|
||||
export async function emitSlackModalLifecycleEvent(params: {
|
||||
async function emitSlackModalLifecycleEvent(params: {
|
||||
ctx: SlackMonitorContext;
|
||||
body: SlackModalBody;
|
||||
interactionType: SlackModalInteractionKind;
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { SlackMessageChangedEvent, SlackMessageDeletedEvent } from "../type
|
||||
|
||||
type SupportedSubtype = "message_changed" | "message_deleted";
|
||||
|
||||
export type SlackMessageSubtypeHandler = {
|
||||
type SlackMessageSubtypeHandler = {
|
||||
subtype: SupportedSubtype;
|
||||
eventKind: SupportedSubtype;
|
||||
describe: (channelLabel: string) => string;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { authorizeSlackSystemEventSender } from "../auth.js";
|
||||
import { resolveSlackChannelLabel } from "../channel-config.js";
|
||||
import type { SlackMonitorContext } from "../context.js";
|
||||
|
||||
export type SlackAuthorizedSystemEventContext = {
|
||||
type SlackAuthorizedSystemEventContext = {
|
||||
channelLabel: string;
|
||||
sessionKey: string;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ const SLACK_EXTERNAL_ARG_MENU_TTL_MS = 10 * 60 * 1000;
|
||||
export const SLACK_EXTERNAL_ARG_MENU_PREFIX = "openclaw_cmdarg_ext:";
|
||||
|
||||
export type SlackExternalArgMenuChoice = { label: string; value: string };
|
||||
export type SlackExternalArgMenuEntry = {
|
||||
type SlackExternalArgMenuEntry = {
|
||||
choices: SlackExternalArgMenuChoice[];
|
||||
userId: string;
|
||||
expiresAt: number;
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { SlackFile, SlackMessageEvent } from "../../types.js";
|
||||
import { MAX_SLACK_MEDIA_FILES, type SlackMediaResult } from "../media-types.js";
|
||||
import type { SlackThreadStarter } from "../thread.js";
|
||||
|
||||
export type SlackResolvedMessageContent = {
|
||||
type SlackResolvedMessageContent = {
|
||||
rawBody: string;
|
||||
effectiveDirectMedia: SlackMediaResult[] | null;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export type SlackRoutingContextDeps = {
|
||||
threadHistoryScope: "thread" | "channel";
|
||||
};
|
||||
|
||||
export type SlackRoutingContext = {
|
||||
type SlackRoutingContext = {
|
||||
route: ReturnType<typeof resolveAgentRoute>;
|
||||
runtimeBinding: RuntimeConversationBindingRouteResult["bindingRecord"];
|
||||
runtimeBoundSessionKey: string | undefined;
|
||||
|
||||
@@ -21,7 +21,7 @@ function loadSlackMediaModule(): Promise<SlackMediaModule> {
|
||||
return slackMediaModulePromise;
|
||||
}
|
||||
|
||||
export type SlackThreadContextData = {
|
||||
type SlackThreadContextData = {
|
||||
threadStarterBody: string | undefined;
|
||||
threadHistoryBody: string | undefined;
|
||||
threadSessionPreviousTimestamp: number | undefined;
|
||||
|
||||
@@ -11,7 +11,7 @@ type SlackSocketModeConfig = Pick<
|
||||
"clientPingTimeout" | "serverPingTimeout" | "pingPongLoggingEnabled"
|
||||
>;
|
||||
|
||||
export const OPENCLAW_SLACK_CLIENT_PING_TIMEOUT_MS = 15_000;
|
||||
const OPENCLAW_SLACK_CLIENT_PING_TIMEOUT_MS = 15_000;
|
||||
|
||||
export type SlackBoltResolvedExports = {
|
||||
App: SlackAppConstructor;
|
||||
|
||||
@@ -9,7 +9,7 @@ export const SLACK_SOCKET_RECONNECT_POLICY = {
|
||||
maxAttempts: 12,
|
||||
} as const;
|
||||
|
||||
export type SlackSocketDisconnectEvent = "disconnect" | "unable_to_socket_mode_start" | "error";
|
||||
type SlackSocketDisconnectEvent = "disconnect" | "unable_to_socket_mode_start" | "error";
|
||||
|
||||
type EmitterLike = {
|
||||
on: (event: string, listener: (...args: unknown[]) => void) => unknown;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ChannelRuntimeSurface } from "openclaw/plugin-sdk/channel-contract";
|
||||
import type { OpenClawConfig, SlackSlashCommandConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
|
||||
import type { SlackFile, SlackMessageEvent } from "../types.js";
|
||||
import type { SlackMessageEvent } from "../types.js";
|
||||
|
||||
export type MonitorSlackOpts = {
|
||||
botToken?: string;
|
||||
@@ -93,5 +93,3 @@ export type SlackMessageDeletedEvent = {
|
||||
previous_message?: { ts?: string; user?: string; bot_id?: string };
|
||||
event_ts?: string;
|
||||
};
|
||||
|
||||
export type { SlackFile, SlackMessageEvent };
|
||||
|
||||
@@ -5,7 +5,7 @@ type SlackChannelRuntime = {
|
||||
handleSlackAction?: typeof import("./action-runtime.js").handleSlackAction;
|
||||
};
|
||||
|
||||
export type SlackRuntime = PluginRuntime & {
|
||||
type SlackRuntime = PluginRuntime & {
|
||||
channel: PluginRuntime["channel"] & {
|
||||
slack?: SlackChannelRuntime;
|
||||
};
|
||||
@@ -15,9 +15,8 @@ const {
|
||||
setRuntime: setSlackRuntime,
|
||||
clearRuntime: clearSlackRuntime,
|
||||
tryGetRuntime: getOptionalSlackRuntime,
|
||||
getRuntime: getSlackRuntime,
|
||||
} = createPluginRuntimeStore<SlackRuntime>({
|
||||
pluginId: "slack",
|
||||
errorMessage: "Slack runtime not initialized",
|
||||
});
|
||||
export { clearSlackRuntime, getOptionalSlackRuntime, getSlackRuntime, setSlackRuntime };
|
||||
export { clearSlackRuntime, getOptionalSlackRuntime, setSlackRuntime };
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
hasOwnProperty,
|
||||
type ResolverContext,
|
||||
type SecretDefaults,
|
||||
type SecretTargetRegistryEntry,
|
||||
} from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
||||
|
||||
export const secretTargetRegistryEntries = [
|
||||
@@ -97,7 +96,7 @@ export const secretTargetRegistryEntries = [
|
||||
includeInConfigure: true,
|
||||
includeInAudit: true,
|
||||
},
|
||||
] satisfies SecretTargetRegistryEntry[];
|
||||
] satisfies import("openclaw/plugin-sdk/channel-secret-basic-runtime").SecretTargetRegistryEntry[];
|
||||
|
||||
export function collectRuntimeConfigAssignments(params: {
|
||||
config: { channels?: Record<string, unknown> };
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
type StreamingMode,
|
||||
} from "./streaming-compat.js";
|
||||
|
||||
export type SlackStreamMode = SlackLegacyDraftStreamMode;
|
||||
export type SlackStreamingMode = StreamingMode;
|
||||
type SlackStreamMode = SlackLegacyDraftStreamMode;
|
||||
type SlackStreamingMode = StreamingMode;
|
||||
const DEFAULT_STREAM_MODE: SlackStreamMode = "replace";
|
||||
|
||||
export function resolveSlackStreamMode(raw: unknown): SlackStreamMode {
|
||||
|
||||
@@ -39,7 +39,7 @@ export type SlackStreamSession = {
|
||||
pendingText: string;
|
||||
};
|
||||
|
||||
export type StartSlackStreamParams = {
|
||||
type StartSlackStreamParams = {
|
||||
client: WebClient;
|
||||
channel: string;
|
||||
threadTs: string;
|
||||
@@ -59,12 +59,12 @@ export type StartSlackStreamParams = {
|
||||
userId?: string;
|
||||
};
|
||||
|
||||
export type AppendSlackStreamParams = {
|
||||
type AppendSlackStreamParams = {
|
||||
session: SlackStreamSession;
|
||||
text: string;
|
||||
};
|
||||
|
||||
export type StopSlackStreamParams = {
|
||||
type StopSlackStreamParams = {
|
||||
session: SlackStreamSession;
|
||||
/** Optional final markdown text to append before stopping. */
|
||||
text?: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ReplyToMode } from "openclaw/plugin-sdk/config-types";
|
||||
import type { SlackAppMentionEvent, SlackMessageEvent } from "./types.js";
|
||||
|
||||
export type SlackThreadContext = {
|
||||
type SlackThreadContext = {
|
||||
incomingThreadTs?: string;
|
||||
messageTs?: string;
|
||||
isThreadReply: boolean;
|
||||
|
||||
Reference in New Issue
Block a user