feat: collect BPM field evidence and equip ZCode mapping assistant
This commit is contained in:
1 parent
24dbbb74c3
commit
d4070e08f9
30 files changed
+453
-61
No files matched your search
@@ -3,7 +3,7 @@ const {fail}=require('./store.cjs'),{secureBpmTransport}=require('../bpm/api.cjs
|
||||
function bodyKeys(body,keys){if(!body||Array.isArray(body)||Object.keys(body).some(k=>!keys.includes(k)))throw fail('助手请求包含不支持的字段。');}
|
||||
async function assistantApi({assistant,user,sessionId,route,method,body,request,reply,workspace,trustedProxy=false}){
|
||||
if(!route.startsWith('/api/assistant'))return false;if(!assistant)throw fail('ZCode 助手服务未启动。',503);const principal={user,sessionId};
|
||||
if(route==='/api/assistant'&&method==='GET'){const settings=assistant.store.settings();reply(200,{settings:user.role==='admin'?settings:{enabled:settings.enabled,allowActions:settings.allowActions,model:settings.model},usage:assistant.store.usage(),conversations:assistant.store.conversations(user.id)});return true;}
|
||||
if(route==='/api/assistant'&&method==='GET'){const settings=assistant.store.settings();reply(200,{settings:user.role==='admin'?settings:{enabled:settings.enabled,allowActions:settings.allowActions,model:settings.model},skills:require('./skills.cjs').projectSkills(),usage:assistant.store.usage(),conversations:assistant.store.conversations(user.id)});return true;}
|
||||
if((route==='/api/assistant/settings'||route==='/api/assistant/check')&&method==='POST'){
|
||||
if(user.role!=='admin')throw fail('仅管理员可以配置或检查 ZCode。',403);if(!secureBpmTransport(request,trustedProxy))throw fail('请在部署机本地或 HTTPS 页面维护模型配置。',403);
|
||||
if(route.endsWith('/settings')){const saved=assistant.store.saveSettings(body);workspace?.record(user,'配置 ZCode 助手',saved.enabled?'已启用':'已暂停');reply(200,saved);}else{bodyKeys(body,[]);reply(200,await assistant.check());}return true;
|
||||
|
||||
Reference in new issue
Block a user