feat(wechat): add admin-pluggable LLM intent router separate from H5.
Memind CI / Test, build, and release guards (push) Failing after 8s
Memind CI / Test, build, and release guards (push) Failing after 8s
Give WeChat MP its own chat.general→page.generate LLM refinement layer with memindadm toggles, shadow mode, and canary openids so service account routing stays independent of the H5 chatIntentRouter. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -702,3 +702,94 @@ test('admin system test route executes shared validation service', async () => {
|
||||
await server.close();
|
||||
}
|
||||
});
|
||||
|
||||
test('admin wechat intent router config routes', async () => {
|
||||
const updates = [];
|
||||
const router = createAdminApi({
|
||||
jsonBody: express.json(),
|
||||
getToken() {
|
||||
return 'token-admin';
|
||||
},
|
||||
userAuth: {
|
||||
async getMe(token) {
|
||||
if (token !== 'token-admin') return null;
|
||||
return { id: 'admin-1', role: 'admin' };
|
||||
},
|
||||
},
|
||||
wechatIntentRouterConfigService: {
|
||||
async getConfig() {
|
||||
return {
|
||||
enabled: true,
|
||||
shadowMode: true,
|
||||
modelProviderKeyId: 'key-1',
|
||||
model: 'deepseek-v4-pro',
|
||||
minConfidence: 0.65,
|
||||
timeoutMs: 4000,
|
||||
canaryOpenids: ['openid-a'],
|
||||
updatedAt: 123,
|
||||
updatedBy: 'admin-1',
|
||||
};
|
||||
},
|
||||
async updateConfig(patch, { updatedBy }) {
|
||||
updates.push({ patch, updatedBy });
|
||||
return {
|
||||
enabled: false,
|
||||
shadowMode: true,
|
||||
modelProviderKeyId: null,
|
||||
model: null,
|
||||
minConfidence: 0.65,
|
||||
timeoutMs: 4000,
|
||||
canaryOpenids: [],
|
||||
updatedAt: 456,
|
||||
updatedBy,
|
||||
};
|
||||
},
|
||||
async getRuntimeState() {
|
||||
return {
|
||||
source: 'admin-db',
|
||||
updatedAt: 123,
|
||||
updatedBy: 'admin-1',
|
||||
fingerprint: 'fp-1',
|
||||
overrides: { MEMIND_WECHAT_INTENT_LLM_ENABLED: '1' },
|
||||
config: { enabled: true, shadowMode: true },
|
||||
};
|
||||
},
|
||||
},
|
||||
plazaPosts: null,
|
||||
plazaOps: null,
|
||||
wechatAdmin: null,
|
||||
subscriptionService: null,
|
||||
});
|
||||
|
||||
const server = await startTestServer(router);
|
||||
try {
|
||||
const configRes = await fetch(`${server.baseUrl}/admin-api/wechat/intent-router/config`, {
|
||||
headers: { cookie: 'h5_user_session=token-admin' },
|
||||
});
|
||||
assert.equal(configRes.status, 200);
|
||||
const configBody = await configRes.json();
|
||||
assert.equal(configBody.config.enabled, true);
|
||||
assert.equal(configBody.config.model, 'deepseek-v4-pro');
|
||||
|
||||
const updateRes = await fetch(`${server.baseUrl}/admin-api/wechat/intent-router/config`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
cookie: 'h5_user_session=token-admin',
|
||||
},
|
||||
body: JSON.stringify({ enabled: false }),
|
||||
});
|
||||
assert.equal(updateRes.status, 200);
|
||||
assert.deepEqual(updates, [{ patch: { enabled: false }, updatedBy: 'admin-1' }]);
|
||||
|
||||
const runtimeRes = await fetch(`${server.baseUrl}/admin-api/wechat/intent-router/runtime`, {
|
||||
headers: { cookie: 'h5_user_session=token-admin' },
|
||||
});
|
||||
assert.equal(runtimeRes.status, 200);
|
||||
assert.deepEqual((await runtimeRes.json()).overrides, {
|
||||
MEMIND_WECHAT_INTENT_LLM_ENABLED: '1',
|
||||
});
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user