feat(turn-init): use internal Discord channel member resolver for bootstrap (no public tool)

This commit is contained in:
2026-03-08 06:08:51 +00:00
parent 121786e6e3
commit 307235e207
5 changed files with 162 additions and 11 deletions

View File

@@ -14,7 +14,7 @@ type MessageReceivedDeps = {
getLivePluginConfig: (api: OpenClawPluginApi, fallback: DirigentConfig) => DirigentConfig;
shouldDebugLog: (config: DirigentConfig & DebugConfig, channelId?: string) => boolean;
debugCtxSummary: (ctx: Record<string, unknown>, event: Record<string, unknown>) => Record<string, unknown>;
ensureTurnOrder: (api: OpenClawPluginApi, channelId: string) => void;
ensureTurnOrder: (api: OpenClawPluginApi, channelId: string) => Promise<void> | void;
getModeratorUserId: (cfg: DirigentConfig) => string | undefined;
recordChannelAccount: (channelId: string, accountId: string) => boolean;
extractMentionedUserIds: (content: string) => string[];
@@ -46,7 +46,7 @@ export function registerMessageReceivedHook(deps: MessageReceivedDeps): void {
}
if (preChannelId) {
ensureTurnOrder(api, preChannelId);
await ensureTurnOrder(api, preChannelId);
const metadata = (e as Record<string, unknown>).metadata as Record<string, unknown> | undefined;
const from =
(typeof metadata?.senderId === "string" && metadata.senderId) ||
@@ -65,7 +65,7 @@ export function registerMessageReceivedHook(deps: MessageReceivedDeps): void {
if (senderAccountId && senderAccountId !== "default") {
const isNew = recordChannelAccount(preChannelId, senderAccountId);
if (isNew) {
ensureTurnOrder(api, preChannelId);
await ensureTurnOrder(api, preChannelId);
api.logger.info(`dirigent: new account ${senderAccountId} seen in channel=${preChannelId}, turn order updated`);
}
}
@@ -79,7 +79,7 @@ export function registerMessageReceivedHook(deps: MessageReceivedDeps): void {
const mentionedAccountIds = mentionedUserIds.map((uid) => userIdMap.get(uid)).filter((aid): aid is string => !!aid);
if (mentionedAccountIds.length > 0) {
ensureTurnOrder(api, preChannelId);
await ensureTurnOrder(api, preChannelId);
const overrideSet = setMentionOverride(preChannelId, mentionedAccountIds);
if (overrideSet) {
api.logger.info(