# flow_plan_confirm.dspy - 产线流程裁剪计划的用户确认/驳回端点 # # 入参(form-encoded): # plan_id 流程计划 id(pipeline_flow_plans.id) # decision confirm | reject # comment 驳回意见(reject 时必填;confirm 可空) # # 安全:确认动作是用户专属(同机构 + owner.superuser/项目创建者校验在 # flow_plan_capability._check_confirm_operator);agent 无对应工具,无法代替确认。 # 驳回意见落 reject_comment,会话 agent 用 get_flow_plan 读到后按意见修订重提(version+1)。 user_id = await get_user() if not user_id: return json.dumps({"success": False, "error": "未登录"}, ensure_ascii=False) plan_id = str((params_kw or {}).get('plan_id') or '').strip() decision = str((params_kw or {}).get('decision') or '').strip().lower() comment = str((params_kw or {}).get('comment') or '').strip() if not plan_id: return json.dumps({"success": False, "error": "缺少 plan_id"}, ensure_ascii=False) if decision == 'confirm': ok, msg = await flow_plan_confirm(plan_id, operator_id=user_id) elif decision == 'reject': if not comment: return json.dumps({"success": False, "error": "驳回必须填写意见(助手按意见修订流程)"}, ensure_ascii=False) ok, msg = await flow_plan_reject(plan_id, comment, operator_id=user_id) else: return json.dumps({"success": False, "error": "decision 必须是 confirm 或 reject"}, ensure_ascii=False) if ok: return json.dumps({"success": True, "message": msg}, ensure_ascii=False) return json.dumps({"success": False, "error": msg}, ensure_ascii=False)