package controller import ( "context" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" kubeclawv1alpha1 "github.com/nousresearch/kubeclaw/api/v1alpha1" ) // AgentReconciler reconciles Agent resources. type AgentReconciler struct { client.Client Scheme *runtime.Scheme } // +kubebuilder:rbac:groups=kubeclaw.nousresearch.com,resources=agents,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=kubeclaw.nousresearch.com,resources=agents/status,verbs=get;update;patch // +kubebuilder:rbac:groups=kubeclaw.nousresearch.com,resources=agents/finalizers,verbs=update // +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch func (r *AgentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := log.FromContext(ctx) var agent kubeclawv1alpha1.Agent if err := r.Get(ctx, req.NamespacedName, &agent); err != nil { log.Error(err, "unable to fetch Agent") return ctrl.Result{}, client.IgnoreNotFound(err) } log.Info("Reconciling Agent", "agent", agent.Name) // TODO: Build or update the agent pod from the Agent spec // TODO: Wire judge sidecar and workflow executor sidecar // TODO: Inject ConfigMap and Secret references // TODO: Update AgentStatus with pod reference and conditions return ctrl.Result{}, nil } func (r *AgentReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). For(&kubeclawv1alpha1.Agent{}). Owns(&corev1.Pod{}). Complete(r) }