MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / handleUpdateAgent

Method handleUpdateAgent

internal/httpapi/agents_write.go:119–147  ·  view source on GitHub ↗
(ctx context.Context, in *updateAgentInput)

Source from the content-addressed store, hash-verified

117}
118
119func (s *Server) handleUpdateAgent(ctx context.Context, in *updateAgentInput) (*agentOutput, error) {
120 // Mutating an agent is account administration — an agent-scoped credential
121 // must not rename its own agent (Slice 5a hard ceiling), so this is
122 // account-only even for the bound agent. (Screening posture moved to the
123 // account-scoped /protection sub-resource; only the display name is left.)
124 if _, err := s.requireAccountScope(ctx); err != nil {
125 return nil, err
126 }
127 ag, err := s.resolveOwnedAgent(ctx, in.Address)
128 if err != nil {
129 return nil, err
130 }
131 if in.Body.Name == nil {
132 return nil, NewError(http.StatusBadRequest, "invalid_request", "no recognized fields in request")
133 }
134 if s.deps.UpdateAgentName == nil {
135 return nil, NewError(http.StatusInternalServerError, "internal_error", "update unavailable")
136 }
137 if err := s.deps.UpdateAgentName(ctx, ag.ID, ag.UserID, *in.Body.Name); err != nil {
138 return nil, NewError(http.StatusBadRequest, "invalid_request", err.Error())
139 }
140
141 // Re-read for the authoritative post-update state (ag.ID is the email).
142 updated, err := s.deps.GetAgent(ctx, ag.ID)
143 if err != nil || updated == nil {
144 return nil, NewError(http.StatusInternalServerError, "internal_error", "failed to reload agent")
145 }
146 return &agentOutput{Body: agentViewFromIdentity(updated)}, nil
147}
148
149type deleteAgentOutput struct{}
150

Callers

nothing calls this directly

Calls 6

requireAccountScopeMethod · 0.95
resolveOwnedAgentMethod · 0.95
NewErrorFunction · 0.85
agentViewFromIdentityFunction · 0.85
UpdateAgentNameMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected