Files
davidandClaude Opus 5.5 311d2e815b 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>
2026-11-25 10:54:53 -07:00

68 lines
4.1 KiB
HTML

{{define "content"}}{{with .Data}}
<div class="page-head">
<h1>Approvals</h1>
<p class="lede">What agents ask to send out of Supermarket: posts, emails, mailing-list adds, changes to the sites. Nothing goes until a person approves it, unless that kind of action has been allowed on its own. Edit it first if you like.</p>
</div>
{{if .Waiting}}
{{range .Waiting}}{{$req := .}}
<form class="card approval" method="post" action="/approvals/{{.ID}}/approve" id="r-{{.ID}}">
<p class="meta"><strong>{{.Agent}}</strong> <span class="pill">agent</span> asks to: <strong>{{.Summary}}</strong> · {{ago .Created}}</p>
{{with .Draft}}
{{if eq .Channel "reddit"}}<label class="small">Title <input name="title" value="{{.Title}}" maxlength="300"></label>
<p class="small muted">r/{{.Target}}</p>{{end}}
<textarea name="content" rows="{{if eq .Channel "x"}}5{{else}}10{{end}}" data-count="{{.Channel}}" data-limit="{{.Limit}}" data-reserve="{{if eq .Channel "x"}}{{xreserve .SourceURL}}{{else}}0{{end}}">{{.Content}}</textarea>
{{with .SourceURL}}<p class="small">Source: <a href="{{.}}" target="_blank" rel="noopener noreferrer">{{.}}</a></p>{{end}}
{{if $req.Accounts}}<label class="small inline-label">From
<select name="account">{{range $req.Accounts}}<option value="{{.ID}}" {{if eq (printf "post:%d" .ID) $req.Class}}selected{{end}}>{{.Label}}</option>{{end}}</select></label>
{{else}}<p class="warn-text small">You can't post to any account for this channel: an admin can let you (Settings → Posting accounts).</p>{{end}}
{{if not $req.At.IsZero}}<p class="small">To go out {{$req.At.Local.Format "Mon 2 Jan 2006, 15:04"}} (or at once, if that's passed).</p>{{end}}
{{end}}
{{with .Message}}
<p class="small">To <strong>{{.Contact.Name}}</strong> &lt;{{.To}}&gt;{{with .Company}} at {{.}}{{end}}</p>
<label class="small">Subject <input name="subject" value="{{.Subject}}"></label>
<textarea name="body" rows="10">{{.Body}}</textarea>
{{end}}
{{with .Change}}
<p class="small">{{.Page}}</p>
<label class="small">Title <input name="title" value="{{.NewTitle}}"></label>
<label class="small">Description <textarea name="description" rows="3">{{.NewDescription}}</textarea></label>
{{end}}
<div class="actions">
<button type="submit">Approve</button>
<button type="submit" class="secondary danger" formaction="/approvals/{{.ID}}/refuse">Refuse</button>
</div>
<label class="check small"><input type="checkbox" name="trust"> <span>And let {{.Agent}} {{.ClassLabel}} on its own from now on, up to <input name="cap" type="number" min="0" value="5" size="3" class="tiny"> a day (0: no cap)</span></label>
</form>
{{end}}
{{else}}
<section class="card empty"><p>Nothing waiting for you.</p></section>
{{end}}
{{if .Allowed}}
<section class="card">
<h2>What agents may do on their own</h2>
<table class="list">
<thead><tr><th>Agent</th><th>May</th><th>Cap</th><th>Since</th><th></th></tr></thead>
<tbody>{{range .Allowed}}<tr>
<td>{{.Agent}}</td><td>{{.Label}}</td><td>{{if .DailyCap}}{{.DailyCap}} a day{{else}}none{{end}}</td><td>{{ago .Granted}}{{with by .GrantedBy}} {{.}}{{end}}</td>
<td>{{if .Mine}}<form class="inline" method="post" action="/approvals/allowed/withdraw"><input type="hidden" name="agent" value="{{.Grant.Agent}}"><input type="hidden" name="class" value="{{.Class}}"><button type="submit" class="secondary small">Withdraw</button></form>{{end}}</td>
</tr>{{end}}</tbody>
</table>
</section>
{{end}}
{{if .Recent}}
<section class="card">
<h2>Decided</h2>
<table class="list">
<thead><tr><th>When</th><th>Agent</th><th>Asked to</th><th>Outcome</th></tr></thead>
<tbody>{{range .Recent}}<tr>
<td>{{ago .Decided}}</td><td>{{.Agent}}</td><td>{{.Summary}}</td>
<td>{{if eq .Status "refused"}}Refused{{with by .DecidedBy}} {{.}}{{end}}{{else if eq .Status "failed"}}<span class="error-text">Failed</span>: {{truncate 120 .Result}}{{else if .OnItsOwn}}Done on its own{{with .Result}}: {{truncate 120 .}}{{end}}{{else}}Approved{{with by .DecidedBy}} {{.}}{{end}}{{with .Result}}: {{truncate 120 .}}{{end}}{{end}}</td>
</tr>{{end}}</tbody>
</table>
</section>
{{end}}
{{end}}{{end}}