mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-17 10:00:45 +08:00
Add per-DM and per-group Agent Preset overrides (4.9.1-ops.19).
Access grants can pin an agentPreset on direct members and groups; new sessions resolve override over the bot-global preset. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
7993499273
commit
2718586fda
12 changed files with 590 additions and 232 deletions
|
|
@ -7,7 +7,7 @@ import {
|
|||
normalizeMessageContent,
|
||||
} from '@whiskeysockets/baileys';
|
||||
|
||||
import { emptyAccessGrant, ensureGroupBucket } from '../shared/access-grant.mjs';
|
||||
import { emptyAccessGrant, ensureGroupBucket, normalizeAccessPhone, phoneFromWhatsappJid, resolveAccessAgentPreset } from '../shared/access-grant.mjs';
|
||||
import { splitMessageText } from '../shared/editable-message-stream.mjs';
|
||||
import { t } from '../shared/i18n.mjs';
|
||||
import { ImagePromptError } from '../shared/image-prompt.mjs';
|
||||
|
|
@ -823,6 +823,20 @@ export class WhatsappRuntime {
|
|||
logger: this.#logger,
|
||||
replyTimeoutMs: this.#replyTimeoutMs,
|
||||
signal: controller.signal,
|
||||
resolveAgentPreset: (message) => {
|
||||
if (!this.#workspaces || !this.#botId) return null;
|
||||
const grant = this.#workspaces.accessGrantFor(this.#botId);
|
||||
return resolveAccessAgentPreset(grant, {
|
||||
kind: message?.kind === 'group' ? 'group' : 'direct',
|
||||
groupJid: message?.conversationId,
|
||||
conversationId: message?.conversationId,
|
||||
phone: phoneFromWhatsappJid(message?.senderId)
|
||||
?? normalizeAccessPhone(message?.senderId)
|
||||
?? phoneFromWhatsappJid(message?.senderAlternateId)
|
||||
?? normalizeAccessPhone(message?.senderAlternateId),
|
||||
senderId: message?.senderId,
|
||||
});
|
||||
},
|
||||
});
|
||||
const now = Date.now();
|
||||
this.#status.ready = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue