Phase 11, part 1: agents and their keys
Agents are users of kind agent, each given modules to read, or to read and act on, and the CRM scope. Admins make them under Settings → Agents, on every edition; keys (sm_…) are shown once and kept as hashes, can expire, be rotated (the old one works a day) or revoked, and record their last use. /mcp takes agent keys and offers each agent only the tools its scopes allow. On the local edition, mcp-token is the key of a built-in Hermes agent with the CRM and the Market. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
{{define "content"}}{{template "settings-start" .}}{{with .Data}}{{$d := .}}{{$a := .Row}}
|
||||
<p><a href="/settings/agents">← Agents</a></p>
|
||||
<h2>{{$a.Name}}{{if $a.BuiltIn}} <span class="pill">built in</span>{{end}}{{if eq $a.Status "disabled"}} <span class="pill">turned off</span>{{end}}</h2>
|
||||
{{with .Problem}}<p class="error" role="alert">{{.}}</p>{{end}}
|
||||
|
||||
<form class="card" method="post" action="/settings/agents/{{$a.ID}}/save">
|
||||
<label>Name <input name="name" value="{{$a.Name}}" required></label>
|
||||
<label>What it's for <textarea name="description" rows="2">{{$a.Description}}</textarea></label>
|
||||
{{template "agent-scopes" (dict "Scopes" $a.Modules "Grants" .Grants)}}
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
|
||||
<section class="card" id="keys">
|
||||
<h2>Keys</h2>
|
||||
<table class="list">
|
||||
<thead><tr><th>Key</th><th>Made</th><th>Expires</th><th>Last used</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
{{range $a.Keys}}<tr>
|
||||
<td><code>{{.Prefix}}…</code>
|
||||
{{if not .Revoked.IsZero}} <span class="pill">revoked {{ago .Revoked}}</span>
|
||||
{{else if not (.Working $d.Now)}} <span class="pill">stopped</span>
|
||||
{{else if not .Retires.IsZero}} <span class="pill warn">replaced: works until {{.Retires.Local.Format "2 Jan 15:04"}}</span>
|
||||
{{else}} <span class="pill ok">working</span>{{end}}</td>
|
||||
<td>{{.Created.Local.Format "2 Jan 2006"}}</td>
|
||||
<td>{{if .Expires.IsZero}}<span class="muted">never</span>{{else}}{{.Expires.Local.Format "2 Jan 2006"}}{{end}}</td>
|
||||
<td>{{if .Used.IsZero}}<span class="muted">never</span>{{else}}{{ago .Used}}{{with .UsedFrom}} <span class="muted small">from {{.}}</span>{{end}}{{end}}</td>
|
||||
<td>{{if .Working $d.Now}}<form class="inline" method="post" action="/settings/agents/{{$a.ID}}/revoke" data-confirm="Revoke this key? Whatever uses it stops at once."><input type="hidden" name="key" value="{{.ID}}"><button type="submit" class="secondary small danger">Revoke</button></form>{{end}}</td>
|
||||
</tr>{{else}}<tr><td colspan="5" class="muted">No keys.</td></tr>{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="actions">
|
||||
<form class="inline" method="post" action="/settings/agents/{{$a.ID}}/rotate"><button type="submit" class="secondary">Rotate the key</button></form>
|
||||
<form class="inline row" method="post" action="/settings/agents/{{$a.ID}}/new-key"><label class="small">Expires <input type="date" name="expires"></label><button type="submit" class="secondary">Add a key</button></form>
|
||||
</div>
|
||||
<p class="help"><strong>Rotate</strong> makes a new key; the old one keeps working for a day, so whatever uses it can be switched over. After a leak, <strong>revoke</strong> it instead: it stops at once.</p>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<div class="actions">
|
||||
{{if eq $a.Status "disabled"}}
|
||||
<form class="inline" method="post" action="/settings/agents/{{$a.ID}}/enable"><button type="submit" class="secondary">Turn it back on</button></form>
|
||||
{{else}}
|
||||
<form class="inline" method="post" action="/settings/agents/{{$a.ID}}/disable"><button type="submit" class="secondary danger">Turn it off</button></form>
|
||||
{{end}}
|
||||
{{if not $a.BuiltIn}}<form class="inline" method="post" action="/settings/agents/{{$a.ID}}/remove" data-confirm="Remove {{$a.Name}} and its keys for good?"><button type="submit" class="danger">Remove</button></form>{{end}}
|
||||
</div>
|
||||
<p class="help">Turned off, none of its keys work, until it's turned back on.</p>
|
||||
</section>
|
||||
{{end}}{{template "settings-end"}}{{end}}
|
||||
Reference in New Issue
Block a user