(ctx context.Context, in *deleteAgentInput)
| 157 | } |
| 158 | |
| 159 | func (s *Server) handleDeleteAgent(ctx context.Context, in *deleteAgentInput) (*deleteAgentOutput, error) { |
| 160 | // Deleting an agent is account administration — barred for agent-scoped |
| 161 | // credentials even on their own bound agent (Slice 5a hard ceiling). |
| 162 | if _, err := s.requireAccountScope(ctx); err != nil { |
| 163 | return nil, err |
| 164 | } |
| 165 | ag, err := s.resolveOwnedAgent(ctx, in.Address) |
| 166 | if err != nil { |
| 167 | return nil, err |
| 168 | } |
| 169 | // Confirm after ownership: don't prompt to confirm deleting an agent the |
| 170 | // caller can't even touch (a not-owned agent is 403/404 first). |
| 171 | if in.Confirm != "DELETE" { |
| 172 | return nil, NewError(http.StatusBadRequest, "confirmation_required", "add ?confirm=DELETE to the request to proceed — this is irreversible") |
| 173 | } |
| 174 | if s.deps.DeleteAgent == nil { |
| 175 | return nil, NewError(http.StatusInternalServerError, "internal_error", "delete unavailable") |
| 176 | } |
| 177 | if err := s.deps.DeleteAgent(ctx, ag.ID, ag.UserID); err != nil { |
| 178 | return nil, NewError(http.StatusInternalServerError, "internal_error", "failed to delete agent") |
| 179 | } |
| 180 | return &deleteAgentOutput{}, nil |
| 181 | } |
| 182 | |
| 183 | func (s *Server) handleCreateAgent(ctx context.Context, in *createAgentInput) (*createAgentOutput, error) { |
| 184 | user, err := s.requireAccountUser(ctx) |
nothing calls this directly
no test coverage detected