# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from langchain_core.tools import BaseTool import pytest from artemis.mcp.action_specs import OPERATOR_SHELL_ORDER, operator_shell_tool @pytest.mark.asyncio async def test_operator_shell_tools(): """Every manifest-generated Operator shell is a declaration-only LangChain tool.""" sample_args = { "click": {"target": 1, "times": 1, "delay_ms": 100}, "input_text": {"text": "hello", "target": 1, "clear_exist": True}, "swipe": {"gesture": "up"}, "drag": {"start": [100, 200], "end": [100, 220], "target_description": "timeline"}, "action_sequence": {"steps": [{"action": "wait", "time_in_ms": 50}]}, "pinch": { "center": [500, 500], "start_span": 100, "end_span": 200, "target_description": "canvas", }, "touch_gesture": { "frames": [ {"at_ms": 0, "points": [[400, 500]]}, {"at_ms": 500, "points": [[600, 500]]}, ], "target_description": "canvas path", }, "read_control": {"selector": {"content_desc": "slider"}}, "control_action": { "selector": {"content_desc": "slider"}, "action": "set_progress", "value": 50, }, "wait_until": {"selector": {"content_desc": "status"}, "state": "visible"}, "scroll_to": {"container": {"content_desc": "list"}, "target": {"text": "target"}}, "press_key": {"key": "ENTER"}, "manage_app": {"action": "launch", "app_name": "Settings"}, "wait_for_delay": {"time_in_ms": 1000}, "long_press": {"target": 1, "duration": 1000}, } assert set(sample_args) == set(OPERATOR_SHELL_ORDER) for name in OPERATOR_SHELL_ORDER: tool = operator_shell_tool(name) assert isinstance(tool, BaseTool) assert tool.name == name assert tool.invoke(sample_args[name]) == "Action Recorded"