mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
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:
parent
2723e94541
commit
74c58bdcde
21 changed files with 1388 additions and 395 deletions
27
plugin-src/host/channels/shared/default-model-rpc.mjs
Normal file
27
plugin-src/host/channels/shared/default-model-rpc.mjs
Normal 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 };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue