Phase 11, part 3: approvals for what agents send out

Agents can now ask to publish or schedule a post, send an email, add
someone to a mailing list, or apply an SEO change. Each waits on the
Approvals page (with a count in the sidebar) for an admin or a member with
edit on its module, who can edit it first, approve or refuse it, and let
the agent take that class of action on its own with a cap per day. A
rotation after a leak revokes the old keys and withdraws everything
allowed. All of it is in the audit log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 10:54:53 -07:00
co-authored by Claude Opus 5.5
parent bfb74e7700
commit 311d2e815b
17 changed files with 1396 additions and 13 deletions
+13 -3
View File
@@ -344,6 +344,9 @@ func (s *Server) Handler() (http.Handler, error) {
mux.HandleFunc("GET /settings/about", s.aboutPage)
mux.HandleFunc("GET /settings/connections", s.connectionsPage)
mux.HandleFunc("GET /settings/activity", s.activityPage)
mux.HandleFunc("GET /approvals", s.approvalsPage)
mux.HandleFunc("POST /approvals/allowed/withdraw", s.approvalWithdraw)
mux.HandleFunc("POST /approvals/{id}/{action}", s.approvalAction)
mux.HandleFunc("GET /settings/agents", s.agentsPage)
mux.HandleFunc("POST /settings/agents", s.agentCreate)
mux.HandleFunc("GET /settings/agents/{id}", s.agentPage)
@@ -577,9 +580,10 @@ type page struct {
NewProspects int // companies and people waiting for review, shown in the menu
Drafts int // outreach drafts waiting, shown in the menu
Bare bool // no sidebar: pages before signing in
CSRF string // the form token, for htmx (app.js)
Viewer *viewer // who's looking
Bare bool // no sidebar: pages before signing in
CSRF string // the form token, for htmx (app.js)
Approvals int // agents' requests waiting for this viewer
Viewer *viewer // who's looking
}
// Section is the top bar's first breadcrumb, from Nav.
@@ -655,6 +659,9 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, p p
p.Error = sentence(p.Error)
p.CSRF = csrfToken(r)
p.Viewer = viewerOf(r)
if !p.Bare {
p.Approvals = s.waitingFor(p.Viewer)
}
out, err := withCSRF(r, func(b *bytes.Buffer) error { return t.ExecuteTemplate(b, "layout.html", p) })
if err != nil {
s.Log.Error("render", "page", name, "err", err)
@@ -704,6 +711,9 @@ var flashes = map[string]string{
"joined": "Welcome to Supermarket.",
"key-revoked": "Revoked: that key no longer works.",
"agent-off": "Turned off: none of its keys work.",
"refused": "Refused: the agent is told.",
"approved-request": "Approved, and done.",
"withdrawn-class": "Withdrawn: it asks again from now on.",
"account-removed": "Signed out: posts scheduled to it are back in Posts.",
"own-account-connected": "Connected: you can post as it, and an admin can let others.",
"deleted": "Deleted.",