Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(vaults-ui): active access control center — live grants + countdown + revoke (#685)

Call White2e7039323aac
diff --git a/docs/plans/avault-custody-core.md b/docs/plans/avault-custody-core.md
index ed4a9c67c..a4a44c52c 100644
--- a/docs/plans/avault-custody-core.md
+++ b/docs/plans/avault-custody-core.md
@@ -1,6 +1,6 @@
# avault — Rust custody core for Avibe Vaults (Avibe-side integration)
-**Status:** Approved · implementation started. The custody core lives in its own repo:
+**Status:** P0→P2 implemented & merged (2026-06-28); agent-consumer integration + protected-tier browser sandbox remain — see §15. The custody core lives in its own repo:
[`avibe-bot/avault`](https://github.com/avibe-bot/avault) (Rust). The **authoritative full
design** is `avault/docs/DESIGN.md` (mirrored from this document). **This doc now tracks the
Avibe side** — how the Python daemon integrates avault — and stays in sync with the repo.
@@ -387,14 +387,29 @@ This is an internal store selection inside `avault`, not an Avibe-level plugin l
## 15. Roadmap
+> **Implementation status — 2026-06-28.** P0→P2 are implemented and merged. What
+> remains is the *consumer-facing* surface (how an agent asks for and receives a
+> secret in a normal turn) and the protected tier's browser sandbox — see §15.1.
+
| Phase | Scope | State |
|---|---|---|
-| **P0** | Python standard tier: DB + envelope + delivery + `$<NAME>` (#631) | **done — keep & merge; not replaced before P1** |
-| **P1** | `avault-core` + CLI + `file+mlock` store; Rust takes standard-tier seal/open; blind-box create; `vibe runtime prepare` ensure + Dependencies card. Closes the memory-hygiene gap. | next |
-| **P2** | Resident agent + `SO_PEERCRED` + scope-grant DEK cache + signer (secp256k1; approval-card context in the sign prompt). Protected-tier non-browser factors via hardware stores. | after P1 |
-| **P3** | Multi-factor (passkey-PRF copies, TPM, KMS KEK); external `SignerProvider` (hardware wallet / WalletConnect). | later |
+| **P0** | Python standard tier: DB + envelope + delivery + `$<NAME>` (#631) | **superseded** — Python value-crypto removed; all paths route through avault |
+| **P1** | `avault-core` + CLI + `file+mlock` store; Rust takes standard-tier seal/open; blind-box create; `vibe runtime prepare` ensure + Dependencies card | **merged** |
+| **P1.1** | complete the deliver surface (`deliver fetch` / `inject`) | **merged** |
+| **P2** | resident agent (`SO_PEERCRED`/`LOCAL_PEERCRED` socket) + scope-grant DEK cache + secp256k1 signer (ECDSA-recoverable + DER + Schnorr-BIP340) + `file+passphrase` store + operation-bound blind-box AAD; protected delivery through the agent; browser crypto library; Vaults UI (hub, create form, active-access control center) | **merged** — avault #10, browser #674, Python #673, delivery #677, UI #678 + #685 |
+
+### 15.1 Remaining after P2 (open items for the owner)
+
+Established by an audit of merged code on 2026-06-28 — deliberately *not* in P2:
+
+1. **Agent-facing consumer surface — the real usability gap.** The deliver primitives exist in Python (`deliver run`/`fetch`/`inject` via the avault CLI + resident agent), but there is no routed/agent-facing surface to *discover* vaults/scopes and *request* a secret within a normal turn, and the request→approval→grant flow has no in-chat producer yet. Net effect: the grant/request management UI is in place but stays empty until this lands. **Open decision:** the consumer-surface shape — an askill-shaped CLI the agent calls (recommended), vs HTTP endpoints, vs the resident-agent socket directly.
+2. **In-chat approval card (design ①②).** The approve flow is multi-branch — access→grant (scope picker; standard tier works today) vs per-use sign (`grantable=False`) vs protected (browser sandbox, next version). Needs a UX pass on where the card lives (chat vs hub) before building.
+3. **Keypair creation in the UI.** `create_secret` takes a caller-sealed envelope; generating a signing key needs a browser keygen+seal flow (the crypto lib exists).
+4. **Deny-request endpoint.** None yet; pending requests only auto-expire via `expires_at`.
+5. **Protected tier end-to-end → next version.** Browser signing sandbox (cross-origin iframe isolation), WalletConnect-first + local iframe fallback, with all protected-tier crypto (sign *and* non-sign) unified in the sandbox.
+6. **Tags as loadable bundles** (group stays single-select) → next increment: `--env-tag` + `tag:` grant scope.
-**Recommendation:** make P1 **CLI-only** — push the agent, grants, and signing to P2 — so the first step is small and headlessly verifiable.
+**Dropped (decided 2026-06-28):** a per-secret **ETH/BTC chain badge** — keypairs are chain-agnostic secp256k1; the chain is fixed by the signature *scheme* at sign time, not a secret attribute. The "Signing" badge is the correct representation.
---
diff --git a/ui/src/components/workbench/VaultsPage.tsx b/ui/src/components/workbench/VaultsPage.tsx
index 85b41a2aa..97300ee21 100644
--- a/ui/src/components/workbench/VaultsPage.tsx
+++ b/ui/src/components/workbench/VaultsPage.tsx
@@ -1,12 +1,12 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
-import { History, KeyRound, Loader2, Plus, RefreshCw, Trash2, Wallet } from 'lucide-react';
+import { Clock, History, KeyRound, Layers, Loader2, Plus, Puzzle, RefreshCw, ShieldCheck, ShieldOff, Trash2, Wallet } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { CapabilityTabs } from './CapabilityTabs';
import { WorkbenchPageHeader } from './WorkbenchPageHeader';
import { Badge } from '../ui/badge';
import { Button } from '../ui/button';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/dialog';
-import { useApi, type VaultAuditEvent, type VaultSecret } from '../../context/ApiContext';
+import { useApi, type VaultAuditEvent, type VaultGrant, type VaultSecret } from '../../context/ApiContext';
import { useToast } from '../../context/ToastContext';
import { VaultSecretForm } from '../ui/vault-secret-form';
@@ -84,17 +84,83 @@ const SecretRow: React.FC<{ secret: VaultSecret; onDelete: (name: string) => voi
);
};
+const SCOPE_ICON: Record<VaultGrant['scope_type'], typeof KeyRound> = {
+ secret: KeyRound,
+ skill: Puzzle,
+ group: Layers,
+};
+
+/** Break a grant's time-to-expiry into parts; the units are localized in the row. */
+function remaining(expiresAt: string, now: number): { h: number; m: number; s: number; expired: boolean; urgent: boolean } {
+ const end = Date.parse(expiresAt);
+ const secs = Math.floor((end - now) / 1000);
+ if (Number.isNaN(end) || secs <= 0) return { h: 0, m: 0, s: 0, expired: true, urgent: true };
+ return { h: Math.floor(secs / 3600), m: Math.floor((secs % 3600) / 60), s: secs % 60, expired: false, urgent: secs <= 60 };
+}
+
+function isExpired(expiresAt: string, now: number): boolean {
+ const end = Date.parse(expiresAt);
+ return !Number.isNaN(end) && end <= now;
+}
+
+const GrantRow: React.FC<{ grant: VaultGrant; now: number; onRevoke: (grant: VaultGrant) => void }> = ({
+ grant: g,
+ now,
+ onRevoke,
+}) => {
+ const { t } = useTranslation();
+ const Icon = SCOPE_ICON[g.scope_type] ?? KeyRound;
+ const rem = remaining(g.expires_at, now);
+ const time =
+ rem.h > 0
+ ? t('vaults.grants.dur.hm', { h: rem.h, m: rem.m })
+ : rem.m > 0
+ ? t('vaults.grants.dur.ms', { m: rem.m, s: rem.s })
+ : t('vaults.grants.dur.s', { s: rem.s });
+ return (
+ <div className="flex items-center gap-3.5 rounded-xl border border-border bg-surface px-4 py-3">
+ <div className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-mint/10 text-mint">
+ <Icon className="size-4" />
+ </div>
+ <div className="flex min-w-0 flex-col gap-1">
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="truncate font-mono text-sm font-semibold">{g.scope_ref}</span>
+ <Badge variant="secondary">{t(`vaults.grants.scope.${g.scope_type}`)}</Badge>
+ <Badge variant="outline">
+ {g.session_id ? t('vaults.grants.session.bound') : t('vaults.grants.session.any')}
+ </Badge>
+ </div>
+ <span className="flex items-center gap-1.5 text-xs text-muted">
+ <span>{t('vaults.secretCount', { count: g.runtime_member_count })}</span>
+ <span aria-hidden>·</span>
+ <Clock className="size-3" />
+ <span className={rem.urgent ? 'text-warning' : undefined}>
+ {rem.expired ? t('vaults.grants.expired') : t('vaults.grants.expiresIn', { time })}
+ </span>
+ </span>
+ </div>
+ <div className="ml-auto">
+ <Button variant="ghost" size="icon" onClick={() => onRevoke(g)} aria-label={t('vaults.grants.revoke')}>
+ <ShieldOff className="size-4" />
+ </Button>
+ </div>
+ </div>
+ );
+};
+
export const VaultsPage: React.FC = () => {
const { t } = useTranslation();
const api = useApi();
const { showToast } = useToast();
const [secrets, setSecrets] = useState<VaultSecret[]>([]);
+ const [grants, setGrants] = useState<VaultGrant[]>([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const [adding, setAdding] = useState(false);
const [showAudit, setShowAudit] = useState(false);
const [audit, setAudit] = useState<VaultAuditEvent[]>([]);
const [view, setView] = useState<ViewMode>('all');
+ const [now, setNow] = useState(() => Date.now());
const refresh = useCallback(async () => {
setLoading(true);
@@ -107,12 +173,40 @@ export const VaultsPage: React.FC = () => {
} finally {
setLoading(false);
}
+ // Active grants are a best-effort control strip; a grants failure (e.g. an
+ // older backend without the route) must neither blank out the secret
+ // inventory nor surface an error toast, so suppress error handling here.
+ try {
+ const res = await api.getVaultGrants({ status: 'active' }, { handleError: false });
+ setGrants(res.grants ?? []);
+ } catch {
+ setGrants([]);
+ }
}, [api]);
useEffect(() => {
refresh();
}, [refresh]);
+ // Tick once a second while there are live grants: advance the countdown and
+ // drop any grant that has reached its expiry. The backend's status=active
+ // filter only applies at fetch time, so without this the "Active access"
+ // strip and its count would linger on a dead grant and the timer would run
+ // forever; when the last grant expires the interval tears down on its own.
+ const hasGrants = grants.length > 0;
+ useEffect(() => {
+ if (!hasGrants) return;
+ const id = setInterval(() => {
+ const t = Date.now();
+ setNow(t);
+ setGrants((prev) => {
+ const live = prev.filter((g) => !isExpired(g.expires_at, t));
+ return live.length === prev.length ? prev : live;
+ });
+ }, 1000);
+ return () => clearInterval(id);
+ }, [hasGrants]);
+
const groups = useMemo(() => {
const byGroup = new Map<string, VaultSecret[]>();
for (const s of secrets) {
@@ -146,6 +240,17 @@ export const VaultsPage: React.FC = () => {
}
};
+ const onRevokeGrant = async (g: VaultGrant) => {
+ if (!window.confirm(t('vaults.grants.revokeConfirm', { scope: g.scope_ref }))) return;
+ try {
+ await api.revokeVaultGrant(g.id);
+ showToast(t('vaults.grants.revoked', { scope: g.scope_ref }), 'success');
+ refresh();
+ } catch (err: any) {
+ setError(err?.message ?? String(err));
+ }
+ };
+
return (
<div className="mx-auto flex w-full max-w-[1200px] flex-col gap-5 py-2">
<CapabilityTabs />
@@ -171,6 +276,19 @@ export const VaultsPage: React.FC = () => {
{error && (
<div className="rounded-xl border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive">{error}</div>
)}
+ {grants.length > 0 && (
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center gap-2 px-1">
+ <ShieldCheck className="size-4 text-mint" />
+ <span className="text-sm font-semibold">{t('vaults.grants.title')}</span>
+ <Badge variant="secondary">{grants.length}</Badge>
+ <span className="hidden text-xs text-muted sm:inline">{t('vaults.grants.subtitle')}</span>
+ </div>
+ {grants.map((g) => (
+ <GrantRow key={g.id} grant={g} now={now} onRevoke={onRevokeGrant} />
+ ))}
+ </div>
+ )}
{secrets.length > 0 ? (
<div className="flex items-center gap-1 self-start rounded-lg border border-border bg-surface p-1">
<Button variant={view === 'all' ? 'secondary' : 'ghost'} size="sm" onClick={() => setView('all')}>
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 1ba47e4c5..d5cf0e8a2 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -306,7 +306,7 @@ export type ApiContextType = {
createVaultSecret: (payload: VaultCreatePayload, opts?: { handleError?: boolean }) => Promise<{ ok: boolean; secret?: VaultSecret; code?: string; message?: string }>;
deleteVaultSecret: (name: string) => Promise<{ ok: boolean; removed?: boolean; code?: string; message?: string }>;
getVaultRequests: (params?: { status?: string; type?: string; limit?: number }) => Promise<{ ok: boolean; requests: VaultRequest[] }>;
- getVaultGrants: (params?: { status?: string; sessionId?: string }) => Promise<{ ok: boolean; grants: VaultGrant[] }>;
+ getVaultGrants: (params?: { status?: string; sessionId?: string }, opts?: { handleError?: boolean }) => Promise<{ ok: boolean; grants: VaultGrant[] }>;
createVaultGrant: (payload: Record<string, unknown>) => Promise<{ ok: boolean; grant: VaultGrant; code?: string; message?: string }>;
revokeVaultGrant: (grantId: string) => Promise<{ ok: boolean; grant?: VaultGrant; code?: string; message?: string }>;
signVaultDigest: (payload: Record<string, unknown>) => Promise<{ ok: boolean; signature?: Record<string, unknown>; request?: VaultRequest; code?: string; message?: string }>;
@@ -1389,15 +1389,21 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
throw new ApiError(errorMessage, res.status, errorCode);
};
- const getJson = async (path: string) => {
+ const getJson = async (path: string, { handleError = true }: { handleError?: boolean } = {}) => {
const res = await apiFetch(path);
- if (!res.ok) {
+ if (!res.ok && handleError) {
await handleApiError(res, path);
}
return res.json();
};
- const getCachedJson = (path: string, ttlMs = 1500) => {
+ const getCachedJson = (path: string, ttlMs = 1500, opts?: { handleError?: boolean }) => {
+ // Best-effort callers (handleError: false) bypass the shared read cache so a
+ // silently-failing request can't hand its suppressed-error promise to a
+ // toast-enabled caller hitting the same path.
+ if (opts?.handleError === false) {
+ return getJson(path, opts);
+ }
const now = Date.now();
const cached = readCacheRef.current.get(path);
if (cached && cached.expiresAt > now) {
@@ -2016,12 +2022,12 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
const qs = search.toString();
return getCachedJson(qs ? `/api/vault/requests?${qs}` : '/api/vault/requests', 1500);
},
- getVaultGrants: (params) => {
+ getVaultGrants: (params, opts) => {
const search = new URLSearchParams();
if (params?.status) search.set('status', params.status);
if (params?.sessionId) search.set('session_id', params.sessionId);
const qs = search.toString();
- return getCachedJson(qs ? `/api/vault/grants?${qs}` : '/api/vault/grants', 1500);
+ return getCachedJson(qs ? `/api/vault/grants?${qs}` : '/api/vault/grants', 1500, opts);
},
createVaultGrant: (payload) => postJson('/api/vault/grants', payload),
revokeVaultGrant: (grantId) => deleteJson(`/api/vault/grants/${encodeURIComponent(grantId)}`),
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index e94e13a0b..8e51bc03a 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -2089,6 +2089,29 @@
"standard": "Standard",
"signing": "Signing",
"secretCount": "{{count}} secrets",
+ "grants": {
+ "title": "Active access",
+ "subtitle": "Grants agents can use right now — revoke to cut access immediately.",
+ "expiresIn": "expires in {{time}}",
+ "expired": "expired",
+ "revoke": "Revoke",
+ "revokeConfirm": "Revoke access to \"{{scope}}\" now? Agents lose it immediately.",
+ "revoked": "Revoked access to {{scope}}",
+ "scope": {
+ "secret": "Secret",
+ "skill": "Skill",
+ "group": "Group"
+ },
+ "dur": {
+ "hm": "{{h}}h {{m}}m",
+ "ms": "{{m}}m {{s}}s",
+ "s": "{{s}}s"
+ },
+ "session": {
+ "bound": "Session-bound",
+ "any": "Any session"
+ }
+ },
"view": {
"all": "All",
"byGroup": "By group"
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index c55deadb5..fa998190a 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -2088,6 +2088,29 @@
"standard": "标准档",
"signing": "签名",
"secretCount": "{{count}} 个密钥",
+ "grants": {
+ "title": "活跃授权",
+ "subtitle": "Agent 当前可用的授权——吊销即刻断开访问。",
+ "expiresIn": "{{time}} 后过期",
+ "expired": "已过期",
+ "revoke": "吊销",
+ "revokeConfirm": "立即吊销对「{{scope}}」的访问?Agent 将即刻失去访问权。",
+ "revoked": "已吊销对「{{scope}}」的访问",
+ "scope": {
+ "secret": "密钥",
+ "skill": "技能",
+ "group": "分组"
+ },
+ "dur": {
+ "hm": "{{h}} 时 {{m}} 分",
+ "ms": "{{m}} 分 {{s}} 秒",
+ "s": "{{s}} 秒"
+ },
+ "session": {
+ "bound": "限单会话",
+ "any": "全部会话"
+ }
+ },
"view": {
"all": "全部",
"byGroup": "按分组"