feat(android): add native controls and continuous multi-touch

This commit is contained in:
chenmingxuan committed 2026-11-02 21:33:45 +08:00
1 parent 3dd96078db
commit 4b12ae7728
70 files changed
+13105 -179

No files matched your search

+13 -3
View File
@@ -19,21 +19,31 @@ _SMALL_ACTIONS = frozenset(
"wait_for_delay",
"action_sequence",
"drag",
"pinch",
"touch_gesture",
"read_control",
"wait_until",
"scroll_to",
}
)
_ARGUMENT_LIMITS = {
**dict.fromkeys(_SMALL_ACTIONS, SMALL_ACTION_ARGUMENT_LIMIT),
"control_action": 512 * 1024,
}
class ToolArgumentOverflow(ValueError):
def __init__(self, name: str, characters: int):
limit = _ARGUMENT_LIMITS.get(name, SMALL_ACTION_ARGUMENT_LIMIT)
self.details = {
"reason": "tool_arguments_too_large",
"tool": name,
"argument_chars": characters,
"limit_chars": SMALL_ACTION_ARGUMENT_LIMIT,
"limit_chars": limit,
}
super().__init__(
f"收到的 {name} 参数流超出安全限制({characters} 字符,"
f"保护上限 {SMALL_ACTION_ARGUMENT_LIMIT});已关闭输出流,未执行本次动作。"
f"保护上限 {limit});已关闭输出流,未执行本次动作。"
)
@@ -57,5 +67,5 @@ class ToolArgumentGuard:
arguments = tool.get("args")
if isinstance(arguments, str):
state.characters += len(arguments)
if state.name in _SMALL_ACTIONS and state.characters > SMALL_ACTION_ARGUMENT_LIMIT:
if state.name in _ARGUMENT_LIMITS and state.characters > _ARGUMENT_LIMITS[state.name]:
raise ToolArgumentOverflow(state.name, state.characters)