diff --git a/src/admin/pages/CursorChannelPage.tsx b/src/admin/pages/CursorChannelPage.tsx index 2bbdc4e..dfad1f2 100644 --- a/src/admin/pages/CursorChannelPage.tsx +++ b/src/admin/pages/CursorChannelPage.tsx @@ -8,6 +8,8 @@ import { } from '../../api/client'; import type { AdminUserRow, + CursorChannelFeatureKey, + CursorChannelFeatures, WechatCursorExecutorAdminConfig, WechatCursorExecutorRuntimeState, } from '../../types'; @@ -19,10 +21,70 @@ type CursorChannelForm = { wechatEnabled: boolean; selectedUserIds: string[]; manualAllowlistEntries: string[]; - intentAllowlist: string; + features: CursorChannelFeatures; fallbackToDeepseek: boolean; }; +const FEATURE_OPTIONS: Array<{ + key: CursorChannelFeatureKey; + label: string; + description: string; +}> = [ + { + key: 'pageGenerate', + label: '页面生成', + description: 'H5 / 服务号 page.generate 与页面落盘任务走 Cursor。', + }, + { + key: 'pageData', + label: '问卷 Page Data', + description: 'H5 问卷收集、PG 持久化与相关分析页走 Cursor。', + }, + { + key: 'excelAnalysis', + label: 'Excel 分析', + description: 'H5 表格分析与结果页走 Cursor。', + }, + { + key: 'chatBridge', + label: '普通聊天(Chat Bridge)', + description: '白名单用户的 Goose 会话 LLM 走 Cursor Chat Bridge;需服务端 MEMIND_CURSOR_CHAT_BRIDGE_ENABLED=1。', + }, + { + key: 'scheduledTasks', + label: '定时任务执行', + description: '到点自动任务(新闻/天气等)走 Cursor 而非 Goose Session。', + }, +]; + +function defaultFeatures(): CursorChannelFeatures { + return { + pageGenerate: { enabled: true }, + pageData: { enabled: false }, + excelAnalysis: { enabled: false }, + chatBridge: { enabled: false }, + scheduledTasks: { enabled: false }, + }; +} + +function normalizeFeatures( + config: WechatCursorExecutorAdminConfig | undefined, +): CursorChannelFeatures { + const base = defaultFeatures(); + const raw = config?.features; + if (raw) { + for (const option of FEATURE_OPTIONS) { + base[option.key] = { + enabled: Boolean(raw[option.key]?.enabled), + }; + } + return base; + } + const intents = Array.isArray(config?.intentAllowlist) ? config.intentAllowlist : ['page.generate']; + base.pageGenerate.enabled = intents.includes('page.generate'); + return base; +} + const USER_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; @@ -77,9 +139,7 @@ function configToForm( wechatEnabled: channels.includes('wechat_mp'), selectedUserIds, manualAllowlistEntries, - intentAllowlist: Array.isArray(config?.intentAllowlist) - ? config.intentAllowlist.join('\n') - : 'page.generate', + features: normalizeFeatures(config), fallbackToDeepseek: config?.fallbackToDeepseek !== false, }; } @@ -316,10 +376,7 @@ export function CursorChannelPage() { enabled: form.enabled, userAllowlist: formToAllowlist(form), channelAllowlist, - intentAllowlist: form.intentAllowlist - .split(/[\s,]+/u) - .map((item) => item.trim()) - .filter(Boolean), + features: form.features, fallbackToDeepseek: form.fallbackToDeepseek, }); const nextForm = configToForm(result.config, users); @@ -350,12 +407,15 @@ export function CursorChannelPage() {
服务端需开启 MEMIND_CURSOR_EXECUTOR_ENABLED=1 与 Tool Gateway;详见 Memind{' '}
@@ -432,8 +492,39 @@ export function CursorChannelPage() {
)
}
/>{' '}
- Cursor 失败时自动回退 DeepSeek
+ Cursor 失败时自动回退 DeepSeek / Goose
+