衍生解释:Re-export 模式是 TypeScript/JavaScript 中常见的模块组织模式。一个模块不包含任何逻辑,只通过 export { X } from "Y" 语句从其他模块中"挑选"符号重新导出。这样做的好处是:(1) 调用方只需导入一个模块而非散落在多处的实现;(2) 模块作者可以精确控制哪些 API 对外可见,形成稳定的公共接口边界。
export type {
OpenClawPluginApi, // 插件注册 API(最核心的接口)
OpenClawPluginService, // 后台服务定义
OpenClawPluginServiceContext, // 服务运行上下文
} from "../plugins/types.js";
export type { PluginRuntime } from "../plugins/runtime/types.js";
export type { OpenClawConfig } from "../config/config.js";
export type { ChannelDock } from "../channels/dock.js";
export {
DiscordConfigSchema,
GoogleChatConfigSchema,
IMessageConfigSchema,
MSTeamsConfigSchema,
SignalConfigSchema,
SlackConfigSchema,
TelegramConfigSchema,
} from "../config/zod-schema.providers-core.js";
export { WhatsAppConfigSchema } from "../config/zod-schema.providers-whatsapp.js";
export { LineConfigSchema } from "../line/config-schema.js";
// Channel: Discord
export { listDiscordAccountIds, resolveDefaultDiscordAccountId,
resolveDiscordAccount } from "../discord/accounts.js";
export { discordOnboardingAdapter } from "../channels/plugins/onboarding/discord.js";
// Channel: Telegram
export { listTelegramAccountIds, resolveTelegramAccount } from "../telegram/accounts.js";
export { telegramOnboardingAdapter } from "../channels/plugins/onboarding/telegram.js";
// Channel: WhatsApp
export { listWhatsAppAccountIds, resolveWhatsAppAccount } from "../web/accounts.js";
export { whatsappOnboardingAdapter } from "../channels/plugins/onboarding/whatsapp.js";
// Channel: LINE
export { createInfoCard, createListCard, createImageCard,
createActionCard } from "../line/flex-templates.js";
export { processLineMessage, hasMarkdownToConvert } from "../line/markdown-to-line.js";
// 消息操作工具
export { createActionGate, jsonResult, readNumberParam,
readStringParam } from "../agents/tools/common.js";
// 允许列表管理
export { mergeAllowlist, summarizeMapping } from "../channels/allowlists/resolve-utils.js";
// 提及门控
export { resolveMentionGating } from "../channels/mention-gating.js";
// ACK 响应
export { shouldAckReaction, removeAckReactionAfterReply } from "../channels/ack-reactions.js";
// 媒体处理
export { detectMime, extensionForMime } from "../media/mime.js";
export { loadWebMedia } from "../web/media.js";
// 日志传输
export { registerLogTransport } from "../logging/logger.js";
// 诊断事件
export { emitDiagnosticEvent, isDiagnosticsEnabled,
onDiagnosticEvent } from "../infra/diagnostic-events.js";
// hooks.ts — 同步执行 + Promise 防护
function runToolResultPersist(event, ctx) {
for (const hook of hooks) {
const out = hook.handler({ ...event, message: current }, ctx);
// 防护:如果处理函数错误地返回了 Promise,则忽略其结果
if (out && typeof out.then === "function") {
logger?.warn("tool_result_persist handler returned a Promise; this hook is sync-only");
continue;
}
if (out?.message) current = out.message;
}
return { message: current };
}