feat: category-based approval for runtime tools

Replace 20+ individual runtime tool toggles with 5 permission categories
(read, write, shell, web_fetch, store_memory) matching how Copilot CLI,
Cline, and other coding agents handle approvals.

- Add resolveApprovalToolKey() to map permission kinds to category IDs
- Simplify fallbackRuntimeApprovalTools to 5 categories
- Thread alwaysApprove through PendingApprovalHandle → sidecar resolve
- Update ApprovalBanner to use category labels for Always Approve button
- Update ResolveApprovalCommand contract with alwaysApprove field
- Update tests for category-based model

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-27 21:36:27 +01:00
co-authored by Copilot
parent f04e3b9dcc
commit 689b335220
8 changed files with 93 additions and 72 deletions
+22
View File
@@ -193,6 +193,28 @@ export function approvalPolicyRequiresCheckpoint(
return rule.agentIds.includes(normalizedAgentId);
}
const runtimePermissionKinds: ReadonlySet<string> = new Set(['read', 'write', 'shell', 'memory', 'url']);
/**
* Resolves the canonical approval key for a pending approval.
*
* Runtime tools always use their permission-kind category (`read`, `write`, `shell`)
* mapped to the corresponding approval-tool id. MCP/custom/hook tools use their
* specific tool name.
*/
export function resolveApprovalToolKey(
toolName: string | undefined,
permissionKind: string | undefined,
): string | undefined {
if (permissionKind && runtimePermissionKinds.has(permissionKind)) {
if (permissionKind === 'memory') return 'store_memory';
if (permissionKind === 'url') return 'web_fetch';
return permissionKind;
}
return toolName;
}
export function approvalPolicyAutoApprovesTool(
policy: ApprovalPolicy | undefined,
toolName?: string,