/** * XG-IM 消息发送模块 * * 调用 IM 接口将 AI 回复发送到指定群聊,并 @ 原始发送者。 * 支持 RICH_TEXT 与带资源 fileId 的 FILE 类型(attachments)。 */ import type { Log } from "./auth.js"; import type { SendMessageFileAttachment, SendMessageReply, XgImConfig } from "./types.js"; /** * 生成一次投递的客户端幂等键。 * * 服务端按 `clientMsgId + groupId + 最近 10 分钟` 去重:同一逻辑消息在其内部 6 次重试间 * 复用同一 `clientMsgId`,超时/断连重发会命中服务端已有消息,不产生重复气泡。 * 每个独立投递块生成一次(不同块必须不同)。 */ export declare function generateClientMsgId(): string; /** 从发送接口响应中解析服务端消息 id(`data.id`)与回显 `clientMsgId`,用于对账日志。 */ export declare function extractSentMessageInfo(resData: unknown): { serverMsgId?: string; clientMsgId?: string; }; /** OpenClaw dispatch deliver 单块载荷:文本 + 可选媒体 URL(与 plugin-sdk 约定对齐)。 */ export type ReplyDeliverPayload = { markdown?: string; text?: string; isThinking?: boolean; mediaUrl?: string; mediaUrls?: string[]; /** OpenClaw 运营通知:模型 failover 状态变化(非助手正文) */ isFallbackNotice?: boolean; isCompactionNotice?: boolean; isError?: boolean; /** OpenClaw assistant thinking/reasoning 块(对应 transcript type: thinking) */ isReasoning?: boolean; }; /** * 将 deliver 块发到 IM:若有媒体则先 POST baseUrl/file/upDownload/uploadWholeFile 再发 FILE;否则发 RICH_TEXT。 * * @param agentWorkspaceDir 可选。Agent 在宿主机的 workspace 绝对路径(由 resolveAgentWorkspaceDir 得到)。 * 用于在多沙箱 agent 场景下正确解析 /workspace/ 前缀路径。 * 未传时回退到 process.cwd(),单 agent 部署下行为不变。 */ export declare function sendReplyDeliverBlock(config: XgImConfig, token: string, groupId: string, payload: ReplyDeliverPayload, atUserIds?: string[], log?: Log, _deprecatedMsgId?: string, reply?: SendMessageReply, agentWorkspaceDir?: string): Promise; /** * 发送一条已上传资源的 FILE 消息到指定 IM 群聊。 * * 与 {@link sendReplyDeliverBlock} 不同:本函数**不做** URL 下载 / 上传失败降级为文本的逻辑, * 仅负责把已经拿到 fileId 的附件组装成 FILE 消息发出。失败直接抛出,由调用方(工具)返回明确错误, * 不会产生「降级成文本却报成功」的假成功。上传步骤请在调用前用 * {@link uploadWholeResourceFileWithRetry} 完成。 * * 复用 {@link postImMessage} 的 6 次网络重试与服务端 clientMsgId 去重。 */ export declare function sendUploadedFileMessage(args: { config: XgImConfig; token: string; groupId: string; /** 附件说明;为空时用单空格占位,避免部分 IM 接口拒收空文本 */ caption?: string; attachment: SendMessageFileAttachment; atUserIds?: string[]; /** 幂等键;省略时自动生成 */ clientMsgId?: string; reply?: SendMessageReply; log?: Log; }): Promise<{ clientMsgId: string; serverMsgId?: string; }>; /** * 发送文本消息到指定 IM 群聊。 * * @param config 插件配置 * @param token 鉴权 token * @param groupId 目标群聊 ID(gid / groupId) * @param content 消息内容文本 * @param atUserIds 需要 @ 的用户 ID 列表(可为空) * @param log 日志接口 * @param _deprecatedMsgId 已废弃的占位消息 ID 参数,不再使用(保留以兼容旧调用签名) * @param reply 可选的被回复消息信息(用于在 IM 中建立“回复某条消息”的关联) */ export declare function sendTextMessage(config: XgImConfig, token: string, groupId: string, content: string, atUserIds?: string[], log?: Log, _deprecatedMsgId?: string, reply?: SendMessageReply): Promise; //# sourceMappingURL=send-service.d.ts.map