fix(gateway): honor approval scope capabilities

This commit is contained in:
loulanyue
2026-08-09 08:32:20 +08:00
committed by brooklyn!
parent e63786fc23
commit 4e8419dadb
4 changed files with 65 additions and 17 deletions
+11 -3
View File
@@ -117,10 +117,17 @@ _BROWSER_CONTROL_PROTOCOL_VERSION = 1
_BROWSER_CONTROL_WS_PROTOCOL = "hermes-browser-control-v1"
_BROWSER_CONTROL_TICKET_PROTOCOL_PREFIX = "hermes-browser-control-ticket."
def _approval_event_choices(*, smart_denied: bool, allow_permanent: bool) -> list[str]:
if smart_denied:
def _approval_event_choices(
*, smart_denied: bool, allow_session: bool, allow_permanent: bool
) -> list[str]:
if smart_denied or not allow_session:
return ["once", "deny"]
return ["once", "session", "always", "deny"] if allow_permanent else ["once", "session", "deny"]
return (
["once", "session", "always", "deny"]
if allow_permanent
else ["once", "session", "deny"]
)
try:
@@ -7750,6 +7757,7 @@ class APIServerAdapter(BasePlatformAdapter):
"timestamp": time.time(),
"choices": _approval_event_choices(
smart_denied=bool(event.get("smart_denied")),
allow_session=event.get("allow_session") is not False,
allow_permanent=event.get("allow_permanent") is not False,
),
})