feat: add semantic WeChat session actions

This commit is contained in:
john
2026-07-23 17:18:25 +08:00
parent baa383548c
commit 7e20ec14f1
8 changed files with 235 additions and 2 deletions
+5 -1
View File
@@ -6,6 +6,7 @@ import {
isTopicResetText,
wantsDocxDownload,
} from './patterns.mjs';
import { WECHAT_SESSION_ACTION } from './session-action.mjs';
/**
* @typedef {object} WechatPageGenerateIntent
@@ -15,6 +16,7 @@ import {
*
* @typedef {object} WechatSessionResetIntent
* @property {'session.reset'} kind
* @property {string} sessionAction
*
* @typedef {object} WechatStatusProbeIntent
* @property {'status.probe'} kind
@@ -46,7 +48,9 @@ export function classifyWechatIntent(intent) {
const text = String(intent?.agentText ?? intent?.displayText ?? '').trim();
if (msgType === 'text' || msgType === 'voice') {
if (isTopicResetText(text)) return { kind: 'session.reset' };
if (isTopicResetText(text)) {
return { kind: 'session.reset', sessionAction: WECHAT_SESSION_ACTION.RESET };
}
if (STATUS_PROBE_PATTERN.test(text)) return { kind: 'status.probe' };
if (GREETING_PATTERN.test(text.replace(/[!!。.\s]+$/g, ''))) return { kind: 'greeting' };
if (CONNECTIVITY_TEST_PATTERN.test(text.replace(/[!!。.\s]+$/g, ''))) {