From f15b2dced3ea8316324fe5845baa718416d3e553 Mon Sep 17 00:00:00 2001 From: matevip Date: Wed, 27 May 2026 14:08:04 +0800 Subject: [PATCH] feat(ui): auto-approve banner dropdown, management page, and workspace chip --- mateclaw-ui/src/api/index.ts | 46 +++ mateclaw-ui/src/components/chat/ChatInput.vue | 86 +++- mateclaw-ui/src/i18n/locales/en-US.ts | 72 ++++ mateclaw-ui/src/i18n/locales/zh-CN.ts | 72 ++++ mateclaw-ui/src/router/index.ts | 6 + mateclaw-ui/src/types/index.ts | 72 ++++ mateclaw-ui/src/views/ChatConsole.vue | 56 ++- .../Security/AutoApproveGrants/index.vue | 375 ++++++++++++++++++ mateclaw-ui/src/views/Security/Layout.vue | 6 + mateclaw-ui/src/views/layout/MainLayout.vue | 52 ++- 10 files changed, 840 insertions(+), 3 deletions(-) create mode 100644 mateclaw-ui/src/views/Security/AutoApproveGrants/index.vue diff --git a/mateclaw-ui/src/api/index.ts b/mateclaw-ui/src/api/index.ts index 09227e38..7fdcfd9d 100644 --- a/mateclaw-ui/src/api/index.ts +++ b/mateclaw-ui/src/api/index.ts @@ -1,5 +1,12 @@ import axios from 'axios' import { handleAuthFailure, updateTokenFromHeader } from '@/utils/auth' +import type { + ApprovalGrant, + ActiveGrantsSummary, + CreateGrantPayload, + ResolutionLog, + GrantScope, +} from '@/types' // Axios 实例 export const http = axios.create({ @@ -1275,3 +1282,42 @@ export const goalApi = { addCriterion: (id: string, criterion: string) => http.post(`/goals/${id}/criteria`, { criterion }), } + +// ==================== Approval Auto-Grant ==================== + +/** + * Client for the /api/v1/approval/* surface. The backend serializes all + * snowflake ids as strings (CLAUDE.md precision convention); callers should + * keep them as strings end-to-end and never run them through Number(). + */ +export const approvalApi = { + /** List grants visible in the current workspace. mine=true skips the admin gate. */ + listGrants: (params?: { + scopeType?: GrantScope + toolName?: string + revoked?: 0 | 1 + mine?: boolean + }) => http.get('/approval/grants', { params }), + + /** Active-grant summary used by the global chip + ChatInput pill counters. */ + activeSummary: () => + http.get('/approval/grants/active'), + + /** Create a grant. Returns the persisted row. */ + createGrant: (payload: CreateGrantPayload) => + http.post('/approval/grants', payload), + + /** Soft-revoke a grant. Caller must be the grant owner OR a workspace admin. */ + revokeGrant: (id: string) => + http.delete(`/approval/grants/${id}`), + + /** + * Read approval-layer final decisions. {@code grantId} queries require admin; + * {@code conversationId} queries are visible to any workspace member. + */ + listResolutions: (params: { + grantId?: string + conversationId?: string + limit?: number + }) => http.get('/approval/resolutions', { params }), +} diff --git a/mateclaw-ui/src/components/chat/ChatInput.vue b/mateclaw-ui/src/components/chat/ChatInput.vue index 38c20d58..cfc5ab08 100644 --- a/mateclaw-ui/src/components/chat/ChatInput.vue +++ b/mateclaw-ui/src/components/chat/ChatInput.vue @@ -84,6 +84,32 @@