Keep IM tool approvals in chat and add WhatsApp default model.

Claim in-flight IM turns before ownership flips active so approvals no longer stick only in DSH Web, auto-recover stale session models once, and let WhatsApp bots pick a shared default model for new sessions.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-15 20:02:45 +08:00
parent 2723e94541
commit 74c58bdcde
21 changed files with 1388 additions and 395 deletions

View file

@ -0,0 +1,27 @@
import { normalizeDefaultModel } from '../../../../src/channels/shared/default-model.mjs';
export const SET_DEFAULT_MODEL_ENDPOINT = 'bot.model.set';
function isRecord(value) {
return value !== null && typeof value === 'object' && !Array.isArray(value);
}
export function validDefaultModelPayload(payload) {
if (!isRecord(payload)
|| !Object.keys(payload).every((key) => ['botId', 'defaultModel'].includes(key))
|| typeof payload.botId !== 'string'
|| !/^[A-Za-z0-9_-]{1,128}$/.test(payload.botId)) {
return false;
}
if (payload.defaultModel === null) return true;
return Boolean(normalizeDefaultModel(payload.defaultModel));
}
export function publicDefaultModelError(error) {
if (![
'default-model-invalid',
'default-model-unavailable',
'workspace-bot-not-found',
].includes(error?.code)) return null;
return { code: error.code, message: error.message };
}