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): tag/skill-tag UI and fixed-set approval cards (#755)

Call White737d01809697
diff --git a/ui/src/components/ui/vault-approval-card.tsx b/ui/src/components/ui/vault-approval-card.tsx
index 601a0c70e..506523c42 100644
--- a/ui/src/components/ui/vault-approval-card.tsx
+++ b/ui/src/components/ui/vault-approval-card.tsx
@@ -1,8 +1,9 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
-import { Check, Cpu, Loader2, LockKeyhole, PenTool, ShieldCheck, Wallet } from 'lucide-react';
+import { Check, Clock, Cpu, KeyRound, Loader2, LockKeyhole, PenTool, Puzzle, ShieldCheck, Tag, Wallet } from 'lucide-react';
import { useTranslation } from 'react-i18next';
-import { useApi, type VaultRequest } from '@/context/ApiContext';
+import { useApi, type VaultRequest, type VaultSourceSelector } from '@/context/ApiContext';
+import { partitionTags } from '@/lib/vaultTags';
import { useProtectedVault, type ProtectedUnlockMaterial } from '@/lib/useProtectedVault';
import {
blindBoxAgentDeliverOperationHash,
@@ -17,16 +18,23 @@ import { Button } from './button';
import { Switch } from './switch';
import { VaultProtectedUnlock } from './vault-protected-unlock';
-/** The approval `card` the daemon attaches to a request's delivery payload. */
-type ScopeOption = {
- scope_type: 'secret' | 'skill' | 'group';
- scope_ref: string;
- default_ttl_seconds: number;
- ttl_options_seconds: number[];
- session_binding_default: boolean;
- member_count: number;
- member_snapshot: string[];
- /** Hydrated for UI audience: the protected members of this scope to release. */
+/**
+ * The fixed protected grant the daemon attaches to an access request's card. In the
+ * grant-id model there is exactly one: the protected set covered by the request's
+ * selector. `scope_type`/`scope_ref` are NOT a product concept — they are the opaque
+ * binding the DEK blind box is sealed against (blindBoxAgentDeliverOperationHash),
+ * relayed verbatim to the resident avault agent pending the avault-side grant_id
+ * migration (Track A). The UI never renders them.
+ */
+type GrantOption = {
+ scope_type?: string;
+ scope_ref?: string;
+ default_ttl_seconds?: number;
+ session_binding_default?: boolean;
+ member_count?: number;
+ member_snapshot?: string[];
+ source_selector?: VaultSourceSelector;
+ /** Hydrated for UI audience: the protected members of this set to DEK-release. */
unlock_material?: ProtectedUnlockMaterial[];
};
@@ -39,7 +47,13 @@ type ApprovalCard = {
command?: string | null;
egress?: string | null;
session_id?: string | null;
- scope_options?: ScopeOption[];
+ purpose?: string | null;
+ /** How the protected set was selected: explicit env names vs tags/skills. */
+ source_selector?: VaultSourceSelector;
+ default_ttl_seconds?: number;
+ /** The fixed protected grant. New backend sends `grant_options`; older sends `scope_options`. */
+ grant_options?: GrantOption[];
+ scope_options?: GrantOption[];
/** Hydrated for UI audience when the requested secret is protected. */
secret_unlock_material?: ProtectedUnlockMaterial | null;
};
@@ -96,28 +110,50 @@ export const VaultApprovalCard: React.FC<{
// The request is passed in already hydrated by the UI-audience inbox list
// (`getVaultRequests`, #708), so `card.secret_unlock_material` /
- // `scope_options[].unlock_material` are present for protected requests. No fetch or
+ // `grant_options[].unlock_material` are present for protected requests. No fetch or
// loading state is needed here — the single-request GET is agent-audience (value-free).
const card = (request.card ?? null) as ApprovalCard | null;
const delivery = (request.delivery ?? {}) as { digest?: string; scheme?: string };
const isSign = (card?.request_type ?? request.request_type) === 'sign';
const isProtected = card?.protection === 'protected';
const isKeypair = card?.kind === 'keypair';
- const scopeOptions = card?.scope_options ?? [];
- const [scopeIdx, setScopeIdx] = useState(0);
- const [thisSessionOnly, setThisSessionOnly] = useState(
- () => scopeOptions.length === 0 || scopeOptions[0].session_binding_default !== false,
- );
+ // A grant covers a fixed protected set — there is no scope picker.
+ const grantOptions = useMemo(() => card?.grant_options ?? card?.scope_options ?? [], [card]);
+ const option = useMemo(() => {
+ if (!grantOptions.length) return undefined;
+ // New backend: exactly one fixed protected set covered by the request's selector.
+ if (card?.grant_options?.length) return grantOptions[0];
+ // Legacy pre-refactor scope_options are ordered [secret, skill, group] and only options
+ // containing protected members get hydrated unlock_material. Prefer the EXACT
+ // requested-secret scope so approving never auto-selects a broader skill/group option that
+ // would release unrelated protected secrets; fall back to a protected option only if the
+ // secret scope is absent.
+ const exact = grantOptions.find((o) => o.scope_type === 'secret');
+ return exact ?? grantOptions.find((o) => (o.unlock_material?.length ?? 0) > 0) ?? grantOptions[0];
+ }, [grantOptions, card]);
+ const materials = useMemo(() => option?.unlock_material ?? [], [option]);
+ // Protected secret names to be granted (design: "show the protected secret names covered").
+ const protectedNames = useMemo(() => materials.map((m) => m.name), [materials]);
+ const source = useMemo<VaultSourceSelector>(() => card?.source_selector ?? option?.source_selector ?? {}, [card, option]);
+ const sourceChips = useMemo(() => {
+ const chips: Array<{ key: string; label: string; icon: typeof KeyRound; mono?: boolean }> = [];
+ for (const env of source.env ?? []) chips.push({ key: `env:${env}`, label: env, icon: KeyRound, mono: true });
+ const { tags, skills } = partitionTags(source.tags);
+ for (const skill of skills) chips.push({ key: `skill:${skill}`, label: t('vaults.approval.sourceSkill', { name: skill }), icon: Puzzle });
+ for (const tag of tags) chips.push({ key: `tag:${tag}`, label: t('vaults.approval.sourceTag', { name: tag }), icon: Tag });
+ return chips;
+ }, [source, t]);
+ // TTL is a fixed product default (env-list 300s, tag/skill 900s), not a user control.
+ const ttlSeconds = option?.default_ttl_seconds ?? card?.default_ttl_seconds ?? (source.tags?.length ? 900 : 300);
+
+ const [thisSessionOnly, setThisSessionOnly] = useState(() => option?.session_binding_default !== false);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
- const selectedOption = scopeOptions[scopeIdx];
- const selectedMaterials = useMemo(() => selectedOption?.unlock_material ?? [], [selectedOption]);
-
// A request needs the browser VMK unlocked when it touches protected key material:
- // a protected sign, or an access whose chosen scope includes protected members.
- const needsUnlock = isSign ? isProtected : selectedMaterials.length > 0;
+ // a protected sign, or an access whose fixed set includes protected members.
+ const needsUnlock = isSign ? isProtected : materials.length > 0;
const unlocked = vault.status === 'unlocked';
useEffect(() => {
@@ -143,21 +179,22 @@ export const VaultApprovalCard: React.FC<{
const approveAccess = () =>
finish(async () => {
- const option = selectedOption;
if (!option) throw new Error(t('vaults.approval.errors.noScope'));
- const ttlSeconds = option.default_ttl_seconds;
- const materials = option.unlock_material ?? [];
// A protected secret with no hydrated unlock material means the request was read
// without UI-audience hydration — fail clearly instead of taking the standard path
// (which the daemon rejects for a protected secret anyway).
if (isProtected && materials.length === 0) throw new Error(t('vaults.approval.errors.missingMaterial'));
+ // `scope_type`/`scope_ref` are the opaque binding the DEK blind box is sealed against
+ // and relayed with; the backend supplies them (grant_id bridge). Never shown to the user.
+ const bindScopeType = option.scope_type ?? '';
+ const bindScopeRef = option.scope_ref ?? '';
if (materials.length === 0) {
- // Standard members only — a metadata-only scope grant, no DEK release.
+ // No protected members (a hidden always-ask standard case) — metadata-only grant, no DEK.
failIfNotOk(
await api.createVaultGrant({
request_id: request.id,
- scope_type: option.scope_type,
- scope_ref: option.scope_ref,
+ scope_type: bindScopeType,
+ scope_ref: bindScopeRef,
ttl_seconds: ttlSeconds,
this_session_only: thisSessionOnly,
}),
@@ -173,8 +210,8 @@ export const VaultApprovalCard: React.FC<{
const approvalNonce = crypto.getRandomValues(new Uint8Array(16));
const context = await protectedDekReleaseBlindBoxContext(material.name, {
kind: 'agent-deliver',
- scopeType: option.scope_type,
- scopeRef: option.scope_ref,
+ scopeType: bindScopeType,
+ scopeRef: bindScopeRef,
ttlSecs: ttlSeconds,
approval: { nonce: approvalNonce, expiresAtUnix },
operationHash: await blindBoxAgentDeliverOperationHash(material.name, ttlSeconds),
@@ -190,8 +227,8 @@ export const VaultApprovalCard: React.FC<{
}
failIfNotOk(
await api.fulfillVaultAccessRequest(request.id, {
- scope_type: option.scope_type,
- scope_ref: option.scope_ref,
+ scope_type: bindScopeType,
+ scope_ref: bindScopeRef,
ttl_seconds: ttlSeconds,
this_session_only: thisSessionOnly,
agent_pubkey: agentPubkey,
@@ -247,7 +284,7 @@ export const VaultApprovalCard: React.FC<{
);
}
- const approveDisabled = busy || (needsUnlock && !unlocked) || (!isSign && !selectedOption);
+ const approveDisabled = busy || (needsUnlock && !unlocked) || (!isSign && !option);
return (
<div className="flex flex-col gap-4">
@@ -319,62 +356,39 @@ export const VaultApprovalCard: React.FC<{
<div className="h-px bg-border" />
- {/* Approval scope (access only) */}
- {!isSign && scopeOptions.length > 0 ? (
- <div className="flex flex-col gap-2">
- <span className="px-1 text-xs font-semibold uppercase tracking-wide text-muted">
- {t('vaults.approval.scopeTitle')}
- </span>
- <div
- role="radiogroup"
- aria-label={t('vaults.approval.scopeTitle')}
- className="flex flex-col gap-2"
- onKeyDown={(e) => {
- if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
- e.preventDefault();
- setScopeIdx((i) => (i + 1) % scopeOptions.length);
- } else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
- e.preventDefault();
- setScopeIdx((i) => (i - 1 + scopeOptions.length) % scopeOptions.length);
- }
- }}
- >
- {scopeOptions.map((option, idx) => {
- const selected = idx === scopeIdx;
- return (
- <button
- key={`${option.scope_type}:${option.scope_ref}`}
- type="button"
- role="radio"
- aria-checked={selected}
- tabIndex={selected ? 0 : -1}
- onClick={() => setScopeIdx(idx)}
- className={cn(
- 'flex items-center gap-2.5 rounded-lg border p-2.5 text-left transition-colors',
- selected ? 'border-mint bg-mint-soft' : 'border-border bg-surface hover:bg-surface-2',
- )}
- >
- <span
- className={cn(
- 'flex size-[18px] shrink-0 items-center justify-center rounded-full border-[1.5px]',
- selected ? 'border-2 border-mint' : 'border-border-strong',
- )}
- >
- {selected ? <span className="size-2 rounded-full bg-mint" /> : null}
- </span>
- <span className="flex min-w-0 flex-col gap-px">
- <span className={cn('flex flex-wrap items-center gap-1.5 text-[13px]', selected ? 'font-semibold' : 'font-medium')}>
- {t(`vaults.approval.scope.${option.scope_type}`, { ref: option.scope_ref })}
- <Badge variant="secondary">{ttlLabel(option.default_ttl_seconds)}</Badge>
- </span>
- <span className="text-[11px] text-muted-foreground">
- {t('vaults.approval.scopeMembers', { count: option.member_count })}
- </span>
- </span>
- </button>
- );
- })}
- </div>
+ {/* Access grant summary (access only): how the set was selected, the fixed protected
+ secret names to be granted, and the fixed access duration. There is no scope
+ picker — the grant is a fixed protected set determined by the request's selector. */}
+ {!isSign ? (
+ <div className="flex flex-col gap-3.5">
+ {sourceChips.length > 0 ? (
+ <DetailRow label={t('vaults.approval.source')}>
+ {sourceChips.map((chip) => {
+ const Icon = chip.icon;
+ return (
+ <Badge key={chip.key} variant="outline" className={cn('gap-1', chip.mono && 'font-mono')}>
+ <Icon className="size-3 shrink-0 text-muted" />
+ {chip.label}
+ </Badge>
+ );
+ })}
+ </DetailRow>
+ ) : null}
+ {protectedNames.length > 0 ? (
+ <DetailRow label={t('vaults.approval.protectedSecrets')}>
+ {protectedNames.map((name) => (
+ <Badge key={name} variant="warning" className="font-mono">
+ {name}
+ </Badge>
+ ))}
+ </DetailRow>
+ ) : null}
+ <DetailRow label={t('vaults.approval.duration')}>
+ <span className="flex items-center gap-1.5 text-[13px] text-foreground">
+ <Clock className="size-3.5 shrink-0 text-muted" />
+ {t('vaults.approval.durationValue', { time: ttlLabel(ttlSeconds) })}
+ </span>
+ </DetailRow>
</div>
) : null}
diff --git a/ui/src/components/ui/vault-secret-form.tsx b/ui/src/components/ui/vault-secret-form.tsx
index eefbb9f6a..3cc38f36f 100644
--- a/ui/src/components/ui/vault-secret-form.tsx
+++ b/ui/src/components/ui/vault-secret-form.tsx
@@ -19,6 +19,7 @@ import { useTranslation } from 'react-i18next';
import { ApiError, useApi, type DependencyItem, type VaultRequestSpec } from '@/context/ApiContext';
import { cn } from '@/lib/utils';
+import { mergeTags, normalizeSkillEntry, normalizeTagEntry, partitionTags } from '@/lib/vaultTags';
import {
generateSigningKey,
importSigningKey,
@@ -30,7 +31,6 @@ import {
import { useProtectedVault } from '@/lib/useProtectedVault';
import { Badge } from './badge';
import { Button } from './button';
-import { Combobox } from './combobox';
import { Input } from './input';
import { SegmentedRadio } from './segmented';
import { TagInput } from './tag-input';
@@ -42,7 +42,6 @@ type FetchAuthMode = 'bearer' | 'header' | 'query';
type StaticSecretSource = 'text' | 'file';
const AVAULT_P2_MIN_VERSION = '0.1.3';
-const DEFAULT_GROUP = 'default';
const MAX_SECRET_FILE_BYTES = 1024 * 1024;
const HTTP_HEADER_TOKEN_RE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
const QUERY_PARAM_RE = /^[A-Za-z0-9._~-]+$/;
@@ -113,7 +112,6 @@ export const VaultSecretForm: React.FC<{
provisionRequestId?: string | null;
requestSpec?: VaultRequestSpec | null;
treatExistingAsFulfilled?: boolean;
- groups?: string[];
}> = ({
fixedName,
onCancel,
@@ -123,7 +121,6 @@ export const VaultSecretForm: React.FC<{
provisionRequestId,
requestSpec,
treatExistingAsFulfilled = false,
- groups = [],
}) => {
const { t } = useTranslation();
const api = useApi();
@@ -137,14 +134,20 @@ export const VaultSecretForm: React.FC<{
const [signingKey, setSigningKey] = useState<SigningKeyMaterial | null>(null);
const [signingError, setSigningError] = useState<string | null>(null);
const [copied, setCopied] = useState(false);
- const [group, setGroup] = useState(requestSpec?.group ?? DEFAULT_GROUP);
- const [tags, setTags] = useState<string[]>(requestSpec?.tags ?? []);
+ // A spec's `tags` may already carry `skill:<name>` entries; split them so the UI edits
+ // plain tags and bare skills separately, then re-fold on submit (lib/vaultTags).
+ const specParts = useMemo(() => partitionTags(requestSpec?.tags), [requestSpec]);
+ const [tags, setTags] = useState<string[]>(() => specParts.tags);
+ const [skills, setSkills] = useState<string[]>(() => [
+ ...new Set([...specParts.skills, ...(requestSpec?.links?.skills ?? [])]),
+ ]);
const [description, setDescription] = useState(requestSpec?.description ?? '');
const [allowHosts, setAllowHosts] = useState<string[]>(requestSpec?.policy?.allowed_hosts ?? []);
- const [linkedSkills, setLinkedSkills] = useState<string[]>(requestSpec?.links?.skills ?? []);
const [fetchAuthMode, setFetchAuthMode] = useState<FetchAuthMode>(requestSpec?.policy?.auth?.type ?? 'bearer');
const [fetchAuthName, setFetchAuthName] = useState(requestSpec?.policy?.auth?.name ?? '');
- const [advancedOpen, setAdvancedOpen] = useState(Boolean(requestSpec?.description || requestSpec?.tags?.length || requestSpec?.policy));
+ const [advancedOpen, setAdvancedOpen] = useState(
+ Boolean(requestSpec?.description || requestSpec?.tags?.length || requestSpec?.links?.skills?.length || requestSpec?.policy),
+ );
const [tagsPending, setTagsPending] = useState(false);
const [hostsPending, setHostsPending] = useState(false);
const [skillsPending, setSkillsPending] = useState(false);
@@ -187,14 +190,15 @@ export const VaultSecretForm: React.FC<{
if (!requestSpec) return;
if (requestSpec.kind) setKind(requestSpec.kind);
if (requestSpec.protection) setProtection(requestSpec.protection);
- if (requestSpec.group) setGroup(requestSpec.group);
if (requestSpec.description) setDescription(requestSpec.description);
- if (requestSpec.tags) setTags(requestSpec.tags);
+ const parts = partitionTags(requestSpec.tags);
+ if (requestSpec.tags?.length) setTags(parts.tags);
+ const specSkills = [...new Set([...parts.skills, ...(requestSpec.links?.skills ?? [])])];
+ if (specSkills.length) setSkills(specSkills);
if (requestSpec.policy?.allowed_hosts) setAllowHosts(requestSpec.policy.allowed_hosts);
- if (requestSpec.links?.skills) setLinkedSkills(requestSpec.links.skills);
if (requestSpec.policy?.auth?.type) setFetchAuthMode(requestSpec.policy.auth.type);
if (requestSpec.policy?.auth?.name) setFetchAuthName(requestSpec.policy.auth.name);
- if (requestSpec.description || requestSpec.tags?.length || requestSpec.policy) setAdvancedOpen(true);
+ if (requestSpec.description || requestSpec.tags?.length || specSkills.length || requestSpec.policy) setAdvancedOpen(true);
}, [requestSpec]);
const p2Ready = useMemo(() => avaultP2Ready(avaultDep), [avaultDep]);
@@ -202,7 +206,6 @@ export const VaultSecretForm: React.FC<{
const protectedCreateReady = protectedVault.status === 'unlocked';
const isKeypair = kind === 'keypair';
const isProvision = Boolean(fixedName);
- const showLinkedSkills = isProvision && Boolean(requestSpec?.links?.skills?.length || linkedSkills.length);
const fileInputRef = useRef<HTMLInputElement | null>(null);
// Hold the latest key material in a ref too, so the unmount cleanup can zero
@@ -289,9 +292,8 @@ export const VaultSecretForm: React.FC<{
// the create-mode Advanced collapsible and are always visible in provision mode — guard
// whichever is on screen. Collapsing Advanced clears the pending flags, so a hidden draft can
// never block submit.
- const tagsVisible = isProvision || advancedOpen;
- const hostsVisible = isProvision || advancedOpen;
- if ((tagsVisible && tagsPending) || (hostsVisible && hostsPending) || (showLinkedSkills && skillsPending)) {
+ const advancedVisible = isProvision || advancedOpen;
+ if (advancedVisible && (tagsPending || hostsPending || skillsPending)) {
setError(t('vaults.dialog.errors.pendingDraft'));
return;
}
@@ -323,9 +325,10 @@ export const VaultSecretForm: React.FC<{
setSubmitting(true);
setError(null);
try {
- // NOTE: the "Always ask before each use" toggle (policy.always_ask) is intentionally
- // not wired here yet — the backend access flow does not honor it (standard-tier ignores
- // it; protected-tier rejects it). It returns once backend support lands (PR #722).
+ // `policy.always_ask` is intentionally not exposed in the product UI (design:
+ // vaults-grant-delivery-refactor.md §1 item 6, §11). It remains a backend policy
+ // capability, so any value already stored on a secret is preserved; the form never
+ // sets or clears it.
const policy: Record<string, unknown> = {};
if (allowHosts.length) policy.allowed_hosts = allowHosts;
if (fetchAuthMode === 'header') {
@@ -333,14 +336,19 @@ export const VaultSecretForm: React.FC<{
} else if (fetchAuthMode === 'query') {
policy.auth = { type: 'query', name: normalizedFetchAuthName };
}
+ // Skills are stored as reserved `skill:<name>` tags — fold them into one flat tag list.
+ const mergedTags = mergeTags(tags, skills);
const base = {
name: secretName,
protection,
- group: group.trim() || undefined,
description: description.trim() || undefined,
- tags: tags.length ? tags : undefined,
+ tags: mergedTags.length ? mergedTags : undefined,
+ // Bridge: send the bare skill names too. The pre-Track-B backend resolves skill scopes
+ // from vault_links (populated by payload.links.skills), so skill-scoped access can't
+ // find this secret from `skill:` tags alone until the refactor lands; `links.skills`
+ // is part of the final request spec as well (design §5), so this is safe on both.
+ links: skills.length ? { skills } : undefined,
policy: Object.keys(policy).length ? policy : undefined,
- links: linkedSkills.length ? { skills: linkedSkills } : undefined,
provision_request_id: provisionRequestId || undefined,
...(isKeypair && signingKey
? {
@@ -541,6 +549,40 @@ export const VaultSecretForm: React.FC<{
</div>
);
+ // Tags + skills — the only grouping/selector model (no groups). Skills are edited as bare
+ // names and stored as reserved `skill:<name>` tags; both feed grant tag/skill selectors.
+ const tagsField = (
+ <div className="flex flex-col gap-1.5">
+ <span className={FIELD_LABEL}>{t('vaults.dialog.tags')}</span>
+ <TagInput
+ values={tags}
+ onChange={setTags}
+ normalize={normalizeTagEntry}
+ placeholder={t('vaults.dialog.tagsPlaceholder')}
+ ariaLabel={t('vaults.dialog.tags')}
+ removeLabel={(value) => t('vaults.dialog.removeChip', { value })}
+ onPendingChange={setTagsPending}
+ />
+ <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.tagsHelp')}</span>
+ </div>
+ );
+
+ const skillsField = (
+ <div className="flex flex-col gap-1.5">
+ <span className={FIELD_LABEL}>{t('vaults.dialog.skills')}</span>
+ <TagInput
+ values={skills}
+ onChange={setSkills}
+ normalize={normalizeSkillEntry}
+ placeholder={t('vaults.dialog.skillsPlaceholder')}
+ ariaLabel={t('vaults.dialog.skills')}
+ removeLabel={(value) => t('vaults.dialog.removeChip', { value })}
+ onPendingChange={setSkillsPending}
+ />
+ <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.skillsHelp')}</span>
+ </div>
+ );
+
// Protection selector — two cards (Standard / Protected) matching design.pen `vyed5`.
const protectionCards = (
<div className="flex flex-col gap-1.5">
@@ -644,23 +686,6 @@ export const VaultSecretForm: React.FC<{
</div>
</div>
- <label className="flex flex-col gap-1.5">
- <span className={FIELD_LABEL}>{t('vaults.dialog.group')}</span>
- <Combobox
- options={[...new Set([DEFAULT_GROUP, ...groups])].map((g) => ({ value: g, label: g }))}
- value={group}
- onValueChange={setGroup}
- allowCustomValue
- commitOnClose
- withFolderIcon
- createLabel={(v) => t('vaults.dialog.groupCreate', { name: v })}
- createButtonLabel={t('vaults.dialog.groupCreateCta')}
- createHeading={t('vaults.dialog.groupCreateHeading')}
- placeholder={t('vaults.dialog.groupPlaceholder')}
- searchPlaceholder={t('vaults.dialog.groupSearch')}
- />
- </label>
-
<label className="flex flex-col gap-1.5">
<span className={FIELD_LABEL}>{t('vaults.dialog.description')}</span>
<Input
@@ -670,33 +695,8 @@ export const VaultSecretForm: React.FC<{
/>
</label>
- <div className="flex flex-col gap-1.5">
- <span className={FIELD_LABEL}>{t('vaults.dialog.tags')}</span>
- <TagInput
- values={tags}
- onChange={setTags}
- placeholder={t('vaults.dialog.tagsPlaceholder')}
- ariaLabel={t('vaults.dialog.tags')}
- removeLabel={(value) => t('vaults.dialog.removeChip', { value })}
- onPendingChange={setTagsPending}
- />
- <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.tagsHelp')}</span>
- </div>
-
- {showLinkedSkills && (
- <div className="flex flex-col gap-1.5">
- <span className={FIELD_LABEL}>{t('vaults.dialog.linkedSkills')}</span>
- <TagInput
- values={linkedSkills}
- onChange={setLinkedSkills}
- placeholder={t('vaults.dialog.linkedSkillsPlaceholder')}
- ariaLabel={t('vaults.dialog.linkedSkills')}
- removeLabel={(value) => t('vaults.dialog.removeChip', { value })}
- onPendingChange={setSkillsPending}
- />
- <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.linkedSkillsHelp')}</span>
- </div>
- )}
+ {tagsField}
+ {skillsField}
{/* Allowed hosts — a provisioned secret used for brokered HTTP fetch needs at least
one allowed host, else vibe/cli.py refuses the fetch as proxy_unbound. */}
@@ -884,35 +884,18 @@ export const VaultSecretForm: React.FC<{
{/* Protection */}
{protectionCards}
- {/* Group */}
- <label className="flex flex-col gap-1.5">
- <span className={FIELD_LABEL}>{t('vaults.dialog.group')}</span>
- <Combobox
- options={[...new Set([DEFAULT_GROUP, ...groups])].map((g) => ({ value: g, label: g }))}
- value={group}
- onValueChange={setGroup}
- allowCustomValue
- commitOnClose
- withFolderIcon
- createLabel={(v) => t('vaults.dialog.groupCreate', { name: v })}
- createButtonLabel={t('vaults.dialog.groupCreateCta')}
- createHeading={t('vaults.dialog.groupCreateHeading')}
- placeholder={t('vaults.dialog.groupPlaceholder')}
- searchPlaceholder={t('vaults.dialog.groupSearch')}
- />
- </label>
-
- {/* Advanced — collapsible: description, tags, allowed hosts, always-ask. */}
+ {/* Advanced — collapsible: description, tags, skills, allowed hosts. */}
<div className="flex flex-col overflow-hidden rounded-[10px] bg-surface-2">
<button
type="button"
onClick={() => {
setAdvancedOpen((open) => {
- // Collapsing hides the tag/host inputs — drop their pending-draft flags so a
+ // Collapsing hides the tag/skill/host inputs — drop their pending-draft flags so a
// draft the user can no longer see doesn't block submit.
if (open) {
setHostsPending(false);
setTagsPending(false);
+ setSkillsPending(false);
}
return !open;
});
@@ -922,9 +905,10 @@ export const VaultSecretForm: React.FC<{
>
<SlidersHorizontal className="size-3.5 text-muted" />
<span className="flex-1 text-xs font-semibold text-foreground">{t('vaults.dialog.advanced')}</span>
- {!advancedOpen && (description || tags.length > 0 || allowHosts.length > 0 || fetchAuthMode !== 'bearer') && (
- <span className="size-1.5 rounded-full bg-mint" aria-hidden />
- )}
+ {!advancedOpen &&
+ (description || tags.length > 0 || skills.length > 0 || allowHosts.length > 0 || fetchAuthMode !== 'bearer') && (
+ <span className="size-1.5 rounded-full bg-mint" aria-hidden />
+ )}
</button>
{advancedOpen && (
<div className="flex flex-col gap-3 px-3 pb-3">
@@ -938,19 +922,9 @@ export const VaultSecretForm: React.FC<{
/>
</label>
- {/* Tags (kept functional; absent from the vyed5 mock — folded here). */}
- <div className="flex flex-col gap-1.5">
- <span className={FIELD_LABEL}>{t('vaults.dialog.tags')}</span>
- <TagInput
- values={tags}
- onChange={setTags}
- placeholder={t('vaults.dialog.tagsPlaceholder')}
- ariaLabel={t('vaults.dialog.tags')}
- removeLabel={(value) => t('vaults.dialog.removeChip', { value })}
- onPendingChange={setTagsPending}
- />
- <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.tagsHelp')}</span>
- </div>
+ {/* Tags + skills (the only grouping/selector model; folded under Advanced). */}
+ {tagsField}
+ {skillsField}
{/* Allowed hosts (for proxy fetch). */}
<div className="flex flex-col gap-1.5">
diff --git a/ui/src/components/workbench/VaultsPage.tsx b/ui/src/components/workbench/VaultsPage.tsx
index 8e039ed28..43f437f87 100644
--- a/ui/src/components/workbench/VaultsPage.tsx
+++ b/ui/src/components/workbench/VaultsPage.tsx
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
-import { Check, Clock, Copy, Folder, Globe, History, Inbox, KeyRound, Layers, Link2, Loader2, Plus, Puzzle, RefreshCw, ShieldCheck, Trash2, Wallet, X } from 'lucide-react';
+import { Check, Clock, Copy, Globe, History, Inbox, KeyRound, Layers, Link2, Loader2, Plus, Puzzle, RefreshCw, ShieldCheck, Tag, Trash2, Wallet, X } from 'lucide-react';
+import type { TFunction } from 'i18next';
import { useTranslation } from 'react-i18next';
import { CapabilityTabs } from './CapabilityTabs';
import { WorkbenchPageHeader } from './WorkbenchPageHeader';
@@ -7,6 +8,7 @@ import { Badge } from '../ui/badge';
import { Button } from '../ui/button';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/dialog';
import { cn } from '../../lib/utils';
+import { partitionTags } from '../../lib/vaultTags';
import { useApi, type VaultAuditEvent, type VaultGrant, type VaultRequest, type VaultRequestSpec, type VaultSecret } from '../../context/ApiContext';
import { useToast } from '../../context/ToastContext';
import { VaultApprovalCard, type ApprovalOutcome } from '../ui/vault-approval-card';
@@ -15,9 +17,8 @@ import { VaultSecretForm } from '../ui/vault-secret-form';
const AddSecretDialog: React.FC<{
onClose: () => void;
onCreated: (name: string, reason?: 'created' | 'already_exists') => void;
- groups: string[];
request?: VaultRequest | null;
-}> = ({ onClose, onCreated, groups, request }) => {
+}> = ({ onClose, onCreated, request }) => {
const { t } = useTranslation();
const requestCard = (request?.card ?? null) as { default_protection?: unknown; spec?: VaultRequestSpec } | null;
const requestSpec = (requestCard?.spec ?? null) as VaultRequestSpec | null;
@@ -45,7 +46,6 @@ const AddSecretDialog: React.FC<{
defaultProtection={defaultProtection}
onCancel={onClose}
onCreated={onCreated}
- groups={groups}
treatExistingAsFulfilled={Boolean(request)}
/>
</DialogContent>
@@ -53,22 +53,20 @@ const AddSecretDialog: React.FC<{
);
};
-type ViewMode = 'all' | 'group';
-
/** All allowed proxy-fetch hosts on a secret (for the `proxy · <host> +N` badge). */
const proxyHosts = (s: VaultSecret): string[] => {
const hosts = (s.policy as { allowed_hosts?: string[] })?.allowed_hosts;
return Array.isArray(hosts) ? hosts : [];
};
-const isAlwaysAsk = (s: VaultSecret): boolean => Boolean((s.policy as { always_ask?: boolean })?.always_ask);
-
const SecretRow: React.FC<{ secret: VaultSecret; onDelete: (name: string) => void }> = ({ secret: s, onDelete }) => {
const { t } = useTranslation();
const isKeypair = s.kind === 'keypair';
const isProtected = s.protection === 'protected';
const [copied, setCopied] = useState(false);
const publicKey = s.signing_public_key?.public_key;
+ // Skills are stored as reserved `skill:<name>` tags; render them as their own chips.
+ const { tags, skills } = useMemo(() => partitionTags(s.tags), [s.tags]);
return (
<div className="flex items-center gap-3.5 rounded-xl border border-border bg-surface px-4 py-3">
<div
@@ -92,14 +90,19 @@ const SecretRow: React.FC<{ secret: VaultSecret; onDelete: (name: string) => voi
{t('vaults.signing')}
</Badge>
) : null}
- {isAlwaysAsk(s) ? <Badge variant="destructive">{t('vaults.alwaysAsk')}</Badge> : null}
{proxyHosts(s).length > 0 ? (
<Badge variant="info">
{t('vaults.proxyHost', { host: proxyHosts(s)[0] })}
{proxyHosts(s).length > 1 ? ` +${proxyHosts(s).length - 1}` : ''}
</Badge>
) : null}
- {s.tags?.map((tag) => (
+ {skills.map((skill) => (
+ <Badge key={`skill:${skill}`} variant="outline" className="gap-1 border-violet/40 bg-violet-soft text-violet">
+ <Puzzle className="size-3" />
+ {skill}
+ </Badge>
+ ))}
+ {tags.map((tag) => (
<Badge key={tag} variant="outline" className="text-muted">
{tag}
</Badge>
@@ -136,12 +139,6 @@ 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);
@@ -162,9 +159,42 @@ function chipCountdown(rem: { h: number; m: number; s: number }): string {
}
/**
- * Active-grant chip (design.pen `y4rw5Q` ACTIVE GRANTS row): a compact mint pill with the
- * scope icon, `type · ref`, a live countdown, and an inline × to revoke. Replaces the older
- * full-width grant card so the strip reads as a quick "what's live right now" glance.
+ * Icon + labels for an active grant. Builds from EVERY populated `source_selector` bucket
+ * (skills, tags, explicit env), so a mixed grant (e.g. same skill but a different `--tag`
+ * or `--env`) stays distinguishable and revoke targets the right access. Returns a compact
+ * `label` (truncated for the chip) and a `full` form (every token) for the tooltip and the
+ * revoke confirmation. For a legacy pre-refactor grant (no source_selector) it falls back to
+ * the scope ref / member names until the grant-id backend lands.
+ */
+function describeGrant(g: VaultGrant, t: TFunction): { Icon: typeof KeyRound; label: string; full: string } {
+ const compact = (tokens: string[]): string =>
+ tokens.length > 2 ? t('vaults.grants.moreLabel', { names: tokens.slice(0, 2).join(', '), extra: tokens.length - 2 }) : tokens.join(', ');
+
+ const selector = g.source_selector ?? {};
+ const { tags, skills } = partitionTags(selector.tags);
+ const env = selector.env ?? [];
+ const tokens = [...skills, ...tags, ...env];
+ if (tokens.length) {
+ // Icon reflects the primary bucket, but the label spans all of them.
+ const Icon = skills.length ? Puzzle : tags.length ? Tag : KeyRound;
+ return { Icon, label: compact(tokens), full: tokens.join(', ') };
+ }
+ // Legacy grant: no source_selector. Use the concrete scope ref / member names.
+ if (g.scope_ref) {
+ const Icon = g.scope_type === 'skill' ? Puzzle : g.scope_type === 'group' ? Layers : KeyRound;
+ return { Icon, label: g.scope_ref, full: g.scope_ref };
+ }
+ const names = g.member_snapshot ?? [];
+ if (names.length) return { Icon: KeyRound, label: compact(names), full: names.join(', ') };
+ const count = t('vaults.grants.secretCount', { count: g.member_count || 0 });
+ return { Icon: KeyRound, label: count, full: count };
+}
+
+/**
+ * Active-grant chip (design.pen `y4rw5Q` ACTIVE GRANTS row): a compact mint pill describing
+ * how the protected set was selected (explicit secrets, a tag, or a skill), a live countdown,
+ * and an inline × to revoke. A grant is a fixed protected set keyed by grant_id — the chip
+ * summarizes its `source_selector` (or the legacy scope during the bridge), never a group.
*/
const GrantChip: React.FC<{ grant: VaultGrant; now: number; onRevoke: (grant: VaultGrant) => void }> = ({
grant: g,
@@ -172,14 +202,20 @@ const GrantChip: React.FC<{ grant: VaultGrant; now: number; onRevoke: (grant: Va
onRevoke,
}) => {
const { t } = useTranslation();
- const Icon = SCOPE_ICON[g.scope_type] ?? KeyRound;
const rem = remaining(g.expires_at, now);
+ const { Icon, label, full } = useMemo(() => describeGrant(g, t), [g, t]);
+ // Tooltip carries the full selector plus the covered secret names, so a truncated label
+ // never hides which grant this is.
+ const tip = [full, g.member_snapshot?.length ? g.member_snapshot.join(', ') : '']
+ .filter(Boolean)
+ .join(' · ');
return (
- <span className="inline-flex items-center gap-2 rounded-full border border-mint/40 bg-mint-soft py-1 pl-2.5 pr-1.5 text-xs text-mint">
+ <span
+ className="inline-flex items-center gap-2 rounded-full border border-mint/40 bg-mint-soft py-1 pl-2.5 pr-1.5 text-xs text-mint"
+ title={tip || undefined}
+ >
<Icon className="size-3.5 shrink-0" />
- <span className="font-medium">
- {t(`vaults.grants.scope.${g.scope_type}`)} · {g.scope_ref}
- </span>
+ <span className="font-medium">{label}</span>
<span
className="flex shrink-0"
title={g.session_id ? t('vaults.grants.session.bound') : t('vaults.grants.session.any')}
@@ -249,7 +285,7 @@ const RequestRow: React.FC<{ request: VaultRequest; onReview: (request: VaultReq
* Best-effort — a requests fetch failure (e.g. an older backend without the route) must
* not surface an error or blank the rest of the hub.
*/
-const PendingRequestsSection: React.FC<{ groups: string[]; onResolved: () => void }> = ({ groups, onResolved }) => {
+const PendingRequestsSection: React.FC<{ onResolved: () => void }> = ({ onResolved }) => {
const { t } = useTranslation();
const api = useApi();
const { showToast } = useToast();
@@ -340,7 +376,6 @@ const PendingRequestsSection: React.FC<{ groups: string[]; onResolved: () => voi
{provisioning != null ? (
<AddSecretDialog
request={provisioning}
- groups={groups}
onClose={() => setProvisioning(null)}
onCreated={(name, reason) => {
setProvisioning(null);
@@ -357,6 +392,21 @@ const PendingRequestsSection: React.FC<{ groups: string[]; onResolved: () => voi
);
};
+/** A toggleable tag/skill filter pill. */
+const FilterChip: React.FC<{ active: boolean; onClick: () => void; children: React.ReactNode }> = ({ active, onClick, children }) => (
+ <button
+ type="button"
+ aria-pressed={active}
+ onClick={onClick}
+ className={cn(
+ 'inline-flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs transition-colors',
+ active ? 'border-accent bg-accent/10 text-accent' : 'border-border bg-surface text-muted hover:bg-surface-2',
+ )}
+ >
+ {children}
+ </button>
+);
+
export const VaultsPage: React.FC = () => {
const { t } = useTranslation();
const api = useApi();
@@ -368,7 +418,8 @@ export const VaultsPage: React.FC = () => {
const [adding, setAdding] = useState(false);
const [showAudit, setShowAudit] = useState(false);
const [audit, setAudit] = useState<VaultAuditEvent[]>([]);
- const [view, setView] = useState<ViewMode>('all');
+ const [activeTags, setActiveTags] = useState<string[]>([]);
+ const [activeSkills, setActiveSkills] = useState<string[]>([]);
const [now, setNow] = useState(() => Date.now());
const refresh = useCallback(async () => {
@@ -416,15 +467,32 @@ export const VaultsPage: React.FC = () => {
return () => clearInterval(id);
}, [hasGrants]);
- const groups = useMemo(() => {
- const byGroup = new Map<string, VaultSecret[]>();
+ // Every distinct tag and skill across the inventory, for the filter bar.
+ const { allTags, allSkills } = useMemo(() => {
+ const tagSet = new Set<string>();
+ const skillSet = new Set<string>();
for (const s of secrets) {
- const key = s.group || 'default';
- (byGroup.get(key) ?? byGroup.set(key, []).get(key)!).push(s);
+ const parts = partitionTags(s.tags);
+ parts.tags.forEach((tag) => tagSet.add(tag));
+ parts.skills.forEach((skill) => skillSet.add(skill));
}
- return [...byGroup.entries()].sort((a, b) => a[0].localeCompare(b[0]));
+ return { allTags: [...tagSet].sort(), allSkills: [...skillSet].sort() };
}, [secrets]);
+ // A secret is visible when it carries every active tag and skill filter (intersection).
+ const visibleSecrets = useMemo(() => {
+ if (activeTags.length === 0 && activeSkills.length === 0) return secrets;
+ return secrets.filter((s) => {
+ const parts = partitionTags(s.tags);
+ return activeTags.every((tag) => parts.tags.includes(tag)) && activeSkills.every((skill) => parts.skills.includes(skill));
+ });
+ }, [secrets, activeTags, activeSkills]);
+
+ const toggleFilter = (list: string[], setList: (next: string[]) => void, value: string) =>
+ setList(list.includes(value) ? list.filter((v) => v !== value) : [...list, value]);
+
+ const hasActiveFilter = activeTags.length > 0 || activeSkills.length > 0;
+
const toggleAudit = useCallback(async () => {
const next = !showAudit;
setShowAudit(next);
@@ -450,10 +518,13 @@ export const VaultsPage: React.FC = () => {
};
const onRevokeGrant = async (g: VaultGrant) => {
- if (!window.confirm(t('vaults.grants.revokeConfirm', { scope: g.scope_ref }))) return;
+ // Name the grant by its FULL selector in the confirm/toast so two grants that share a
+ // bucket (e.g. the same skill but a different tag/env) aren't confused.
+ const { label, full } = describeGrant(g, t);
+ if (!window.confirm(t('vaults.grants.revokeConfirm', { target: full }))) return;
try {
await api.revokeVaultGrant(g.id);
- showToast(t('vaults.grants.revoked', { scope: g.scope_ref }), 'success');
+ showToast(t('vaults.grants.revoked', { target: label }), 'success');
refresh();
} catch (err: any) {
setError(err?.message ?? String(err));
@@ -485,7 +556,7 @@ 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>
)}
- <PendingRequestsSection groups={groups.map(([g]) => g)} onResolved={refresh} />
+ <PendingRequestsSection onResolved={refresh} />
{grants.length > 0 && (
<div className="flex flex-col gap-2">
<div className="flex items-center gap-2 px-1">
@@ -501,14 +572,36 @@ export const VaultsPage: React.FC = () => {
</div>
</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')}>
- {t('vaults.view.all')}
- </Button>
- <Button variant={view === 'group' ? 'secondary' : 'ghost'} size="sm" onClick={() => setView('group')}>
- {t('vaults.view.byGroup')}
- </Button>
+ {allTags.length > 0 || allSkills.length > 0 || hasActiveFilter ? (
+ <div className="flex flex-wrap items-center gap-2">
+ {allSkills.map((skill) => (
+ <FilterChip
+ key={`skill:${skill}`}
+ active={activeSkills.includes(skill)}
+ onClick={() => toggleFilter(activeSkills, setActiveSkills, skill)}
+ >
+ <Puzzle className="size-3" />
+ {skill}
+ </FilterChip>
+ ))}
+ {allTags.map((tag) => (
+ <FilterChip key={tag} active={activeTags.includes(tag)} onClick={() => toggleFilter(activeTags, setActiveTags, tag)}>
+ <Tag className="size-3" />
+ {tag}
+ </FilterChip>
+ ))}
+ {hasActiveFilter ? (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => {
+ setActiveTags([]);
+ setActiveSkills([]);
+ }}
+ >
+ {t('vaults.filter.clear')}
+ </Button>
+ ) : null}
</div>
) : null}
{loading && secrets.length === 0 ? (
@@ -518,29 +611,11 @@ export const VaultsPage: React.FC = () => {
</div>
) : secrets.length === 0 ? (
<div className="rounded-2xl border border-border bg-surface p-8 text-center text-sm text-muted">{t('vaults.empty')}</div>
- ) : view === 'group' ? (
- <div className="flex flex-col gap-4">
- {groups.map(([group, items]) => {
- const allKeys = items.every((s) => s.kind === 'keypair');
- return (
- <div key={group} className="flex flex-col gap-2">
- <div className="flex items-center gap-2 px-1 text-xs font-semibold text-foreground">
- <Folder className="size-3.5 text-muted" />
- <span>{group}</span>
- <span className="font-normal text-muted">
- {allKeys ? t('vaults.keyCount', { count: items.length }) : t('vaults.secretCount', { count: items.length })}
- </span>
- </div>
- {items.map((s) => (
- <SecretRow key={s.name} secret={s} onDelete={onDelete} />
- ))}
- </div>
- );
- })}
- </div>
+ ) : visibleSecrets.length === 0 ? (
+ <div className="rounded-2xl border border-border bg-surface p-8 text-center text-sm text-muted">{t('vaults.filter.empty')}</div>
) : (
<div className="flex flex-col gap-2">
- {secrets.map((s) => (
+ {visibleSecrets.map((s) => (
<SecretRow key={s.name} secret={s} onDelete={onDelete} />
))}
</div>
@@ -565,7 +640,6 @@ export const VaultsPage: React.FC = () => {
)}
{adding && (
<AddSecretDialog
- groups={groups.map(([g]) => g)}
onClose={() => setAdding(false)}
onCreated={(name, reason) => {
if (reason === 'already_exists') return;
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 951cf38fc..80a4f6b6e 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -18,7 +18,7 @@ export type GlobalPromptFile = {
export type VaultSecret = {
name: string;
- group: string;
+ /** Flat tag list; skill association is a reserved `skill:<name>` tag (see lib/vaultTags). */
tags: string[];
kind: string;
protection: string;
@@ -61,8 +61,8 @@ export type VaultRequest = {
export type VaultRequestSpec = {
kind?: 'static';
protection?: 'standard' | 'protected';
- group?: string;
description?: string;
+ /** May already include `skill:<name>` tags; `links.skills` is a bare-name convenience mirror. */
tags?: string[];
policy?: {
allowed_hosts?: string[];
@@ -71,19 +71,38 @@ export type VaultRequestSpec = {
links?: { skills?: string[] };
};
+/**
+ * How a grant's protected set was selected. Env selectors are explicit secret/env
+ * names (`OPENAI_API_KEY`, `DB_URL=PROD_DB_URL`); tag selectors group by tag, with
+ * skill selectors carried as `skill:<name>` tags.
+ */
+export type VaultSourceSelector = { env?: string[]; tags?: string[] };
+
+/**
+ * A grant is a first-class, time-limited authorization for avault to use a fixed set
+ * of protected secrets (design: docs/plans/vaults-grant-delivery-refactor.md §6). It
+ * is keyed by `id` (the grant_id); `member_snapshot` is the frozen protected set and
+ * `source_selector` records how it was chosen. Tag edits never mutate an active grant.
+ */
export type VaultGrant = {
id: string;
- scope_type: 'secret' | 'skill' | 'group';
- scope_ref: string;
+ source_selector: VaultSourceSelector;
session_id: string | null;
+ purpose: string;
status: string;
- created_by_request_id: string | null;
+ request_id: string | null;
created_at: string;
expires_at: string;
revoked_at: string | null;
member_snapshot: string[];
member_count: number;
runtime_member_count: number;
+ one_shot?: boolean;
+ /** Legacy pre-refactor bridge only: the current backend still returns scope_type/scope_ref
+ * (no source_selector). Read to keep grant chips distinguishable until Track B lands; not
+ * part of the final product shape and never written by the UI. */
+ scope_type?: string;
+ scope_ref?: string;
};
type VaultBlindBox = {
@@ -96,18 +115,19 @@ type VaultBlindBox = {
* Browser-relayed protected access fulfillment. The browser releases each protected
* DEK as an opaque HPKE blind box addressed to the resident avault agent and submits
* ONLY `{name, dek_blindbox, approval}` per secret — never a raw DEK or plaintext.
- * Mirrors the backend contract in PR #711 so the two additions dedupe cleanly on merge.
+ *
+ * `scope_type`/`scope_ref` are NOT a product concept: they are the opaque binding the
+ * DEK blind box is sealed against (blindBoxAgentDeliverOperationHash), relayed verbatim
+ * pending the avault-side grant_id migration (Track A). The UI never shows them.
*/
export type VaultAccessFulfillmentPayload = {
- scope_type?: 'secret' | 'skill' | 'group';
+ scope_type?: string;
scope_ref?: string;
session_id?: string | null;
ttl_seconds?: number;
this_session_only?: boolean;
agent_pubkey?: { public_key?: string; fingerprint?: string };
deks?: Array<{ name: string; dek_blindbox: VaultBlindBox; approval: Record<string, unknown> }>;
- agent_deks?: Array<{ name: string; dek_blindbox: VaultBlindBox; approval: Record<string, unknown> }>;
- deks_by_secret?: Record<string, { dek_blindbox: VaultBlindBox; approval: Record<string, unknown> } | VaultBlindBox>;
};
type VaultSealedEnvelope = {
@@ -128,13 +148,16 @@ export type VaultCreatePayload = {
blind_box?: VaultBlindBox;
sealed?: VaultSealedEnvelope;
envelope?: VaultSealedEnvelope;
- group?: string;
description?: string;
+ /** Flat tag list; skill association is folded in as `skill:<name>` tags (see lib/vaultTags). */
tags?: string[];
kind?: string;
signer_kind?: string | null;
policy?: Record<string, unknown>;
public_meta?: Record<string, unknown>;
+ /** Bare skill names. Sent alongside the folded `skill:<name>` tags so skill scopes work on
+ * the pre-refactor backend (which populates vault_links from links.skills); `links.skills`
+ * is also part of the final request spec (design §5). */
links?: { skills?: string[] };
provision_request_id?: string;
/** Set on the first protected secret so the daemon atomically guards single VMK init. */
@@ -345,7 +368,7 @@ export type ApiContextType = {
updateVibeAgent: (name: string, payload: VibeAgentUpdatePayload) => Promise<{ ok: boolean; agent: VibeAgentFull }>;
setDefaultVibeAgent: (name: string) => Promise<{ ok: boolean; default_agent_name: string; agent: VibeAgentBrief }>;
removeVibeAgent: (name: string) => Promise<{ ok: boolean; code?: string; message?: string; references?: Record<string, number>; removed_agent?: string }>;
- listVaultSecrets: (params?: { group?: string }) => Promise<{ ok: boolean; secrets: VaultSecret[] }>;
+ listVaultSecrets: () => Promise<{ ok: boolean; secrets: VaultSecret[] }>;
getVaultVmk: () => Promise<VaultVmkResult>;
getVaultPubkey: () => Promise<{ ok: boolean; public_key: string; fingerprint: string }>;
getVaultAgentPubkey: () => Promise<{ ok: boolean; public_key: string; fingerprint: string }>;
@@ -2059,12 +2082,7 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
setDefaultVibeAgent: (name) => postJson('/api/agents/default', { name }),
removeVibeAgent: (name) => deleteJson(`/api/agents/${encodeURIComponent(name)}`),
getVaultVmk: () => getCachedJson('/api/vault/vmk', 1500, { handleError: false }),
- listVaultSecrets: (params) => {
- const search = new URLSearchParams();
- if (params?.group) search.set('group', params.group);
- const qs = search.toString();
- return getCachedJson(qs ? `/api/vault/secrets?${qs}` : '/api/vault/secrets', 1500);
- },
+ listVaultSecrets: () => getCachedJson('/api/vault/secrets', 1500),
getVaultPubkey: () => getCachedJson('/api/vault/pubkey', 1500),
getVaultAgentPubkey: () => getCachedJson('/api/vault/agent/pubkey', 1500),
createVaultSecret: (payload, opts) => postJson('/api/vault/secrets', payload, opts),
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 8824c6d80..3fe050199 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -2185,40 +2185,28 @@
"protected": "Protected",
"proxyBound": "Proxy-bound",
"proxyHost": "proxy · {{host}}",
- "alwaysAsk": "always-ask",
"used": "used {{count}}×",
"neverUsed": "never used",
"standard": "Standard",
"signing": "Signing",
- "secretCount": "{{count}} secrets",
- "keyCount": "{{count}} keys",
+ "filter": {
+ "clear": "Clear filters",
+ "empty": "No secrets match the selected tags."
+ },
"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"
- },
+ "revokeConfirm": "Revoke access to \"{{target}}\" now? Agents lose it immediately.",
+ "revoked": "Revoked access to {{target}}",
+ "secretCount": "{{count}} secrets",
+ "moreLabel": "{{names}} +{{extra}}",
"session": {
"bound": "Session-bound",
"any": "Any session"
}
},
- "view": {
- "all": "All",
- "byGroup": "By group"
- },
"delete": "Delete",
"deleteConfirm": "Delete secret \"{{name}}\"? Agents will no longer be able to use it.",
"deleted": "Deleted {{name}}",
@@ -2309,13 +2297,6 @@
"checkingAvault": "Checking avault…",
"p2Unavailable": "Browser-side vault create requires avault {{version}} or newer. Installed: {{installed}}. Install a compatible avault release before saving standard secrets.",
"browserSealingPending": "Browser-side sealing requires a compatible avault release. This UI never sends plaintext values to Python.",
- "group": "Group",
- "groupPlaceholder": "Pick or create a group",
- "groupSearch": "Search or type a new group",
- "groupCreate": "{{name}}",
- "groupCreateCta": "Create",
- "groupCreateHeading": "New group",
- "groupHint": "Group · pick one or create a new one inline",
"advanced": "Advanced",
"description": "Description",
"descriptionPlaceholder": "Optional note about this secret",
@@ -2328,14 +2309,12 @@
"fetchAuthQuery": "Query",
"fetchAuthNamePlaceholder": "X-Api-Key or api_key",
"fetchAuthHelp": "Defaults to Authorization: Bearer <value>. Use Header or Query for APIs that expect another credential placement.",
- "alwaysAsk": "Always ask before each use",
- "alwaysAskHelp": "Never granted in advance, even per-key",
"tags": "Tags",
"tagsPlaceholder": "tag, then Enter",
- "tagsHelp": "Optional labels to find and group secrets.",
- "linkedSkills": "Linked skills",
- "linkedSkillsPlaceholder": "skill name, then Enter",
- "linkedSkillsHelp": "Suggested by the requesting agent. Remove any skill that should not receive this secret through skill-scope grants.",
+ "tagsHelp": "Labels to find secrets and to select them by tag in runs and grants. Add skills in the Skills field.",
+ "skills": "Skills",
+ "skillsPlaceholder": "skill name, then Enter",
+ "skillsHelp": "Stored as skill:<name> tags. A run or grant that selects the skill includes this secret.",
"removeChip": "Remove {{value}}",
"protection": "Protection",
"protectedProtection": "Protected",
@@ -2387,13 +2366,12 @@
"command": "Command",
"egress": "Egress",
"digest": "Digest",
- "scopeTitle": "Approval scope",
- "scopeMembers": "Covers {{count}} secrets",
- "scope": {
- "secret": "This secret only",
- "skill": "Skill · {{ref}}",
- "group": "Group · {{ref}}"
- },
+ "source": "Source",
+ "sourceTag": "Tag · {{name}}",
+ "sourceSkill": "Skill · {{name}}",
+ "protectedSecrets": "Protected",
+ "duration": "Duration",
+ "durationValue": "Access lasts {{time}}",
"thisSessionOnly": "This session only",
"approve": "Approve",
"sign": "Sign",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index cbcabfd43..076d9e532 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -2184,40 +2184,28 @@
"protected": "加密档",
"proxyBound": "已绑定代理",
"proxyHost": "代理 · {{host}}",
- "alwaysAsk": "每次询问",
"used": "已使用 {{count}} 次",
"neverUsed": "从未使用",
"standard": "标准档",
"signing": "签名",
- "secretCount": "{{count}} 个密钥",
- "keyCount": "{{count}} 把密钥",
+ "filter": {
+ "clear": "清除筛选",
+ "empty": "没有匹配所选标签的密钥。"
+ },
"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}} 秒"
- },
+ "revokeConfirm": "立即吊销对「{{target}}」的访问?Agent 将即刻失去访问权。",
+ "revoked": "已吊销对「{{target}}」的访问",
+ "secretCount": "{{count}} 个密钥",
+ "moreLabel": "{{names}} +{{extra}}",
"session": {
"bound": "限单会话",
"any": "全部会话"
}
},
- "view": {
- "all": "全部",
- "byGroup": "按分组"
- },
"delete": "删除",
"deleteConfirm": "删除密钥「{{name}}」?Agent 将无法再使用它。",
"deleted": "已删除 {{name}}",
@@ -2308,13 +2296,6 @@
"checkingAvault": "正在检查 avault…",
"p2Unavailable": "浏览器侧保险库创建需要 avault {{version}} 或更新版本。当前安装:{{installed}}。请先安装兼容的 avault 发布版,再保存标准密钥。",
"browserSealingPending": "浏览器侧封箱需要兼容的 avault 发布版。这个 UI 永远不会把明文值发送给 Python。",
- "group": "分组",
- "groupPlaceholder": "选择或新建分组",
- "groupSearch": "搜索或输入新分组",
- "groupCreate": "{{name}}",
- "groupCreateCta": "新建",
- "groupCreateHeading": "新建分组",
- "groupHint": "分组 · 选一个,或就地新建一个",
"advanced": "高级",
"description": "描述",
"descriptionPlaceholder": "关于这条密钥的可选备注",
@@ -2327,14 +2308,12 @@
"fetchAuthQuery": "Query",
"fetchAuthNamePlaceholder": "X-Api-Key 或 api_key",
"fetchAuthHelp": "默认使用 Authorization: Bearer <value>。如果目标 API 要求其他位置,可改用 Header 或 Query。",
- "alwaysAsk": "每次使用都询问",
- "alwaysAskHelp": "绝不预先授权,连按密钥也不行",
"tags": "标签",
"tagsPlaceholder": "输入标签后回车",
- "tagsHelp": "可选,用来查找和归类密钥。",
- "linkedSkills": "关联技能",
- "linkedSkillsPlaceholder": "输入技能名称后回车",
- "linkedSkillsHelp": "由请求的 Agent 建议。若某个技能不应通过技能级授权拿到这条密钥,请先移除。",
+ "tagsHelp": "用于查找密钥,也可在运行和授权中按标签选择密钥。技能请在“技能”栏添加。",
+ "skills": "技能",
+ "skillsPlaceholder": "输入技能名称后回车",
+ "skillsHelp": "以 skill:<名称> 标签存储。按该技能选择的运行或授权会包含这条密钥。",
"removeChip": "移除 {{value}}",
"protection": "保护级别",
"protectedProtection": "受保护",
@@ -2386,13 +2365,12 @@
"command": "命令",
"egress": "出网",
"digest": "摘要",
- "scopeTitle": "授权范围",
- "scopeMembers": "覆盖 {{count}} 个密钥",
- "scope": {
- "secret": "仅此密钥",
- "skill": "技能 · {{ref}}",
- "group": "分组 · {{ref}}"
- },
+ "source": "来源",
+ "sourceTag": "标签 · {{name}}",
+ "sourceSkill": "技能 · {{name}}",
+ "protectedSecrets": "加密档",
+ "duration": "时长",
+ "durationValue": "访问持续 {{time}}",
"thisSessionOnly": "仅限本会话",
"approve": "批准",
"sign": "签名",
diff --git a/ui/src/lib/vaultTags.test.ts b/ui/src/lib/vaultTags.test.ts
new file mode 100644
index 000000000..c81a67301
--- /dev/null
+++ b/ui/src/lib/vaultTags.test.ts
@@ -0,0 +1,80 @@
+import { describe, expect, it } from 'vitest';
+
+import {
+ SKILL_TAG_PREFIX,
+ isSkillTag,
+ mergeTags,
+ normalizeSkillEntry,
+ normalizeTagEntry,
+ partitionTags,
+ skillName,
+ toSkillTag,
+} from './vaultTags';
+
+describe('skill tag helpers', () => {
+ it('detects and strips the reserved prefix', () => {
+ expect(SKILL_TAG_PREFIX).toBe('skill:');
+ expect(isSkillTag('skill:github-release')).toBe(true);
+ expect(isSkillTag('deploy')).toBe(false);
+ expect(skillName('skill:deploy-aws')).toBe('deploy-aws');
+ expect(skillName('prod')).toBe('prod');
+ });
+
+ it('wraps a bare skill name once', () => {
+ expect(toSkillTag('github-release')).toBe('skill:github-release');
+ expect(toSkillTag('skill:github-release')).toBe('skill:github-release');
+ expect(toSkillTag(' deploy ')).toBe('skill:deploy');
+ expect(toSkillTag('')).toBe('');
+ });
+});
+
+describe('tag entry normalization', () => {
+ it('trims and rejects empty or whitespace-bearing tags', () => {
+ expect(normalizeTagEntry(' prod ')).toBe('prod');
+ expect(normalizeTagEntry('')).toBeNull();
+ expect(normalizeTagEntry('two words')).toBeNull();
+ });
+
+ it('rejects reserved skill: tags in the tag field (skills belong in the skills input)', () => {
+ expect(normalizeTagEntry('skill:deploy')).toBeNull();
+ // The skills input strips the prefix first, so it still accepts the same entry.
+ expect(normalizeSkillEntry('skill:deploy')).toBe('deploy');
+ });
+
+ it('normalizes skill entries to a bare, prefix-free name', () => {
+ expect(normalizeSkillEntry('github-release')).toBe('github-release');
+ // A pasted `skill:` entry is accepted but not double-prefixed.
+ expect(normalizeSkillEntry('skill:deploy')).toBe('deploy');
+ expect(normalizeSkillEntry('bad name')).toBeNull();
+ });
+});
+
+describe('partitionTags', () => {
+ it('splits a flat tag list into normal tags and bare skills', () => {
+ const { tags, skills } = partitionTags(['prod', 'skill:github-release', 'deploy', 'skill:deploy-aws']);
+ expect(tags).toEqual(['prod', 'deploy']);
+ expect(skills).toEqual(['github-release', 'deploy-aws']);
+ });
+
+ it('is resilient to nullish, blank, and non-string entries', () => {
+ expect(partitionTags(null)).toEqual({ tags: [], skills: [] });
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ expect(partitionTags([' ', 'prod', 123 as any, 'prod'])).toEqual({ tags: ['prod'], skills: [] });
+ });
+});
+
+describe('mergeTags', () => {
+ it('re-prefixes skills and dedupes the merged list', () => {
+ expect(mergeTags(['prod', 'deploy'], ['github-release'])).toEqual(['prod', 'deploy', 'skill:github-release']);
+ });
+
+ it('round-trips with partitionTags', () => {
+ const flat = ['prod', 'skill:github-release', 'deploy'];
+ const { tags, skills } = partitionTags(flat);
+ expect(mergeTags(tags, skills)).toEqual(['prod', 'deploy', 'skill:github-release']);
+ });
+
+ it('drops blanks and collapses duplicates across both inputs', () => {
+ expect(mergeTags(['prod', ' prod ', ''], ['deploy', 'skill:deploy'])).toEqual(['prod', 'skill:deploy']);
+ });
+});
diff --git a/ui/src/lib/vaultTags.ts b/ui/src/lib/vaultTags.ts
new file mode 100644
index 000000000..d546a033a
--- /dev/null
+++ b/ui/src/lib/vaultTags.ts
@@ -0,0 +1,83 @@
+/**
+ * Tag helpers for the Vaults UI.
+ *
+ * Vaults keep one global secret namespace plus tags — there are no groups. Skill
+ * association is a reserved tag (`skill:<name>`), so a secret's flat `tags` array
+ * can mix normal tags (`prod`, `deploy`) with skill tags (`skill:github-release`).
+ * The UI renders skills in their own section but stores and selects on tags only,
+ * matching the backend (`storage/vault_service.py` `skill_tag` / `SKILL_TAG_PREFIX`).
+ */
+
+export const SKILL_TAG_PREFIX = 'skill:';
+
+/** True for a reserved skill tag (`skill:<name>`). */
+export function isSkillTag(tag: string): boolean {
+ return tag.startsWith(SKILL_TAG_PREFIX);
+}
+
+/** Strip the `skill:` prefix to the bare skill name; a normal tag is returned as-is. */
+export function skillName(tag: string): string {
+ return isSkillTag(tag) ? tag.slice(SKILL_TAG_PREFIX.length) : tag;
+}
+
+/** Wrap a bare skill name into its reserved tag form; already-prefixed input is left alone. */
+export function toSkillTag(name: string): string {
+ const trimmed = name.trim();
+ if (!trimmed) return '';
+ return isSkillTag(trimmed) ? trimmed : `${SKILL_TAG_PREFIX}${trimmed}`;
+}
+
+/**
+ * Normalize a tag entry the way the backend does (`_normalize_tag`): trimmed,
+ * non-empty, no interior whitespace. Also rejects the reserved `skill:` prefix — skills
+ * belong in the dedicated skills input, which owns the prefix and the `links.skills` bridge.
+ * Accepting `skill:` here would store a skill tag with no matching skill link (rendered/
+ * filtered as a skill but invisible to skill-scoped access on the pre-refactor backend).
+ * Returns `null` to reject — the shape the {@link TagInput} `normalize` prop expects.
+ */
+export function normalizeTagEntry(raw: string): string | null {
+ const tag = raw.trim();
+ if (!tag) return null;
+ if (/\s/.test(tag)) return null;
+ if (isSkillTag(tag)) return null;
+ return tag;
+}
+
+/**
+ * Normalize a skill entry: a bare skill name with no whitespace and without the
+ * reserved prefix (the prefix is added on submit). Rejects a raw `skill:` entry so
+ * the two inputs don't double-prefix.
+ */
+export function normalizeSkillEntry(raw: string): string | null {
+ const name = skillName(raw.trim());
+ return normalizeTagEntry(name);
+}
+
+const dedupe = (values: string[]): string[] => [...new Set(values)];
+
+/**
+ * Split a secret's flat tag list into display buckets: normal `tags` and bare
+ * `skills` (prefix stripped). Order is preserved; duplicates collapse.
+ */
+export function partitionTags(tags: readonly string[] | null | undefined): { tags: string[]; skills: string[] } {
+ const plain: string[] = [];
+ const skills: string[] = [];
+ for (const raw of tags ?? []) {
+ if (typeof raw !== 'string') continue;
+ const tag = raw.trim();
+ if (!tag) continue;
+ if (isSkillTag(tag)) skills.push(skillName(tag));
+ else plain.push(tag);
+ }
+ return { tags: dedupe(plain), skills: dedupe(skills) };
+}
+
+/**
+ * Merge normal tags and bare skill names back into the flat, deduped tag array the
+ * backend stores. Skill names are re-prefixed; empties are dropped.
+ */
+export function mergeTags(tags: readonly string[], skills: readonly string[]): string[] {
+ const normalTags = tags.map((tag) => tag.trim()).filter(Boolean);
+ const skillTags = skills.map(toSkillTag).filter(Boolean);
+ return dedupe([...normalTags, ...skillTags]);
+}