Phase 14, part 1: plans, each team's account, and their limits
The multi-tenant edition's plans (Free and Paid as decided, or a plans file) and each team's billing account, with a 14-day trial of Paid. A team's plan caps what its people and agents may change: modules outside it stay readable, a lapsed team changes nothing, and agents, Market entries, crawls and background jobs keep to it. Without a Stripe key, no billing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,12 @@ func (s *Server) AgentAuth(r *http.Request, key string) (*mcpserver.Caller, erro
|
||||
if err != nil {
|
||||
return nil, users.ErrBadKey
|
||||
}
|
||||
if plan, ro := ts.teamPlan(); plan != nil {
|
||||
if ro {
|
||||
return nil, &mcpserver.Refusal{Status: http.StatusForbidden, Reason: sentence(errLapsed.Error()) + "."}
|
||||
}
|
||||
m = planned(m, plan, ro)
|
||||
}
|
||||
lim, err := users.LimitsOf(ts.DB, u.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -315,6 +321,9 @@ func (s *Server) agentCreate(w http.ResponseWriter, r *http.Request) {
|
||||
f := agentForm{Name: strings.TrimSpace(r.PostFormValue("name")), Description: strings.TrimSpace(r.PostFormValue("description")),
|
||||
Expires: r.PostFormValue("expires"), Scopes: agentScopesFromForm(r)}
|
||||
expires, err := expiryFromForm(r, now)
|
||||
if err == nil {
|
||||
err = s.limitAgents()
|
||||
}
|
||||
switch {
|
||||
case f.Name == "":
|
||||
err = errors.New("give the agent a name")
|
||||
@@ -510,6 +519,10 @@ func (s *Server) agentAction(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
case "enable":
|
||||
if lerr := s.limitAgents(); lerr != nil {
|
||||
s.renderAgent(w, r, u, sentence(lerr.Error())+".", http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
if err = users.SetStatus(s.DB, u.ID, users.Active); err == nil {
|
||||
s.audit(r, "enabled", u.Name, "an agent")
|
||||
redirect(w, r, back, "enabled")
|
||||
|
||||
Reference in New Issue
Block a user