mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
在九个渠道的设置页卡片上选择 Host 已有预设;未选则跟随默认,只影响之后新建的会话。 Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
846 B
JavaScript
21 lines
846 B
JavaScript
import { AGENT_PRESET_ID } from '../../../../src/channels/shared/agent-preset.mjs';
|
|
|
|
export const SET_AGENT_PRESET_ENDPOINT = 'bot.preset.set';
|
|
|
|
function isRecord(value) {
|
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
}
|
|
|
|
export function validAgentPresetPayload(payload) {
|
|
return isRecord(payload)
|
|
&& Object.keys(payload).every((key) => ['botId', 'agentPreset'].includes(key))
|
|
&& typeof payload.botId === 'string'
|
|
&& /^[A-Za-z0-9_-]{1,128}$/.test(payload.botId)
|
|
&& (payload.agentPreset === null
|
|
|| (typeof payload.agentPreset === 'string' && AGENT_PRESET_ID.test(payload.agentPreset)));
|
|
}
|
|
|
|
export function publicAgentPresetError(error) {
|
|
if (!['agent-preset-invalid', 'workspace-bot-not-found'].includes(error?.code)) return null;
|
|
return { code: error.code, message: error.message };
|
|
}
|