chore(approvals) consolidate guardian calls for shell tools (#31267)

## Summary
As part of our effort to start simplifying approvals code, this PR
extracts Guardian approvals logic from shell tool calls, and replaces it
with the ApprovalAction abstraction instead. This way, tools don't need
to know about Guardian at all.

## Testing
- [x] Adds integration test
This commit is contained in:
Dylan Hurd authored and GitHub committed 2026-07-06 13:23:01 -07:00
1 parent 58ec528315
commit aa94ea1397
8 files changed
+210 -66

No files matched your search

+4
View File
@@ -133,6 +133,8 @@ pub(crate) struct ApprovalCtx<'a> {
pub network_approval_context: Option<NetworkApprovalContext>,
}
pub(crate) type ApprovalAction = crate::guardian::GuardianApprovalRequest;
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct PermissionRequestPayload {
pub tool_name: HookToolName,
@@ -368,6 +370,8 @@ pub(crate) trait Approvable<Req> {
req: &'a Req,
ctx: ApprovalCtx<'a>,
) -> BoxFuture<'a, ReviewDecision>;
fn approval_action(&self, req: &Req, ctx: &ApprovalCtx<'_>) -> std::io::Result<ApprovalAction>;
}
pub(crate) trait Sandboxable {